diff --git a/app/Config/Schema/db_acl.php b/app/Config/Schema/db_acl.php index 7dfc7f7ef8..234797b7e6 100644 --- a/app/Config/Schema/db_acl.php +++ b/app/Config/Schema/db_acl.php @@ -30,7 +30,7 @@ class DbAclSchema extends CakeSchema { * @param array $event The event data. * @return bool Success */ - public function before($event = array()) { + public function before($event = []) { return true; } @@ -40,62 +40,62 @@ public function before($event = array()) { * @param array $event The event data. * @return void */ - public function after($event = array()) { + public function after($event = []) { } /** * ACO - Access Control Object - Something that is wanted */ - public $acos = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), - 'parent_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'model' => array('type' => 'string', 'null' => true), - 'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'alias' => array('type' => 'string', 'null' => true), - 'lft' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'idx_acos_lft_rght' => array('column' => array('lft', 'rght'), 'unique' => 0), - 'idx_acos_alias' => array('column' => 'alias', 'unique' => 0) - ) - ); + public $acos = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'], + 'parent_id' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'model' => ['type' => 'string', 'null' => true], + 'foreign_key' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'alias' => ['type' => 'string', 'null' => true], + 'lft' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'rght' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'idx_acos_lft_rght' => ['column' => ['lft', 'rght'], 'unique' => 0], + 'idx_acos_alias' => ['column' => 'alias', 'unique' => 0] + ] + ]; /** * ARO - Access Request Object - Something that wants something */ - public $aros = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), - 'parent_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'model' => array('type' => 'string', 'null' => true), - 'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'alias' => array('type' => 'string', 'null' => true), - 'lft' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'idx_aros_lft_rght' => array('column' => array('lft', 'rght'), 'unique' => 0), - 'idx_aros_alias' => array('column' => 'alias', 'unique' => 0) - ) - ); + public $aros = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'], + 'parent_id' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'model' => ['type' => 'string', 'null' => true], + 'foreign_key' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'alias' => ['type' => 'string', 'null' => true], + 'lft' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'rght' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'idx_aros_lft_rght' => ['column' => ['lft', 'rght'], 'unique' => 0], + 'idx_aros_alias' => ['column' => 'alias', 'unique' => 0] + ] + ]; /** * Used by the Cake::Model:Permission class. * Checks if the given $aro has access to action $action in $aco. */ - public $aros_acos = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), - 'aro_id' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'), - 'aco_id' => array('type' => 'integer', 'null' => false, 'length' => 10), - '_create' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), - '_read' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), - '_update' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), - '_delete' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'ARO_ACO_KEY' => array('column' => array('aro_id', 'aco_id'), 'unique' => 1), - 'idx_aco_id' => array('column' => 'aco_id', 'unique' => 0) - ) - ); + public $aros_acos = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'], + 'aro_id' => ['type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'], + 'aco_id' => ['type' => 'integer', 'null' => false, 'length' => 10], + '_create' => ['type' => 'string', 'null' => false, 'default' => '0', 'length' => 2], + '_read' => ['type' => 'string', 'null' => false, 'default' => '0', 'length' => 2], + '_update' => ['type' => 'string', 'null' => false, 'default' => '0', 'length' => 2], + '_delete' => ['type' => 'string', 'null' => false, 'default' => '0', 'length' => 2], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'ARO_ACO_KEY' => ['column' => ['aro_id', 'aco_id'], 'unique' => 1], + 'idx_aco_id' => ['column' => 'aco_id', 'unique' => 0] + ] + ]; } diff --git a/app/Config/Schema/i18n.php b/app/Config/Schema/i18n.php index 63dc0db9f7..c71580b3a2 100644 --- a/app/Config/Schema/i18n.php +++ b/app/Config/Schema/i18n.php @@ -40,7 +40,7 @@ class I18nSchema extends CakeSchema { * @param array $event Schema object properties * @return bool Should process continue */ - public function before($event = array()) { + public function before($event = []) { return true; } @@ -50,7 +50,7 @@ public function before($event = array()) { * @param array $event Schema object properties * @return void */ - public function after($event = array()) { + public function after($event = []) { } /** @@ -58,14 +58,14 @@ public function after($event = array()) { * * @var array */ - public $i18n = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), - 'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'), - 'model' => array('type' => 'string', 'null' => false, 'key' => 'index'), - 'foreign_key' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'), - 'field' => array('type' => 'string', 'null' => false, 'key' => 'index'), - 'content' => array('type' => 'text', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0)) - ); + public $i18n = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'], + 'locale' => ['type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'], + 'model' => ['type' => 'string', 'null' => false, 'key' => 'index'], + 'foreign_key' => ['type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'], + 'field' => ['type' => 'string', 'null' => false, 'key' => 'index'], + 'content' => ['type' => 'text', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1], 'locale' => ['column' => 'locale', 'unique' => 0], 'model' => ['column' => 'model', 'unique' => 0], 'row_id' => ['column' => 'foreign_key', 'unique' => 0], 'field' => ['column' => 'field', 'unique' => 0]] + ]; } diff --git a/app/Config/Schema/sessions.php b/app/Config/Schema/sessions.php index b766ebff0d..7586e00cab 100644 --- a/app/Config/Schema/sessions.php +++ b/app/Config/Schema/sessions.php @@ -37,7 +37,7 @@ class SessionsSchema extends CakeSchema { * @param array $event Schema object properties * @return bool Should process continue */ - public function before($event = array()) { + public function before($event = []) { return true; } @@ -47,7 +47,7 @@ public function before($event = array()) { * @param array $event Schema object properties * @return void */ - public function after($event = array()) { + public function after($event = []) { } /** @@ -55,11 +55,11 @@ public function after($event = array()) { * * @var array */ - public $cake_sessions = array( - 'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'), - 'data' => array('type' => 'text', 'null' => true, 'default' => null), - 'expires' => array('type' => 'integer', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)) - ); + public $cake_sessions = [ + 'id' => ['type' => 'string', 'null' => false, 'key' => 'primary'], + 'data' => ['type' => 'text', 'null' => true, 'default' => null], + 'expires' => ['type' => 'integer', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1]] + ]; } diff --git a/app/Config/acl.php b/app/Config/acl.php index cddb9f47e5..adb8eeeb38 100644 --- a/app/Config/acl.php +++ b/app/Config/acl.php @@ -114,32 +114,32 @@ * The role map defines how to resolve the user record from your application * to the roles you defined in the roles configuration. */ -$config['map'] = array( +$config['map'] = [ 'User' => 'User/username', 'Role' => 'User/group_id', -); +]; /** * define aliases to map your model information to * the roles defined in your role configuration. */ -$config['alias'] = array( +$config['alias'] = [ 'Role/4' => 'Role/editor', -); +]; /** * role configuration */ -$config['roles'] = array( +$config['roles'] = [ 'Role/admin' => null, -); +]; /** * rule configuration */ -$config['rules'] = array( - 'allow' => array( +$config['rules'] = [ + 'allow' => [ '*' => 'Role/admin', - ), - 'deny' => array(), -); + ], + 'deny' => [], +]; diff --git a/app/Config/bootstrap.php b/app/Config/bootstrap.php index b4fb5290a0..c0966a03f4 100644 --- a/app/Config/bootstrap.php +++ b/app/Config/bootstrap.php @@ -23,7 +23,7 @@ */ // Setup a 'default' cache configuration for use in the application. -Cache::config('default', array('engine' => 'File')); +Cache::config('default', ['engine' => 'File']); /** * The settings below can be used to set additional paths to models, views and controllers. @@ -90,22 +90,22 @@ * * )); */ -Configure::write('Dispatcher.filters', array( +Configure::write('Dispatcher.filters', [ 'AssetDispatcher', 'CacheDispatcher' -)); +]); /** * Configures default file logging options */ App::uses('CakeLog', 'Log'); -CakeLog::config('debug', array( +CakeLog::config('debug', [ 'engine' => 'File', - 'types' => array('notice', 'info', 'debug'), + 'types' => ['notice', 'info', 'debug'], 'file' => 'debug', -)); -CakeLog::config('error', array( +]); +CakeLog::config('error', [ 'engine' => 'File', - 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), + 'types' => ['warning', 'error', 'critical', 'alert', 'emergency'], 'file' => 'error', -)); +]); diff --git a/app/Config/core.php b/app/Config/core.php index da5555a340..2566cb17ca 100644 --- a/app/Config/core.php +++ b/app/Config/core.php @@ -51,11 +51,11 @@ * * @see ErrorHandler for more information on error handling and configuration. */ - Configure::write('Error', array( + Configure::write('Error', [ 'handler' => 'ErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, 'trace' => true - )); + ]); /** * Configure the Exception handler used for uncaught exceptions. By default, @@ -79,11 +79,11 @@ * * @see ErrorHandler for more information on exception handling and configuration. */ - Configure::write('Exception', array( + Configure::write('Exception', [ 'handler' => 'ErrorHandler::handleException', 'renderer' => 'ExceptionRenderer', 'log' => true - )); + ]); /** * Application wide charset encoding @@ -226,9 +226,9 @@ * To use database sessions, run the app/Config/Schema/sessions.php schema using * the cake shell command: cake schema create Sessions */ - Configure::write('Session', array( + Configure::write('Session', [ 'defaults' => 'php' - )); + ]); /** * A random string used in security hashing methods. @@ -376,22 +376,22 @@ * Configure the cache used for general framework caching. Path information, * object listings, and translation cache files are stored with this configuration. */ -Cache::config('_cake_core_', array( +Cache::config('_cake_core_', [ 'engine' => $engine, 'prefix' => $prefix . 'cake_core_', 'path' => CACHE . 'persistent' . DS, 'serialize' => ($engine === 'File'), 'duration' => $duration -)); +]); /** * Configure the cache for model and datasource caches. This cache configuration * is used to store schema descriptions, and table listings in connections. */ -Cache::config('_cake_model_', array( +Cache::config('_cake_model_', [ 'engine' => $engine, 'prefix' => $prefix . 'cake_model_', 'path' => CACHE . 'models' . DS, 'serialize' => ($engine === 'File'), 'duration' => $duration -)); +]); diff --git a/app/Config/routes.php b/app/Config/routes.php index 492471f868..68b6ccf0f9 100644 --- a/app/Config/routes.php +++ b/app/Config/routes.php @@ -25,11 +25,11 @@ * its action called 'display', and we pass a param to select the view file * to use (in this case, /app/View/Pages/home.ctp)... */ - Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); + Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']); /** * ...and connect the rest of 'Pages' controller's URLs. */ - Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); + Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']); /** * Load all plugin routes. See the CakePlugin documentation on diff --git a/app/Console/cake.php b/app/Console/cake.php index d4a6aeaf01..bbab9ef4c3 100644 --- a/app/Console/cake.php +++ b/app/Console/cake.php @@ -24,8 +24,8 @@ $dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; if (function_exists('ini_set')) { - $root = dirname(dirname(dirname(__FILE__))); - $appDir = basename(dirname(dirname(__FILE__))); + $root = dirname(__FILE__, 3); + $appDir = basename(dirname(__FILE__, 2)); $install = $root . DS . 'lib'; $composerInstall = $root . DS . $appDir . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; diff --git a/app/Controller/PagesController.php b/app/Controller/PagesController.php index bf1dbefa69..410da018ff 100644 --- a/app/Controller/PagesController.php +++ b/app/Controller/PagesController.php @@ -35,7 +35,7 @@ class PagesController extends AppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * Displays a view diff --git a/app/webroot/index.php b/app/webroot/index.php index 18c098d8e0..bb6dc4f1d6 100644 --- a/app/webroot/index.php +++ b/app/webroot/index.php @@ -33,14 +33,14 @@ * The full path to the directory which holds "app", WITHOUT a trailing DS. */ if (!defined('ROOT')) { - define('ROOT', dirname(dirname(dirname(__FILE__)))); + define('ROOT', dirname(__FILE__, 3)); } /** * The actual directory name for the "app". */ if (!defined('APP_DIR')) { - define('APP_DIR', basename(dirname(dirname(__FILE__)))); + define('APP_DIR', basename(dirname(__FILE__, 2))); } /** @@ -81,10 +81,10 @@ * Change at your own risk. */ if (!defined('WEBROOT_DIR')) { - define('WEBROOT_DIR', basename(dirname(__FILE__))); + define('WEBROOT_DIR', basename(__DIR__)); } if (!defined('WWW_ROOT')) { - define('WWW_ROOT', dirname(__FILE__) . DS); + define('WWW_ROOT', __DIR__ . DS); } // For the built-in server diff --git a/app/webroot/test.php b/app/webroot/test.php index 2f8f8d3c0c..9682447cdd 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -36,14 +36,14 @@ * The full path to the directory which holds "app", WITHOUT a trailing DS. */ if (!defined('ROOT')) { - define('ROOT', dirname(dirname(dirname(__FILE__)))); + define('ROOT', dirname(__FILE__, 3)); } /** * The actual directory name for the "app". */ if (!defined('APP_DIR')) { - define('APP_DIR', basename(dirname(dirname(__FILE__)))); + define('APP_DIR', basename(dirname(__FILE__, 2))); } /** @@ -81,10 +81,10 @@ * Change at your own risk. */ if (!defined('WEBROOT_DIR')) { - define('WEBROOT_DIR', basename(dirname(__FILE__))); + define('WEBROOT_DIR', basename(__DIR__)); } if (!defined('WWW_ROOT')) { - define('WWW_ROOT', dirname(__FILE__) . DS); + define('WWW_ROOT', __DIR__ . DS); } if (!defined('CAKE_CORE_INCLUDE_PATH')) { diff --git a/composer.json b/composer.json index 8557694a05..d55ed0999c 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ }, "require-dev": { "phpunit/phpunit": "^9.5", - "cakephp/cakephp-codesniffer": "^1.0.0" + "cakephp/cakephp-codesniffer": "^1.0.0", + "rector/rector": "^2.0" }, "config": { "vendor-dir": "vendors/", diff --git a/lib/Cake/Cache/Cache.php b/lib/Cake/Cache/Cache.php index 3db66c4f97..6b17e7b4b3 100644 --- a/lib/Cake/Cache/Cache.php +++ b/lib/Cake/Cache/Cache.php @@ -49,14 +49,14 @@ class Cache { * * @var array */ - protected static $_config = array(); + protected static $_config = []; /** * Group to Config mapping * * @var array */ - protected static $_groups = array(); + protected static $_groups = []; /** * Whether to reset the settings with the next call to Cache::set(); @@ -70,7 +70,7 @@ class Cache { * * @var array */ - protected static $_engines = array(); + protected static $_engines = []; /** * Set the cache configuration to use. config() can @@ -119,12 +119,12 @@ class Cache { * @throws CacheException * @see app/Config/core.php for configuration settings */ - public static function config($name = null, $settings = array()) { + public static function config($name = null, $settings = []) { if (is_array($name)) { $settings = $name; } - $current = array(); + $current = []; if (isset(static::$_config[$name])) { $current = static::$_config[$name]; } @@ -166,7 +166,7 @@ public static function config($name = null, $settings = array()) { protected static function _buildEngine($name) { $config = static::$_config[$name]; - list($plugin, $class) = pluginSplit($config['engine'], true); + [$plugin, $class] = pluginSplit($config['engine'], true); $cacheClass = $class . 'Engine'; App::uses($cacheClass, $plugin . 'Cache/Engine'); if (!class_exists($cacheClass)) { @@ -239,7 +239,7 @@ public static function drop($name) { * @param string $config The configuration name you are changing. Defaults to 'default' * @return array Array of settings. */ - public static function set($settings = array(), $value = null, $config = 'default') { + public static function set($settings = [], $value = null, $config = 'default') { if (is_array($settings) && $value !== null) { $config = $value; } @@ -256,7 +256,7 @@ public static function set($settings = array(), $value = null, $config = 'defaul $settings = static::$_config[$config]; } else { if (is_string($settings) && $value !== null) { - $settings = array($settings => $value); + $settings = [$settings => $value]; } $settings += static::$_config[$config]; if (isset($settings['duration']) && !is_numeric($settings['duration'])) { @@ -511,7 +511,7 @@ public static function settings($name = 'default') { if (!empty(static::$_engines[$name])) { return static::$_engines[$name]->settings(); } - return array(); + return []; } /** @@ -538,7 +538,7 @@ public static function groupConfigs($group = null) { return static::$_groups; } if (isset(static::$_groups[$group])) { - return array($group => static::$_groups[$group]); + return [$group => static::$_groups[$group]]; } throw new CacheException(__d('cake_dev', 'Invalid cache group %s', $group)); } diff --git a/lib/Cake/Cache/CacheEngine.php b/lib/Cake/Cache/CacheEngine.php index 3e2c25632c..9342027bc4 100644 --- a/lib/Cake/Cache/CacheEngine.php +++ b/lib/Cake/Cache/CacheEngine.php @@ -26,7 +26,7 @@ abstract class CacheEngine { * * @var array */ - public $settings = array(); + public $settings = []; /** * Contains the compiled string with all groups @@ -44,13 +44,13 @@ abstract class CacheEngine { * @param array $settings Associative array of parameters for the engine * @return bool True if the engine has been successfully initialized, false if not */ - public function init($settings = array()) { - $settings += $this->settings + array( + public function init($settings = []) { + $settings += $this->settings + [ 'prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, - 'groups' => array() - ); + 'groups' => [] + ]; $this->settings = $settings; if (!empty($this->settings['groups'])) { sort($this->settings['groups']); @@ -184,7 +184,7 @@ public function key($key) { $prefix = md5(implode('_', $this->groups())); } - $key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace(array(DS, '/', '.'), '_', strval($key))))); + $key = preg_replace('/[\s]+/', '_', strtolower(trim(str_replace([DS, '/', '.'], '_', strval($key))))); return $prefix . $key; } } diff --git a/lib/Cake/Cache/Engine/ApcEngine.php b/lib/Cake/Cache/Engine/ApcEngine.php index 329e87196c..c21bd86ed4 100644 --- a/lib/Cake/Cache/Engine/ApcEngine.php +++ b/lib/Cake/Cache/Engine/ApcEngine.php @@ -29,7 +29,7 @@ class ApcEngine extends CacheEngine { * * @var array */ - protected $_compiledGroupNames = array(); + protected $_compiledGroupNames = []; /** * APC or APCu extension @@ -48,11 +48,11 @@ class ApcEngine extends CacheEngine { * @return bool 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) . '_'; } - $settings += array('engine' => 'Apc'); + $settings += ['engine' => 'Apc']; parent::init($settings); if (function_exists('apcu_dec')) { $this->_apcExtension = 'apcu'; @@ -153,7 +153,7 @@ public function clear($check) { } $cache = $this->_apcExtension === 'apc' ? apc_cache_info('user') : apcu_cache_info(); foreach ($cache['cache_list'] as $key) { - if (strpos($key['info'], $this->settings['prefix']) === 0) { + if (str_starts_with($key['info'], $this->settings['prefix'])) { $func($key['info']); } } @@ -187,7 +187,7 @@ public function groups() { ksort($groups); } - $result = array(); + $result = []; $groups = array_values($groups); foreach ($this->settings['groups'] as $i => $group) { $result[] = $group . $groups[$i]; diff --git a/lib/Cake/Cache/Engine/FileEngine.php b/lib/Cake/Cache/Engine/FileEngine.php index 7599d61884..e4b5b0f667 100644 --- a/lib/Cake/Cache/Engine/FileEngine.php +++ b/lib/Cake/Cache/Engine/FileEngine.php @@ -48,7 +48,7 @@ class FileEngine extends CacheEngine { * @var array * @see CacheEngine::__defaults */ - public $settings = array(); + public $settings = []; /** * True unless FileEngine::__active(); fails @@ -66,8 +66,8 @@ class FileEngine extends CacheEngine { * @param array $settings array of setting for the engine * @return bool True if the engine has been successfully initialized, false if not */ - public function init($settings = array()) { - $settings += array( + public function init($settings = []) { + $settings += [ 'engine' => 'File', 'path' => CACHE, 'prefix' => 'cake_', @@ -75,7 +75,7 @@ public function init($settings = array()) { 'serialize' => true, 'isWindows' => false, 'mask' => 0664 - ); + ]; parent::init($settings); if (DS === '\\') { @@ -132,7 +132,7 @@ public function write($key, $data, $duration) { } $expires = time() + $duration; - $contents = implode(array($expires, $lineBreak, $data, $lineBreak)); + $contents = implode('', [$expires, $lineBreak, $data, $lineBreak]); if ($this->settings['lock']) { $this->_File->flock(LOCK_EX); @@ -236,7 +236,7 @@ public function clear($check) { $directory = new RecursiveDirectoryIterator($this->settings['path']); $contents = new RecursiveIteratorIterator($directory, RecursiveIteratorIterator::SELF_FIRST); - $cleared = array(); + $cleared = []; foreach ($contents as $path) { if ($path->isFile()) { continue; @@ -278,7 +278,7 @@ protected function _clearDirectory($path, $now, $threshold) { try { $file = new SplFileObject($path . $entry, 'r'); - } catch (Exception $e) { + } catch (Exception) { continue; } @@ -369,7 +369,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; @@ -407,7 +407,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; } @@ -422,10 +422,10 @@ public function clearGroup($group) { $directoryIterator = new RecursiveDirectoryIterator($this->settings['path']); $contents = new RecursiveIteratorIterator($directoryIterator, RecursiveIteratorIterator::CHILD_FIRST); foreach ($contents as $object) { - $containsGroup = strpos($object->getPathName(), DS . $group . DS) !== false; + $containsGroup = str_contains($object->getPathName(), DS . $group . DS); $hasPrefix = true; if (strlen($this->settings['prefix']) !== 0) { - $hasPrefix = strpos($object->getBaseName(), $this->settings['prefix']) === 0; + $hasPrefix = str_starts_with($object->getBaseName(), $this->settings['prefix']); } if ($object->isFile() && $containsGroup && $hasPrefix) { $path = $object->getPathName(); diff --git a/lib/Cake/Cache/Engine/MemcacheEngine.php b/lib/Cake/Cache/Engine/MemcacheEngine.php index d70c1c56df..c8ec15da65 100644 --- a/lib/Cake/Cache/Engine/MemcacheEngine.php +++ b/lib/Cake/Cache/Engine/MemcacheEngine.php @@ -32,7 +32,7 @@ class MemcacheEngine extends CacheEngine { * * @var array */ - protected $_compiledGroupNames = array(); + protected $_compiledGroupNames = []; /** * Memcache wrapper. @@ -50,7 +50,7 @@ class MemcacheEngine extends CacheEngine { * * @var array */ - public $settings = array(); + public $settings = []; /** * Initialize the Cache Engine @@ -61,32 +61,32 @@ class MemcacheEngine extends CacheEngine { * @param array $settings array of setting for the engine * @return bool True if the engine has been successfully initialized, false if not */ - public function init($settings = array()) { + public function init($settings = []) { if (!class_exists('Memcache')) { return false; } if (!isset($settings['prefix'])) { $settings['prefix'] = Inflector::slug(APP_DIR) . '_'; } - $settings += array( + $settings += [ 'engine' => 'Memcache', - 'servers' => array('127.0.0.1'), + 'servers' => ['127.0.0.1'], 'compress' => false, 'persistent' => true - ); + ]; parent::init($settings); if ($this->settings['compress']) { $this->settings['compress'] = MEMCACHE_COMPRESSED; } if (is_string($this->settings['servers'])) { - $this->settings['servers'] = array($this->settings['servers']); + $this->settings['servers'] = [$this->settings['servers']]; } if (!isset($this->_Memcache)) { $return = false; $this->_Memcache = new Memcache(); foreach ($this->settings['servers'] as $server) { - list($host, $port) = $this->_parseServerString($server); + [$host, $port] = $this->_parseServerString($server); if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) { $return = true; } @@ -104,10 +104,10 @@ public function init($settings = array()) { * @return array Array containing host, port */ protected function _parseServerString($server) { - if (strpos($server, 'unix://') === 0) { - return array($server, 0); + if (str_starts_with($server, 'unix://')) { + return [$server, 0]; } - if (substr($server, 0, 1) === '[') { + if (str_starts_with($server, '[')) { $position = strpos($server, ']:'); if ($position !== false) { $position++; @@ -121,7 +121,7 @@ protected function _parseServerString($server) { $host = substr($server, 0, $position); $port = substr($server, $position + 1); } - return array($host, $port); + return [$host, $port]; } /** @@ -163,7 +163,7 @@ public function read($key) { public function increment($key, $offset = 1) { if ($this->settings['compress']) { throw new CacheException( - __d('cake_dev', 'Method %s not implemented for compressed cache in %s', 'increment()', __CLASS__) + __d('cake_dev', 'Method %s not implemented for compressed cache in %s', 'increment()', self::class) ); } return $this->_Memcache->increment($key, $offset); @@ -180,7 +180,7 @@ public function increment($key, $offset = 1) { public function decrement($key, $offset = 1) { if ($this->settings['compress']) { throw new CacheException( - __d('cake_dev', 'Method %s not implemented for compressed cache in %s', 'decrement()', __CLASS__) + __d('cake_dev', 'Method %s not implemented for compressed cache in %s', 'decrement()', self::class) ); } return $this->_Memcache->decrement($key, $offset); @@ -218,7 +218,7 @@ public function clear($check) { continue; } foreach (array_keys($stats) as $key) { - if (strpos($key, $this->settings['prefix']) === 0) { + if (str_starts_with($key, $this->settings['prefix'])) { $this->_Memcache->delete($key); } } @@ -270,7 +270,7 @@ public function groups() { ksort($groups); } - $result = array(); + $result = []; $groups = array_values($groups); foreach ($this->settings['groups'] as $i => $group) { $result[] = $group . $groups[$i]; diff --git a/lib/Cake/Cache/Engine/MemcachedEngine.php b/lib/Cake/Cache/Engine/MemcachedEngine.php index 655eb5d1cf..505a0cdf2a 100644 --- a/lib/Cake/Cache/Engine/MemcachedEngine.php +++ b/lib/Cake/Cache/Engine/MemcachedEngine.php @@ -52,7 +52,7 @@ class MemcachedEngine extends CacheEngine { * * @var array */ - public $settings = array(); + public $settings = []; /** * List of available serializer engines @@ -61,11 +61,11 @@ 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 @@ -77,7 +77,7 @@ class MemcachedEngine extends CacheEngine { * @return bool True if the engine has been successfully initialized, false if not * @throws CacheException 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; } @@ -89,20 +89,20 @@ public function init($settings = array()) { $this->_serializers['msgpack'] = Memcached::SERIALIZER_MSGPACK; } - $settings += array( + $settings += [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1'), + 'servers' => ['127.0.0.1'], 'compress' => false, 'persistent' => false, 'login' => null, 'password' => null, 'serialize' => 'php', - 'options' => array() - ); + 'options' => [] + ]; 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)) { @@ -120,7 +120,7 @@ public function init($settings = array()) { return true; } - $servers = array(); + $servers = []; foreach ($this->settings['servers'] as $server) { $servers[] = $this->_parseServerString($server); } @@ -188,10 +188,10 @@ protected function _setOptions() { */ protected function _parseServerString($server) { $socketTransport = 'unix://'; - if (strpos($server, $socketTransport) === 0) { - return array(substr($server, strlen($socketTransport)), 0); + if (str_starts_with($server, $socketTransport)) { + return [substr($server, strlen($socketTransport)), 0]; } - if (substr($server, 0, 1) === '[') { + if (str_starts_with($server, '[')) { $position = strpos($server, ']:'); if ($position !== false) { $position++; @@ -205,7 +205,7 @@ protected function _parseServerString($server) { $host = substr($server, 0, $position); $port = substr($server, $position + 1); } - return array($host, (int)$port); + return [$host, (int)$port]; } /** @@ -290,7 +290,7 @@ public function clear($check) { } foreach ($keys as $key) { - if (strpos($key, $this->settings['prefix']) === 0) { + if (str_starts_with($key, $this->settings['prefix'])) { $this->_Memcached->delete($key); } } @@ -323,7 +323,7 @@ public function groups() { ksort($groups); } - $result = array(); + $result = []; $groups = array_values($groups); foreach ($this->settings['groups'] as $i => $group) { $result[] = $group . $groups[$i]; diff --git a/lib/Cake/Cache/Engine/RedisEngine.php b/lib/Cake/Cache/Engine/RedisEngine.php index 405729227f..1632244e00 100644 --- a/lib/Cake/Cache/Engine/RedisEngine.php +++ b/lib/Cake/Cache/Engine/RedisEngine.php @@ -42,7 +42,7 @@ class RedisEngine extends CacheEngine { * * @var array */ - public $settings = array(); + public $settings = []; /** * Initialize the Cache Engine @@ -53,11 +53,11 @@ class RedisEngine extends CacheEngine { * @param array $settings array of setting for the engine * @return bool 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([ 'engine' => 'Redis', 'prefix' => Inflector::slug(APP_DIR) . '_', 'server' => '127.0.0.1', @@ -67,7 +67,7 @@ public function init($settings = array()) { 'timeout' => 0, 'persistent' => true, 'unix_socket' => false - ), $settings) + ], $settings) ); return $this->_connect(); @@ -89,7 +89,7 @@ protected function _connect() { $persistentId = $this->settings['port'] . $this->settings['timeout'] . $this->settings['database']; $return = $this->_Redis->pconnect($this->settings['server'], $this->settings['port'], $this->settings['timeout'], $persistentId); } - } catch (RedisException $e) { + } catch (RedisException) { $return = false; } if (!$return) { @@ -201,7 +201,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) { diff --git a/lib/Cake/Cache/Engine/WincacheEngine.php b/lib/Cake/Cache/Engine/WincacheEngine.php index dc83481715..21a026f555 100644 --- a/lib/Cake/Cache/Engine/WincacheEngine.php +++ b/lib/Cake/Cache/Engine/WincacheEngine.php @@ -31,7 +31,7 @@ class WincacheEngine extends CacheEngine { * * @var array */ - protected $_compiledGroupNames = array(); + protected $_compiledGroupNames = []; /** * Initialize the Cache Engine @@ -43,11 +43,11 @@ class WincacheEngine extends CacheEngine { * @return bool 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) . '_'; } - $settings += array('engine' => 'Wincache'); + $settings += ['engine' => 'Wincache']; parent::init($settings); return function_exists('wincache_ucache_info'); } @@ -63,10 +63,10 @@ public function init($settings = array()) { public function write($key, $value, $duration) { $expires = time() + $duration; - $data = array( + $data = [ $key . '_expires' => $expires, $key => $value - ); + ]; $result = wincache_ucache_set($data, null, $duration); return empty($result); } @@ -135,7 +135,7 @@ public function clear($check) { $cacheKeys = $info['ucache_entries']; unset($info); foreach ($cacheKeys as $key) { - if (strpos($key['key_name'], $this->settings['prefix']) === 0) { + if (str_starts_with($key['key_name'], $this->settings['prefix'])) { wincache_ucache_delete($key['key_name']); } } @@ -167,7 +167,7 @@ public function groups() { ksort($groups); } - $result = array(); + $result = []; $groups = array_values($groups); foreach ($this->settings['groups'] as $i => $group) { $result[] = $group . $groups[$i]; diff --git a/lib/Cake/Cache/Engine/XcacheEngine.php b/lib/Cake/Cache/Engine/XcacheEngine.php index 2ce3324f1e..8059bf1820 100644 --- a/lib/Cake/Cache/Engine/XcacheEngine.php +++ b/lib/Cake/Cache/Engine/XcacheEngine.php @@ -32,7 +32,7 @@ class XcacheEngine extends CacheEngine { * * @var array */ - public $settings = array(); + public $settings = []; /** * Initialize the Cache Engine @@ -43,14 +43,14 @@ class XcacheEngine extends CacheEngine { * @param array $settings array of setting for the engine * @return bool True if the engine has been successfully initialized, false if not */ - public function init($settings = array()) { + public function init($settings = []) { if (PHP_SAPI !== 'cli') { - parent::init(array_merge(array( + parent::init(array_merge([ 'engine' => 'Xcache', 'prefix' => Inflector::slug(APP_DIR) . '_', 'PHP_AUTH_USER' => 'user', 'PHP_AUTH_PW' => 'password' - ), $settings) + ], $settings) ); return function_exists('xcache_info'); } @@ -148,7 +148,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) { @@ -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])) { diff --git a/lib/Cake/Config/routes.php b/lib/Cake/Config/routes.php index 5d603ed8e3..5b5d9504eb 100644 --- a/lib/Cake/Config/routes.php +++ b/lib/Cake/Config/routes.php @@ -48,29 +48,29 @@ $plugins[$key] = Inflector::underscore($value); } $pluginPattern = implode('|', $plugins); - $match = array('plugin' => $pluginPattern, 'defaultRoute' => true); - $shortParams = array('routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern, 'defaultRoute' => true); + $match = ['plugin' => $pluginPattern, 'defaultRoute' => true]; + $shortParams = ['routeClass' => 'PluginShortRoute', 'plugin' => $pluginPattern, 'defaultRoute' => true]; foreach ($prefixes as $prefix) { - $params = array('prefix' => $prefix, $prefix => true); - $indexParams = $params + array('action' => 'index'); + $params = ['prefix' => $prefix, $prefix => true]; + $indexParams = $params + ['action' => 'index']; Router::connect("/{$prefix}/:plugin", $indexParams, $shortParams); Router::connect("/{$prefix}/:plugin/:controller", $indexParams, $match); Router::connect("/{$prefix}/:plugin/:controller/:action/*", $params, $match); } - Router::connect('/:plugin', array('action' => 'index'), $shortParams); - Router::connect('/:plugin/:controller', array('action' => 'index'), $match); - Router::connect('/:plugin/:controller/:action/*', array(), $match); + Router::connect('/:plugin', ['action' => 'index'], $shortParams); + Router::connect('/:plugin/:controller', ['action' => 'index'], $match); + Router::connect('/:plugin/:controller/:action/*', [], $match); } foreach ($prefixes as $prefix) { - $params = array('prefix' => $prefix, $prefix => true); - $indexParams = $params + array('action' => 'index'); - Router::connect("/{$prefix}/:controller", $indexParams, array('defaultRoute' => true)); - Router::connect("/{$prefix}/:controller/:action/*", $params, array('defaultRoute' => true)); + $params = ['prefix' => $prefix, $prefix => true]; + $indexParams = $params + ['action' => 'index']; + Router::connect("/{$prefix}/:controller", $indexParams, ['defaultRoute' => true]); + Router::connect("/{$prefix}/:controller/:action/*", $params, ['defaultRoute' => true]); } -Router::connect('/:controller', array('action' => 'index'), array('defaultRoute' => true)); -Router::connect('/:controller/:action/*', array(), array('defaultRoute' => true)); +Router::connect('/:controller', ['action' => 'index'], ['defaultRoute' => true]); +Router::connect('/:controller/:action/*', [], ['defaultRoute' => true]); $namedConfig = Router::namedConfig(); if ($namedConfig['rules'] === false) { diff --git a/lib/Cake/Config/unicode/casefolding/0080_00ff.php b/lib/Cake/Config/unicode/casefolding/0080_00ff.php index f79b4df620..a5e80bbffa 100644 --- a/lib/Cake/Config/unicode/casefolding/0080_00ff.php +++ b/lib/Cake/Config/unicode/casefolding/0080_00ff.php @@ -37,36 +37,36 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0080_00ff'][] = array('upper' => 181, 'status' => 'C', 'lower' => array(956)); -$config['0080_00ff'][] = array('upper' => 924, 'status' => 'C', 'lower' => array(181)); -$config['0080_00ff'][] = array('upper' => 192, 'status' => 'C', 'lower' => array(224)); /* LATIN CAPITAL LETTER A WITH GRAVE */ -$config['0080_00ff'][] = array('upper' => 193, 'status' => 'C', 'lower' => array(225)); /* LATIN CAPITAL LETTER A WITH ACUTE */ -$config['0080_00ff'][] = array('upper' => 194, 'status' => 'C', 'lower' => array(226)); /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ -$config['0080_00ff'][] = array('upper' => 195, 'status' => 'C', 'lower' => array(227)); /* LATIN CAPITAL LETTER A WITH TILDE */ -$config['0080_00ff'][] = array('upper' => 196, 'status' => 'C', 'lower' => array(228)); /* LATIN CAPITAL LETTER A WITH DIAERESIS */ -$config['0080_00ff'][] = array('upper' => 197, 'status' => 'C', 'lower' => array(229)); /* LATIN CAPITAL LETTER A WITH RING ABOVE */ -$config['0080_00ff'][] = array('upper' => 198, 'status' => 'C', 'lower' => array(230)); /* LATIN CAPITAL LETTER AE */ -$config['0080_00ff'][] = array('upper' => 199, 'status' => 'C', 'lower' => array(231)); /* LATIN CAPITAL LETTER C WITH CEDILLA */ -$config['0080_00ff'][] = array('upper' => 200, 'status' => 'C', 'lower' => array(232)); /* LATIN CAPITAL LETTER E WITH GRAVE */ -$config['0080_00ff'][] = array('upper' => 201, 'status' => 'C', 'lower' => array(233)); /* LATIN CAPITAL LETTER E WITH ACUTE */ -$config['0080_00ff'][] = array('upper' => 202, 'status' => 'C', 'lower' => array(234)); /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */ -$config['0080_00ff'][] = array('upper' => 203, 'status' => 'C', 'lower' => array(235)); /* LATIN CAPITAL LETTER E WITH DIAERESIS */ -$config['0080_00ff'][] = array('upper' => 204, 'status' => 'C', 'lower' => array(236)); /* LATIN CAPITAL LETTER I WITH GRAVE */ -$config['0080_00ff'][] = array('upper' => 205, 'status' => 'C', 'lower' => array(237)); /* LATIN CAPITAL LETTER I WITH ACUTE */ -$config['0080_00ff'][] = array('upper' => 206, 'status' => 'C', 'lower' => array(238)); /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ -$config['0080_00ff'][] = array('upper' => 207, 'status' => 'C', 'lower' => array(239)); /* LATIN CAPITAL LETTER I WITH DIAERESIS */ -$config['0080_00ff'][] = array('upper' => 208, 'status' => 'C', 'lower' => array(240)); /* LATIN CAPITAL LETTER ETH */ -$config['0080_00ff'][] = array('upper' => 209, 'status' => 'C', 'lower' => array(241)); /* LATIN CAPITAL LETTER N WITH TILDE */ -$config['0080_00ff'][] = array('upper' => 210, 'status' => 'C', 'lower' => array(242)); /* LATIN CAPITAL LETTER O WITH GRAVE */ -$config['0080_00ff'][] = array('upper' => 211, 'status' => 'C', 'lower' => array(243)); /* LATIN CAPITAL LETTER O WITH ACUTE */ -$config['0080_00ff'][] = array('upper' => 212, 'status' => 'C', 'lower' => array(244)); /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ -$config['0080_00ff'][] = array('upper' => 213, 'status' => 'C', 'lower' => array(245)); /* LATIN CAPITAL LETTER O WITH TILDE */ -$config['0080_00ff'][] = array('upper' => 214, 'status' => 'C', 'lower' => array(246)); /* LATIN CAPITAL LETTER O WITH DIAERESIS */ -$config['0080_00ff'][] = array('upper' => 216, 'status' => 'C', 'lower' => array(248)); /* LATIN CAPITAL LETTER O WITH STROKE */ -$config['0080_00ff'][] = array('upper' => 217, 'status' => 'C', 'lower' => array(249)); /* LATIN CAPITAL LETTER U WITH GRAVE */ -$config['0080_00ff'][] = array('upper' => 218, 'status' => 'C', 'lower' => array(250)); /* LATIN CAPITAL LETTER U WITH ACUTE */ -$config['0080_00ff'][] = array('upper' => 219, 'status' => 'C', 'lower' => array(251)); /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */ -$config['0080_00ff'][] = array('upper' => 220, 'status' => 'C', 'lower' => array(252)); /* LATIN CAPITAL LETTER U WITH DIAERESIS */ -$config['0080_00ff'][] = array('upper' => 221, 'status' => 'C', 'lower' => array(253)); /* LATIN CAPITAL LETTER Y WITH ACUTE */ -$config['0080_00ff'][] = array('upper' => 222, 'status' => 'C', 'lower' => array(254)); /* LATIN CAPITAL LETTER THORN */ -$config['0080_00ff'][] = array('upper' => 223, 'status' => 'F', 'lower' => array(115, 115)); /* LATIN SMALL LETTER SHARP S */ +$config['0080_00ff'][] = ['upper' => 181, 'status' => 'C', 'lower' => [956]]; +$config['0080_00ff'][] = ['upper' => 924, 'status' => 'C', 'lower' => [181]]; +$config['0080_00ff'][] = ['upper' => 192, 'status' => 'C', 'lower' => [224]]; /* LATIN CAPITAL LETTER A WITH GRAVE */ +$config['0080_00ff'][] = ['upper' => 193, 'status' => 'C', 'lower' => [225]]; /* LATIN CAPITAL LETTER A WITH ACUTE */ +$config['0080_00ff'][] = ['upper' => 194, 'status' => 'C', 'lower' => [226]]; /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX */ +$config['0080_00ff'][] = ['upper' => 195, 'status' => 'C', 'lower' => [227]]; /* LATIN CAPITAL LETTER A WITH TILDE */ +$config['0080_00ff'][] = ['upper' => 196, 'status' => 'C', 'lower' => [228]]; /* LATIN CAPITAL LETTER A WITH DIAERESIS */ +$config['0080_00ff'][] = ['upper' => 197, 'status' => 'C', 'lower' => [229]]; /* LATIN CAPITAL LETTER A WITH RING ABOVE */ +$config['0080_00ff'][] = ['upper' => 198, 'status' => 'C', 'lower' => [230]]; /* LATIN CAPITAL LETTER AE */ +$config['0080_00ff'][] = ['upper' => 199, 'status' => 'C', 'lower' => [231]]; /* LATIN CAPITAL LETTER C WITH CEDILLA */ +$config['0080_00ff'][] = ['upper' => 200, 'status' => 'C', 'lower' => [232]]; /* LATIN CAPITAL LETTER E WITH GRAVE */ +$config['0080_00ff'][] = ['upper' => 201, 'status' => 'C', 'lower' => [233]]; /* LATIN CAPITAL LETTER E WITH ACUTE */ +$config['0080_00ff'][] = ['upper' => 202, 'status' => 'C', 'lower' => [234]]; /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX */ +$config['0080_00ff'][] = ['upper' => 203, 'status' => 'C', 'lower' => [235]]; /* LATIN CAPITAL LETTER E WITH DIAERESIS */ +$config['0080_00ff'][] = ['upper' => 204, 'status' => 'C', 'lower' => [236]]; /* LATIN CAPITAL LETTER I WITH GRAVE */ +$config['0080_00ff'][] = ['upper' => 205, 'status' => 'C', 'lower' => [237]]; /* LATIN CAPITAL LETTER I WITH ACUTE */ +$config['0080_00ff'][] = ['upper' => 206, 'status' => 'C', 'lower' => [238]]; /* LATIN CAPITAL LETTER I WITH CIRCUMFLEX */ +$config['0080_00ff'][] = ['upper' => 207, 'status' => 'C', 'lower' => [239]]; /* LATIN CAPITAL LETTER I WITH DIAERESIS */ +$config['0080_00ff'][] = ['upper' => 208, 'status' => 'C', 'lower' => [240]]; /* LATIN CAPITAL LETTER ETH */ +$config['0080_00ff'][] = ['upper' => 209, 'status' => 'C', 'lower' => [241]]; /* LATIN CAPITAL LETTER N WITH TILDE */ +$config['0080_00ff'][] = ['upper' => 210, 'status' => 'C', 'lower' => [242]]; /* LATIN CAPITAL LETTER O WITH GRAVE */ +$config['0080_00ff'][] = ['upper' => 211, 'status' => 'C', 'lower' => [243]]; /* LATIN CAPITAL LETTER O WITH ACUTE */ +$config['0080_00ff'][] = ['upper' => 212, 'status' => 'C', 'lower' => [244]]; /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX */ +$config['0080_00ff'][] = ['upper' => 213, 'status' => 'C', 'lower' => [245]]; /* LATIN CAPITAL LETTER O WITH TILDE */ +$config['0080_00ff'][] = ['upper' => 214, 'status' => 'C', 'lower' => [246]]; /* LATIN CAPITAL LETTER O WITH DIAERESIS */ +$config['0080_00ff'][] = ['upper' => 216, 'status' => 'C', 'lower' => [248]]; /* LATIN CAPITAL LETTER O WITH STROKE */ +$config['0080_00ff'][] = ['upper' => 217, 'status' => 'C', 'lower' => [249]]; /* LATIN CAPITAL LETTER U WITH GRAVE */ +$config['0080_00ff'][] = ['upper' => 218, 'status' => 'C', 'lower' => [250]]; /* LATIN CAPITAL LETTER U WITH ACUTE */ +$config['0080_00ff'][] = ['upper' => 219, 'status' => 'C', 'lower' => [251]]; /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX */ +$config['0080_00ff'][] = ['upper' => 220, 'status' => 'C', 'lower' => [252]]; /* LATIN CAPITAL LETTER U WITH DIAERESIS */ +$config['0080_00ff'][] = ['upper' => 221, 'status' => 'C', 'lower' => [253]]; /* LATIN CAPITAL LETTER Y WITH ACUTE */ +$config['0080_00ff'][] = ['upper' => 222, 'status' => 'C', 'lower' => [254]]; /* LATIN CAPITAL LETTER THORN */ +$config['0080_00ff'][] = ['upper' => 223, 'status' => 'F', 'lower' => [115, 115]]; /* LATIN SMALL LETTER SHARP S */ diff --git a/lib/Cake/Config/unicode/casefolding/0100_017f.php b/lib/Cake/Config/unicode/casefolding/0100_017f.php index 236311c168..22bb157fbc 100644 --- a/lib/Cake/Config/unicode/casefolding/0100_017f.php +++ b/lib/Cake/Config/unicode/casefolding/0100_017f.php @@ -37,69 +37,69 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0100_017f'][] = array('upper' => 256, 'status' => 'C', 'lower' => array(257)); /* LATIN CAPITAL LETTER A WITH MACRON */ -$config['0100_017f'][] = array('upper' => 258, 'status' => 'C', 'lower' => array(259)); /* LATIN CAPITAL LETTER A WITH BREVE */ -$config['0100_017f'][] = array('upper' => 260, 'status' => 'C', 'lower' => array(261)); /* LATIN CAPITAL LETTER A WITH OGONEK */ -$config['0100_017f'][] = array('upper' => 262, 'status' => 'C', 'lower' => array(263)); /* LATIN CAPITAL LETTER C WITH ACUTE */ -$config['0100_017f'][] = array('upper' => 264, 'status' => 'C', 'lower' => array(265)); /* LATIN CAPITAL LETTER C WITH CIRCUMFLEX */ -$config['0100_017f'][] = array('upper' => 266, 'status' => 'C', 'lower' => array(267)); /* LATIN CAPITAL LETTER C WITH DOT ABOVE */ -$config['0100_017f'][] = array('upper' => 268, 'status' => 'C', 'lower' => array(269)); /* LATIN CAPITAL LETTER C WITH CARON */ -$config['0100_017f'][] = array('upper' => 270, 'status' => 'C', 'lower' => array(271)); /* LATIN CAPITAL LETTER D WITH CARON */ -$config['0100_017f'][] = array('upper' => 272, 'status' => 'C', 'lower' => array(273)); /* LATIN CAPITAL LETTER D WITH STROKE */ -$config['0100_017f'][] = array('upper' => 274, 'status' => 'C', 'lower' => array(275)); /* LATIN CAPITAL LETTER E WITH MACRON */ -$config['0100_017f'][] = array('upper' => 276, 'status' => 'C', 'lower' => array(277)); /* LATIN CAPITAL LETTER E WITH BREVE */ -$config['0100_017f'][] = array('upper' => 278, 'status' => 'C', 'lower' => array(279)); /* LATIN CAPITAL LETTER E WITH DOT ABOVE */ -$config['0100_017f'][] = array('upper' => 280, 'status' => 'C', 'lower' => array(281)); /* LATIN CAPITAL LETTER E WITH OGONEK */ -$config['0100_017f'][] = array('upper' => 282, 'status' => 'C', 'lower' => array(283)); /* LATIN CAPITAL LETTER E WITH CARON */ -$config['0100_017f'][] = array('upper' => 284, 'status' => 'C', 'lower' => array(285)); /* LATIN CAPITAL LETTER G WITH CIRCUMFLEX */ -$config['0100_017f'][] = array('upper' => 286, 'status' => 'C', 'lower' => array(287)); /* LATIN CAPITAL LETTER G WITH BREVE */ -$config['0100_017f'][] = array('upper' => 288, 'status' => 'C', 'lower' => array(289)); /* LATIN CAPITAL LETTER G WITH DOT ABOVE */ -$config['0100_017f'][] = array('upper' => 290, 'status' => 'C', 'lower' => array(291)); /* LATIN CAPITAL LETTER G WITH CEDILLA */ -$config['0100_017f'][] = array('upper' => 292, 'status' => 'C', 'lower' => array(293)); /* LATIN CAPITAL LETTER H WITH CIRCUMFLEX */ -$config['0100_017f'][] = array('upper' => 294, 'status' => 'C', 'lower' => array(295)); /* LATIN CAPITAL LETTER H WITH STROKE */ -$config['0100_017f'][] = array('upper' => 296, 'status' => 'C', 'lower' => array(297)); /* LATIN CAPITAL LETTER I WITH TILDE */ -$config['0100_017f'][] = array('upper' => 298, 'status' => 'C', 'lower' => array(299)); /* LATIN CAPITAL LETTER I WITH MACRON */ -$config['0100_017f'][] = array('upper' => 300, 'status' => 'C', 'lower' => array(301)); /* LATIN CAPITAL LETTER I WITH BREVE */ -$config['0100_017f'][] = array('upper' => 302, 'status' => 'C', 'lower' => array(303)); /* LATIN CAPITAL LETTER I WITH OGONEK */ -$config['0100_017f'][] = array('upper' => 304, 'status' => 'F', 'lower' => array(105, 775)); /* LATIN CAPITAL LETTER I WITH DOT ABOVE */ -$config['0100_017f'][] = array('upper' => 304, 'status' => 'T', 'lower' => array(105)); /* LATIN CAPITAL LETTER I WITH DOT ABOVE */ -$config['0100_017f'][] = array('upper' => 306, 'status' => 'C', 'lower' => array(307)); /* LATIN CAPITAL LIGATURE IJ */ -$config['0100_017f'][] = array('upper' => 308, 'status' => 'C', 'lower' => array(309)); /* LATIN CAPITAL LETTER J WITH CIRCUMFLEX */ -$config['0100_017f'][] = array('upper' => 310, 'status' => 'C', 'lower' => array(311)); /* LATIN CAPITAL LETTER K WITH CEDILLA */ -$config['0100_017f'][] = array('upper' => 313, 'status' => 'C', 'lower' => array(314)); /* LATIN CAPITAL LETTER L WITH ACUTE */ -$config['0100_017f'][] = array('upper' => 315, 'status' => 'C', 'lower' => array(316)); /* LATIN CAPITAL LETTER L WITH CEDILLA */ -$config['0100_017f'][] = array('upper' => 317, 'status' => 'C', 'lower' => array(318)); /* LATIN CAPITAL LETTER L WITH CARON */ -$config['0100_017f'][] = array('upper' => 319, 'status' => 'C', 'lower' => array(320)); /* LATIN CAPITAL LETTER L WITH MIDDLE DOT */ -$config['0100_017f'][] = array('upper' => 321, 'status' => 'C', 'lower' => array(322)); /* LATIN CAPITAL LETTER L WITH STROKE */ -$config['0100_017f'][] = array('upper' => 323, 'status' => 'C', 'lower' => array(324)); /* LATIN CAPITAL LETTER N WITH ACUTE */ -$config['0100_017f'][] = array('upper' => 325, 'status' => 'C', 'lower' => array(326)); /* LATIN CAPITAL LETTER N WITH CEDILLA */ -$config['0100_017f'][] = array('upper' => 327, 'status' => 'C', 'lower' => array(328)); /* LATIN CAPITAL LETTER N WITH CARON */ -$config['0100_017f'][] = array('upper' => 329, 'status' => 'F', 'lower' => array(700, 110)); /* LATIN SMALL LETTER N PRECEDED BY APOSTROPHE */ -$config['0100_017f'][] = array('upper' => 330, 'status' => 'C', 'lower' => array(331)); /* LATIN CAPITAL LETTER ENG */ -$config['0100_017f'][] = array('upper' => 332, 'status' => 'C', 'lower' => array(333)); /* LATIN CAPITAL LETTER O WITH MACRON */ -$config['0100_017f'][] = array('upper' => 334, 'status' => 'C', 'lower' => array(335)); /* LATIN CAPITAL LETTER O WITH BREVE */ -$config['0100_017f'][] = array('upper' => 336, 'status' => 'C', 'lower' => array(337)); /* LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */ -$config['0100_017f'][] = array('upper' => 338, 'status' => 'C', 'lower' => array(339)); /* LATIN CAPITAL LIGATURE OE */ -$config['0100_017f'][] = array('upper' => 340, 'status' => 'C', 'lower' => array(341)); /* LATIN CAPITAL LETTER R WITH ACUTE */ -$config['0100_017f'][] = array('upper' => 342, 'status' => 'C', 'lower' => array(343)); /* LATIN CAPITAL LETTER R WITH CEDILLA */ -$config['0100_017f'][] = array('upper' => 344, 'status' => 'C', 'lower' => array(345)); /* LATIN CAPITAL LETTER R WITH CARON */ -$config['0100_017f'][] = array('upper' => 346, 'status' => 'C', 'lower' => array(347)); /* LATIN CAPITAL LETTER S WITH ACUTE */ -$config['0100_017f'][] = array('upper' => 348, 'status' => 'C', 'lower' => array(349)); /* LATIN CAPITAL LETTER S WITH CIRCUMFLEX */ -$config['0100_017f'][] = array('upper' => 350, 'status' => 'C', 'lower' => array(351)); /* LATIN CAPITAL LETTER S WITH CEDILLA */ -$config['0100_017f'][] = array('upper' => 352, 'status' => 'C', 'lower' => array(353)); /* LATIN CAPITAL LETTER S WITH CARON */ -$config['0100_017f'][] = array('upper' => 354, 'status' => 'C', 'lower' => array(355)); /* LATIN CAPITAL LETTER T WITH CEDILLA */ -$config['0100_017f'][] = array('upper' => 356, 'status' => 'C', 'lower' => array(357)); /* LATIN CAPITAL LETTER T WITH CARON */ -$config['0100_017f'][] = array('upper' => 358, 'status' => 'C', 'lower' => array(359)); /* LATIN CAPITAL LETTER T WITH STROKE */ -$config['0100_017f'][] = array('upper' => 360, 'status' => 'C', 'lower' => array(361)); /* LATIN CAPITAL LETTER U WITH TILDE */ -$config['0100_017f'][] = array('upper' => 362, 'status' => 'C', 'lower' => array(363)); /* LATIN CAPITAL LETTER U WITH MACRON */ -$config['0100_017f'][] = array('upper' => 364, 'status' => 'C', 'lower' => array(365)); /* LATIN CAPITAL LETTER U WITH BREVE */ -$config['0100_017f'][] = array('upper' => 366, 'status' => 'C', 'lower' => array(367)); /* LATIN CAPITAL LETTER U WITH RING ABOVE */ -$config['0100_017f'][] = array('upper' => 368, 'status' => 'C', 'lower' => array(369)); /* LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */ -$config['0100_017f'][] = array('upper' => 370, 'status' => 'C', 'lower' => array(371)); /* LATIN CAPITAL LETTER U WITH OGONEK */ -$config['0100_017f'][] = array('upper' => 372, 'status' => 'C', 'lower' => array(373)); /* LATIN CAPITAL LETTER W WITH CIRCUMFLEX */ -$config['0100_017f'][] = array('upper' => 374, 'status' => 'C', 'lower' => array(375)); /* LATIN CAPITAL LETTER Y WITH CIRCUMFLEX */ -$config['0100_017f'][] = array('upper' => 376, 'status' => 'C', 'lower' => array(255)); /* LATIN CAPITAL LETTER Y WITH DIAERESIS */ -$config['0100_017f'][] = array('upper' => 377, 'status' => 'C', 'lower' => array(378)); /* LATIN CAPITAL LETTER Z WITH ACUTE */ -$config['0100_017f'][] = array('upper' => 379, 'status' => 'C', 'lower' => array(380)); /* LATIN CAPITAL LETTER Z WITH DOT ABOVE */ -$config['0100_017f'][] = array('upper' => 381, 'status' => 'C', 'lower' => array(382)); /* LATIN CAPITAL LETTER Z WITH CARON */ -$config['0100_017f'][] = array('upper' => 383, 'status' => 'C', 'lower' => array(115)); /* LATIN SMALL LETTER LONG S */ +$config['0100_017f'][] = ['upper' => 256, 'status' => 'C', 'lower' => [257]]; /* LATIN CAPITAL LETTER A WITH MACRON */ +$config['0100_017f'][] = ['upper' => 258, 'status' => 'C', 'lower' => [259]]; /* LATIN CAPITAL LETTER A WITH BREVE */ +$config['0100_017f'][] = ['upper' => 260, 'status' => 'C', 'lower' => [261]]; /* LATIN CAPITAL LETTER A WITH OGONEK */ +$config['0100_017f'][] = ['upper' => 262, 'status' => 'C', 'lower' => [263]]; /* LATIN CAPITAL LETTER C WITH ACUTE */ +$config['0100_017f'][] = ['upper' => 264, 'status' => 'C', 'lower' => [265]]; /* LATIN CAPITAL LETTER C WITH CIRCUMFLEX */ +$config['0100_017f'][] = ['upper' => 266, 'status' => 'C', 'lower' => [267]]; /* LATIN CAPITAL LETTER C WITH DOT ABOVE */ +$config['0100_017f'][] = ['upper' => 268, 'status' => 'C', 'lower' => [269]]; /* LATIN CAPITAL LETTER C WITH CARON */ +$config['0100_017f'][] = ['upper' => 270, 'status' => 'C', 'lower' => [271]]; /* LATIN CAPITAL LETTER D WITH CARON */ +$config['0100_017f'][] = ['upper' => 272, 'status' => 'C', 'lower' => [273]]; /* LATIN CAPITAL LETTER D WITH STROKE */ +$config['0100_017f'][] = ['upper' => 274, 'status' => 'C', 'lower' => [275]]; /* LATIN CAPITAL LETTER E WITH MACRON */ +$config['0100_017f'][] = ['upper' => 276, 'status' => 'C', 'lower' => [277]]; /* LATIN CAPITAL LETTER E WITH BREVE */ +$config['0100_017f'][] = ['upper' => 278, 'status' => 'C', 'lower' => [279]]; /* LATIN CAPITAL LETTER E WITH DOT ABOVE */ +$config['0100_017f'][] = ['upper' => 280, 'status' => 'C', 'lower' => [281]]; /* LATIN CAPITAL LETTER E WITH OGONEK */ +$config['0100_017f'][] = ['upper' => 282, 'status' => 'C', 'lower' => [283]]; /* LATIN CAPITAL LETTER E WITH CARON */ +$config['0100_017f'][] = ['upper' => 284, 'status' => 'C', 'lower' => [285]]; /* LATIN CAPITAL LETTER G WITH CIRCUMFLEX */ +$config['0100_017f'][] = ['upper' => 286, 'status' => 'C', 'lower' => [287]]; /* LATIN CAPITAL LETTER G WITH BREVE */ +$config['0100_017f'][] = ['upper' => 288, 'status' => 'C', 'lower' => [289]]; /* LATIN CAPITAL LETTER G WITH DOT ABOVE */ +$config['0100_017f'][] = ['upper' => 290, 'status' => 'C', 'lower' => [291]]; /* LATIN CAPITAL LETTER G WITH CEDILLA */ +$config['0100_017f'][] = ['upper' => 292, 'status' => 'C', 'lower' => [293]]; /* LATIN CAPITAL LETTER H WITH CIRCUMFLEX */ +$config['0100_017f'][] = ['upper' => 294, 'status' => 'C', 'lower' => [295]]; /* LATIN CAPITAL LETTER H WITH STROKE */ +$config['0100_017f'][] = ['upper' => 296, 'status' => 'C', 'lower' => [297]]; /* LATIN CAPITAL LETTER I WITH TILDE */ +$config['0100_017f'][] = ['upper' => 298, 'status' => 'C', 'lower' => [299]]; /* LATIN CAPITAL LETTER I WITH MACRON */ +$config['0100_017f'][] = ['upper' => 300, 'status' => 'C', 'lower' => [301]]; /* LATIN CAPITAL LETTER I WITH BREVE */ +$config['0100_017f'][] = ['upper' => 302, 'status' => 'C', 'lower' => [303]]; /* LATIN CAPITAL LETTER I WITH OGONEK */ +$config['0100_017f'][] = ['upper' => 304, 'status' => 'F', 'lower' => [105, 775]]; /* LATIN CAPITAL LETTER I WITH DOT ABOVE */ +$config['0100_017f'][] = ['upper' => 304, 'status' => 'T', 'lower' => [105]]; /* LATIN CAPITAL LETTER I WITH DOT ABOVE */ +$config['0100_017f'][] = ['upper' => 306, 'status' => 'C', 'lower' => [307]]; /* LATIN CAPITAL LIGATURE IJ */ +$config['0100_017f'][] = ['upper' => 308, 'status' => 'C', 'lower' => [309]]; /* LATIN CAPITAL LETTER J WITH CIRCUMFLEX */ +$config['0100_017f'][] = ['upper' => 310, 'status' => 'C', 'lower' => [311]]; /* LATIN CAPITAL LETTER K WITH CEDILLA */ +$config['0100_017f'][] = ['upper' => 313, 'status' => 'C', 'lower' => [314]]; /* LATIN CAPITAL LETTER L WITH ACUTE */ +$config['0100_017f'][] = ['upper' => 315, 'status' => 'C', 'lower' => [316]]; /* LATIN CAPITAL LETTER L WITH CEDILLA */ +$config['0100_017f'][] = ['upper' => 317, 'status' => 'C', 'lower' => [318]]; /* LATIN CAPITAL LETTER L WITH CARON */ +$config['0100_017f'][] = ['upper' => 319, 'status' => 'C', 'lower' => [320]]; /* LATIN CAPITAL LETTER L WITH MIDDLE DOT */ +$config['0100_017f'][] = ['upper' => 321, 'status' => 'C', 'lower' => [322]]; /* LATIN CAPITAL LETTER L WITH STROKE */ +$config['0100_017f'][] = ['upper' => 323, 'status' => 'C', 'lower' => [324]]; /* LATIN CAPITAL LETTER N WITH ACUTE */ +$config['0100_017f'][] = ['upper' => 325, 'status' => 'C', 'lower' => [326]]; /* LATIN CAPITAL LETTER N WITH CEDILLA */ +$config['0100_017f'][] = ['upper' => 327, 'status' => 'C', 'lower' => [328]]; /* LATIN CAPITAL LETTER N WITH CARON */ +$config['0100_017f'][] = ['upper' => 329, 'status' => 'F', 'lower' => [700, 110]]; /* LATIN SMALL LETTER N PRECEDED BY APOSTROPHE */ +$config['0100_017f'][] = ['upper' => 330, 'status' => 'C', 'lower' => [331]]; /* LATIN CAPITAL LETTER ENG */ +$config['0100_017f'][] = ['upper' => 332, 'status' => 'C', 'lower' => [333]]; /* LATIN CAPITAL LETTER O WITH MACRON */ +$config['0100_017f'][] = ['upper' => 334, 'status' => 'C', 'lower' => [335]]; /* LATIN CAPITAL LETTER O WITH BREVE */ +$config['0100_017f'][] = ['upper' => 336, 'status' => 'C', 'lower' => [337]]; /* LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */ +$config['0100_017f'][] = ['upper' => 338, 'status' => 'C', 'lower' => [339]]; /* LATIN CAPITAL LIGATURE OE */ +$config['0100_017f'][] = ['upper' => 340, 'status' => 'C', 'lower' => [341]]; /* LATIN CAPITAL LETTER R WITH ACUTE */ +$config['0100_017f'][] = ['upper' => 342, 'status' => 'C', 'lower' => [343]]; /* LATIN CAPITAL LETTER R WITH CEDILLA */ +$config['0100_017f'][] = ['upper' => 344, 'status' => 'C', 'lower' => [345]]; /* LATIN CAPITAL LETTER R WITH CARON */ +$config['0100_017f'][] = ['upper' => 346, 'status' => 'C', 'lower' => [347]]; /* LATIN CAPITAL LETTER S WITH ACUTE */ +$config['0100_017f'][] = ['upper' => 348, 'status' => 'C', 'lower' => [349]]; /* LATIN CAPITAL LETTER S WITH CIRCUMFLEX */ +$config['0100_017f'][] = ['upper' => 350, 'status' => 'C', 'lower' => [351]]; /* LATIN CAPITAL LETTER S WITH CEDILLA */ +$config['0100_017f'][] = ['upper' => 352, 'status' => 'C', 'lower' => [353]]; /* LATIN CAPITAL LETTER S WITH CARON */ +$config['0100_017f'][] = ['upper' => 354, 'status' => 'C', 'lower' => [355]]; /* LATIN CAPITAL LETTER T WITH CEDILLA */ +$config['0100_017f'][] = ['upper' => 356, 'status' => 'C', 'lower' => [357]]; /* LATIN CAPITAL LETTER T WITH CARON */ +$config['0100_017f'][] = ['upper' => 358, 'status' => 'C', 'lower' => [359]]; /* LATIN CAPITAL LETTER T WITH STROKE */ +$config['0100_017f'][] = ['upper' => 360, 'status' => 'C', 'lower' => [361]]; /* LATIN CAPITAL LETTER U WITH TILDE */ +$config['0100_017f'][] = ['upper' => 362, 'status' => 'C', 'lower' => [363]]; /* LATIN CAPITAL LETTER U WITH MACRON */ +$config['0100_017f'][] = ['upper' => 364, 'status' => 'C', 'lower' => [365]]; /* LATIN CAPITAL LETTER U WITH BREVE */ +$config['0100_017f'][] = ['upper' => 366, 'status' => 'C', 'lower' => [367]]; /* LATIN CAPITAL LETTER U WITH RING ABOVE */ +$config['0100_017f'][] = ['upper' => 368, 'status' => 'C', 'lower' => [369]]; /* LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */ +$config['0100_017f'][] = ['upper' => 370, 'status' => 'C', 'lower' => [371]]; /* LATIN CAPITAL LETTER U WITH OGONEK */ +$config['0100_017f'][] = ['upper' => 372, 'status' => 'C', 'lower' => [373]]; /* LATIN CAPITAL LETTER W WITH CIRCUMFLEX */ +$config['0100_017f'][] = ['upper' => 374, 'status' => 'C', 'lower' => [375]]; /* LATIN CAPITAL LETTER Y WITH CIRCUMFLEX */ +$config['0100_017f'][] = ['upper' => 376, 'status' => 'C', 'lower' => [255]]; /* LATIN CAPITAL LETTER Y WITH DIAERESIS */ +$config['0100_017f'][] = ['upper' => 377, 'status' => 'C', 'lower' => [378]]; /* LATIN CAPITAL LETTER Z WITH ACUTE */ +$config['0100_017f'][] = ['upper' => 379, 'status' => 'C', 'lower' => [380]]; /* LATIN CAPITAL LETTER Z WITH DOT ABOVE */ +$config['0100_017f'][] = ['upper' => 381, 'status' => 'C', 'lower' => [382]]; /* LATIN CAPITAL LETTER Z WITH CARON */ +$config['0100_017f'][] = ['upper' => 383, 'status' => 'C', 'lower' => [115]]; /* LATIN SMALL LETTER LONG S */ diff --git a/lib/Cake/Config/unicode/casefolding/0180_024F.php b/lib/Cake/Config/unicode/casefolding/0180_024F.php index f803be4e03..e557d3e37d 100644 --- a/lib/Cake/Config/unicode/casefolding/0180_024F.php +++ b/lib/Cake/Config/unicode/casefolding/0180_024F.php @@ -37,111 +37,111 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0180_024F'][] = array('upper' => 385, 'status' => 'C', 'lower' => array(595)); /* LATIN CAPITAL LETTER B WITH HOOK */ -$config['0180_024F'][] = array('upper' => 386, 'status' => 'C', 'lower' => array(387)); /* LATIN CAPITAL LETTER B WITH TOPBAR */ -$config['0180_024F'][] = array('upper' => 388, 'status' => 'C', 'lower' => array(389)); /* LATIN CAPITAL LETTER TONE SIX */ -$config['0180_024F'][] = array('upper' => 390, 'status' => 'C', 'lower' => array(596)); /* LATIN CAPITAL LETTER OPEN O */ -$config['0180_024F'][] = array('upper' => 391, 'status' => 'C', 'lower' => array(392)); /* LATIN CAPITAL LETTER C WITH HOOK */ -$config['0180_024F'][] = array('upper' => 393, 'status' => 'C', 'lower' => array(598)); /* LATIN CAPITAL LETTER AFRICAN D */ -$config['0180_024F'][] = array('upper' => 394, 'status' => 'C', 'lower' => array(599)); /* LATIN CAPITAL LETTER D WITH HOOK */ -$config['0180_024F'][] = array('upper' => 395, 'status' => 'C', 'lower' => array(396)); /* LATIN CAPITAL LETTER D WITH TOPBAR */ -$config['0180_024F'][] = array('upper' => 398, 'status' => 'C', 'lower' => array(477)); /* LATIN CAPITAL LETTER REVERSED E */ -$config['0180_024F'][] = array('upper' => 399, 'status' => 'C', 'lower' => array(601)); /* LATIN CAPITAL LETTER SCHWA */ -$config['0180_024F'][] = array('upper' => 400, 'status' => 'C', 'lower' => array(603)); /* LATIN CAPITAL LETTER OPEN E */ -$config['0180_024F'][] = array('upper' => 401, 'status' => 'C', 'lower' => array(402)); /* LATIN CAPITAL LETTER F WITH HOOK */ -$config['0180_024F'][] = array('upper' => 403, 'status' => 'C', 'lower' => array(608)); /* LATIN CAPITAL LETTER G WITH HOOK */ -$config['0180_024F'][] = array('upper' => 404, 'status' => 'C', 'lower' => array(611)); /* LATIN CAPITAL LETTER GAMMA */ -$config['0180_024F'][] = array('upper' => 406, 'status' => 'C', 'lower' => array(617)); /* LATIN CAPITAL LETTER IOTA */ -$config['0180_024F'][] = array('upper' => 407, 'status' => 'C', 'lower' => array(616)); /* LATIN CAPITAL LETTER I WITH STROKE */ -$config['0180_024F'][] = array('upper' => 408, 'status' => 'C', 'lower' => array(409)); /* LATIN CAPITAL LETTER K WITH HOOK */ -$config['0180_024F'][] = array('upper' => 412, 'status' => 'C', 'lower' => array(623)); /* LATIN CAPITAL LETTER TURNED M */ -$config['0180_024F'][] = array('upper' => 413, 'status' => 'C', 'lower' => array(626)); /* LATIN CAPITAL LETTER N WITH LEFT HOOK */ -$config['0180_024F'][] = array('upper' => 415, 'status' => 'C', 'lower' => array(629)); /* LATIN CAPITAL LETTER O WITH MIDDLE TILDE */ -$config['0180_024F'][] = array('upper' => 416, 'status' => 'C', 'lower' => array(417)); /* LATIN CAPITAL LETTER O WITH HORN */ -$config['0180_024F'][] = array('upper' => 418, 'status' => 'C', 'lower' => array(419)); /* LATIN CAPITAL LETTER OI */ -$config['0180_024F'][] = array('upper' => 420, 'status' => 'C', 'lower' => array(421)); /* LATIN CAPITAL LETTER P WITH HOOK */ -$config['0180_024F'][] = array('upper' => 422, 'status' => 'C', 'lower' => array(640)); /* LATIN LETTER YR */ -$config['0180_024F'][] = array('upper' => 423, 'status' => 'C', 'lower' => array(424)); /* LATIN CAPITAL LETTER TONE TWO */ -$config['0180_024F'][] = array('upper' => 425, 'status' => 'C', 'lower' => array(643)); /* LATIN CAPITAL LETTER ESH */ -$config['0180_024F'][] = array('upper' => 428, 'status' => 'C', 'lower' => array(429)); /* LATIN CAPITAL LETTER T WITH HOOK */ -$config['0180_024F'][] = array('upper' => 430, 'status' => 'C', 'lower' => array(648)); /* LATIN CAPITAL LETTER T WITH RETROFLEX HOOK */ -$config['0180_024F'][] = array('upper' => 431, 'status' => 'C', 'lower' => array(432)); /* LATIN CAPITAL LETTER U WITH HORN */ -$config['0180_024F'][] = array('upper' => 433, 'status' => 'C', 'lower' => array(650)); /* LATIN CAPITAL LETTER UPSILON */ -$config['0180_024F'][] = array('upper' => 434, 'status' => 'C', 'lower' => array(651)); /* LATIN CAPITAL LETTER V WITH HOOK */ -$config['0180_024F'][] = array('upper' => 435, 'status' => 'C', 'lower' => array(436)); /* LATIN CAPITAL LETTER Y WITH HOOK */ -$config['0180_024F'][] = array('upper' => 437, 'status' => 'C', 'lower' => array(438)); /* LATIN CAPITAL LETTER Z WITH STROKE */ -$config['0180_024F'][] = array('upper' => 439, 'status' => 'C', 'lower' => array(658)); /* LATIN CAPITAL LETTER EZH */ -$config['0180_024F'][] = array('upper' => 440, 'status' => 'C', 'lower' => array(441)); /* LATIN CAPITAL LETTER EZH REVERSED */ -$config['0180_024F'][] = array('upper' => 444, 'status' => 'C', 'lower' => array(445)); /* LATIN CAPITAL LETTER TONE FIVE */ -$config['0180_024F'][] = array('upper' => 452, 'status' => 'C', 'lower' => array(454)); /* LATIN CAPITAL LETTER DZ WITH CARON */ -$config['0180_024F'][] = array('upper' => 453, 'status' => 'C', 'lower' => array(454)); /* LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON */ -$config['0180_024F'][] = array('upper' => 455, 'status' => 'C', 'lower' => array(457)); /* LATIN CAPITAL LETTER LJ */ -$config['0180_024F'][] = array('upper' => 456, 'status' => 'C', 'lower' => array(457)); /* LATIN CAPITAL LETTER L WITH SMALL LETTER J */ -$config['0180_024F'][] = array('upper' => 458, 'status' => 'C', 'lower' => array(460)); /* LATIN CAPITAL LETTER NJ */ -$config['0180_024F'][] = array('upper' => 459, 'status' => 'C', 'lower' => array(460)); /* LATIN CAPITAL LETTER N WITH SMALL LETTER J */ -$config['0180_024F'][] = array('upper' => 461, 'status' => 'C', 'lower' => array(462)); /* LATIN CAPITAL LETTER A WITH CARON */ -$config['0180_024F'][] = array('upper' => 463, 'status' => 'C', 'lower' => array(464)); /* LATIN CAPITAL LETTER I WITH CARON */ -$config['0180_024F'][] = array('upper' => 465, 'status' => 'C', 'lower' => array(466)); /* LATIN CAPITAL LETTER O WITH CARON */ -$config['0180_024F'][] = array('upper' => 467, 'status' => 'C', 'lower' => array(468)); /* LATIN CAPITAL LETTER U WITH CARON */ -$config['0180_024F'][] = array('upper' => 469, 'status' => 'C', 'lower' => array(470)); /* LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON */ -$config['0180_024F'][] = array('upper' => 471, 'status' => 'C', 'lower' => array(472)); /* LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE */ -$config['0180_024F'][] = array('upper' => 473, 'status' => 'C', 'lower' => array(474)); /* LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON */ -$config['0180_024F'][] = array('upper' => 475, 'status' => 'C', 'lower' => array(476)); /* LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE */ -$config['0180_024F'][] = array('upper' => 478, 'status' => 'C', 'lower' => array(479)); /* LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON */ -$config['0180_024F'][] = array('upper' => 480, 'status' => 'C', 'lower' => array(481)); /* LATIN CAPITAL LETTER A WITH DOT ABOVE AND MACRON */ -$config['0180_024F'][] = array('upper' => 482, 'status' => 'C', 'lower' => array(483)); /* LATIN CAPITAL LETTER AE WITH MACRON */ -$config['0180_024F'][] = array('upper' => 484, 'status' => 'C', 'lower' => array(485)); /* LATIN CAPITAL LETTER G WITH STROKE */ -$config['0180_024F'][] = array('upper' => 486, 'status' => 'C', 'lower' => array(487)); /* LATIN CAPITAL LETTER G WITH CARON */ -$config['0180_024F'][] = array('upper' => 488, 'status' => 'C', 'lower' => array(489)); /* LATIN CAPITAL LETTER K WITH CARON */ -$config['0180_024F'][] = array('upper' => 490, 'status' => 'C', 'lower' => array(491)); /* LATIN CAPITAL LETTER O WITH OGONEK */ -$config['0180_024F'][] = array('upper' => 492, 'status' => 'C', 'lower' => array(493)); /* LATIN CAPITAL LETTER O WITH OGONEK AND MACRON */ -$config['0180_024F'][] = array('upper' => 494, 'status' => 'C', 'lower' => array(495)); /* LATIN CAPITAL LETTER EZH WITH CARON */ -$config['0180_024F'][] = array('upper' => 496, 'status' => 'F', 'lower' => array(106, 780)); /* LATIN SMALL LETTER J WITH CARON */ -$config['0180_024F'][] = array('upper' => 497, 'status' => 'C', 'lower' => array(499)); /* LATIN CAPITAL LETTER DZ */ -$config['0180_024F'][] = array('upper' => 498, 'status' => 'C', 'lower' => array(499)); /* LATIN CAPITAL LETTER D WITH SMALL LETTER Z */ -$config['0180_024F'][] = array('upper' => 500, 'status' => 'C', 'lower' => array(501)); /* LATIN CAPITAL LETTER G WITH ACUTE */ -$config['0180_024F'][] = array('upper' => 502, 'status' => 'C', 'lower' => array(405)); /* LATIN CAPITAL LETTER HWAIR */ -$config['0180_024F'][] = array('upper' => 503, 'status' => 'C', 'lower' => array(447)); /* LATIN CAPITAL LETTER WYNN */ -$config['0180_024F'][] = array('upper' => 504, 'status' => 'C', 'lower' => array(505)); /* LATIN CAPITAL LETTER N WITH GRAVE */ -$config['0180_024F'][] = array('upper' => 506, 'status' => 'C', 'lower' => array(507)); /* LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE */ -$config['0180_024F'][] = array('upper' => 508, 'status' => 'C', 'lower' => array(509)); /* LATIN CAPITAL LETTER AE WITH ACUTE */ -$config['0180_024F'][] = array('upper' => 510, 'status' => 'C', 'lower' => array(511)); /* LATIN CAPITAL LETTER O WITH STROKE AND ACUTE */ -$config['0180_024F'][] = array('upper' => 512, 'status' => 'C', 'lower' => array(513)); /* LATIN CAPITAL LETTER A WITH DOUBLE GRAVE */ -$config['0180_024F'][] = array('upper' => 514, 'status' => 'C', 'lower' => array(515)); /* LATIN CAPITAL LETTER A WITH INVERTED BREVE */ -$config['0180_024F'][] = array('upper' => 516, 'status' => 'C', 'lower' => array(517)); /* LATIN CAPITAL LETTER E WITH DOUBLE GRAVE */ -$config['0180_024F'][] = array('upper' => 518, 'status' => 'C', 'lower' => array(519)); /* LATIN CAPITAL LETTER E WITH INVERTED BREVE */ -$config['0180_024F'][] = array('upper' => 520, 'status' => 'C', 'lower' => array(521)); /* LATIN CAPITAL LETTER I WITH DOUBLE GRAVE */ -$config['0180_024F'][] = array('upper' => 522, 'status' => 'C', 'lower' => array(523)); /* LATIN CAPITAL LETTER I WITH INVERTED BREVE */ -$config['0180_024F'][] = array('upper' => 524, 'status' => 'C', 'lower' => array(525)); /* LATIN CAPITAL LETTER O WITH DOUBLE GRAVE */ -$config['0180_024F'][] = array('upper' => 526, 'status' => 'C', 'lower' => array(527)); /* LATIN CAPITAL LETTER O WITH INVERTED BREVE */ -$config['0180_024F'][] = array('upper' => 528, 'status' => 'C', 'lower' => array(529)); /* LATIN CAPITAL LETTER R WITH DOUBLE GRAVE */ -$config['0180_024F'][] = array('upper' => 530, 'status' => 'C', 'lower' => array(531)); /* LATIN CAPITAL LETTER R WITH INVERTED BREVE */ -$config['0180_024F'][] = array('upper' => 532, 'status' => 'C', 'lower' => array(533)); /* LATIN CAPITAL LETTER U WITH DOUBLE GRAVE */ -$config['0180_024F'][] = array('upper' => 534, 'status' => 'C', 'lower' => array(535)); /* LATIN CAPITAL LETTER U WITH INVERTED BREVE */ -$config['0180_024F'][] = array('upper' => 536, 'status' => 'C', 'lower' => array(537)); /* LATIN CAPITAL LETTER S WITH COMMA BELOW */ -$config['0180_024F'][] = array('upper' => 538, 'status' => 'C', 'lower' => array(539)); /* LATIN CAPITAL LETTER T WITH COMMA BELOW */ -$config['0180_024F'][] = array('upper' => 540, 'status' => 'C', 'lower' => array(541)); /* LATIN CAPITAL LETTER YOGH */ -$config['0180_024F'][] = array('upper' => 542, 'status' => 'C', 'lower' => array(543)); /* LATIN CAPITAL LETTER H WITH CARON */ -$config['0180_024F'][] = array('upper' => 544, 'status' => 'C', 'lower' => array(414)); /* LATIN CAPITAL LETTER N WITH LONG RIGHT LEG */ -$config['0180_024F'][] = array('upper' => 546, 'status' => 'C', 'lower' => array(547)); /* LATIN CAPITAL LETTER OU */ -$config['0180_024F'][] = array('upper' => 548, 'status' => 'C', 'lower' => array(549)); /* LATIN CAPITAL LETTER Z WITH HOOK */ -$config['0180_024F'][] = array('upper' => 550, 'status' => 'C', 'lower' => array(551)); /* LATIN CAPITAL LETTER A WITH DOT ABOVE */ -$config['0180_024F'][] = array('upper' => 552, 'status' => 'C', 'lower' => array(553)); /* LATIN CAPITAL LETTER E WITH CEDILLA */ -$config['0180_024F'][] = array('upper' => 554, 'status' => 'C', 'lower' => array(555)); /* LATIN CAPITAL LETTER O WITH DIAERESIS AND MACRON */ -$config['0180_024F'][] = array('upper' => 556, 'status' => 'C', 'lower' => array(557)); /* LATIN CAPITAL LETTER O WITH TILDE AND MACRON */ -$config['0180_024F'][] = array('upper' => 558, 'status' => 'C', 'lower' => array(559)); /* LATIN CAPITAL LETTER O WITH DOT ABOVE */ -$config['0180_024F'][] = array('upper' => 560, 'status' => 'C', 'lower' => array(561)); /* LATIN CAPITAL LETTER O WITH DOT ABOVE AND MACRON */ -$config['0180_024F'][] = array('upper' => 562, 'status' => 'C', 'lower' => array(563)); /* LATIN CAPITAL LETTER Y WITH MACRON */ -$config['0180_024F'][] = array('upper' => 570, 'status' => 'C', 'lower' => array(11365)); /* LATIN CAPITAL LETTER A WITH STROKE */ -$config['0180_024F'][] = array('upper' => 571, 'status' => 'C', 'lower' => array(572)); /* LATIN CAPITAL LETTER C WITH STROKE */ -$config['0180_024F'][] = array('upper' => 573, 'status' => 'C', 'lower' => array(410)); /* LATIN CAPITAL LETTER L WITH BAR */ -$config['0180_024F'][] = array('upper' => 574, 'status' => 'C', 'lower' => array(11366)); /* LATIN CAPITAL LETTER T WITH DIAGONAL STROKE */ -$config['0180_024F'][] = array('upper' => 577, 'status' => 'C', 'lower' => array(578)); /* LATIN CAPITAL LETTER GLOTTAL STOP */ -$config['0180_024F'][] = array('upper' => 579, 'status' => 'C', 'lower' => array(384)); /* LATIN CAPITAL LETTER B WITH STROKE */ -$config['0180_024F'][] = array('upper' => 580, 'status' => 'C', 'lower' => array(649)); /* LATIN CAPITAL LETTER U BAR */ -$config['0180_024F'][] = array('upper' => 581, 'status' => 'C', 'lower' => array(652)); /* LATIN CAPITAL LETTER TURNED V */ -$config['0180_024F'][] = array('upper' => 582, 'status' => 'C', 'lower' => array(583)); /* LATIN CAPITAL LETTER E WITH STROKE */ -$config['0180_024F'][] = array('upper' => 584, 'status' => 'C', 'lower' => array(585)); /* LATIN CAPITAL LETTER J WITH STROKE */ -$config['0180_024F'][] = array('upper' => 586, 'status' => 'C', 'lower' => array(587)); /* LATIN CAPITAL LETTER SMALL Q WITH HOOK TAIL */ -$config['0180_024F'][] = array('upper' => 588, 'status' => 'C', 'lower' => array(589)); /* LATIN CAPITAL LETTER R WITH STROKE */ -$config['0180_024F'][] = array('upper' => 590, 'status' => 'C', 'lower' => array(591)); /* LATIN CAPITAL LETTER Y WITH STROKE */ +$config['0180_024F'][] = ['upper' => 385, 'status' => 'C', 'lower' => [595]]; /* LATIN CAPITAL LETTER B WITH HOOK */ +$config['0180_024F'][] = ['upper' => 386, 'status' => 'C', 'lower' => [387]]; /* LATIN CAPITAL LETTER B WITH TOPBAR */ +$config['0180_024F'][] = ['upper' => 388, 'status' => 'C', 'lower' => [389]]; /* LATIN CAPITAL LETTER TONE SIX */ +$config['0180_024F'][] = ['upper' => 390, 'status' => 'C', 'lower' => [596]]; /* LATIN CAPITAL LETTER OPEN O */ +$config['0180_024F'][] = ['upper' => 391, 'status' => 'C', 'lower' => [392]]; /* LATIN CAPITAL LETTER C WITH HOOK */ +$config['0180_024F'][] = ['upper' => 393, 'status' => 'C', 'lower' => [598]]; /* LATIN CAPITAL LETTER AFRICAN D */ +$config['0180_024F'][] = ['upper' => 394, 'status' => 'C', 'lower' => [599]]; /* LATIN CAPITAL LETTER D WITH HOOK */ +$config['0180_024F'][] = ['upper' => 395, 'status' => 'C', 'lower' => [396]]; /* LATIN CAPITAL LETTER D WITH TOPBAR */ +$config['0180_024F'][] = ['upper' => 398, 'status' => 'C', 'lower' => [477]]; /* LATIN CAPITAL LETTER REVERSED E */ +$config['0180_024F'][] = ['upper' => 399, 'status' => 'C', 'lower' => [601]]; /* LATIN CAPITAL LETTER SCHWA */ +$config['0180_024F'][] = ['upper' => 400, 'status' => 'C', 'lower' => [603]]; /* LATIN CAPITAL LETTER OPEN E */ +$config['0180_024F'][] = ['upper' => 401, 'status' => 'C', 'lower' => [402]]; /* LATIN CAPITAL LETTER F WITH HOOK */ +$config['0180_024F'][] = ['upper' => 403, 'status' => 'C', 'lower' => [608]]; /* LATIN CAPITAL LETTER G WITH HOOK */ +$config['0180_024F'][] = ['upper' => 404, 'status' => 'C', 'lower' => [611]]; /* LATIN CAPITAL LETTER GAMMA */ +$config['0180_024F'][] = ['upper' => 406, 'status' => 'C', 'lower' => [617]]; /* LATIN CAPITAL LETTER IOTA */ +$config['0180_024F'][] = ['upper' => 407, 'status' => 'C', 'lower' => [616]]; /* LATIN CAPITAL LETTER I WITH STROKE */ +$config['0180_024F'][] = ['upper' => 408, 'status' => 'C', 'lower' => [409]]; /* LATIN CAPITAL LETTER K WITH HOOK */ +$config['0180_024F'][] = ['upper' => 412, 'status' => 'C', 'lower' => [623]]; /* LATIN CAPITAL LETTER TURNED M */ +$config['0180_024F'][] = ['upper' => 413, 'status' => 'C', 'lower' => [626]]; /* LATIN CAPITAL LETTER N WITH LEFT HOOK */ +$config['0180_024F'][] = ['upper' => 415, 'status' => 'C', 'lower' => [629]]; /* LATIN CAPITAL LETTER O WITH MIDDLE TILDE */ +$config['0180_024F'][] = ['upper' => 416, 'status' => 'C', 'lower' => [417]]; /* LATIN CAPITAL LETTER O WITH HORN */ +$config['0180_024F'][] = ['upper' => 418, 'status' => 'C', 'lower' => [419]]; /* LATIN CAPITAL LETTER OI */ +$config['0180_024F'][] = ['upper' => 420, 'status' => 'C', 'lower' => [421]]; /* LATIN CAPITAL LETTER P WITH HOOK */ +$config['0180_024F'][] = ['upper' => 422, 'status' => 'C', 'lower' => [640]]; /* LATIN LETTER YR */ +$config['0180_024F'][] = ['upper' => 423, 'status' => 'C', 'lower' => [424]]; /* LATIN CAPITAL LETTER TONE TWO */ +$config['0180_024F'][] = ['upper' => 425, 'status' => 'C', 'lower' => [643]]; /* LATIN CAPITAL LETTER ESH */ +$config['0180_024F'][] = ['upper' => 428, 'status' => 'C', 'lower' => [429]]; /* LATIN CAPITAL LETTER T WITH HOOK */ +$config['0180_024F'][] = ['upper' => 430, 'status' => 'C', 'lower' => [648]]; /* LATIN CAPITAL LETTER T WITH RETROFLEX HOOK */ +$config['0180_024F'][] = ['upper' => 431, 'status' => 'C', 'lower' => [432]]; /* LATIN CAPITAL LETTER U WITH HORN */ +$config['0180_024F'][] = ['upper' => 433, 'status' => 'C', 'lower' => [650]]; /* LATIN CAPITAL LETTER UPSILON */ +$config['0180_024F'][] = ['upper' => 434, 'status' => 'C', 'lower' => [651]]; /* LATIN CAPITAL LETTER V WITH HOOK */ +$config['0180_024F'][] = ['upper' => 435, 'status' => 'C', 'lower' => [436]]; /* LATIN CAPITAL LETTER Y WITH HOOK */ +$config['0180_024F'][] = ['upper' => 437, 'status' => 'C', 'lower' => [438]]; /* LATIN CAPITAL LETTER Z WITH STROKE */ +$config['0180_024F'][] = ['upper' => 439, 'status' => 'C', 'lower' => [658]]; /* LATIN CAPITAL LETTER EZH */ +$config['0180_024F'][] = ['upper' => 440, 'status' => 'C', 'lower' => [441]]; /* LATIN CAPITAL LETTER EZH REVERSED */ +$config['0180_024F'][] = ['upper' => 444, 'status' => 'C', 'lower' => [445]]; /* LATIN CAPITAL LETTER TONE FIVE */ +$config['0180_024F'][] = ['upper' => 452, 'status' => 'C', 'lower' => [454]]; /* LATIN CAPITAL LETTER DZ WITH CARON */ +$config['0180_024F'][] = ['upper' => 453, 'status' => 'C', 'lower' => [454]]; /* LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON */ +$config['0180_024F'][] = ['upper' => 455, 'status' => 'C', 'lower' => [457]]; /* LATIN CAPITAL LETTER LJ */ +$config['0180_024F'][] = ['upper' => 456, 'status' => 'C', 'lower' => [457]]; /* LATIN CAPITAL LETTER L WITH SMALL LETTER J */ +$config['0180_024F'][] = ['upper' => 458, 'status' => 'C', 'lower' => [460]]; /* LATIN CAPITAL LETTER NJ */ +$config['0180_024F'][] = ['upper' => 459, 'status' => 'C', 'lower' => [460]]; /* LATIN CAPITAL LETTER N WITH SMALL LETTER J */ +$config['0180_024F'][] = ['upper' => 461, 'status' => 'C', 'lower' => [462]]; /* LATIN CAPITAL LETTER A WITH CARON */ +$config['0180_024F'][] = ['upper' => 463, 'status' => 'C', 'lower' => [464]]; /* LATIN CAPITAL LETTER I WITH CARON */ +$config['0180_024F'][] = ['upper' => 465, 'status' => 'C', 'lower' => [466]]; /* LATIN CAPITAL LETTER O WITH CARON */ +$config['0180_024F'][] = ['upper' => 467, 'status' => 'C', 'lower' => [468]]; /* LATIN CAPITAL LETTER U WITH CARON */ +$config['0180_024F'][] = ['upper' => 469, 'status' => 'C', 'lower' => [470]]; /* LATIN CAPITAL LETTER U WITH DIAERESIS AND MACRON */ +$config['0180_024F'][] = ['upper' => 471, 'status' => 'C', 'lower' => [472]]; /* LATIN CAPITAL LETTER U WITH DIAERESIS AND ACUTE */ +$config['0180_024F'][] = ['upper' => 473, 'status' => 'C', 'lower' => [474]]; /* LATIN CAPITAL LETTER U WITH DIAERESIS AND CARON */ +$config['0180_024F'][] = ['upper' => 475, 'status' => 'C', 'lower' => [476]]; /* LATIN CAPITAL LETTER U WITH DIAERESIS AND GRAVE */ +$config['0180_024F'][] = ['upper' => 478, 'status' => 'C', 'lower' => [479]]; /* LATIN CAPITAL LETTER A WITH DIAERESIS AND MACRON */ +$config['0180_024F'][] = ['upper' => 480, 'status' => 'C', 'lower' => [481]]; /* LATIN CAPITAL LETTER A WITH DOT ABOVE AND MACRON */ +$config['0180_024F'][] = ['upper' => 482, 'status' => 'C', 'lower' => [483]]; /* LATIN CAPITAL LETTER AE WITH MACRON */ +$config['0180_024F'][] = ['upper' => 484, 'status' => 'C', 'lower' => [485]]; /* LATIN CAPITAL LETTER G WITH STROKE */ +$config['0180_024F'][] = ['upper' => 486, 'status' => 'C', 'lower' => [487]]; /* LATIN CAPITAL LETTER G WITH CARON */ +$config['0180_024F'][] = ['upper' => 488, 'status' => 'C', 'lower' => [489]]; /* LATIN CAPITAL LETTER K WITH CARON */ +$config['0180_024F'][] = ['upper' => 490, 'status' => 'C', 'lower' => [491]]; /* LATIN CAPITAL LETTER O WITH OGONEK */ +$config['0180_024F'][] = ['upper' => 492, 'status' => 'C', 'lower' => [493]]; /* LATIN CAPITAL LETTER O WITH OGONEK AND MACRON */ +$config['0180_024F'][] = ['upper' => 494, 'status' => 'C', 'lower' => [495]]; /* LATIN CAPITAL LETTER EZH WITH CARON */ +$config['0180_024F'][] = ['upper' => 496, 'status' => 'F', 'lower' => [106, 780]]; /* LATIN SMALL LETTER J WITH CARON */ +$config['0180_024F'][] = ['upper' => 497, 'status' => 'C', 'lower' => [499]]; /* LATIN CAPITAL LETTER DZ */ +$config['0180_024F'][] = ['upper' => 498, 'status' => 'C', 'lower' => [499]]; /* LATIN CAPITAL LETTER D WITH SMALL LETTER Z */ +$config['0180_024F'][] = ['upper' => 500, 'status' => 'C', 'lower' => [501]]; /* LATIN CAPITAL LETTER G WITH ACUTE */ +$config['0180_024F'][] = ['upper' => 502, 'status' => 'C', 'lower' => [405]]; /* LATIN CAPITAL LETTER HWAIR */ +$config['0180_024F'][] = ['upper' => 503, 'status' => 'C', 'lower' => [447]]; /* LATIN CAPITAL LETTER WYNN */ +$config['0180_024F'][] = ['upper' => 504, 'status' => 'C', 'lower' => [505]]; /* LATIN CAPITAL LETTER N WITH GRAVE */ +$config['0180_024F'][] = ['upper' => 506, 'status' => 'C', 'lower' => [507]]; /* LATIN CAPITAL LETTER A WITH RING ABOVE AND ACUTE */ +$config['0180_024F'][] = ['upper' => 508, 'status' => 'C', 'lower' => [509]]; /* LATIN CAPITAL LETTER AE WITH ACUTE */ +$config['0180_024F'][] = ['upper' => 510, 'status' => 'C', 'lower' => [511]]; /* LATIN CAPITAL LETTER O WITH STROKE AND ACUTE */ +$config['0180_024F'][] = ['upper' => 512, 'status' => 'C', 'lower' => [513]]; /* LATIN CAPITAL LETTER A WITH DOUBLE GRAVE */ +$config['0180_024F'][] = ['upper' => 514, 'status' => 'C', 'lower' => [515]]; /* LATIN CAPITAL LETTER A WITH INVERTED BREVE */ +$config['0180_024F'][] = ['upper' => 516, 'status' => 'C', 'lower' => [517]]; /* LATIN CAPITAL LETTER E WITH DOUBLE GRAVE */ +$config['0180_024F'][] = ['upper' => 518, 'status' => 'C', 'lower' => [519]]; /* LATIN CAPITAL LETTER E WITH INVERTED BREVE */ +$config['0180_024F'][] = ['upper' => 520, 'status' => 'C', 'lower' => [521]]; /* LATIN CAPITAL LETTER I WITH DOUBLE GRAVE */ +$config['0180_024F'][] = ['upper' => 522, 'status' => 'C', 'lower' => [523]]; /* LATIN CAPITAL LETTER I WITH INVERTED BREVE */ +$config['0180_024F'][] = ['upper' => 524, 'status' => 'C', 'lower' => [525]]; /* LATIN CAPITAL LETTER O WITH DOUBLE GRAVE */ +$config['0180_024F'][] = ['upper' => 526, 'status' => 'C', 'lower' => [527]]; /* LATIN CAPITAL LETTER O WITH INVERTED BREVE */ +$config['0180_024F'][] = ['upper' => 528, 'status' => 'C', 'lower' => [529]]; /* LATIN CAPITAL LETTER R WITH DOUBLE GRAVE */ +$config['0180_024F'][] = ['upper' => 530, 'status' => 'C', 'lower' => [531]]; /* LATIN CAPITAL LETTER R WITH INVERTED BREVE */ +$config['0180_024F'][] = ['upper' => 532, 'status' => 'C', 'lower' => [533]]; /* LATIN CAPITAL LETTER U WITH DOUBLE GRAVE */ +$config['0180_024F'][] = ['upper' => 534, 'status' => 'C', 'lower' => [535]]; /* LATIN CAPITAL LETTER U WITH INVERTED BREVE */ +$config['0180_024F'][] = ['upper' => 536, 'status' => 'C', 'lower' => [537]]; /* LATIN CAPITAL LETTER S WITH COMMA BELOW */ +$config['0180_024F'][] = ['upper' => 538, 'status' => 'C', 'lower' => [539]]; /* LATIN CAPITAL LETTER T WITH COMMA BELOW */ +$config['0180_024F'][] = ['upper' => 540, 'status' => 'C', 'lower' => [541]]; /* LATIN CAPITAL LETTER YOGH */ +$config['0180_024F'][] = ['upper' => 542, 'status' => 'C', 'lower' => [543]]; /* LATIN CAPITAL LETTER H WITH CARON */ +$config['0180_024F'][] = ['upper' => 544, 'status' => 'C', 'lower' => [414]]; /* LATIN CAPITAL LETTER N WITH LONG RIGHT LEG */ +$config['0180_024F'][] = ['upper' => 546, 'status' => 'C', 'lower' => [547]]; /* LATIN CAPITAL LETTER OU */ +$config['0180_024F'][] = ['upper' => 548, 'status' => 'C', 'lower' => [549]]; /* LATIN CAPITAL LETTER Z WITH HOOK */ +$config['0180_024F'][] = ['upper' => 550, 'status' => 'C', 'lower' => [551]]; /* LATIN CAPITAL LETTER A WITH DOT ABOVE */ +$config['0180_024F'][] = ['upper' => 552, 'status' => 'C', 'lower' => [553]]; /* LATIN CAPITAL LETTER E WITH CEDILLA */ +$config['0180_024F'][] = ['upper' => 554, 'status' => 'C', 'lower' => [555]]; /* LATIN CAPITAL LETTER O WITH DIAERESIS AND MACRON */ +$config['0180_024F'][] = ['upper' => 556, 'status' => 'C', 'lower' => [557]]; /* LATIN CAPITAL LETTER O WITH TILDE AND MACRON */ +$config['0180_024F'][] = ['upper' => 558, 'status' => 'C', 'lower' => [559]]; /* LATIN CAPITAL LETTER O WITH DOT ABOVE */ +$config['0180_024F'][] = ['upper' => 560, 'status' => 'C', 'lower' => [561]]; /* LATIN CAPITAL LETTER O WITH DOT ABOVE AND MACRON */ +$config['0180_024F'][] = ['upper' => 562, 'status' => 'C', 'lower' => [563]]; /* LATIN CAPITAL LETTER Y WITH MACRON */ +$config['0180_024F'][] = ['upper' => 570, 'status' => 'C', 'lower' => [11365]]; /* LATIN CAPITAL LETTER A WITH STROKE */ +$config['0180_024F'][] = ['upper' => 571, 'status' => 'C', 'lower' => [572]]; /* LATIN CAPITAL LETTER C WITH STROKE */ +$config['0180_024F'][] = ['upper' => 573, 'status' => 'C', 'lower' => [410]]; /* LATIN CAPITAL LETTER L WITH BAR */ +$config['0180_024F'][] = ['upper' => 574, 'status' => 'C', 'lower' => [11366]]; /* LATIN CAPITAL LETTER T WITH DIAGONAL STROKE */ +$config['0180_024F'][] = ['upper' => 577, 'status' => 'C', 'lower' => [578]]; /* LATIN CAPITAL LETTER GLOTTAL STOP */ +$config['0180_024F'][] = ['upper' => 579, 'status' => 'C', 'lower' => [384]]; /* LATIN CAPITAL LETTER B WITH STROKE */ +$config['0180_024F'][] = ['upper' => 580, 'status' => 'C', 'lower' => [649]]; /* LATIN CAPITAL LETTER U BAR */ +$config['0180_024F'][] = ['upper' => 581, 'status' => 'C', 'lower' => [652]]; /* LATIN CAPITAL LETTER TURNED V */ +$config['0180_024F'][] = ['upper' => 582, 'status' => 'C', 'lower' => [583]]; /* LATIN CAPITAL LETTER E WITH STROKE */ +$config['0180_024F'][] = ['upper' => 584, 'status' => 'C', 'lower' => [585]]; /* LATIN CAPITAL LETTER J WITH STROKE */ +$config['0180_024F'][] = ['upper' => 586, 'status' => 'C', 'lower' => [587]]; /* LATIN CAPITAL LETTER SMALL Q WITH HOOK TAIL */ +$config['0180_024F'][] = ['upper' => 588, 'status' => 'C', 'lower' => [589]]; /* LATIN CAPITAL LETTER R WITH STROKE */ +$config['0180_024F'][] = ['upper' => 590, 'status' => 'C', 'lower' => [591]]; /* LATIN CAPITAL LETTER Y WITH STROKE */ diff --git a/lib/Cake/Config/unicode/casefolding/0250_02af.php b/lib/Cake/Config/unicode/casefolding/0250_02af.php index b9e09a8c6e..8cc1fbf9f6 100644 --- a/lib/Cake/Config/unicode/casefolding/0250_02af.php +++ b/lib/Cake/Config/unicode/casefolding/0250_02af.php @@ -37,4 +37,4 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0250_02af'][] = array('upper' => 422, 'status' => 'C', 'lower' => array(640)); +$config['0250_02af'][] = ['upper' => 422, 'status' => 'C', 'lower' => [640]]; diff --git a/lib/Cake/Config/unicode/casefolding/0370_03ff.php b/lib/Cake/Config/unicode/casefolding/0370_03ff.php index 97eac64419..a1c5afcec8 100644 --- a/lib/Cake/Config/unicode/casefolding/0370_03ff.php +++ b/lib/Cake/Config/unicode/casefolding/0370_03ff.php @@ -37,65 +37,65 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0370_03ff'][] = array('upper' => 902, 'status' => 'C', 'lower' => array(940)); /* GREEK CAPITAL LETTER ALPHA WITH TONOS */ -$config['0370_03ff'][] = array('upper' => 904, 'status' => 'C', 'lower' => array(941)); /* GREEK CAPITAL LETTER EPSILON WITH TONOS */ -$config['0370_03ff'][] = array('upper' => 905, 'status' => 'C', 'lower' => array(942)); /* GREEK CAPITAL LETTER ETA WITH TONOS */ -$config['0370_03ff'][] = array('upper' => 906, 'status' => 'C', 'lower' => array(943)); /* GREEK CAPITAL LETTER IOTA WITH TONOS */ -$config['0370_03ff'][] = array('upper' => 908, 'status' => 'C', 'lower' => array(972)); /* GREEK CAPITAL LETTER OMICRON WITH TONOS */ -$config['0370_03ff'][] = array('upper' => 910, 'status' => 'C', 'lower' => array(973)); /* GREEK CAPITAL LETTER UPSILON WITH TONOS */ -$config['0370_03ff'][] = array('upper' => 911, 'status' => 'C', 'lower' => array(974)); /* GREEK CAPITAL LETTER OMEGA WITH TONOS */ +$config['0370_03ff'][] = ['upper' => 902, 'status' => 'C', 'lower' => [940]]; /* GREEK CAPITAL LETTER ALPHA WITH TONOS */ +$config['0370_03ff'][] = ['upper' => 904, 'status' => 'C', 'lower' => [941]]; /* GREEK CAPITAL LETTER EPSILON WITH TONOS */ +$config['0370_03ff'][] = ['upper' => 905, 'status' => 'C', 'lower' => [942]]; /* GREEK CAPITAL LETTER ETA WITH TONOS */ +$config['0370_03ff'][] = ['upper' => 906, 'status' => 'C', 'lower' => [943]]; /* GREEK CAPITAL LETTER IOTA WITH TONOS */ +$config['0370_03ff'][] = ['upper' => 908, 'status' => 'C', 'lower' => [972]]; /* GREEK CAPITAL LETTER OMICRON WITH TONOS */ +$config['0370_03ff'][] = ['upper' => 910, 'status' => 'C', 'lower' => [973]]; /* GREEK CAPITAL LETTER UPSILON WITH TONOS */ +$config['0370_03ff'][] = ['upper' => 911, 'status' => 'C', 'lower' => [974]]; /* GREEK CAPITAL LETTER OMEGA WITH TONOS */ //$config['0370_03ff'][] = array('upper' => 912, 'status' => 'F', 'lower' => array(953, 776, 769)); /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */ -$config['0370_03ff'][] = array('upper' => 913, 'status' => 'C', 'lower' => array(945)); /* GREEK CAPITAL LETTER ALPHA */ -$config['0370_03ff'][] = array('upper' => 914, 'status' => 'C', 'lower' => array(946)); /* GREEK CAPITAL LETTER BETA */ -$config['0370_03ff'][] = array('upper' => 915, 'status' => 'C', 'lower' => array(947)); /* GREEK CAPITAL LETTER GAMMA */ -$config['0370_03ff'][] = array('upper' => 916, 'status' => 'C', 'lower' => array(948)); /* GREEK CAPITAL LETTER DELTA */ -$config['0370_03ff'][] = array('upper' => 917, 'status' => 'C', 'lower' => array(949)); /* GREEK CAPITAL LETTER EPSILON */ -$config['0370_03ff'][] = array('upper' => 918, 'status' => 'C', 'lower' => array(950)); /* GREEK CAPITAL LETTER ZETA */ -$config['0370_03ff'][] = array('upper' => 919, 'status' => 'C', 'lower' => array(951)); /* GREEK CAPITAL LETTER ETA */ -$config['0370_03ff'][] = array('upper' => 920, 'status' => 'C', 'lower' => array(952)); /* GREEK CAPITAL LETTER THETA */ -$config['0370_03ff'][] = array('upper' => 921, 'status' => 'C', 'lower' => array(953)); /* GREEK CAPITAL LETTER IOTA */ -$config['0370_03ff'][] = array('upper' => 922, 'status' => 'C', 'lower' => array(954)); /* GREEK CAPITAL LETTER KAPPA */ -$config['0370_03ff'][] = array('upper' => 923, 'status' => 'C', 'lower' => array(955)); /* GREEK CAPITAL LETTER LAMDA */ -$config['0370_03ff'][] = array('upper' => 924, 'status' => 'C', 'lower' => array(956)); /* GREEK CAPITAL LETTER MU */ -$config['0370_03ff'][] = array('upper' => 925, 'status' => 'C', 'lower' => array(957)); /* GREEK CAPITAL LETTER NU */ -$config['0370_03ff'][] = array('upper' => 926, 'status' => 'C', 'lower' => array(958)); /* GREEK CAPITAL LETTER XI */ -$config['0370_03ff'][] = array('upper' => 927, 'status' => 'C', 'lower' => array(959)); /* GREEK CAPITAL LETTER OMICRON */ -$config['0370_03ff'][] = array('upper' => 928, 'status' => 'C', 'lower' => array(960)); /* GREEK CAPITAL LETTER PI */ -$config['0370_03ff'][] = array('upper' => 929, 'status' => 'C', 'lower' => array(961)); /* GREEK CAPITAL LETTER RHO */ -$config['0370_03ff'][] = array('upper' => 931, 'status' => 'C', 'lower' => array(963)); /* GREEK CAPITAL LETTER SIGMA */ -$config['0370_03ff'][] = array('upper' => 932, 'status' => 'C', 'lower' => array(964)); /* GREEK CAPITAL LETTER TAU */ -$config['0370_03ff'][] = array('upper' => 933, 'status' => 'C', 'lower' => array(965)); /* GREEK CAPITAL LETTER UPSILON */ -$config['0370_03ff'][] = array('upper' => 934, 'status' => 'C', 'lower' => array(966)); /* GREEK CAPITAL LETTER PHI */ -$config['0370_03ff'][] = array('upper' => 935, 'status' => 'C', 'lower' => array(967)); /* GREEK CAPITAL LETTER CHI */ -$config['0370_03ff'][] = array('upper' => 936, 'status' => 'C', 'lower' => array(968)); /* GREEK CAPITAL LETTER PSI */ -$config['0370_03ff'][] = array('upper' => 937, 'status' => 'C', 'lower' => array(969)); /* GREEK CAPITAL LETTER OMEGA */ -$config['0370_03ff'][] = array('upper' => 938, 'status' => 'C', 'lower' => array(970)); /* GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */ -$config['0370_03ff'][] = array('upper' => 939, 'status' => 'C', 'lower' => array(971)); /* GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */ -$config['0370_03ff'][] = array('upper' => 944, 'status' => 'F', 'lower' => array(965, 776, 769)); /* GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */ -$config['0370_03ff'][] = array('upper' => 962, 'status' => 'C', 'lower' => array(963)); /* GREEK SMALL LETTER FINAL SIGMA */ -$config['0370_03ff'][] = array('upper' => 976, 'status' => 'C', 'lower' => array(946)); /* GREEK BETA SYMBOL */ -$config['0370_03ff'][] = array('upper' => 977, 'status' => 'C', 'lower' => array(952)); /* GREEK THETA SYMBOL */ -$config['0370_03ff'][] = array('upper' => 981, 'status' => 'C', 'lower' => array(966)); /* GREEK PHI SYMBOL */ -$config['0370_03ff'][] = array('upper' => 982, 'status' => 'C', 'lower' => array(960)); /* GREEK PI SYMBOL */ -$config['0370_03ff'][] = array('upper' => 984, 'status' => 'C', 'lower' => array(985)); /* GREEK LETTER ARCHAIC KOPPA */ -$config['0370_03ff'][] = array('upper' => 986, 'status' => 'C', 'lower' => array(987)); /* GREEK LETTER STIGMA */ -$config['0370_03ff'][] = array('upper' => 988, 'status' => 'C', 'lower' => array(989)); /* GREEK LETTER DIGAMMA */ -$config['0370_03ff'][] = array('upper' => 990, 'status' => 'C', 'lower' => array(991)); /* GREEK LETTER KOPPA */ -$config['0370_03ff'][] = array('upper' => 992, 'status' => 'C', 'lower' => array(993)); /* GREEK LETTER SAMPI */ -$config['0370_03ff'][] = array('upper' => 994, 'status' => 'C', 'lower' => array(995)); /* COPTIC CAPITAL LETTER SHEI */ -$config['0370_03ff'][] = array('upper' => 996, 'status' => 'C', 'lower' => array(997)); /* COPTIC CAPITAL LETTER FEI */ -$config['0370_03ff'][] = array('upper' => 998, 'status' => 'C', 'lower' => array(999)); /* COPTIC CAPITAL LETTER KHEI */ -$config['0370_03ff'][] = array('upper' => 1000, 'status' => 'C', 'lower' => array(1001)); /* COPTIC CAPITAL LETTER HORI */ -$config['0370_03ff'][] = array('upper' => 1002, 'status' => 'C', 'lower' => array(1003)); /* COPTIC CAPITAL LETTER GANGIA */ -$config['0370_03ff'][] = array('upper' => 1004, 'status' => 'C', 'lower' => array(1005)); /* COPTIC CAPITAL LETTER SHIMA */ -$config['0370_03ff'][] = array('upper' => 1006, 'status' => 'C', 'lower' => array(1007)); /* COPTIC CAPITAL LETTER DEI */ -$config['0370_03ff'][] = array('upper' => 1008, 'status' => 'C', 'lower' => array(954)); /* GREEK KAPPA SYMBOL */ -$config['0370_03ff'][] = array('upper' => 1009, 'status' => 'C', 'lower' => array(961)); /* GREEK RHO SYMBOL */ -$config['0370_03ff'][] = array('upper' => 1012, 'status' => 'C', 'lower' => array(952)); /* GREEK CAPITAL THETA SYMBOL */ -$config['0370_03ff'][] = array('upper' => 1013, 'status' => 'C', 'lower' => array(949)); /* GREEK LUNATE EPSILON SYMBOL */ -$config['0370_03ff'][] = array('upper' => 1015, 'status' => 'C', 'lower' => array(1016)); /* GREEK CAPITAL LETTER SHO */ -$config['0370_03ff'][] = array('upper' => 1017, 'status' => 'C', 'lower' => array(1010)); /* GREEK CAPITAL LUNATE SIGMA SYMBOL */ -$config['0370_03ff'][] = array('upper' => 1018, 'status' => 'C', 'lower' => array(1019)); /* GREEK CAPITAL LETTER SAN */ -$config['0370_03ff'][] = array('upper' => 1021, 'status' => 'C', 'lower' => array(891)); /* GREEK CAPITAL REVERSED LUNATE SIGMA SYMBOL */ -$config['0370_03ff'][] = array('upper' => 1022, 'status' => 'C', 'lower' => array(892)); /* GREEK CAPITAL DOTTED LUNATE SIGMA SYMBOL */ -$config['0370_03ff'][] = array('upper' => 1023, 'status' => 'C', 'lower' => array(893)); /* GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL */ +$config['0370_03ff'][] = ['upper' => 913, 'status' => 'C', 'lower' => [945]]; /* GREEK CAPITAL LETTER ALPHA */ +$config['0370_03ff'][] = ['upper' => 914, 'status' => 'C', 'lower' => [946]]; /* GREEK CAPITAL LETTER BETA */ +$config['0370_03ff'][] = ['upper' => 915, 'status' => 'C', 'lower' => [947]]; /* GREEK CAPITAL LETTER GAMMA */ +$config['0370_03ff'][] = ['upper' => 916, 'status' => 'C', 'lower' => [948]]; /* GREEK CAPITAL LETTER DELTA */ +$config['0370_03ff'][] = ['upper' => 917, 'status' => 'C', 'lower' => [949]]; /* GREEK CAPITAL LETTER EPSILON */ +$config['0370_03ff'][] = ['upper' => 918, 'status' => 'C', 'lower' => [950]]; /* GREEK CAPITAL LETTER ZETA */ +$config['0370_03ff'][] = ['upper' => 919, 'status' => 'C', 'lower' => [951]]; /* GREEK CAPITAL LETTER ETA */ +$config['0370_03ff'][] = ['upper' => 920, 'status' => 'C', 'lower' => [952]]; /* GREEK CAPITAL LETTER THETA */ +$config['0370_03ff'][] = ['upper' => 921, 'status' => 'C', 'lower' => [953]]; /* GREEK CAPITAL LETTER IOTA */ +$config['0370_03ff'][] = ['upper' => 922, 'status' => 'C', 'lower' => [954]]; /* GREEK CAPITAL LETTER KAPPA */ +$config['0370_03ff'][] = ['upper' => 923, 'status' => 'C', 'lower' => [955]]; /* GREEK CAPITAL LETTER LAMDA */ +$config['0370_03ff'][] = ['upper' => 924, 'status' => 'C', 'lower' => [956]]; /* GREEK CAPITAL LETTER MU */ +$config['0370_03ff'][] = ['upper' => 925, 'status' => 'C', 'lower' => [957]]; /* GREEK CAPITAL LETTER NU */ +$config['0370_03ff'][] = ['upper' => 926, 'status' => 'C', 'lower' => [958]]; /* GREEK CAPITAL LETTER XI */ +$config['0370_03ff'][] = ['upper' => 927, 'status' => 'C', 'lower' => [959]]; /* GREEK CAPITAL LETTER OMICRON */ +$config['0370_03ff'][] = ['upper' => 928, 'status' => 'C', 'lower' => [960]]; /* GREEK CAPITAL LETTER PI */ +$config['0370_03ff'][] = ['upper' => 929, 'status' => 'C', 'lower' => [961]]; /* GREEK CAPITAL LETTER RHO */ +$config['0370_03ff'][] = ['upper' => 931, 'status' => 'C', 'lower' => [963]]; /* GREEK CAPITAL LETTER SIGMA */ +$config['0370_03ff'][] = ['upper' => 932, 'status' => 'C', 'lower' => [964]]; /* GREEK CAPITAL LETTER TAU */ +$config['0370_03ff'][] = ['upper' => 933, 'status' => 'C', 'lower' => [965]]; /* GREEK CAPITAL LETTER UPSILON */ +$config['0370_03ff'][] = ['upper' => 934, 'status' => 'C', 'lower' => [966]]; /* GREEK CAPITAL LETTER PHI */ +$config['0370_03ff'][] = ['upper' => 935, 'status' => 'C', 'lower' => [967]]; /* GREEK CAPITAL LETTER CHI */ +$config['0370_03ff'][] = ['upper' => 936, 'status' => 'C', 'lower' => [968]]; /* GREEK CAPITAL LETTER PSI */ +$config['0370_03ff'][] = ['upper' => 937, 'status' => 'C', 'lower' => [969]]; /* GREEK CAPITAL LETTER OMEGA */ +$config['0370_03ff'][] = ['upper' => 938, 'status' => 'C', 'lower' => [970]]; /* GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */ +$config['0370_03ff'][] = ['upper' => 939, 'status' => 'C', 'lower' => [971]]; /* GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */ +$config['0370_03ff'][] = ['upper' => 944, 'status' => 'F', 'lower' => [965, 776, 769]]; /* GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */ +$config['0370_03ff'][] = ['upper' => 962, 'status' => 'C', 'lower' => [963]]; /* GREEK SMALL LETTER FINAL SIGMA */ +$config['0370_03ff'][] = ['upper' => 976, 'status' => 'C', 'lower' => [946]]; /* GREEK BETA SYMBOL */ +$config['0370_03ff'][] = ['upper' => 977, 'status' => 'C', 'lower' => [952]]; /* GREEK THETA SYMBOL */ +$config['0370_03ff'][] = ['upper' => 981, 'status' => 'C', 'lower' => [966]]; /* GREEK PHI SYMBOL */ +$config['0370_03ff'][] = ['upper' => 982, 'status' => 'C', 'lower' => [960]]; /* GREEK PI SYMBOL */ +$config['0370_03ff'][] = ['upper' => 984, 'status' => 'C', 'lower' => [985]]; /* GREEK LETTER ARCHAIC KOPPA */ +$config['0370_03ff'][] = ['upper' => 986, 'status' => 'C', 'lower' => [987]]; /* GREEK LETTER STIGMA */ +$config['0370_03ff'][] = ['upper' => 988, 'status' => 'C', 'lower' => [989]]; /* GREEK LETTER DIGAMMA */ +$config['0370_03ff'][] = ['upper' => 990, 'status' => 'C', 'lower' => [991]]; /* GREEK LETTER KOPPA */ +$config['0370_03ff'][] = ['upper' => 992, 'status' => 'C', 'lower' => [993]]; /* GREEK LETTER SAMPI */ +$config['0370_03ff'][] = ['upper' => 994, 'status' => 'C', 'lower' => [995]]; /* COPTIC CAPITAL LETTER SHEI */ +$config['0370_03ff'][] = ['upper' => 996, 'status' => 'C', 'lower' => [997]]; /* COPTIC CAPITAL LETTER FEI */ +$config['0370_03ff'][] = ['upper' => 998, 'status' => 'C', 'lower' => [999]]; /* COPTIC CAPITAL LETTER KHEI */ +$config['0370_03ff'][] = ['upper' => 1000, 'status' => 'C', 'lower' => [1001]]; /* COPTIC CAPITAL LETTER HORI */ +$config['0370_03ff'][] = ['upper' => 1002, 'status' => 'C', 'lower' => [1003]]; /* COPTIC CAPITAL LETTER GANGIA */ +$config['0370_03ff'][] = ['upper' => 1004, 'status' => 'C', 'lower' => [1005]]; /* COPTIC CAPITAL LETTER SHIMA */ +$config['0370_03ff'][] = ['upper' => 1006, 'status' => 'C', 'lower' => [1007]]; /* COPTIC CAPITAL LETTER DEI */ +$config['0370_03ff'][] = ['upper' => 1008, 'status' => 'C', 'lower' => [954]]; /* GREEK KAPPA SYMBOL */ +$config['0370_03ff'][] = ['upper' => 1009, 'status' => 'C', 'lower' => [961]]; /* GREEK RHO SYMBOL */ +$config['0370_03ff'][] = ['upper' => 1012, 'status' => 'C', 'lower' => [952]]; /* GREEK CAPITAL THETA SYMBOL */ +$config['0370_03ff'][] = ['upper' => 1013, 'status' => 'C', 'lower' => [949]]; /* GREEK LUNATE EPSILON SYMBOL */ +$config['0370_03ff'][] = ['upper' => 1015, 'status' => 'C', 'lower' => [1016]]; /* GREEK CAPITAL LETTER SHO */ +$config['0370_03ff'][] = ['upper' => 1017, 'status' => 'C', 'lower' => [1010]]; /* GREEK CAPITAL LUNATE SIGMA SYMBOL */ +$config['0370_03ff'][] = ['upper' => 1018, 'status' => 'C', 'lower' => [1019]]; /* GREEK CAPITAL LETTER SAN */ +$config['0370_03ff'][] = ['upper' => 1021, 'status' => 'C', 'lower' => [891]]; /* GREEK CAPITAL REVERSED LUNATE SIGMA SYMBOL */ +$config['0370_03ff'][] = ['upper' => 1022, 'status' => 'C', 'lower' => [892]]; /* GREEK CAPITAL DOTTED LUNATE SIGMA SYMBOL */ +$config['0370_03ff'][] = ['upper' => 1023, 'status' => 'C', 'lower' => [893]]; /* GREEK CAPITAL REVERSED DOTTED LUNATE SIGMA SYMBOL */ diff --git a/lib/Cake/Config/unicode/casefolding/0400_04ff.php b/lib/Cake/Config/unicode/casefolding/0400_04ff.php index fd65be1caa..3e124fd5cf 100644 --- a/lib/Cake/Config/unicode/casefolding/0400_04ff.php +++ b/lib/Cake/Config/unicode/casefolding/0400_04ff.php @@ -37,127 +37,127 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0400_04ff'][] = array('upper' => 1024, 'status' => 'C', 'lower' => array(1104)); /* CYRILLIC CAPITAL LETTER IE WITH GRAVE */ -$config['0400_04ff'][] = array('upper' => 1025, 'status' => 'C', 'lower' => array(1105)); /* CYRILLIC CAPITAL LETTER IO */ -$config['0400_04ff'][] = array('upper' => 1026, 'status' => 'C', 'lower' => array(1106)); /* CYRILLIC CAPITAL LETTER DJE */ -$config['0400_04ff'][] = array('upper' => 1027, 'status' => 'C', 'lower' => array(1107)); /* CYRILLIC CAPITAL LETTER GJE */ -$config['0400_04ff'][] = array('upper' => 1028, 'status' => 'C', 'lower' => array(1108)); /* CYRILLIC CAPITAL LETTER UKRAINIAN IE */ -$config['0400_04ff'][] = array('upper' => 1029, 'status' => 'C', 'lower' => array(1109)); /* CYRILLIC CAPITAL LETTER DZE */ -$config['0400_04ff'][] = array('upper' => 1030, 'status' => 'C', 'lower' => array(1110)); /* CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */ -$config['0400_04ff'][] = array('upper' => 1031, 'status' => 'C', 'lower' => array(1111)); /* CYRILLIC CAPITAL LETTER YI */ -$config['0400_04ff'][] = array('upper' => 1032, 'status' => 'C', 'lower' => array(1112)); /* CYRILLIC CAPITAL LETTER JE */ -$config['0400_04ff'][] = array('upper' => 1033, 'status' => 'C', 'lower' => array(1113)); /* CYRILLIC CAPITAL LETTER LJE */ -$config['0400_04ff'][] = array('upper' => 1034, 'status' => 'C', 'lower' => array(1114)); /* CYRILLIC CAPITAL LETTER NJE */ -$config['0400_04ff'][] = array('upper' => 1035, 'status' => 'C', 'lower' => array(1115)); /* CYRILLIC CAPITAL LETTER TSHE */ -$config['0400_04ff'][] = array('upper' => 1036, 'status' => 'C', 'lower' => array(1116)); /* CYRILLIC CAPITAL LETTER KJE */ -$config['0400_04ff'][] = array('upper' => 1037, 'status' => 'C', 'lower' => array(1117)); /* CYRILLIC CAPITAL LETTER I WITH GRAVE */ -$config['0400_04ff'][] = array('upper' => 1038, 'status' => 'C', 'lower' => array(1118)); /* CYRILLIC CAPITAL LETTER SHORT U */ -$config['0400_04ff'][] = array('upper' => 1039, 'status' => 'C', 'lower' => array(1119)); /* CYRILLIC CAPITAL LETTER DZHE */ -$config['0400_04ff'][] = array('upper' => 1040, 'status' => 'C', 'lower' => array(1072)); /* CYRILLIC CAPITAL LETTER A */ -$config['0400_04ff'][] = array('upper' => 1041, 'status' => 'C', 'lower' => array(1073)); /* CYRILLIC CAPITAL LETTER BE */ -$config['0400_04ff'][] = array('upper' => 1042, 'status' => 'C', 'lower' => array(1074)); /* CYRILLIC CAPITAL LETTER VE */ -$config['0400_04ff'][] = array('upper' => 1043, 'status' => 'C', 'lower' => array(1075)); /* CYRILLIC CAPITAL LETTER GHE */ -$config['0400_04ff'][] = array('upper' => 1044, 'status' => 'C', 'lower' => array(1076)); /* CYRILLIC CAPITAL LETTER DE */ -$config['0400_04ff'][] = array('upper' => 1045, 'status' => 'C', 'lower' => array(1077)); /* CYRILLIC CAPITAL LETTER IE */ -$config['0400_04ff'][] = array('upper' => 1046, 'status' => 'C', 'lower' => array(1078)); /* CYRILLIC CAPITAL LETTER ZHE */ -$config['0400_04ff'][] = array('upper' => 1047, 'status' => 'C', 'lower' => array(1079)); /* CYRILLIC CAPITAL LETTER ZE */ -$config['0400_04ff'][] = array('upper' => 1048, 'status' => 'C', 'lower' => array(1080)); /* CYRILLIC CAPITAL LETTER I */ -$config['0400_04ff'][] = array('upper' => 1049, 'status' => 'C', 'lower' => array(1081)); /* CYRILLIC CAPITAL LETTER SHORT I */ -$config['0400_04ff'][] = array('upper' => 1050, 'status' => 'C', 'lower' => array(1082)); /* CYRILLIC CAPITAL LETTER KA */ -$config['0400_04ff'][] = array('upper' => 1051, 'status' => 'C', 'lower' => array(1083)); /* CYRILLIC CAPITAL LETTER EL */ -$config['0400_04ff'][] = array('upper' => 1052, 'status' => 'C', 'lower' => array(1084)); /* CYRILLIC CAPITAL LETTER EM */ -$config['0400_04ff'][] = array('upper' => 1053, 'status' => 'C', 'lower' => array(1085)); /* CYRILLIC CAPITAL LETTER EN */ -$config['0400_04ff'][] = array('upper' => 1054, 'status' => 'C', 'lower' => array(1086)); /* CYRILLIC CAPITAL LETTER O */ -$config['0400_04ff'][] = array('upper' => 1055, 'status' => 'C', 'lower' => array(1087)); /* CYRILLIC CAPITAL LETTER PE */ -$config['0400_04ff'][] = array('upper' => 1056, 'status' => 'C', 'lower' => array(1088)); /* CYRILLIC CAPITAL LETTER ER */ -$config['0400_04ff'][] = array('upper' => 1057, 'status' => 'C', 'lower' => array(1089)); /* CYRILLIC CAPITAL LETTER ES */ -$config['0400_04ff'][] = array('upper' => 1058, 'status' => 'C', 'lower' => array(1090)); /* CYRILLIC CAPITAL LETTER TE */ -$config['0400_04ff'][] = array('upper' => 1059, 'status' => 'C', 'lower' => array(1091)); /* CYRILLIC CAPITAL LETTER U */ -$config['0400_04ff'][] = array('upper' => 1060, 'status' => 'C', 'lower' => array(1092)); /* CYRILLIC CAPITAL LETTER EF */ -$config['0400_04ff'][] = array('upper' => 1061, 'status' => 'C', 'lower' => array(1093)); /* CYRILLIC CAPITAL LETTER HA */ -$config['0400_04ff'][] = array('upper' => 1062, 'status' => 'C', 'lower' => array(1094)); /* CYRILLIC CAPITAL LETTER TSE */ -$config['0400_04ff'][] = array('upper' => 1063, 'status' => 'C', 'lower' => array(1095)); /* CYRILLIC CAPITAL LETTER CHE */ -$config['0400_04ff'][] = array('upper' => 1064, 'status' => 'C', 'lower' => array(1096)); /* CYRILLIC CAPITAL LETTER SHA */ -$config['0400_04ff'][] = array('upper' => 1065, 'status' => 'C', 'lower' => array(1097)); /* CYRILLIC CAPITAL LETTER SHCHA */ -$config['0400_04ff'][] = array('upper' => 1066, 'status' => 'C', 'lower' => array(1098)); /* CYRILLIC CAPITAL LETTER HARD SIGN */ -$config['0400_04ff'][] = array('upper' => 1067, 'status' => 'C', 'lower' => array(1099)); /* CYRILLIC CAPITAL LETTER YERU */ -$config['0400_04ff'][] = array('upper' => 1068, 'status' => 'C', 'lower' => array(1100)); /* CYRILLIC CAPITAL LETTER SOFT SIGN */ -$config['0400_04ff'][] = array('upper' => 1069, 'status' => 'C', 'lower' => array(1101)); /* CYRILLIC CAPITAL LETTER E */ -$config['0400_04ff'][] = array('upper' => 1070, 'status' => 'C', 'lower' => array(1102)); /* CYRILLIC CAPITAL LETTER YU */ -$config['0400_04ff'][] = array('upper' => 1071, 'status' => 'C', 'lower' => array(1103)); /* CYRILLIC CAPITAL LETTER YA */ -$config['0400_04ff'][] = array('upper' => 1120, 'status' => 'C', 'lower' => array(1121)); /* CYRILLIC CAPITAL LETTER OMEGA */ -$config['0400_04ff'][] = array('upper' => 1122, 'status' => 'C', 'lower' => array(1123)); /* CYRILLIC CAPITAL LETTER YAT */ -$config['0400_04ff'][] = array('upper' => 1124, 'status' => 'C', 'lower' => array(1125)); /* CYRILLIC CAPITAL LETTER IOTIFIED E */ -$config['0400_04ff'][] = array('upper' => 1126, 'status' => 'C', 'lower' => array(1127)); /* CYRILLIC CAPITAL LETTER LITTLE YUS */ -$config['0400_04ff'][] = array('upper' => 1128, 'status' => 'C', 'lower' => array(1129)); /* CYRILLIC CAPITAL LETTER IOTIFIED LITTLE YUS */ -$config['0400_04ff'][] = array('upper' => 1130, 'status' => 'C', 'lower' => array(1131)); /* CYRILLIC CAPITAL LETTER BIG YUS */ -$config['0400_04ff'][] = array('upper' => 1132, 'status' => 'C', 'lower' => array(1133)); /* CYRILLIC CAPITAL LETTER IOTIFIED BIG YUS */ -$config['0400_04ff'][] = array('upper' => 1134, 'status' => 'C', 'lower' => array(1135)); /* CYRILLIC CAPITAL LETTER KSI */ -$config['0400_04ff'][] = array('upper' => 1136, 'status' => 'C', 'lower' => array(1137)); /* CYRILLIC CAPITAL LETTER PSI */ -$config['0400_04ff'][] = array('upper' => 1138, 'status' => 'C', 'lower' => array(1139)); /* CYRILLIC CAPITAL LETTER FITA */ -$config['0400_04ff'][] = array('upper' => 1140, 'status' => 'C', 'lower' => array(1141)); /* CYRILLIC CAPITAL LETTER IZHITSA */ -$config['0400_04ff'][] = array('upper' => 1142, 'status' => 'C', 'lower' => array(1143)); /* CYRILLIC CAPITAL LETTER IZHITSA WITH DOUBLE GRAVE ACCENT */ -$config['0400_04ff'][] = array('upper' => 1144, 'status' => 'C', 'lower' => array(1145)); /* CYRILLIC CAPITAL LETTER UK */ -$config['0400_04ff'][] = array('upper' => 1146, 'status' => 'C', 'lower' => array(1147)); /* CYRILLIC CAPITAL LETTER ROUND OMEGA */ -$config['0400_04ff'][] = array('upper' => 1148, 'status' => 'C', 'lower' => array(1149)); /* CYRILLIC CAPITAL LETTER OMEGA WITH TITLO */ -$config['0400_04ff'][] = array('upper' => 1150, 'status' => 'C', 'lower' => array(1151)); /* CYRILLIC CAPITAL LETTER OT */ -$config['0400_04ff'][] = array('upper' => 1152, 'status' => 'C', 'lower' => array(1153)); /* CYRILLIC CAPITAL LETTER KOPPA */ -$config['0400_04ff'][] = array('upper' => 1162, 'status' => 'C', 'lower' => array(1163)); /* CYRILLIC CAPITAL LETTER SHORT I WITH TAIL */ -$config['0400_04ff'][] = array('upper' => 1164, 'status' => 'C', 'lower' => array(1165)); /* CYRILLIC CAPITAL LETTER SEMISOFT SIGN */ -$config['0400_04ff'][] = array('upper' => 1166, 'status' => 'C', 'lower' => array(1167)); /* CYRILLIC CAPITAL LETTER ER WITH TICK */ -$config['0400_04ff'][] = array('upper' => 1168, 'status' => 'C', 'lower' => array(1169)); /* CYRILLIC CAPITAL LETTER GHE WITH UPTURN */ -$config['0400_04ff'][] = array('upper' => 1170, 'status' => 'C', 'lower' => array(1171)); /* CYRILLIC CAPITAL LETTER GHE WITH STROKE */ -$config['0400_04ff'][] = array('upper' => 1172, 'status' => 'C', 'lower' => array(1173)); /* CYRILLIC CAPITAL LETTER GHE WITH MIDDLE HOOK */ -$config['0400_04ff'][] = array('upper' => 1174, 'status' => 'C', 'lower' => array(1175)); /* CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1176, 'status' => 'C', 'lower' => array(1177)); /* CYRILLIC CAPITAL LETTER ZE WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1178, 'status' => 'C', 'lower' => array(1179)); /* CYRILLIC CAPITAL LETTER KA WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1180, 'status' => 'C', 'lower' => array(1181)); /* CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE */ -$config['0400_04ff'][] = array('upper' => 1182, 'status' => 'C', 'lower' => array(1183)); /* CYRILLIC CAPITAL LETTER KA WITH STROKE */ -$config['0400_04ff'][] = array('upper' => 1184, 'status' => 'C', 'lower' => array(1185)); /* CYRILLIC CAPITAL LETTER BASHKIR KA */ -$config['0400_04ff'][] = array('upper' => 1186, 'status' => 'C', 'lower' => array(1187)); /* CYRILLIC CAPITAL LETTER EN WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1188, 'status' => 'C', 'lower' => array(1189)); /* CYRILLIC CAPITAL LIGATURE EN GHE */ -$config['0400_04ff'][] = array('upper' => 1190, 'status' => 'C', 'lower' => array(1191)); /* CYRILLIC CAPITAL LETTER PE WITH MIDDLE HOOK */ -$config['0400_04ff'][] = array('upper' => 1192, 'status' => 'C', 'lower' => array(1193)); /* CYRILLIC CAPITAL LETTER ABKHASIAN HA */ -$config['0400_04ff'][] = array('upper' => 1194, 'status' => 'C', 'lower' => array(1195)); /* CYRILLIC CAPITAL LETTER ES WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1196, 'status' => 'C', 'lower' => array(1197)); /* CYRILLIC CAPITAL LETTER TE WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1198, 'status' => 'C', 'lower' => array(1199)); /* CYRILLIC CAPITAL LETTER STRAIGHT U */ -$config['0400_04ff'][] = array('upper' => 1200, 'status' => 'C', 'lower' => array(1201)); /* CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE */ -$config['0400_04ff'][] = array('upper' => 1202, 'status' => 'C', 'lower' => array(1203)); /* CYRILLIC CAPITAL LETTER HA WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1204, 'status' => 'C', 'lower' => array(1205)); /* CYRILLIC CAPITAL LIGATURE TE TSE */ -$config['0400_04ff'][] = array('upper' => 1206, 'status' => 'C', 'lower' => array(1207)); /* CYRILLIC CAPITAL LETTER CHE WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1208, 'status' => 'C', 'lower' => array(1209)); /* CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE */ -$config['0400_04ff'][] = array('upper' => 1210, 'status' => 'C', 'lower' => array(1211)); /* CYRILLIC CAPITAL LETTER SHHA */ -$config['0400_04ff'][] = array('upper' => 1212, 'status' => 'C', 'lower' => array(1213)); /* CYRILLIC CAPITAL LETTER ABKHASIAN CHE */ -$config['0400_04ff'][] = array('upper' => 1214, 'status' => 'C', 'lower' => array(1215)); /* CYRILLIC CAPITAL LETTER ABKHASIAN CHE WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1216, 'status' => 'C', 'lower' => array(1231)); /* CYRILLIC LETTER PALOCHKA */ -$config['0400_04ff'][] = array('upper' => 1217, 'status' => 'C', 'lower' => array(1218)); /* CYRILLIC CAPITAL LETTER ZHE WITH BREVE */ -$config['0400_04ff'][] = array('upper' => 1219, 'status' => 'C', 'lower' => array(1220)); /* CYRILLIC CAPITAL LETTER KA WITH HOOK */ -$config['0400_04ff'][] = array('upper' => 1221, 'status' => 'C', 'lower' => array(1222)); /* CYRILLIC CAPITAL LETTER EL WITH TAIL */ -$config['0400_04ff'][] = array('upper' => 1223, 'status' => 'C', 'lower' => array(1224)); /* CYRILLIC CAPITAL LETTER EN WITH HOOK */ -$config['0400_04ff'][] = array('upper' => 1225, 'status' => 'C', 'lower' => array(1226)); /* CYRILLIC CAPITAL LETTER EN WITH TAIL */ -$config['0400_04ff'][] = array('upper' => 1227, 'status' => 'C', 'lower' => array(1228)); /* CYRILLIC CAPITAL LETTER KHAKASSIAN CHE */ -$config['0400_04ff'][] = array('upper' => 1229, 'status' => 'C', 'lower' => array(1230)); /* CYRILLIC CAPITAL LETTER EM WITH TAIL */ -$config['0400_04ff'][] = array('upper' => 1232, 'status' => 'C', 'lower' => array(1233)); /* CYRILLIC CAPITAL LETTER A WITH BREVE */ -$config['0400_04ff'][] = array('upper' => 1234, 'status' => 'C', 'lower' => array(1235)); /* CYRILLIC CAPITAL LETTER A WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1236, 'status' => 'C', 'lower' => array(1237)); /* CYRILLIC CAPITAL LIGATURE A IE */ -$config['0400_04ff'][] = array('upper' => 1238, 'status' => 'C', 'lower' => array(1239)); /* CYRILLIC CAPITAL LETTER IE WITH BREVE */ -$config['0400_04ff'][] = array('upper' => 1240, 'status' => 'C', 'lower' => array(1241)); /* CYRILLIC CAPITAL LETTER SCHWA */ -$config['0400_04ff'][] = array('upper' => 1242, 'status' => 'C', 'lower' => array(1243)); /* CYRILLIC CAPITAL LETTER SCHWA WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1244, 'status' => 'C', 'lower' => array(1245)); /* CYRILLIC CAPITAL LETTER ZHE WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1246, 'status' => 'C', 'lower' => array(1247)); /* CYRILLIC CAPITAL LETTER ZE WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1248, 'status' => 'C', 'lower' => array(1249)); /* CYRILLIC CAPITAL LETTER ABKHASIAN DZE */ -$config['0400_04ff'][] = array('upper' => 1250, 'status' => 'C', 'lower' => array(1251)); /* CYRILLIC CAPITAL LETTER I WITH MACRON */ -$config['0400_04ff'][] = array('upper' => 1252, 'status' => 'C', 'lower' => array(1253)); /* CYRILLIC CAPITAL LETTER I WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1254, 'status' => 'C', 'lower' => array(1255)); /* CYRILLIC CAPITAL LETTER O WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1256, 'status' => 'C', 'lower' => array(1257)); /* CYRILLIC CAPITAL LETTER BARRED O */ -$config['0400_04ff'][] = array('upper' => 1258, 'status' => 'C', 'lower' => array(1259)); /* CYRILLIC CAPITAL LETTER BARRED O WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1260, 'status' => 'C', 'lower' => array(1261)); /* CYRILLIC CAPITAL LETTER E WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1262, 'status' => 'C', 'lower' => array(1263)); /* CYRILLIC CAPITAL LETTER U WITH MACRON */ -$config['0400_04ff'][] = array('upper' => 1264, 'status' => 'C', 'lower' => array(1265)); /* CYRILLIC CAPITAL LETTER U WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1266, 'status' => 'C', 'lower' => array(1267)); /* CYRILLIC CAPITAL LETTER U WITH DOUBLE ACUTE */ -$config['0400_04ff'][] = array('upper' => 1268, 'status' => 'C', 'lower' => array(1269)); /* CYRILLIC CAPITAL LETTER CHE WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1270, 'status' => 'C', 'lower' => array(1271)); /* CYRILLIC CAPITAL LETTER GHE WITH DESCENDER */ -$config['0400_04ff'][] = array('upper' => 1272, 'status' => 'C', 'lower' => array(1273)); /* CYRILLIC CAPITAL LETTER YERU WITH DIAERESIS */ -$config['0400_04ff'][] = array('upper' => 1274, 'status' => 'C', 'lower' => array(1275)); /* CYRILLIC CAPITAL LETTER GHE WITH STROKE AND HOOK */ -$config['0400_04ff'][] = array('upper' => 1276, 'status' => 'C', 'lower' => array(1277)); /* CYRILLIC CAPITAL LETTER HA WITH HOOK */ -$config['0400_04ff'][] = array('upper' => 1278, 'status' => 'C', 'lower' => array(1279)); /* CYRILLIC CAPITAL LETTER HA WITH STROKE */ +$config['0400_04ff'][] = ['upper' => 1024, 'status' => 'C', 'lower' => [1104]]; /* CYRILLIC CAPITAL LETTER IE WITH GRAVE */ +$config['0400_04ff'][] = ['upper' => 1025, 'status' => 'C', 'lower' => [1105]]; /* CYRILLIC CAPITAL LETTER IO */ +$config['0400_04ff'][] = ['upper' => 1026, 'status' => 'C', 'lower' => [1106]]; /* CYRILLIC CAPITAL LETTER DJE */ +$config['0400_04ff'][] = ['upper' => 1027, 'status' => 'C', 'lower' => [1107]]; /* CYRILLIC CAPITAL LETTER GJE */ +$config['0400_04ff'][] = ['upper' => 1028, 'status' => 'C', 'lower' => [1108]]; /* CYRILLIC CAPITAL LETTER UKRAINIAN IE */ +$config['0400_04ff'][] = ['upper' => 1029, 'status' => 'C', 'lower' => [1109]]; /* CYRILLIC CAPITAL LETTER DZE */ +$config['0400_04ff'][] = ['upper' => 1030, 'status' => 'C', 'lower' => [1110]]; /* CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */ +$config['0400_04ff'][] = ['upper' => 1031, 'status' => 'C', 'lower' => [1111]]; /* CYRILLIC CAPITAL LETTER YI */ +$config['0400_04ff'][] = ['upper' => 1032, 'status' => 'C', 'lower' => [1112]]; /* CYRILLIC CAPITAL LETTER JE */ +$config['0400_04ff'][] = ['upper' => 1033, 'status' => 'C', 'lower' => [1113]]; /* CYRILLIC CAPITAL LETTER LJE */ +$config['0400_04ff'][] = ['upper' => 1034, 'status' => 'C', 'lower' => [1114]]; /* CYRILLIC CAPITAL LETTER NJE */ +$config['0400_04ff'][] = ['upper' => 1035, 'status' => 'C', 'lower' => [1115]]; /* CYRILLIC CAPITAL LETTER TSHE */ +$config['0400_04ff'][] = ['upper' => 1036, 'status' => 'C', 'lower' => [1116]]; /* CYRILLIC CAPITAL LETTER KJE */ +$config['0400_04ff'][] = ['upper' => 1037, 'status' => 'C', 'lower' => [1117]]; /* CYRILLIC CAPITAL LETTER I WITH GRAVE */ +$config['0400_04ff'][] = ['upper' => 1038, 'status' => 'C', 'lower' => [1118]]; /* CYRILLIC CAPITAL LETTER SHORT U */ +$config['0400_04ff'][] = ['upper' => 1039, 'status' => 'C', 'lower' => [1119]]; /* CYRILLIC CAPITAL LETTER DZHE */ +$config['0400_04ff'][] = ['upper' => 1040, 'status' => 'C', 'lower' => [1072]]; /* CYRILLIC CAPITAL LETTER A */ +$config['0400_04ff'][] = ['upper' => 1041, 'status' => 'C', 'lower' => [1073]]; /* CYRILLIC CAPITAL LETTER BE */ +$config['0400_04ff'][] = ['upper' => 1042, 'status' => 'C', 'lower' => [1074]]; /* CYRILLIC CAPITAL LETTER VE */ +$config['0400_04ff'][] = ['upper' => 1043, 'status' => 'C', 'lower' => [1075]]; /* CYRILLIC CAPITAL LETTER GHE */ +$config['0400_04ff'][] = ['upper' => 1044, 'status' => 'C', 'lower' => [1076]]; /* CYRILLIC CAPITAL LETTER DE */ +$config['0400_04ff'][] = ['upper' => 1045, 'status' => 'C', 'lower' => [1077]]; /* CYRILLIC CAPITAL LETTER IE */ +$config['0400_04ff'][] = ['upper' => 1046, 'status' => 'C', 'lower' => [1078]]; /* CYRILLIC CAPITAL LETTER ZHE */ +$config['0400_04ff'][] = ['upper' => 1047, 'status' => 'C', 'lower' => [1079]]; /* CYRILLIC CAPITAL LETTER ZE */ +$config['0400_04ff'][] = ['upper' => 1048, 'status' => 'C', 'lower' => [1080]]; /* CYRILLIC CAPITAL LETTER I */ +$config['0400_04ff'][] = ['upper' => 1049, 'status' => 'C', 'lower' => [1081]]; /* CYRILLIC CAPITAL LETTER SHORT I */ +$config['0400_04ff'][] = ['upper' => 1050, 'status' => 'C', 'lower' => [1082]]; /* CYRILLIC CAPITAL LETTER KA */ +$config['0400_04ff'][] = ['upper' => 1051, 'status' => 'C', 'lower' => [1083]]; /* CYRILLIC CAPITAL LETTER EL */ +$config['0400_04ff'][] = ['upper' => 1052, 'status' => 'C', 'lower' => [1084]]; /* CYRILLIC CAPITAL LETTER EM */ +$config['0400_04ff'][] = ['upper' => 1053, 'status' => 'C', 'lower' => [1085]]; /* CYRILLIC CAPITAL LETTER EN */ +$config['0400_04ff'][] = ['upper' => 1054, 'status' => 'C', 'lower' => [1086]]; /* CYRILLIC CAPITAL LETTER O */ +$config['0400_04ff'][] = ['upper' => 1055, 'status' => 'C', 'lower' => [1087]]; /* CYRILLIC CAPITAL LETTER PE */ +$config['0400_04ff'][] = ['upper' => 1056, 'status' => 'C', 'lower' => [1088]]; /* CYRILLIC CAPITAL LETTER ER */ +$config['0400_04ff'][] = ['upper' => 1057, 'status' => 'C', 'lower' => [1089]]; /* CYRILLIC CAPITAL LETTER ES */ +$config['0400_04ff'][] = ['upper' => 1058, 'status' => 'C', 'lower' => [1090]]; /* CYRILLIC CAPITAL LETTER TE */ +$config['0400_04ff'][] = ['upper' => 1059, 'status' => 'C', 'lower' => [1091]]; /* CYRILLIC CAPITAL LETTER U */ +$config['0400_04ff'][] = ['upper' => 1060, 'status' => 'C', 'lower' => [1092]]; /* CYRILLIC CAPITAL LETTER EF */ +$config['0400_04ff'][] = ['upper' => 1061, 'status' => 'C', 'lower' => [1093]]; /* CYRILLIC CAPITAL LETTER HA */ +$config['0400_04ff'][] = ['upper' => 1062, 'status' => 'C', 'lower' => [1094]]; /* CYRILLIC CAPITAL LETTER TSE */ +$config['0400_04ff'][] = ['upper' => 1063, 'status' => 'C', 'lower' => [1095]]; /* CYRILLIC CAPITAL LETTER CHE */ +$config['0400_04ff'][] = ['upper' => 1064, 'status' => 'C', 'lower' => [1096]]; /* CYRILLIC CAPITAL LETTER SHA */ +$config['0400_04ff'][] = ['upper' => 1065, 'status' => 'C', 'lower' => [1097]]; /* CYRILLIC CAPITAL LETTER SHCHA */ +$config['0400_04ff'][] = ['upper' => 1066, 'status' => 'C', 'lower' => [1098]]; /* CYRILLIC CAPITAL LETTER HARD SIGN */ +$config['0400_04ff'][] = ['upper' => 1067, 'status' => 'C', 'lower' => [1099]]; /* CYRILLIC CAPITAL LETTER YERU */ +$config['0400_04ff'][] = ['upper' => 1068, 'status' => 'C', 'lower' => [1100]]; /* CYRILLIC CAPITAL LETTER SOFT SIGN */ +$config['0400_04ff'][] = ['upper' => 1069, 'status' => 'C', 'lower' => [1101]]; /* CYRILLIC CAPITAL LETTER E */ +$config['0400_04ff'][] = ['upper' => 1070, 'status' => 'C', 'lower' => [1102]]; /* CYRILLIC CAPITAL LETTER YU */ +$config['0400_04ff'][] = ['upper' => 1071, 'status' => 'C', 'lower' => [1103]]; /* CYRILLIC CAPITAL LETTER YA */ +$config['0400_04ff'][] = ['upper' => 1120, 'status' => 'C', 'lower' => [1121]]; /* CYRILLIC CAPITAL LETTER OMEGA */ +$config['0400_04ff'][] = ['upper' => 1122, 'status' => 'C', 'lower' => [1123]]; /* CYRILLIC CAPITAL LETTER YAT */ +$config['0400_04ff'][] = ['upper' => 1124, 'status' => 'C', 'lower' => [1125]]; /* CYRILLIC CAPITAL LETTER IOTIFIED E */ +$config['0400_04ff'][] = ['upper' => 1126, 'status' => 'C', 'lower' => [1127]]; /* CYRILLIC CAPITAL LETTER LITTLE YUS */ +$config['0400_04ff'][] = ['upper' => 1128, 'status' => 'C', 'lower' => [1129]]; /* CYRILLIC CAPITAL LETTER IOTIFIED LITTLE YUS */ +$config['0400_04ff'][] = ['upper' => 1130, 'status' => 'C', 'lower' => [1131]]; /* CYRILLIC CAPITAL LETTER BIG YUS */ +$config['0400_04ff'][] = ['upper' => 1132, 'status' => 'C', 'lower' => [1133]]; /* CYRILLIC CAPITAL LETTER IOTIFIED BIG YUS */ +$config['0400_04ff'][] = ['upper' => 1134, 'status' => 'C', 'lower' => [1135]]; /* CYRILLIC CAPITAL LETTER KSI */ +$config['0400_04ff'][] = ['upper' => 1136, 'status' => 'C', 'lower' => [1137]]; /* CYRILLIC CAPITAL LETTER PSI */ +$config['0400_04ff'][] = ['upper' => 1138, 'status' => 'C', 'lower' => [1139]]; /* CYRILLIC CAPITAL LETTER FITA */ +$config['0400_04ff'][] = ['upper' => 1140, 'status' => 'C', 'lower' => [1141]]; /* CYRILLIC CAPITAL LETTER IZHITSA */ +$config['0400_04ff'][] = ['upper' => 1142, 'status' => 'C', 'lower' => [1143]]; /* CYRILLIC CAPITAL LETTER IZHITSA WITH DOUBLE GRAVE ACCENT */ +$config['0400_04ff'][] = ['upper' => 1144, 'status' => 'C', 'lower' => [1145]]; /* CYRILLIC CAPITAL LETTER UK */ +$config['0400_04ff'][] = ['upper' => 1146, 'status' => 'C', 'lower' => [1147]]; /* CYRILLIC CAPITAL LETTER ROUND OMEGA */ +$config['0400_04ff'][] = ['upper' => 1148, 'status' => 'C', 'lower' => [1149]]; /* CYRILLIC CAPITAL LETTER OMEGA WITH TITLO */ +$config['0400_04ff'][] = ['upper' => 1150, 'status' => 'C', 'lower' => [1151]]; /* CYRILLIC CAPITAL LETTER OT */ +$config['0400_04ff'][] = ['upper' => 1152, 'status' => 'C', 'lower' => [1153]]; /* CYRILLIC CAPITAL LETTER KOPPA */ +$config['0400_04ff'][] = ['upper' => 1162, 'status' => 'C', 'lower' => [1163]]; /* CYRILLIC CAPITAL LETTER SHORT I WITH TAIL */ +$config['0400_04ff'][] = ['upper' => 1164, 'status' => 'C', 'lower' => [1165]]; /* CYRILLIC CAPITAL LETTER SEMISOFT SIGN */ +$config['0400_04ff'][] = ['upper' => 1166, 'status' => 'C', 'lower' => [1167]]; /* CYRILLIC CAPITAL LETTER ER WITH TICK */ +$config['0400_04ff'][] = ['upper' => 1168, 'status' => 'C', 'lower' => [1169]]; /* CYRILLIC CAPITAL LETTER GHE WITH UPTURN */ +$config['0400_04ff'][] = ['upper' => 1170, 'status' => 'C', 'lower' => [1171]]; /* CYRILLIC CAPITAL LETTER GHE WITH STROKE */ +$config['0400_04ff'][] = ['upper' => 1172, 'status' => 'C', 'lower' => [1173]]; /* CYRILLIC CAPITAL LETTER GHE WITH MIDDLE HOOK */ +$config['0400_04ff'][] = ['upper' => 1174, 'status' => 'C', 'lower' => [1175]]; /* CYRILLIC CAPITAL LETTER ZHE WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1176, 'status' => 'C', 'lower' => [1177]]; /* CYRILLIC CAPITAL LETTER ZE WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1178, 'status' => 'C', 'lower' => [1179]]; /* CYRILLIC CAPITAL LETTER KA WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1180, 'status' => 'C', 'lower' => [1181]]; /* CYRILLIC CAPITAL LETTER KA WITH VERTICAL STROKE */ +$config['0400_04ff'][] = ['upper' => 1182, 'status' => 'C', 'lower' => [1183]]; /* CYRILLIC CAPITAL LETTER KA WITH STROKE */ +$config['0400_04ff'][] = ['upper' => 1184, 'status' => 'C', 'lower' => [1185]]; /* CYRILLIC CAPITAL LETTER BASHKIR KA */ +$config['0400_04ff'][] = ['upper' => 1186, 'status' => 'C', 'lower' => [1187]]; /* CYRILLIC CAPITAL LETTER EN WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1188, 'status' => 'C', 'lower' => [1189]]; /* CYRILLIC CAPITAL LIGATURE EN GHE */ +$config['0400_04ff'][] = ['upper' => 1190, 'status' => 'C', 'lower' => [1191]]; /* CYRILLIC CAPITAL LETTER PE WITH MIDDLE HOOK */ +$config['0400_04ff'][] = ['upper' => 1192, 'status' => 'C', 'lower' => [1193]]; /* CYRILLIC CAPITAL LETTER ABKHASIAN HA */ +$config['0400_04ff'][] = ['upper' => 1194, 'status' => 'C', 'lower' => [1195]]; /* CYRILLIC CAPITAL LETTER ES WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1196, 'status' => 'C', 'lower' => [1197]]; /* CYRILLIC CAPITAL LETTER TE WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1198, 'status' => 'C', 'lower' => [1199]]; /* CYRILLIC CAPITAL LETTER STRAIGHT U */ +$config['0400_04ff'][] = ['upper' => 1200, 'status' => 'C', 'lower' => [1201]]; /* CYRILLIC CAPITAL LETTER STRAIGHT U WITH STROKE */ +$config['0400_04ff'][] = ['upper' => 1202, 'status' => 'C', 'lower' => [1203]]; /* CYRILLIC CAPITAL LETTER HA WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1204, 'status' => 'C', 'lower' => [1205]]; /* CYRILLIC CAPITAL LIGATURE TE TSE */ +$config['0400_04ff'][] = ['upper' => 1206, 'status' => 'C', 'lower' => [1207]]; /* CYRILLIC CAPITAL LETTER CHE WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1208, 'status' => 'C', 'lower' => [1209]]; /* CYRILLIC CAPITAL LETTER CHE WITH VERTICAL STROKE */ +$config['0400_04ff'][] = ['upper' => 1210, 'status' => 'C', 'lower' => [1211]]; /* CYRILLIC CAPITAL LETTER SHHA */ +$config['0400_04ff'][] = ['upper' => 1212, 'status' => 'C', 'lower' => [1213]]; /* CYRILLIC CAPITAL LETTER ABKHASIAN CHE */ +$config['0400_04ff'][] = ['upper' => 1214, 'status' => 'C', 'lower' => [1215]]; /* CYRILLIC CAPITAL LETTER ABKHASIAN CHE WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1216, 'status' => 'C', 'lower' => [1231]]; /* CYRILLIC LETTER PALOCHKA */ +$config['0400_04ff'][] = ['upper' => 1217, 'status' => 'C', 'lower' => [1218]]; /* CYRILLIC CAPITAL LETTER ZHE WITH BREVE */ +$config['0400_04ff'][] = ['upper' => 1219, 'status' => 'C', 'lower' => [1220]]; /* CYRILLIC CAPITAL LETTER KA WITH HOOK */ +$config['0400_04ff'][] = ['upper' => 1221, 'status' => 'C', 'lower' => [1222]]; /* CYRILLIC CAPITAL LETTER EL WITH TAIL */ +$config['0400_04ff'][] = ['upper' => 1223, 'status' => 'C', 'lower' => [1224]]; /* CYRILLIC CAPITAL LETTER EN WITH HOOK */ +$config['0400_04ff'][] = ['upper' => 1225, 'status' => 'C', 'lower' => [1226]]; /* CYRILLIC CAPITAL LETTER EN WITH TAIL */ +$config['0400_04ff'][] = ['upper' => 1227, 'status' => 'C', 'lower' => [1228]]; /* CYRILLIC CAPITAL LETTER KHAKASSIAN CHE */ +$config['0400_04ff'][] = ['upper' => 1229, 'status' => 'C', 'lower' => [1230]]; /* CYRILLIC CAPITAL LETTER EM WITH TAIL */ +$config['0400_04ff'][] = ['upper' => 1232, 'status' => 'C', 'lower' => [1233]]; /* CYRILLIC CAPITAL LETTER A WITH BREVE */ +$config['0400_04ff'][] = ['upper' => 1234, 'status' => 'C', 'lower' => [1235]]; /* CYRILLIC CAPITAL LETTER A WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1236, 'status' => 'C', 'lower' => [1237]]; /* CYRILLIC CAPITAL LIGATURE A IE */ +$config['0400_04ff'][] = ['upper' => 1238, 'status' => 'C', 'lower' => [1239]]; /* CYRILLIC CAPITAL LETTER IE WITH BREVE */ +$config['0400_04ff'][] = ['upper' => 1240, 'status' => 'C', 'lower' => [1241]]; /* CYRILLIC CAPITAL LETTER SCHWA */ +$config['0400_04ff'][] = ['upper' => 1242, 'status' => 'C', 'lower' => [1243]]; /* CYRILLIC CAPITAL LETTER SCHWA WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1244, 'status' => 'C', 'lower' => [1245]]; /* CYRILLIC CAPITAL LETTER ZHE WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1246, 'status' => 'C', 'lower' => [1247]]; /* CYRILLIC CAPITAL LETTER ZE WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1248, 'status' => 'C', 'lower' => [1249]]; /* CYRILLIC CAPITAL LETTER ABKHASIAN DZE */ +$config['0400_04ff'][] = ['upper' => 1250, 'status' => 'C', 'lower' => [1251]]; /* CYRILLIC CAPITAL LETTER I WITH MACRON */ +$config['0400_04ff'][] = ['upper' => 1252, 'status' => 'C', 'lower' => [1253]]; /* CYRILLIC CAPITAL LETTER I WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1254, 'status' => 'C', 'lower' => [1255]]; /* CYRILLIC CAPITAL LETTER O WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1256, 'status' => 'C', 'lower' => [1257]]; /* CYRILLIC CAPITAL LETTER BARRED O */ +$config['0400_04ff'][] = ['upper' => 1258, 'status' => 'C', 'lower' => [1259]]; /* CYRILLIC CAPITAL LETTER BARRED O WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1260, 'status' => 'C', 'lower' => [1261]]; /* CYRILLIC CAPITAL LETTER E WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1262, 'status' => 'C', 'lower' => [1263]]; /* CYRILLIC CAPITAL LETTER U WITH MACRON */ +$config['0400_04ff'][] = ['upper' => 1264, 'status' => 'C', 'lower' => [1265]]; /* CYRILLIC CAPITAL LETTER U WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1266, 'status' => 'C', 'lower' => [1267]]; /* CYRILLIC CAPITAL LETTER U WITH DOUBLE ACUTE */ +$config['0400_04ff'][] = ['upper' => 1268, 'status' => 'C', 'lower' => [1269]]; /* CYRILLIC CAPITAL LETTER CHE WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1270, 'status' => 'C', 'lower' => [1271]]; /* CYRILLIC CAPITAL LETTER GHE WITH DESCENDER */ +$config['0400_04ff'][] = ['upper' => 1272, 'status' => 'C', 'lower' => [1273]]; /* CYRILLIC CAPITAL LETTER YERU WITH DIAERESIS */ +$config['0400_04ff'][] = ['upper' => 1274, 'status' => 'C', 'lower' => [1275]]; /* CYRILLIC CAPITAL LETTER GHE WITH STROKE AND HOOK */ +$config['0400_04ff'][] = ['upper' => 1276, 'status' => 'C', 'lower' => [1277]]; /* CYRILLIC CAPITAL LETTER HA WITH HOOK */ +$config['0400_04ff'][] = ['upper' => 1278, 'status' => 'C', 'lower' => [1279]]; /* CYRILLIC CAPITAL LETTER HA WITH STROKE */ diff --git a/lib/Cake/Config/unicode/casefolding/0500_052f.php b/lib/Cake/Config/unicode/casefolding/0500_052f.php index c5f4373f79..e6a2c81982 100644 --- a/lib/Cake/Config/unicode/casefolding/0500_052f.php +++ b/lib/Cake/Config/unicode/casefolding/0500_052f.php @@ -37,13 +37,13 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0500_052f'][] = array('upper' => 1280, 'status' => 'C', 'lower' => array(1281)); /* CYRILLIC CAPITAL LETTER KOMI DE */ -$config['0500_052f'][] = array('upper' => 1282, 'status' => 'C', 'lower' => array(1283)); /* CYRILLIC CAPITAL LETTER KOMI DJE */ -$config['0500_052f'][] = array('upper' => 1284, 'status' => 'C', 'lower' => array(1285)); /* CYRILLIC CAPITAL LETTER KOMI ZJE */ -$config['0500_052f'][] = array('upper' => 1286, 'status' => 'C', 'lower' => array(1287)); /* CYRILLIC CAPITAL LETTER KOMI DZJE */ -$config['0500_052f'][] = array('upper' => 1288, 'status' => 'C', 'lower' => array(1289)); /* CYRILLIC CAPITAL LETTER KOMI LJE */ -$config['0500_052f'][] = array('upper' => 1290, 'status' => 'C', 'lower' => array(1291)); /* CYRILLIC CAPITAL LETTER KOMI NJE */ -$config['0500_052f'][] = array('upper' => 1292, 'status' => 'C', 'lower' => array(1293)); /* CYRILLIC CAPITAL LETTER KOMI SJE */ -$config['0500_052f'][] = array('upper' => 1294, 'status' => 'C', 'lower' => array(1295)); /* CYRILLIC CAPITAL LETTER KOMI TJE */ -$config['0500_052f'][] = array('upper' => 1296, 'status' => 'C', 'lower' => array(1297)); /* CYRILLIC CAPITAL LETTER ZE */ -$config['0500_052f'][] = array('upper' => 1298, 'status' => 'C', 'lower' => array(1299)); /* CYRILLIC CAPITAL LETTER El with hook */ +$config['0500_052f'][] = ['upper' => 1280, 'status' => 'C', 'lower' => [1281]]; /* CYRILLIC CAPITAL LETTER KOMI DE */ +$config['0500_052f'][] = ['upper' => 1282, 'status' => 'C', 'lower' => [1283]]; /* CYRILLIC CAPITAL LETTER KOMI DJE */ +$config['0500_052f'][] = ['upper' => 1284, 'status' => 'C', 'lower' => [1285]]; /* CYRILLIC CAPITAL LETTER KOMI ZJE */ +$config['0500_052f'][] = ['upper' => 1286, 'status' => 'C', 'lower' => [1287]]; /* CYRILLIC CAPITAL LETTER KOMI DZJE */ +$config['0500_052f'][] = ['upper' => 1288, 'status' => 'C', 'lower' => [1289]]; /* CYRILLIC CAPITAL LETTER KOMI LJE */ +$config['0500_052f'][] = ['upper' => 1290, 'status' => 'C', 'lower' => [1291]]; /* CYRILLIC CAPITAL LETTER KOMI NJE */ +$config['0500_052f'][] = ['upper' => 1292, 'status' => 'C', 'lower' => [1293]]; /* CYRILLIC CAPITAL LETTER KOMI SJE */ +$config['0500_052f'][] = ['upper' => 1294, 'status' => 'C', 'lower' => [1295]]; /* CYRILLIC CAPITAL LETTER KOMI TJE */ +$config['0500_052f'][] = ['upper' => 1296, 'status' => 'C', 'lower' => [1297]]; /* CYRILLIC CAPITAL LETTER ZE */ +$config['0500_052f'][] = ['upper' => 1298, 'status' => 'C', 'lower' => [1299]]; /* CYRILLIC CAPITAL LETTER El with hook */ diff --git a/lib/Cake/Config/unicode/casefolding/0530_058f.php b/lib/Cake/Config/unicode/casefolding/0530_058f.php index 0603db5b4a..76ecdfe8af 100644 --- a/lib/Cake/Config/unicode/casefolding/0530_058f.php +++ b/lib/Cake/Config/unicode/casefolding/0530_058f.php @@ -37,41 +37,41 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['0530_058f'][] = array('upper' => 1329, 'status' => 'C', 'lower' => array(1377)); /* ARMENIAN CAPITAL LETTER AYB */ -$config['0530_058f'][] = array('upper' => 1330, 'status' => 'C', 'lower' => array(1378)); /* ARMENIAN CAPITAL LETTER BEN */ -$config['0530_058f'][] = array('upper' => 1331, 'status' => 'C', 'lower' => array(1379)); /* ARMENIAN CAPITAL LETTER GIM */ -$config['0530_058f'][] = array('upper' => 1332, 'status' => 'C', 'lower' => array(1380)); /* ARMENIAN CAPITAL LETTER DA */ -$config['0530_058f'][] = array('upper' => 1333, 'status' => 'C', 'lower' => array(1381)); /* ARMENIAN CAPITAL LETTER ECH */ -$config['0530_058f'][] = array('upper' => 1334, 'status' => 'C', 'lower' => array(1382)); /* ARMENIAN CAPITAL LETTER ZA */ -$config['0530_058f'][] = array('upper' => 1335, 'status' => 'C', 'lower' => array(1383)); /* ARMENIAN CAPITAL LETTER EH */ -$config['0530_058f'][] = array('upper' => 1336, 'status' => 'C', 'lower' => array(1384)); /* ARMENIAN CAPITAL LETTER ET */ -$config['0530_058f'][] = array('upper' => 1337, 'status' => 'C', 'lower' => array(1385)); /* ARMENIAN CAPITAL LETTER TO */ -$config['0530_058f'][] = array('upper' => 1338, 'status' => 'C', 'lower' => array(1386)); /* ARMENIAN CAPITAL LETTER ZHE */ -$config['0530_058f'][] = array('upper' => 1339, 'status' => 'C', 'lower' => array(1387)); /* ARMENIAN CAPITAL LETTER INI */ -$config['0530_058f'][] = array('upper' => 1340, 'status' => 'C', 'lower' => array(1388)); /* ARMENIAN CAPITAL LETTER LIWN */ -$config['0530_058f'][] = array('upper' => 1341, 'status' => 'C', 'lower' => array(1389)); /* ARMENIAN CAPITAL LETTER XEH */ -$config['0530_058f'][] = array('upper' => 1342, 'status' => 'C', 'lower' => array(1390)); /* ARMENIAN CAPITAL LETTER CA */ -$config['0530_058f'][] = array('upper' => 1343, 'status' => 'C', 'lower' => array(1391)); /* ARMENIAN CAPITAL LETTER KEN */ -$config['0530_058f'][] = array('upper' => 1344, 'status' => 'C', 'lower' => array(1392)); /* ARMENIAN CAPITAL LETTER HO */ -$config['0530_058f'][] = array('upper' => 1345, 'status' => 'C', 'lower' => array(1393)); /* ARMENIAN CAPITAL LETTER JA */ -$config['0530_058f'][] = array('upper' => 1346, 'status' => 'C', 'lower' => array(1394)); /* ARMENIAN CAPITAL LETTER GHAD */ -$config['0530_058f'][] = array('upper' => 1347, 'status' => 'C', 'lower' => array(1395)); /* ARMENIAN CAPITAL LETTER CHEH */ -$config['0530_058f'][] = array('upper' => 1348, 'status' => 'C', 'lower' => array(1396)); /* ARMENIAN CAPITAL LETTER MEN */ -$config['0530_058f'][] = array('upper' => 1349, 'status' => 'C', 'lower' => array(1397)); /* ARMENIAN CAPITAL LETTER YI */ -$config['0530_058f'][] = array('upper' => 1350, 'status' => 'C', 'lower' => array(1398)); /* ARMENIAN CAPITAL LETTER NOW */ -$config['0530_058f'][] = array('upper' => 1351, 'status' => 'C', 'lower' => array(1399)); /* ARMENIAN CAPITAL LETTER SHA */ -$config['0530_058f'][] = array('upper' => 1352, 'status' => 'C', 'lower' => array(1400)); /* ARMENIAN CAPITAL LETTER VO */ -$config['0530_058f'][] = array('upper' => 1353, 'status' => 'C', 'lower' => array(1401)); /* ARMENIAN CAPITAL LETTER CHA */ -$config['0530_058f'][] = array('upper' => 1354, 'status' => 'C', 'lower' => array(1402)); /* ARMENIAN CAPITAL LETTER PEH */ -$config['0530_058f'][] = array('upper' => 1355, 'status' => 'C', 'lower' => array(1403)); /* ARMENIAN CAPITAL LETTER JHEH */ -$config['0530_058f'][] = array('upper' => 1356, 'status' => 'C', 'lower' => array(1404)); /* ARMENIAN CAPITAL LETTER RA */ -$config['0530_058f'][] = array('upper' => 1357, 'status' => 'C', 'lower' => array(1405)); /* ARMENIAN CAPITAL LETTER SEH */ -$config['0530_058f'][] = array('upper' => 1358, 'status' => 'C', 'lower' => array(1406)); /* ARMENIAN CAPITAL LETTER VEW */ -$config['0530_058f'][] = array('upper' => 1359, 'status' => 'C', 'lower' => array(1407)); /* ARMENIAN CAPITAL LETTER TIWN */ -$config['0530_058f'][] = array('upper' => 1360, 'status' => 'C', 'lower' => array(1408)); /* ARMENIAN CAPITAL LETTER REH */ -$config['0530_058f'][] = array('upper' => 1361, 'status' => 'C', 'lower' => array(1409)); /* ARMENIAN CAPITAL LETTER CO */ -$config['0530_058f'][] = array('upper' => 1362, 'status' => 'C', 'lower' => array(1410)); /* ARMENIAN CAPITAL LETTER YIWN */ -$config['0530_058f'][] = array('upper' => 1363, 'status' => 'C', 'lower' => array(1411)); /* ARMENIAN CAPITAL LETTER PIWR */ -$config['0530_058f'][] = array('upper' => 1364, 'status' => 'C', 'lower' => array(1412)); /* ARMENIAN CAPITAL LETTER KEH */ -$config['0530_058f'][] = array('upper' => 1365, 'status' => 'C', 'lower' => array(1413)); /* ARMENIAN CAPITAL LETTER OH */ -$config['0530_058f'][] = array('upper' => 1366, 'status' => 'C', 'lower' => array(1414)); /* ARMENIAN CAPITAL LETTER FEH */ +$config['0530_058f'][] = ['upper' => 1329, 'status' => 'C', 'lower' => [1377]]; /* ARMENIAN CAPITAL LETTER AYB */ +$config['0530_058f'][] = ['upper' => 1330, 'status' => 'C', 'lower' => [1378]]; /* ARMENIAN CAPITAL LETTER BEN */ +$config['0530_058f'][] = ['upper' => 1331, 'status' => 'C', 'lower' => [1379]]; /* ARMENIAN CAPITAL LETTER GIM */ +$config['0530_058f'][] = ['upper' => 1332, 'status' => 'C', 'lower' => [1380]]; /* ARMENIAN CAPITAL LETTER DA */ +$config['0530_058f'][] = ['upper' => 1333, 'status' => 'C', 'lower' => [1381]]; /* ARMENIAN CAPITAL LETTER ECH */ +$config['0530_058f'][] = ['upper' => 1334, 'status' => 'C', 'lower' => [1382]]; /* ARMENIAN CAPITAL LETTER ZA */ +$config['0530_058f'][] = ['upper' => 1335, 'status' => 'C', 'lower' => [1383]]; /* ARMENIAN CAPITAL LETTER EH */ +$config['0530_058f'][] = ['upper' => 1336, 'status' => 'C', 'lower' => [1384]]; /* ARMENIAN CAPITAL LETTER ET */ +$config['0530_058f'][] = ['upper' => 1337, 'status' => 'C', 'lower' => [1385]]; /* ARMENIAN CAPITAL LETTER TO */ +$config['0530_058f'][] = ['upper' => 1338, 'status' => 'C', 'lower' => [1386]]; /* ARMENIAN CAPITAL LETTER ZHE */ +$config['0530_058f'][] = ['upper' => 1339, 'status' => 'C', 'lower' => [1387]]; /* ARMENIAN CAPITAL LETTER INI */ +$config['0530_058f'][] = ['upper' => 1340, 'status' => 'C', 'lower' => [1388]]; /* ARMENIAN CAPITAL LETTER LIWN */ +$config['0530_058f'][] = ['upper' => 1341, 'status' => 'C', 'lower' => [1389]]; /* ARMENIAN CAPITAL LETTER XEH */ +$config['0530_058f'][] = ['upper' => 1342, 'status' => 'C', 'lower' => [1390]]; /* ARMENIAN CAPITAL LETTER CA */ +$config['0530_058f'][] = ['upper' => 1343, 'status' => 'C', 'lower' => [1391]]; /* ARMENIAN CAPITAL LETTER KEN */ +$config['0530_058f'][] = ['upper' => 1344, 'status' => 'C', 'lower' => [1392]]; /* ARMENIAN CAPITAL LETTER HO */ +$config['0530_058f'][] = ['upper' => 1345, 'status' => 'C', 'lower' => [1393]]; /* ARMENIAN CAPITAL LETTER JA */ +$config['0530_058f'][] = ['upper' => 1346, 'status' => 'C', 'lower' => [1394]]; /* ARMENIAN CAPITAL LETTER GHAD */ +$config['0530_058f'][] = ['upper' => 1347, 'status' => 'C', 'lower' => [1395]]; /* ARMENIAN CAPITAL LETTER CHEH */ +$config['0530_058f'][] = ['upper' => 1348, 'status' => 'C', 'lower' => [1396]]; /* ARMENIAN CAPITAL LETTER MEN */ +$config['0530_058f'][] = ['upper' => 1349, 'status' => 'C', 'lower' => [1397]]; /* ARMENIAN CAPITAL LETTER YI */ +$config['0530_058f'][] = ['upper' => 1350, 'status' => 'C', 'lower' => [1398]]; /* ARMENIAN CAPITAL LETTER NOW */ +$config['0530_058f'][] = ['upper' => 1351, 'status' => 'C', 'lower' => [1399]]; /* ARMENIAN CAPITAL LETTER SHA */ +$config['0530_058f'][] = ['upper' => 1352, 'status' => 'C', 'lower' => [1400]]; /* ARMENIAN CAPITAL LETTER VO */ +$config['0530_058f'][] = ['upper' => 1353, 'status' => 'C', 'lower' => [1401]]; /* ARMENIAN CAPITAL LETTER CHA */ +$config['0530_058f'][] = ['upper' => 1354, 'status' => 'C', 'lower' => [1402]]; /* ARMENIAN CAPITAL LETTER PEH */ +$config['0530_058f'][] = ['upper' => 1355, 'status' => 'C', 'lower' => [1403]]; /* ARMENIAN CAPITAL LETTER JHEH */ +$config['0530_058f'][] = ['upper' => 1356, 'status' => 'C', 'lower' => [1404]]; /* ARMENIAN CAPITAL LETTER RA */ +$config['0530_058f'][] = ['upper' => 1357, 'status' => 'C', 'lower' => [1405]]; /* ARMENIAN CAPITAL LETTER SEH */ +$config['0530_058f'][] = ['upper' => 1358, 'status' => 'C', 'lower' => [1406]]; /* ARMENIAN CAPITAL LETTER VEW */ +$config['0530_058f'][] = ['upper' => 1359, 'status' => 'C', 'lower' => [1407]]; /* ARMENIAN CAPITAL LETTER TIWN */ +$config['0530_058f'][] = ['upper' => 1360, 'status' => 'C', 'lower' => [1408]]; /* ARMENIAN CAPITAL LETTER REH */ +$config['0530_058f'][] = ['upper' => 1361, 'status' => 'C', 'lower' => [1409]]; /* ARMENIAN CAPITAL LETTER CO */ +$config['0530_058f'][] = ['upper' => 1362, 'status' => 'C', 'lower' => [1410]]; /* ARMENIAN CAPITAL LETTER YIWN */ +$config['0530_058f'][] = ['upper' => 1363, 'status' => 'C', 'lower' => [1411]]; /* ARMENIAN CAPITAL LETTER PIWR */ +$config['0530_058f'][] = ['upper' => 1364, 'status' => 'C', 'lower' => [1412]]; /* ARMENIAN CAPITAL LETTER KEH */ +$config['0530_058f'][] = ['upper' => 1365, 'status' => 'C', 'lower' => [1413]]; /* ARMENIAN CAPITAL LETTER OH */ +$config['0530_058f'][] = ['upper' => 1366, 'status' => 'C', 'lower' => [1414]]; /* ARMENIAN CAPITAL LETTER FEH */ diff --git a/lib/Cake/Config/unicode/casefolding/1e00_1eff.php b/lib/Cake/Config/unicode/casefolding/1e00_1eff.php index 6709c67795..b0a03c3ef5 100644 --- a/lib/Cake/Config/unicode/casefolding/1e00_1eff.php +++ b/lib/Cake/Config/unicode/casefolding/1e00_1eff.php @@ -37,81 +37,81 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['1e00_1eff'][] = array('upper' => 7680, 'status' => 'C', 'lower' => array(7681)); /* LATIN CAPITAL LETTER A WITH RING BELOW */ -$config['1e00_1eff'][] = array('upper' => 7682, 'status' => 'C', 'lower' => array(7683)); /* LATIN CAPITAL LETTER B WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7684, 'status' => 'C', 'lower' => array(7685)); /* LATIN CAPITAL LETTER B WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7686, 'status' => 'C', 'lower' => array(7687)); /* LATIN CAPITAL LETTER B WITH LINE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7688, 'status' => 'C', 'lower' => array(7689)); /* LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7690, 'status' => 'C', 'lower' => array(7691)); /* LATIN CAPITAL LETTER D WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7692, 'status' => 'C', 'lower' => array(7693)); /* LATIN CAPITAL LETTER D WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7694, 'status' => 'C', 'lower' => array(7695)); /* LATIN CAPITAL LETTER D WITH LINE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7696, 'status' => 'C', 'lower' => array(7697)); /* LATIN CAPITAL LETTER D WITH CEDILLA */ -$config['1e00_1eff'][] = array('upper' => 7698, 'status' => 'C', 'lower' => array(7699)); /* LATIN CAPITAL LETTER D WITH CIRCUMFLEX BELOW */ -$config['1e00_1eff'][] = array('upper' => 7700, 'status' => 'C', 'lower' => array(7701)); /* LATIN CAPITAL LETTER E WITH MACRON AND GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7702, 'status' => 'C', 'lower' => array(7703)); /* LATIN CAPITAL LETTER E WITH MACRON AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7704, 'status' => 'C', 'lower' => array(7705)); /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX BELOW */ -$config['1e00_1eff'][] = array('upper' => 7706, 'status' => 'C', 'lower' => array(7707)); /* LATIN CAPITAL LETTER E WITH TILDE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7708, 'status' => 'C', 'lower' => array(7709)); /* LATIN CAPITAL LETTER E WITH CEDILLA AND BREVE */ -$config['1e00_1eff'][] = array('upper' => 7710, 'status' => 'C', 'lower' => array(7711)); /* LATIN CAPITAL LETTER F WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7712, 'status' => 'C', 'lower' => array(7713)); /* LATIN CAPITAL LETTER G WITH MACRON */ -$config['1e00_1eff'][] = array('upper' => 7714, 'status' => 'C', 'lower' => array(7715)); /* LATIN CAPITAL LETTER H WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7716, 'status' => 'C', 'lower' => array(7717)); /* LATIN CAPITAL LETTER H WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7718, 'status' => 'C', 'lower' => array(7719)); /* LATIN CAPITAL LETTER H WITH DIAERESIS */ -$config['1e00_1eff'][] = array('upper' => 7720, 'status' => 'C', 'lower' => array(7721)); /* LATIN CAPITAL LETTER H WITH CEDILLA */ -$config['1e00_1eff'][] = array('upper' => 7722, 'status' => 'C', 'lower' => array(7723)); /* LATIN CAPITAL LETTER H WITH BREVE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7724, 'status' => 'C', 'lower' => array(7725)); /* LATIN CAPITAL LETTER I WITH TILDE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7726, 'status' => 'C', 'lower' => array(7727)); /* LATIN CAPITAL LETTER I WITH DIAERESIS AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7728, 'status' => 'C', 'lower' => array(7729)); /* LATIN CAPITAL LETTER K WITH ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7730, 'status' => 'C', 'lower' => array(7731)); /* LATIN CAPITAL LETTER K WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7732, 'status' => 'C', 'lower' => array(7733)); /* LATIN CAPITAL LETTER K WITH LINE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7734, 'status' => 'C', 'lower' => array(7735)); /* LATIN CAPITAL LETTER L WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7736, 'status' => 'C', 'lower' => array(7737)); /* LATIN CAPITAL LETTER L WITH DOT BELOW AND MACRON */ -$config['1e00_1eff'][] = array('upper' => 7738, 'status' => 'C', 'lower' => array(7739)); /* LATIN CAPITAL LETTER L WITH LINE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7740, 'status' => 'C', 'lower' => array(7741)); /* LATIN CAPITAL LETTER L WITH CIRCUMFLEX BELOW */ -$config['1e00_1eff'][] = array('upper' => 7742, 'status' => 'C', 'lower' => array(7743)); /* LATIN CAPITAL LETTER M WITH ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7744, 'status' => 'C', 'lower' => array(7745)); /* LATIN CAPITAL LETTER M WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7746, 'status' => 'C', 'lower' => array(7747)); /* LATIN CAPITAL LETTER M WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7748, 'status' => 'C', 'lower' => array(7749)); /* LATIN CAPITAL LETTER N WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7750, 'status' => 'C', 'lower' => array(7751)); /* LATIN CAPITAL LETTER N WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7752, 'status' => 'C', 'lower' => array(7753)); /* LATIN CAPITAL LETTER N WITH LINE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7754, 'status' => 'C', 'lower' => array(7755)); /* LATIN CAPITAL LETTER N WITH CIRCUMFLEX BELOW */ -$config['1e00_1eff'][] = array('upper' => 7756, 'status' => 'C', 'lower' => array(7757)); /* LATIN CAPITAL LETTER O WITH TILDE AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7758, 'status' => 'C', 'lower' => array(7759)); /* LATIN CAPITAL LETTER O WITH TILDE AND DIAERESIS */ -$config['1e00_1eff'][] = array('upper' => 7760, 'status' => 'C', 'lower' => array(7761)); /* LATIN CAPITAL LETTER O WITH MACRON AND GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7762, 'status' => 'C', 'lower' => array(7763)); /* LATIN CAPITAL LETTER O WITH MACRON AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7764, 'status' => 'C', 'lower' => array(7765)); /* LATIN CAPITAL LETTER P WITH ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7766, 'status' => 'C', 'lower' => array(7767)); /* LATIN CAPITAL LETTER P WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7768, 'status' => 'C', 'lower' => array(7769)); /* LATIN CAPITAL LETTER R WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7770, 'status' => 'C', 'lower' => array(7771)); /* LATIN CAPITAL LETTER R WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7772, 'status' => 'C', 'lower' => array(7773)); /* LATIN CAPITAL LETTER R WITH DOT BELOW AND MACRON */ -$config['1e00_1eff'][] = array('upper' => 7774, 'status' => 'C', 'lower' => array(7775)); /* LATIN CAPITAL LETTER R WITH LINE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7776, 'status' => 'C', 'lower' => array(7777)); /* LATIN CAPITAL LETTER S WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7778, 'status' => 'C', 'lower' => array(7779)); /* LATIN CAPITAL LETTER S WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7780, 'status' => 'C', 'lower' => array(7781)); /* LATIN CAPITAL LETTER S WITH ACUTE AND DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7782, 'status' => 'C', 'lower' => array(7783)); /* LATIN CAPITAL LETTER S WITH CARON AND DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7784, 'status' => 'C', 'lower' => array(7785)); /* LATIN CAPITAL LETTER S WITH DOT BELOW AND DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7786, 'status' => 'C', 'lower' => array(7787)); /* LATIN CAPITAL LETTER T WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7788, 'status' => 'C', 'lower' => array(7789)); /* LATIN CAPITAL LETTER T WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7790, 'status' => 'C', 'lower' => array(7791)); /* LATIN CAPITAL LETTER T WITH LINE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7792, 'status' => 'C', 'lower' => array(7793)); /* LATIN CAPITAL LETTER T WITH CIRCUMFLEX BELOW */ -$config['1e00_1eff'][] = array('upper' => 7794, 'status' => 'C', 'lower' => array(7795)); /* LATIN CAPITAL LETTER U WITH DIAERESIS BELOW */ -$config['1e00_1eff'][] = array('upper' => 7796, 'status' => 'C', 'lower' => array(7797)); /* LATIN CAPITAL LETTER U WITH TILDE BELOW */ -$config['1e00_1eff'][] = array('upper' => 7798, 'status' => 'C', 'lower' => array(7799)); /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX BELOW */ -$config['1e00_1eff'][] = array('upper' => 7800, 'status' => 'C', 'lower' => array(7801)); /* LATIN CAPITAL LETTER U WITH TILDE AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7802, 'status' => 'C', 'lower' => array(7803)); /* LATIN CAPITAL LETTER U WITH MACRON AND DIAERESIS */ -$config['1e00_1eff'][] = array('upper' => 7804, 'status' => 'C', 'lower' => array(7805)); /* LATIN CAPITAL LETTER V WITH TILDE */ -$config['1e00_1eff'][] = array('upper' => 7806, 'status' => 'C', 'lower' => array(7807)); /* LATIN CAPITAL LETTER V WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7808, 'status' => 'C', 'lower' => array(7809)); /* LATIN CAPITAL LETTER W WITH GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7810, 'status' => 'C', 'lower' => array(7811)); /* LATIN CAPITAL LETTER W WITH ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7812, 'status' => 'C', 'lower' => array(7813)); /* LATIN CAPITAL LETTER W WITH DIAERESIS */ -$config['1e00_1eff'][] = array('upper' => 7814, 'status' => 'C', 'lower' => array(7815)); /* LATIN CAPITAL LETTER W WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7816, 'status' => 'C', 'lower' => array(7817)); /* LATIN CAPITAL LETTER W WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7818, 'status' => 'C', 'lower' => array(7819)); /* LATIN CAPITAL LETTER X WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7820, 'status' => 'C', 'lower' => array(7821)); /* LATIN CAPITAL LETTER X WITH DIAERESIS */ -$config['1e00_1eff'][] = array('upper' => 7822, 'status' => 'C', 'lower' => array(7823)); /* LATIN CAPITAL LETTER Y WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7824, 'status' => 'C', 'lower' => array(7825)); /* LATIN CAPITAL LETTER Z WITH CIRCUMFLEX */ -$config['1e00_1eff'][] = array('upper' => 7826, 'status' => 'C', 'lower' => array(7827)); /* LATIN CAPITAL LETTER Z WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7828, 'status' => 'C', 'lower' => array(7829)); /* LATIN CAPITAL LETTER Z WITH LINE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7680, 'status' => 'C', 'lower' => [7681]]; /* LATIN CAPITAL LETTER A WITH RING BELOW */ +$config['1e00_1eff'][] = ['upper' => 7682, 'status' => 'C', 'lower' => [7683]]; /* LATIN CAPITAL LETTER B WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7684, 'status' => 'C', 'lower' => [7685]]; /* LATIN CAPITAL LETTER B WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7686, 'status' => 'C', 'lower' => [7687]]; /* LATIN CAPITAL LETTER B WITH LINE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7688, 'status' => 'C', 'lower' => [7689]]; /* LATIN CAPITAL LETTER C WITH CEDILLA AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7690, 'status' => 'C', 'lower' => [7691]]; /* LATIN CAPITAL LETTER D WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7692, 'status' => 'C', 'lower' => [7693]]; /* LATIN CAPITAL LETTER D WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7694, 'status' => 'C', 'lower' => [7695]]; /* LATIN CAPITAL LETTER D WITH LINE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7696, 'status' => 'C', 'lower' => [7697]]; /* LATIN CAPITAL LETTER D WITH CEDILLA */ +$config['1e00_1eff'][] = ['upper' => 7698, 'status' => 'C', 'lower' => [7699]]; /* LATIN CAPITAL LETTER D WITH CIRCUMFLEX BELOW */ +$config['1e00_1eff'][] = ['upper' => 7700, 'status' => 'C', 'lower' => [7701]]; /* LATIN CAPITAL LETTER E WITH MACRON AND GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7702, 'status' => 'C', 'lower' => [7703]]; /* LATIN CAPITAL LETTER E WITH MACRON AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7704, 'status' => 'C', 'lower' => [7705]]; /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX BELOW */ +$config['1e00_1eff'][] = ['upper' => 7706, 'status' => 'C', 'lower' => [7707]]; /* LATIN CAPITAL LETTER E WITH TILDE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7708, 'status' => 'C', 'lower' => [7709]]; /* LATIN CAPITAL LETTER E WITH CEDILLA AND BREVE */ +$config['1e00_1eff'][] = ['upper' => 7710, 'status' => 'C', 'lower' => [7711]]; /* LATIN CAPITAL LETTER F WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7712, 'status' => 'C', 'lower' => [7713]]; /* LATIN CAPITAL LETTER G WITH MACRON */ +$config['1e00_1eff'][] = ['upper' => 7714, 'status' => 'C', 'lower' => [7715]]; /* LATIN CAPITAL LETTER H WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7716, 'status' => 'C', 'lower' => [7717]]; /* LATIN CAPITAL LETTER H WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7718, 'status' => 'C', 'lower' => [7719]]; /* LATIN CAPITAL LETTER H WITH DIAERESIS */ +$config['1e00_1eff'][] = ['upper' => 7720, 'status' => 'C', 'lower' => [7721]]; /* LATIN CAPITAL LETTER H WITH CEDILLA */ +$config['1e00_1eff'][] = ['upper' => 7722, 'status' => 'C', 'lower' => [7723]]; /* LATIN CAPITAL LETTER H WITH BREVE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7724, 'status' => 'C', 'lower' => [7725]]; /* LATIN CAPITAL LETTER I WITH TILDE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7726, 'status' => 'C', 'lower' => [7727]]; /* LATIN CAPITAL LETTER I WITH DIAERESIS AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7728, 'status' => 'C', 'lower' => [7729]]; /* LATIN CAPITAL LETTER K WITH ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7730, 'status' => 'C', 'lower' => [7731]]; /* LATIN CAPITAL LETTER K WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7732, 'status' => 'C', 'lower' => [7733]]; /* LATIN CAPITAL LETTER K WITH LINE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7734, 'status' => 'C', 'lower' => [7735]]; /* LATIN CAPITAL LETTER L WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7736, 'status' => 'C', 'lower' => [7737]]; /* LATIN CAPITAL LETTER L WITH DOT BELOW AND MACRON */ +$config['1e00_1eff'][] = ['upper' => 7738, 'status' => 'C', 'lower' => [7739]]; /* LATIN CAPITAL LETTER L WITH LINE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7740, 'status' => 'C', 'lower' => [7741]]; /* LATIN CAPITAL LETTER L WITH CIRCUMFLEX BELOW */ +$config['1e00_1eff'][] = ['upper' => 7742, 'status' => 'C', 'lower' => [7743]]; /* LATIN CAPITAL LETTER M WITH ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7744, 'status' => 'C', 'lower' => [7745]]; /* LATIN CAPITAL LETTER M WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7746, 'status' => 'C', 'lower' => [7747]]; /* LATIN CAPITAL LETTER M WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7748, 'status' => 'C', 'lower' => [7749]]; /* LATIN CAPITAL LETTER N WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7750, 'status' => 'C', 'lower' => [7751]]; /* LATIN CAPITAL LETTER N WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7752, 'status' => 'C', 'lower' => [7753]]; /* LATIN CAPITAL LETTER N WITH LINE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7754, 'status' => 'C', 'lower' => [7755]]; /* LATIN CAPITAL LETTER N WITH CIRCUMFLEX BELOW */ +$config['1e00_1eff'][] = ['upper' => 7756, 'status' => 'C', 'lower' => [7757]]; /* LATIN CAPITAL LETTER O WITH TILDE AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7758, 'status' => 'C', 'lower' => [7759]]; /* LATIN CAPITAL LETTER O WITH TILDE AND DIAERESIS */ +$config['1e00_1eff'][] = ['upper' => 7760, 'status' => 'C', 'lower' => [7761]]; /* LATIN CAPITAL LETTER O WITH MACRON AND GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7762, 'status' => 'C', 'lower' => [7763]]; /* LATIN CAPITAL LETTER O WITH MACRON AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7764, 'status' => 'C', 'lower' => [7765]]; /* LATIN CAPITAL LETTER P WITH ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7766, 'status' => 'C', 'lower' => [7767]]; /* LATIN CAPITAL LETTER P WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7768, 'status' => 'C', 'lower' => [7769]]; /* LATIN CAPITAL LETTER R WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7770, 'status' => 'C', 'lower' => [7771]]; /* LATIN CAPITAL LETTER R WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7772, 'status' => 'C', 'lower' => [7773]]; /* LATIN CAPITAL LETTER R WITH DOT BELOW AND MACRON */ +$config['1e00_1eff'][] = ['upper' => 7774, 'status' => 'C', 'lower' => [7775]]; /* LATIN CAPITAL LETTER R WITH LINE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7776, 'status' => 'C', 'lower' => [7777]]; /* LATIN CAPITAL LETTER S WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7778, 'status' => 'C', 'lower' => [7779]]; /* LATIN CAPITAL LETTER S WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7780, 'status' => 'C', 'lower' => [7781]]; /* LATIN CAPITAL LETTER S WITH ACUTE AND DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7782, 'status' => 'C', 'lower' => [7783]]; /* LATIN CAPITAL LETTER S WITH CARON AND DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7784, 'status' => 'C', 'lower' => [7785]]; /* LATIN CAPITAL LETTER S WITH DOT BELOW AND DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7786, 'status' => 'C', 'lower' => [7787]]; /* LATIN CAPITAL LETTER T WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7788, 'status' => 'C', 'lower' => [7789]]; /* LATIN CAPITAL LETTER T WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7790, 'status' => 'C', 'lower' => [7791]]; /* LATIN CAPITAL LETTER T WITH LINE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7792, 'status' => 'C', 'lower' => [7793]]; /* LATIN CAPITAL LETTER T WITH CIRCUMFLEX BELOW */ +$config['1e00_1eff'][] = ['upper' => 7794, 'status' => 'C', 'lower' => [7795]]; /* LATIN CAPITAL LETTER U WITH DIAERESIS BELOW */ +$config['1e00_1eff'][] = ['upper' => 7796, 'status' => 'C', 'lower' => [7797]]; /* LATIN CAPITAL LETTER U WITH TILDE BELOW */ +$config['1e00_1eff'][] = ['upper' => 7798, 'status' => 'C', 'lower' => [7799]]; /* LATIN CAPITAL LETTER U WITH CIRCUMFLEX BELOW */ +$config['1e00_1eff'][] = ['upper' => 7800, 'status' => 'C', 'lower' => [7801]]; /* LATIN CAPITAL LETTER U WITH TILDE AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7802, 'status' => 'C', 'lower' => [7803]]; /* LATIN CAPITAL LETTER U WITH MACRON AND DIAERESIS */ +$config['1e00_1eff'][] = ['upper' => 7804, 'status' => 'C', 'lower' => [7805]]; /* LATIN CAPITAL LETTER V WITH TILDE */ +$config['1e00_1eff'][] = ['upper' => 7806, 'status' => 'C', 'lower' => [7807]]; /* LATIN CAPITAL LETTER V WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7808, 'status' => 'C', 'lower' => [7809]]; /* LATIN CAPITAL LETTER W WITH GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7810, 'status' => 'C', 'lower' => [7811]]; /* LATIN CAPITAL LETTER W WITH ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7812, 'status' => 'C', 'lower' => [7813]]; /* LATIN CAPITAL LETTER W WITH DIAERESIS */ +$config['1e00_1eff'][] = ['upper' => 7814, 'status' => 'C', 'lower' => [7815]]; /* LATIN CAPITAL LETTER W WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7816, 'status' => 'C', 'lower' => [7817]]; /* LATIN CAPITAL LETTER W WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7818, 'status' => 'C', 'lower' => [7819]]; /* LATIN CAPITAL LETTER X WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7820, 'status' => 'C', 'lower' => [7821]]; /* LATIN CAPITAL LETTER X WITH DIAERESIS */ +$config['1e00_1eff'][] = ['upper' => 7822, 'status' => 'C', 'lower' => [7823]]; /* LATIN CAPITAL LETTER Y WITH DOT ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7824, 'status' => 'C', 'lower' => [7825]]; /* LATIN CAPITAL LETTER Z WITH CIRCUMFLEX */ +$config['1e00_1eff'][] = ['upper' => 7826, 'status' => 'C', 'lower' => [7827]]; /* LATIN CAPITAL LETTER Z WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7828, 'status' => 'C', 'lower' => [7829]]; /* LATIN CAPITAL LETTER Z WITH LINE BELOW */ //$config['1e00_1eff'][] = array('upper' => 7830, 'status' => 'F', 'lower' => array(104, 817)); /* LATIN SMALL LETTER H WITH LINE BELOW */ //$config['1e00_1eff'][] = array('upper' => 7831, 'status' => 'F', 'lower' => array(116, 776)); /* LATIN SMALL LETTER T WITH DIAERESIS */ @@ -120,48 +120,48 @@ //$config['1e00_1eff'][] = array('upper' => 7834, 'status' => 'F', 'lower' => array(97, 702)); /* LATIN SMALL LETTER A WITH RIGHT HALF RING */ //$config['1e00_1eff'][] = array('upper' => 7835, 'status' => 'C', 'lower' => array(7777)); /* LATIN SMALL LETTER LONG S WITH DOT ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7840, 'status' => 'C', 'lower' => array(7841)); /* LATIN CAPITAL LETTER A WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7842, 'status' => 'C', 'lower' => array(7843)); /* LATIN CAPITAL LETTER A WITH HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7844, 'status' => 'C', 'lower' => array(7845)); /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7846, 'status' => 'C', 'lower' => array(7847)); /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7848, 'status' => 'C', 'lower' => array(7849)); /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7850, 'status' => 'C', 'lower' => array(7851)); /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE */ -$config['1e00_1eff'][] = array('upper' => 7852, 'status' => 'C', 'lower' => array(7853)); /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7854, 'status' => 'C', 'lower' => array(7855)); /* LATIN CAPITAL LETTER A WITH BREVE AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7856, 'status' => 'C', 'lower' => array(7857)); /* LATIN CAPITAL LETTER A WITH BREVE AND GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7858, 'status' => 'C', 'lower' => array(7859)); /* LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7860, 'status' => 'C', 'lower' => array(7861)); /* LATIN CAPITAL LETTER A WITH BREVE AND TILDE */ -$config['1e00_1eff'][] = array('upper' => 7862, 'status' => 'C', 'lower' => array(7863)); /* LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7864, 'status' => 'C', 'lower' => array(7865)); /* LATIN CAPITAL LETTER E WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7866, 'status' => 'C', 'lower' => array(7867)); /* LATIN CAPITAL LETTER E WITH HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7868, 'status' => 'C', 'lower' => array(7869)); /* LATIN CAPITAL LETTER E WITH TILDE */ -$config['1e00_1eff'][] = array('upper' => 7870, 'status' => 'C', 'lower' => array(7871)); /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7872, 'status' => 'C', 'lower' => array(7873)); /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7874, 'status' => 'C', 'lower' => array(7875)); /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7876, 'status' => 'C', 'lower' => array(7877)); /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE */ -$config['1e00_1eff'][] = array('upper' => 7878, 'status' => 'C', 'lower' => array(7879)); /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7880, 'status' => 'C', 'lower' => array(7881)); /* LATIN CAPITAL LETTER I WITH HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7882, 'status' => 'C', 'lower' => array(7883)); /* LATIN CAPITAL LETTER I WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7884, 'status' => 'C', 'lower' => array(7885)); /* LATIN CAPITAL LETTER O WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7886, 'status' => 'C', 'lower' => array(7887)); /* LATIN CAPITAL LETTER O WITH HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7888, 'status' => 'C', 'lower' => array(7889)); /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7890, 'status' => 'C', 'lower' => array(7891)); /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7892, 'status' => 'C', 'lower' => array(7893)); /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7894, 'status' => 'C', 'lower' => array(7895)); /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE */ -$config['1e00_1eff'][] = array('upper' => 7896, 'status' => 'C', 'lower' => array(7897)); /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7898, 'status' => 'C', 'lower' => array(7899)); /* LATIN CAPITAL LETTER O WITH HORN AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7900, 'status' => 'C', 'lower' => array(7901)); /* LATIN CAPITAL LETTER O WITH HORN AND GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7902, 'status' => 'C', 'lower' => array(7903)); /* LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7904, 'status' => 'C', 'lower' => array(7905)); /* LATIN CAPITAL LETTER O WITH HORN AND TILDE */ -$config['1e00_1eff'][] = array('upper' => 7906, 'status' => 'C', 'lower' => array(7907)); /* LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7908, 'status' => 'C', 'lower' => array(7909)); /* LATIN CAPITAL LETTER U WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7910, 'status' => 'C', 'lower' => array(7911)); /* LATIN CAPITAL LETTER U WITH HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7912, 'status' => 'C', 'lower' => array(7913)); /* LATIN CAPITAL LETTER U WITH HORN AND ACUTE */ -$config['1e00_1eff'][] = array('upper' => 7914, 'status' => 'C', 'lower' => array(7915)); /* LATIN CAPITAL LETTER U WITH HORN AND GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7916, 'status' => 'C', 'lower' => array(7917)); /* LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7918, 'status' => 'C', 'lower' => array(7919)); /* LATIN CAPITAL LETTER U WITH HORN AND TILDE */ -$config['1e00_1eff'][] = array('upper' => 7920, 'status' => 'C', 'lower' => array(7921)); /* LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7922, 'status' => 'C', 'lower' => array(7923)); /* LATIN CAPITAL LETTER Y WITH GRAVE */ -$config['1e00_1eff'][] = array('upper' => 7924, 'status' => 'C', 'lower' => array(7925)); /* LATIN CAPITAL LETTER Y WITH DOT BELOW */ -$config['1e00_1eff'][] = array('upper' => 7926, 'status' => 'C', 'lower' => array(7927)); /* LATIN CAPITAL LETTER Y WITH HOOK ABOVE */ -$config['1e00_1eff'][] = array('upper' => 7928, 'status' => 'C', 'lower' => array(7929)); /* LATIN CAPITAL LETTER Y WITH TILDE */ +$config['1e00_1eff'][] = ['upper' => 7840, 'status' => 'C', 'lower' => [7841]]; /* LATIN CAPITAL LETTER A WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7842, 'status' => 'C', 'lower' => [7843]]; /* LATIN CAPITAL LETTER A WITH HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7844, 'status' => 'C', 'lower' => [7845]]; /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7846, 'status' => 'C', 'lower' => [7847]]; /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7848, 'status' => 'C', 'lower' => [7849]]; /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7850, 'status' => 'C', 'lower' => [7851]]; /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND TILDE */ +$config['1e00_1eff'][] = ['upper' => 7852, 'status' => 'C', 'lower' => [7853]]; /* LATIN CAPITAL LETTER A WITH CIRCUMFLEX AND DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7854, 'status' => 'C', 'lower' => [7855]]; /* LATIN CAPITAL LETTER A WITH BREVE AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7856, 'status' => 'C', 'lower' => [7857]]; /* LATIN CAPITAL LETTER A WITH BREVE AND GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7858, 'status' => 'C', 'lower' => [7859]]; /* LATIN CAPITAL LETTER A WITH BREVE AND HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7860, 'status' => 'C', 'lower' => [7861]]; /* LATIN CAPITAL LETTER A WITH BREVE AND TILDE */ +$config['1e00_1eff'][] = ['upper' => 7862, 'status' => 'C', 'lower' => [7863]]; /* LATIN CAPITAL LETTER A WITH BREVE AND DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7864, 'status' => 'C', 'lower' => [7865]]; /* LATIN CAPITAL LETTER E WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7866, 'status' => 'C', 'lower' => [7867]]; /* LATIN CAPITAL LETTER E WITH HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7868, 'status' => 'C', 'lower' => [7869]]; /* LATIN CAPITAL LETTER E WITH TILDE */ +$config['1e00_1eff'][] = ['upper' => 7870, 'status' => 'C', 'lower' => [7871]]; /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7872, 'status' => 'C', 'lower' => [7873]]; /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7874, 'status' => 'C', 'lower' => [7875]]; /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7876, 'status' => 'C', 'lower' => [7877]]; /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND TILDE */ +$config['1e00_1eff'][] = ['upper' => 7878, 'status' => 'C', 'lower' => [7879]]; /* LATIN CAPITAL LETTER E WITH CIRCUMFLEX AND DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7880, 'status' => 'C', 'lower' => [7881]]; /* LATIN CAPITAL LETTER I WITH HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7882, 'status' => 'C', 'lower' => [7883]]; /* LATIN CAPITAL LETTER I WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7884, 'status' => 'C', 'lower' => [7885]]; /* LATIN CAPITAL LETTER O WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7886, 'status' => 'C', 'lower' => [7887]]; /* LATIN CAPITAL LETTER O WITH HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7888, 'status' => 'C', 'lower' => [7889]]; /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7890, 'status' => 'C', 'lower' => [7891]]; /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7892, 'status' => 'C', 'lower' => [7893]]; /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7894, 'status' => 'C', 'lower' => [7895]]; /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND TILDE */ +$config['1e00_1eff'][] = ['upper' => 7896, 'status' => 'C', 'lower' => [7897]]; /* LATIN CAPITAL LETTER O WITH CIRCUMFLEX AND DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7898, 'status' => 'C', 'lower' => [7899]]; /* LATIN CAPITAL LETTER O WITH HORN AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7900, 'status' => 'C', 'lower' => [7901]]; /* LATIN CAPITAL LETTER O WITH HORN AND GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7902, 'status' => 'C', 'lower' => [7903]]; /* LATIN CAPITAL LETTER O WITH HORN AND HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7904, 'status' => 'C', 'lower' => [7905]]; /* LATIN CAPITAL LETTER O WITH HORN AND TILDE */ +$config['1e00_1eff'][] = ['upper' => 7906, 'status' => 'C', 'lower' => [7907]]; /* LATIN CAPITAL LETTER O WITH HORN AND DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7908, 'status' => 'C', 'lower' => [7909]]; /* LATIN CAPITAL LETTER U WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7910, 'status' => 'C', 'lower' => [7911]]; /* LATIN CAPITAL LETTER U WITH HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7912, 'status' => 'C', 'lower' => [7913]]; /* LATIN CAPITAL LETTER U WITH HORN AND ACUTE */ +$config['1e00_1eff'][] = ['upper' => 7914, 'status' => 'C', 'lower' => [7915]]; /* LATIN CAPITAL LETTER U WITH HORN AND GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7916, 'status' => 'C', 'lower' => [7917]]; /* LATIN CAPITAL LETTER U WITH HORN AND HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7918, 'status' => 'C', 'lower' => [7919]]; /* LATIN CAPITAL LETTER U WITH HORN AND TILDE */ +$config['1e00_1eff'][] = ['upper' => 7920, 'status' => 'C', 'lower' => [7921]]; /* LATIN CAPITAL LETTER U WITH HORN AND DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7922, 'status' => 'C', 'lower' => [7923]]; /* LATIN CAPITAL LETTER Y WITH GRAVE */ +$config['1e00_1eff'][] = ['upper' => 7924, 'status' => 'C', 'lower' => [7925]]; /* LATIN CAPITAL LETTER Y WITH DOT BELOW */ +$config['1e00_1eff'][] = ['upper' => 7926, 'status' => 'C', 'lower' => [7927]]; /* LATIN CAPITAL LETTER Y WITH HOOK ABOVE */ +$config['1e00_1eff'][] = ['upper' => 7928, 'status' => 'C', 'lower' => [7929]]; /* LATIN CAPITAL LETTER Y WITH TILDE */ diff --git a/lib/Cake/Config/unicode/casefolding/1f00_1fff.php b/lib/Cake/Config/unicode/casefolding/1f00_1fff.php index 1b3d6367c4..c7123834a9 100644 --- a/lib/Cake/Config/unicode/casefolding/1f00_1fff.php +++ b/lib/Cake/Config/unicode/casefolding/1f00_1fff.php @@ -37,179 +37,179 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['1f00_1fff'][] = array('upper' => 7944, 'status' => 'C', 'lower' => array(7936, 953)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI */ -$config['1f00_1fff'][] = array('upper' => 7945, 'status' => 'C', 'lower' => array(7937)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA */ -$config['1f00_1fff'][] = array('upper' => 7946, 'status' => 'C', 'lower' => array(7938)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 7947, 'status' => 'C', 'lower' => array(7939)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 7948, 'status' => 'C', 'lower' => array(7940)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 7949, 'status' => 'C', 'lower' => array(7941)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 7950, 'status' => 'C', 'lower' => array(7942)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 7951, 'status' => 'C', 'lower' => array(7943)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 7960, 'status' => 'C', 'lower' => array(7952)); /* GREEK CAPITAL LETTER EPSILON WITH PSILI */ -$config['1f00_1fff'][] = array('upper' => 7961, 'status' => 'C', 'lower' => array(7953)); /* GREEK CAPITAL LETTER EPSILON WITH DASIA */ -$config['1f00_1fff'][] = array('upper' => 7962, 'status' => 'C', 'lower' => array(7954)); /* GREEK CAPITAL LETTER EPSILON WITH PSILI AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 7963, 'status' => 'C', 'lower' => array(7955)); /* GREEK CAPITAL LETTER EPSILON WITH DASIA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 7964, 'status' => 'C', 'lower' => array(7956)); /* GREEK CAPITAL LETTER EPSILON WITH PSILI AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 7965, 'status' => 'C', 'lower' => array(7957)); /* GREEK CAPITAL LETTER EPSILON WITH DASIA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 7976, 'status' => 'C', 'lower' => array(7968)); /* GREEK CAPITAL LETTER ETA WITH PSILI */ -$config['1f00_1fff'][] = array('upper' => 7977, 'status' => 'C', 'lower' => array(7969)); /* GREEK CAPITAL LETTER ETA WITH DASIA */ -$config['1f00_1fff'][] = array('upper' => 7978, 'status' => 'C', 'lower' => array(7970)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 7979, 'status' => 'C', 'lower' => array(7971)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 7980, 'status' => 'C', 'lower' => array(7972)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 7981, 'status' => 'C', 'lower' => array(7973)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 7982, 'status' => 'C', 'lower' => array(7974)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 7983, 'status' => 'C', 'lower' => array(7975)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 7992, 'status' => 'C', 'lower' => array(7984)); /* GREEK CAPITAL LETTER IOTA WITH PSILI */ -$config['1f00_1fff'][] = array('upper' => 7993, 'status' => 'C', 'lower' => array(7985)); /* GREEK CAPITAL LETTER IOTA WITH DASIA */ -$config['1f00_1fff'][] = array('upper' => 7994, 'status' => 'C', 'lower' => array(7986)); /* GREEK CAPITAL LETTER IOTA WITH PSILI AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 7995, 'status' => 'C', 'lower' => array(7987)); /* GREEK CAPITAL LETTER IOTA WITH DASIA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 7996, 'status' => 'C', 'lower' => array(7988)); /* GREEK CAPITAL LETTER IOTA WITH PSILI AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 7997, 'status' => 'C', 'lower' => array(7989)); /* GREEK CAPITAL LETTER IOTA WITH DASIA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 7998, 'status' => 'C', 'lower' => array(7990)); /* GREEK CAPITAL LETTER IOTA WITH PSILI AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 7999, 'status' => 'C', 'lower' => array(7991)); /* GREEK CAPITAL LETTER IOTA WITH DASIA AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8008, 'status' => 'C', 'lower' => array(8000)); /* GREEK CAPITAL LETTER OMICRON WITH PSILI */ -$config['1f00_1fff'][] = array('upper' => 8009, 'status' => 'C', 'lower' => array(8001)); /* GREEK CAPITAL LETTER OMICRON WITH DASIA */ -$config['1f00_1fff'][] = array('upper' => 8010, 'status' => 'C', 'lower' => array(8002)); /* GREEK CAPITAL LETTER OMICRON WITH PSILI AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 8011, 'status' => 'C', 'lower' => array(8003)); /* GREEK CAPITAL LETTER OMICRON WITH DASIA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 8012, 'status' => 'C', 'lower' => array(8004)); /* GREEK CAPITAL LETTER OMICRON WITH PSILI AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 8013, 'status' => 'C', 'lower' => array(8005)); /* GREEK CAPITAL LETTER OMICRON WITH DASIA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 8016, 'status' => 'F', 'lower' => array(965, 787)); /* GREEK SMALL LETTER UPSILON WITH PSILI */ -$config['1f00_1fff'][] = array('upper' => 8018, 'status' => 'F', 'lower' => array(965, 787, 768)); /* GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 8020, 'status' => 'F', 'lower' => array(965, 787, 769)); /* GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 8022, 'status' => 'F', 'lower' => array(965, 787, 834)); /* GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8025, 'status' => 'C', 'lower' => array(8017)); /* GREEK CAPITAL LETTER UPSILON WITH DASIA */ -$config['1f00_1fff'][] = array('upper' => 8027, 'status' => 'C', 'lower' => array(8019)); /* GREEK CAPITAL LETTER UPSILON WITH DASIA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 8029, 'status' => 'C', 'lower' => array(8021)); /* GREEK CAPITAL LETTER UPSILON WITH DASIA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 8031, 'status' => 'C', 'lower' => array(8023)); /* GREEK CAPITAL LETTER UPSILON WITH DASIA AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8040, 'status' => 'C', 'lower' => array(8032)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI */ -$config['1f00_1fff'][] = array('upper' => 8041, 'status' => 'C', 'lower' => array(8033)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA */ -$config['1f00_1fff'][] = array('upper' => 8042, 'status' => 'C', 'lower' => array(8034)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 8043, 'status' => 'C', 'lower' => array(8035)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 8044, 'status' => 'C', 'lower' => array(8036)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 8045, 'status' => 'C', 'lower' => array(8037)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 8046, 'status' => 'C', 'lower' => array(8038)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8047, 'status' => 'C', 'lower' => array(8039)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8064, 'status' => 'F', 'lower' => array(7936, 953)); /* GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8065, 'status' => 'F', 'lower' => array(7937, 953)); /* GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8066, 'status' => 'F', 'lower' => array(7938, 953)); /* GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8067, 'status' => 'F', 'lower' => array(7939, 953)); /* GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8068, 'status' => 'F', 'lower' => array(7940, 953)); /* GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8069, 'status' => 'F', 'lower' => array(7941, 953)); /* GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8070, 'status' => 'F', 'lower' => array(7942, 953)); /* GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8071, 'status' => 'F', 'lower' => array(7943, 953)); /* GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8072, 'status' => 'F', 'lower' => array(7936, 953)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8072, 'status' => 'S', 'lower' => array(8064)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8073, 'status' => 'F', 'lower' => array(7937, 953)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8073, 'status' => 'S', 'lower' => array(8065)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8074, 'status' => 'F', 'lower' => array(7938, 953)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8074, 'status' => 'S', 'lower' => array(8066)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8075, 'status' => 'F', 'lower' => array(7939, 953)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8075, 'status' => 'S', 'lower' => array(8067)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8076, 'status' => 'F', 'lower' => array(7940, 953)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8076, 'status' => 'S', 'lower' => array(8068)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8077, 'status' => 'F', 'lower' => array(7941, 953)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8077, 'status' => 'S', 'lower' => array(8069)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8078, 'status' => 'F', 'lower' => array(7942, 953)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8078, 'status' => 'S', 'lower' => array(8070)); /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8079, 'status' => 'F', 'lower' => array(7943, 953)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8079, 'status' => 'S', 'lower' => array(8071)); /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8080, 'status' => 'F', 'lower' => array(7968, 953)); /* GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8081, 'status' => 'F', 'lower' => array(7969, 953)); /* GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8082, 'status' => 'F', 'lower' => array(7970, 953)); /* GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8083, 'status' => 'F', 'lower' => array(7971, 953)); /* GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8084, 'status' => 'F', 'lower' => array(7972, 953)); /* GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8085, 'status' => 'F', 'lower' => array(7973, 953)); /* GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8086, 'status' => 'F', 'lower' => array(7974, 953)); /* GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8087, 'status' => 'F', 'lower' => array(7975, 953)); /* GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8088, 'status' => 'F', 'lower' => array(7968, 953)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8088, 'status' => 'S', 'lower' => array(8080)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8089, 'status' => 'F', 'lower' => array(7969, 953)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8089, 'status' => 'S', 'lower' => array(8081)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8090, 'status' => 'F', 'lower' => array(7970, 953)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8090, 'status' => 'S', 'lower' => array(8082)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8091, 'status' => 'F', 'lower' => array(7971, 953)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8091, 'status' => 'S', 'lower' => array(8083)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8092, 'status' => 'F', 'lower' => array(7972, 953)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8092, 'status' => 'S', 'lower' => array(8084)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8093, 'status' => 'F', 'lower' => array(7973, 953)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8093, 'status' => 'S', 'lower' => array(8085)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8094, 'status' => 'F', 'lower' => array(7974, 953)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8094, 'status' => 'S', 'lower' => array(8086)); /* GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8095, 'status' => 'F', 'lower' => array(7975, 953)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8095, 'status' => 'S', 'lower' => array(8087)); /* GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8096, 'status' => 'F', 'lower' => array(8032, 953)); /* GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8097, 'status' => 'F', 'lower' => array(8033, 953)); /* GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8098, 'status' => 'F', 'lower' => array(8034, 953)); /* GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8099, 'status' => 'F', 'lower' => array(8035, 953)); /* GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8100, 'status' => 'F', 'lower' => array(8036, 953)); /* GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8101, 'status' => 'F', 'lower' => array(8037, 953)); /* GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8102, 'status' => 'F', 'lower' => array(8038, 953)); /* GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8103, 'status' => 'F', 'lower' => array(8039, 953)); /* GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8104, 'status' => 'F', 'lower' => array(8032, 953)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8104, 'status' => 'S', 'lower' => array(8096)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8105, 'status' => 'F', 'lower' => array(8033, 953)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8105, 'status' => 'S', 'lower' => array(8097)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8106, 'status' => 'F', 'lower' => array(8034, 953)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8106, 'status' => 'S', 'lower' => array(8098)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8107, 'status' => 'F', 'lower' => array(8035, 953)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8107, 'status' => 'S', 'lower' => array(8099)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8108, 'status' => 'F', 'lower' => array(8036, 953)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8108, 'status' => 'S', 'lower' => array(8100)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8109, 'status' => 'F', 'lower' => array(8037, 953)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8109, 'status' => 'S', 'lower' => array(8101)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8110, 'status' => 'F', 'lower' => array(8038, 953)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8110, 'status' => 'S', 'lower' => array(8102)); /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8111, 'status' => 'F', 'lower' => array(8039, 953)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8111, 'status' => 'S', 'lower' => array(8103)); /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8114, 'status' => 'F', 'lower' => array(8048, 953)); /* GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8115, 'status' => 'F', 'lower' => array(945, 953)); /* GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8116, 'status' => 'F', 'lower' => array(940, 953)); /* GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8118, 'status' => 'F', 'lower' => array(945, 834)); /* GREEK SMALL LETTER ALPHA WITH PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8119, 'status' => 'F', 'lower' => array(945, 834, 953)); /* GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8120, 'status' => 'C', 'lower' => array(8112)); /* GREEK CAPITAL LETTER ALPHA WITH VRACHY */ -$config['1f00_1fff'][] = array('upper' => 8121, 'status' => 'C', 'lower' => array(8113)); /* GREEK CAPITAL LETTER ALPHA WITH MACRON */ -$config['1f00_1fff'][] = array('upper' => 8122, 'status' => 'C', 'lower' => array(8048)); /* GREEK CAPITAL LETTER ALPHA WITH VARIA */ -$config['1f00_1fff'][] = array('upper' => 8123, 'status' => 'C', 'lower' => array(8049)); /* GREEK CAPITAL LETTER ALPHA WITH OXIA */ -$config['1f00_1fff'][] = array('upper' => 8124, 'status' => 'F', 'lower' => array(945, 953)); /* GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8124, 'status' => 'S', 'lower' => array(8115)); /* GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8126, 'status' => 'C', 'lower' => array(953)); /* GREEK PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8130, 'status' => 'F', 'lower' => array(8052, 953)); /* GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8131, 'status' => 'F', 'lower' => array(951, 953)); /* GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8132, 'status' => 'F', 'lower' => array(942, 953)); /* GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8134, 'status' => 'F', 'lower' => array(951, 834)); /* GREEK SMALL LETTER ETA WITH PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8135, 'status' => 'F', 'lower' => array(951, 834, 953)); /* GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8136, 'status' => 'C', 'lower' => array(8050)); /* GREEK CAPITAL LETTER EPSILON WITH VARIA */ -$config['1f00_1fff'][] = array('upper' => 8137, 'status' => 'C', 'lower' => array(8051)); /* GREEK CAPITAL LETTER EPSILON WITH OXIA */ -$config['1f00_1fff'][] = array('upper' => 8138, 'status' => 'C', 'lower' => array(8052)); /* GREEK CAPITAL LETTER ETA WITH VARIA */ -$config['1f00_1fff'][] = array('upper' => 8139, 'status' => 'C', 'lower' => array(8053)); /* GREEK CAPITAL LETTER ETA WITH OXIA */ -$config['1f00_1fff'][] = array('upper' => 8140, 'status' => 'F', 'lower' => array(951, 953)); /* GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8140, 'status' => 'S', 'lower' => array(8131)); /* GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8146, 'status' => 'F', 'lower' => array(953, 776, 768)); /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 8147, 'status' => 'F', 'lower' => array(953, 776, 769)); /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 8150, 'status' => 'F', 'lower' => array(953, 834)); /* GREEK SMALL LETTER IOTA WITH PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8151, 'status' => 'F', 'lower' => array(953, 776, 834)); /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8152, 'status' => 'C', 'lower' => array(8144)); /* GREEK CAPITAL LETTER IOTA WITH VRACHY */ -$config['1f00_1fff'][] = array('upper' => 8153, 'status' => 'C', 'lower' => array(8145)); /* GREEK CAPITAL LETTER IOTA WITH MACRON */ -$config['1f00_1fff'][] = array('upper' => 8154, 'status' => 'C', 'lower' => array(8054)); /* GREEK CAPITAL LETTER IOTA WITH VARIA */ -$config['1f00_1fff'][] = array('upper' => 8155, 'status' => 'C', 'lower' => array(8055)); /* GREEK CAPITAL LETTER IOTA WITH OXIA */ -$config['1f00_1fff'][] = array('upper' => 8162, 'status' => 'F', 'lower' => array(965, 776, 768)); /* GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA */ -$config['1f00_1fff'][] = array('upper' => 8163, 'status' => 'F', 'lower' => array(965, 776, 769)); /* GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA */ -$config['1f00_1fff'][] = array('upper' => 8164, 'status' => 'F', 'lower' => array(961, 787)); /* GREEK SMALL LETTER RHO WITH PSILI */ -$config['1f00_1fff'][] = array('upper' => 8166, 'status' => 'F', 'lower' => array(965, 834)); /* GREEK SMALL LETTER UPSILON WITH PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8167, 'status' => 'F', 'lower' => array(965, 776, 834)); /* GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8168, 'status' => 'C', 'lower' => array(8160)); /* GREEK CAPITAL LETTER UPSILON WITH VRACHY */ -$config['1f00_1fff'][] = array('upper' => 8169, 'status' => 'C', 'lower' => array(8161)); /* GREEK CAPITAL LETTER UPSILON WITH MACRON */ -$config['1f00_1fff'][] = array('upper' => 8170, 'status' => 'C', 'lower' => array(8058)); /* GREEK CAPITAL LETTER UPSILON WITH VARIA */ -$config['1f00_1fff'][] = array('upper' => 8171, 'status' => 'C', 'lower' => array(8059)); /* GREEK CAPITAL LETTER UPSILON WITH OXIA */ -$config['1f00_1fff'][] = array('upper' => 8172, 'status' => 'C', 'lower' => array(8165)); /* GREEK CAPITAL LETTER RHO WITH DASIA */ -$config['1f00_1fff'][] = array('upper' => 8178, 'status' => 'F', 'lower' => array(8060, 953)); /* GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8179, 'status' => 'F', 'lower' => array(969, 953)); /* GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8180, 'status' => 'F', 'lower' => array(974, 953)); /* GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8182, 'status' => 'F', 'lower' => array(969, 834)); /* GREEK SMALL LETTER OMEGA WITH PERISPOMENI */ -$config['1f00_1fff'][] = array('upper' => 8183, 'status' => 'F', 'lower' => array(969, 834, 953)); /* GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8184, 'status' => 'C', 'lower' => array(8056)); /* GREEK CAPITAL LETTER OMICRON WITH VARIA */ -$config['1f00_1fff'][] = array('upper' => 8185, 'status' => 'C', 'lower' => array(8057)); /* GREEK CAPITAL LETTER OMICRON WITH OXIA */ -$config['1f00_1fff'][] = array('upper' => 8186, 'status' => 'C', 'lower' => array(8060)); /* GREEK CAPITAL LETTER OMEGA WITH VARIA */ -$config['1f00_1fff'][] = array('upper' => 8187, 'status' => 'C', 'lower' => array(8061)); /* GREEK CAPITAL LETTER OMEGA WITH OXIA */ -$config['1f00_1fff'][] = array('upper' => 8188, 'status' => 'F', 'lower' => array(969, 953)); /* GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI */ -$config['1f00_1fff'][] = array('upper' => 8188, 'status' => 'S', 'lower' => array(8179)); /* GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 7944, 'status' => 'C', 'lower' => [7936, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI */ +$config['1f00_1fff'][] = ['upper' => 7945, 'status' => 'C', 'lower' => [7937]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA */ +$config['1f00_1fff'][] = ['upper' => 7946, 'status' => 'C', 'lower' => [7938]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 7947, 'status' => 'C', 'lower' => [7939]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 7948, 'status' => 'C', 'lower' => [7940]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 7949, 'status' => 'C', 'lower' => [7941]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 7950, 'status' => 'C', 'lower' => [7942]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 7951, 'status' => 'C', 'lower' => [7943]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 7960, 'status' => 'C', 'lower' => [7952]]; /* GREEK CAPITAL LETTER EPSILON WITH PSILI */ +$config['1f00_1fff'][] = ['upper' => 7961, 'status' => 'C', 'lower' => [7953]]; /* GREEK CAPITAL LETTER EPSILON WITH DASIA */ +$config['1f00_1fff'][] = ['upper' => 7962, 'status' => 'C', 'lower' => [7954]]; /* GREEK CAPITAL LETTER EPSILON WITH PSILI AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 7963, 'status' => 'C', 'lower' => [7955]]; /* GREEK CAPITAL LETTER EPSILON WITH DASIA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 7964, 'status' => 'C', 'lower' => [7956]]; /* GREEK CAPITAL LETTER EPSILON WITH PSILI AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 7965, 'status' => 'C', 'lower' => [7957]]; /* GREEK CAPITAL LETTER EPSILON WITH DASIA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 7976, 'status' => 'C', 'lower' => [7968]]; /* GREEK CAPITAL LETTER ETA WITH PSILI */ +$config['1f00_1fff'][] = ['upper' => 7977, 'status' => 'C', 'lower' => [7969]]; /* GREEK CAPITAL LETTER ETA WITH DASIA */ +$config['1f00_1fff'][] = ['upper' => 7978, 'status' => 'C', 'lower' => [7970]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 7979, 'status' => 'C', 'lower' => [7971]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 7980, 'status' => 'C', 'lower' => [7972]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 7981, 'status' => 'C', 'lower' => [7973]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 7982, 'status' => 'C', 'lower' => [7974]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 7983, 'status' => 'C', 'lower' => [7975]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 7992, 'status' => 'C', 'lower' => [7984]]; /* GREEK CAPITAL LETTER IOTA WITH PSILI */ +$config['1f00_1fff'][] = ['upper' => 7993, 'status' => 'C', 'lower' => [7985]]; /* GREEK CAPITAL LETTER IOTA WITH DASIA */ +$config['1f00_1fff'][] = ['upper' => 7994, 'status' => 'C', 'lower' => [7986]]; /* GREEK CAPITAL LETTER IOTA WITH PSILI AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 7995, 'status' => 'C', 'lower' => [7987]]; /* GREEK CAPITAL LETTER IOTA WITH DASIA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 7996, 'status' => 'C', 'lower' => [7988]]; /* GREEK CAPITAL LETTER IOTA WITH PSILI AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 7997, 'status' => 'C', 'lower' => [7989]]; /* GREEK CAPITAL LETTER IOTA WITH DASIA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 7998, 'status' => 'C', 'lower' => [7990]]; /* GREEK CAPITAL LETTER IOTA WITH PSILI AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 7999, 'status' => 'C', 'lower' => [7991]]; /* GREEK CAPITAL LETTER IOTA WITH DASIA AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8008, 'status' => 'C', 'lower' => [8000]]; /* GREEK CAPITAL LETTER OMICRON WITH PSILI */ +$config['1f00_1fff'][] = ['upper' => 8009, 'status' => 'C', 'lower' => [8001]]; /* GREEK CAPITAL LETTER OMICRON WITH DASIA */ +$config['1f00_1fff'][] = ['upper' => 8010, 'status' => 'C', 'lower' => [8002]]; /* GREEK CAPITAL LETTER OMICRON WITH PSILI AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 8011, 'status' => 'C', 'lower' => [8003]]; /* GREEK CAPITAL LETTER OMICRON WITH DASIA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 8012, 'status' => 'C', 'lower' => [8004]]; /* GREEK CAPITAL LETTER OMICRON WITH PSILI AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 8013, 'status' => 'C', 'lower' => [8005]]; /* GREEK CAPITAL LETTER OMICRON WITH DASIA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 8016, 'status' => 'F', 'lower' => [965, 787]]; /* GREEK SMALL LETTER UPSILON WITH PSILI */ +$config['1f00_1fff'][] = ['upper' => 8018, 'status' => 'F', 'lower' => [965, 787, 768]]; /* GREEK SMALL LETTER UPSILON WITH PSILI AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 8020, 'status' => 'F', 'lower' => [965, 787, 769]]; /* GREEK SMALL LETTER UPSILON WITH PSILI AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 8022, 'status' => 'F', 'lower' => [965, 787, 834]]; /* GREEK SMALL LETTER UPSILON WITH PSILI AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8025, 'status' => 'C', 'lower' => [8017]]; /* GREEK CAPITAL LETTER UPSILON WITH DASIA */ +$config['1f00_1fff'][] = ['upper' => 8027, 'status' => 'C', 'lower' => [8019]]; /* GREEK CAPITAL LETTER UPSILON WITH DASIA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 8029, 'status' => 'C', 'lower' => [8021]]; /* GREEK CAPITAL LETTER UPSILON WITH DASIA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 8031, 'status' => 'C', 'lower' => [8023]]; /* GREEK CAPITAL LETTER UPSILON WITH DASIA AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8040, 'status' => 'C', 'lower' => [8032]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI */ +$config['1f00_1fff'][] = ['upper' => 8041, 'status' => 'C', 'lower' => [8033]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA */ +$config['1f00_1fff'][] = ['upper' => 8042, 'status' => 'C', 'lower' => [8034]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 8043, 'status' => 'C', 'lower' => [8035]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 8044, 'status' => 'C', 'lower' => [8036]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 8045, 'status' => 'C', 'lower' => [8037]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 8046, 'status' => 'C', 'lower' => [8038]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8047, 'status' => 'C', 'lower' => [8039]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8064, 'status' => 'F', 'lower' => [7936, 953]]; /* GREEK SMALL LETTER ALPHA WITH PSILI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8065, 'status' => 'F', 'lower' => [7937, 953]]; /* GREEK SMALL LETTER ALPHA WITH DASIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8066, 'status' => 'F', 'lower' => [7938, 953]]; /* GREEK SMALL LETTER ALPHA WITH PSILI AND VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8067, 'status' => 'F', 'lower' => [7939, 953]]; /* GREEK SMALL LETTER ALPHA WITH DASIA AND VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8068, 'status' => 'F', 'lower' => [7940, 953]]; /* GREEK SMALL LETTER ALPHA WITH PSILI AND OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8069, 'status' => 'F', 'lower' => [7941, 953]]; /* GREEK SMALL LETTER ALPHA WITH DASIA AND OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8070, 'status' => 'F', 'lower' => [7942, 953]]; /* GREEK SMALL LETTER ALPHA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8071, 'status' => 'F', 'lower' => [7943, 953]]; /* GREEK SMALL LETTER ALPHA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8072, 'status' => 'F', 'lower' => [7936, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8072, 'status' => 'S', 'lower' => [8064]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8073, 'status' => 'F', 'lower' => [7937, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8073, 'status' => 'S', 'lower' => [8065]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8074, 'status' => 'F', 'lower' => [7938, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8074, 'status' => 'S', 'lower' => [8066]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8075, 'status' => 'F', 'lower' => [7939, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8075, 'status' => 'S', 'lower' => [8067]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8076, 'status' => 'F', 'lower' => [7940, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8076, 'status' => 'S', 'lower' => [8068]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8077, 'status' => 'F', 'lower' => [7941, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8077, 'status' => 'S', 'lower' => [8069]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8078, 'status' => 'F', 'lower' => [7942, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8078, 'status' => 'S', 'lower' => [8070]]; /* GREEK CAPITAL LETTER ALPHA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8079, 'status' => 'F', 'lower' => [7943, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8079, 'status' => 'S', 'lower' => [8071]]; /* GREEK CAPITAL LETTER ALPHA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8080, 'status' => 'F', 'lower' => [7968, 953]]; /* GREEK SMALL LETTER ETA WITH PSILI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8081, 'status' => 'F', 'lower' => [7969, 953]]; /* GREEK SMALL LETTER ETA WITH DASIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8082, 'status' => 'F', 'lower' => [7970, 953]]; /* GREEK SMALL LETTER ETA WITH PSILI AND VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8083, 'status' => 'F', 'lower' => [7971, 953]]; /* GREEK SMALL LETTER ETA WITH DASIA AND VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8084, 'status' => 'F', 'lower' => [7972, 953]]; /* GREEK SMALL LETTER ETA WITH PSILI AND OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8085, 'status' => 'F', 'lower' => [7973, 953]]; /* GREEK SMALL LETTER ETA WITH DASIA AND OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8086, 'status' => 'F', 'lower' => [7974, 953]]; /* GREEK SMALL LETTER ETA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8087, 'status' => 'F', 'lower' => [7975, 953]]; /* GREEK SMALL LETTER ETA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8088, 'status' => 'F', 'lower' => [7968, 953]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8088, 'status' => 'S', 'lower' => [8080]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8089, 'status' => 'F', 'lower' => [7969, 953]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8089, 'status' => 'S', 'lower' => [8081]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8090, 'status' => 'F', 'lower' => [7970, 953]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8090, 'status' => 'S', 'lower' => [8082]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8091, 'status' => 'F', 'lower' => [7971, 953]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8091, 'status' => 'S', 'lower' => [8083]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8092, 'status' => 'F', 'lower' => [7972, 953]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8092, 'status' => 'S', 'lower' => [8084]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8093, 'status' => 'F', 'lower' => [7973, 953]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8093, 'status' => 'S', 'lower' => [8085]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8094, 'status' => 'F', 'lower' => [7974, 953]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8094, 'status' => 'S', 'lower' => [8086]]; /* GREEK CAPITAL LETTER ETA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8095, 'status' => 'F', 'lower' => [7975, 953]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8095, 'status' => 'S', 'lower' => [8087]]; /* GREEK CAPITAL LETTER ETA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8096, 'status' => 'F', 'lower' => [8032, 953]]; /* GREEK SMALL LETTER OMEGA WITH PSILI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8097, 'status' => 'F', 'lower' => [8033, 953]]; /* GREEK SMALL LETTER OMEGA WITH DASIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8098, 'status' => 'F', 'lower' => [8034, 953]]; /* GREEK SMALL LETTER OMEGA WITH PSILI AND VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8099, 'status' => 'F', 'lower' => [8035, 953]]; /* GREEK SMALL LETTER OMEGA WITH DASIA AND VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8100, 'status' => 'F', 'lower' => [8036, 953]]; /* GREEK SMALL LETTER OMEGA WITH PSILI AND OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8101, 'status' => 'F', 'lower' => [8037, 953]]; /* GREEK SMALL LETTER OMEGA WITH DASIA AND OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8102, 'status' => 'F', 'lower' => [8038, 953]]; /* GREEK SMALL LETTER OMEGA WITH PSILI AND PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8103, 'status' => 'F', 'lower' => [8039, 953]]; /* GREEK SMALL LETTER OMEGA WITH DASIA AND PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8104, 'status' => 'F', 'lower' => [8032, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8104, 'status' => 'S', 'lower' => [8096]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8105, 'status' => 'F', 'lower' => [8033, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8105, 'status' => 'S', 'lower' => [8097]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8106, 'status' => 'F', 'lower' => [8034, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8106, 'status' => 'S', 'lower' => [8098]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8107, 'status' => 'F', 'lower' => [8035, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8107, 'status' => 'S', 'lower' => [8099]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND VARIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8108, 'status' => 'F', 'lower' => [8036, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8108, 'status' => 'S', 'lower' => [8100]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8109, 'status' => 'F', 'lower' => [8037, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8109, 'status' => 'S', 'lower' => [8101]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND OXIA AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8110, 'status' => 'F', 'lower' => [8038, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8110, 'status' => 'S', 'lower' => [8102]]; /* GREEK CAPITAL LETTER OMEGA WITH PSILI AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8111, 'status' => 'F', 'lower' => [8039, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8111, 'status' => 'S', 'lower' => [8103]]; /* GREEK CAPITAL LETTER OMEGA WITH DASIA AND PERISPOMENI AND PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8114, 'status' => 'F', 'lower' => [8048, 953]]; /* GREEK SMALL LETTER ALPHA WITH VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8115, 'status' => 'F', 'lower' => [945, 953]]; /* GREEK SMALL LETTER ALPHA WITH YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8116, 'status' => 'F', 'lower' => [940, 953]]; /* GREEK SMALL LETTER ALPHA WITH OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8118, 'status' => 'F', 'lower' => [945, 834]]; /* GREEK SMALL LETTER ALPHA WITH PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8119, 'status' => 'F', 'lower' => [945, 834, 953]]; /* GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8120, 'status' => 'C', 'lower' => [8112]]; /* GREEK CAPITAL LETTER ALPHA WITH VRACHY */ +$config['1f00_1fff'][] = ['upper' => 8121, 'status' => 'C', 'lower' => [8113]]; /* GREEK CAPITAL LETTER ALPHA WITH MACRON */ +$config['1f00_1fff'][] = ['upper' => 8122, 'status' => 'C', 'lower' => [8048]]; /* GREEK CAPITAL LETTER ALPHA WITH VARIA */ +$config['1f00_1fff'][] = ['upper' => 8123, 'status' => 'C', 'lower' => [8049]]; /* GREEK CAPITAL LETTER ALPHA WITH OXIA */ +$config['1f00_1fff'][] = ['upper' => 8124, 'status' => 'F', 'lower' => [945, 953]]; /* GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8124, 'status' => 'S', 'lower' => [8115]]; /* GREEK CAPITAL LETTER ALPHA WITH PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8126, 'status' => 'C', 'lower' => [953]]; /* GREEK PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8130, 'status' => 'F', 'lower' => [8052, 953]]; /* GREEK SMALL LETTER ETA WITH VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8131, 'status' => 'F', 'lower' => [951, 953]]; /* GREEK SMALL LETTER ETA WITH YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8132, 'status' => 'F', 'lower' => [942, 953]]; /* GREEK SMALL LETTER ETA WITH OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8134, 'status' => 'F', 'lower' => [951, 834]]; /* GREEK SMALL LETTER ETA WITH PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8135, 'status' => 'F', 'lower' => [951, 834, 953]]; /* GREEK SMALL LETTER ETA WITH PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8136, 'status' => 'C', 'lower' => [8050]]; /* GREEK CAPITAL LETTER EPSILON WITH VARIA */ +$config['1f00_1fff'][] = ['upper' => 8137, 'status' => 'C', 'lower' => [8051]]; /* GREEK CAPITAL LETTER EPSILON WITH OXIA */ +$config['1f00_1fff'][] = ['upper' => 8138, 'status' => 'C', 'lower' => [8052]]; /* GREEK CAPITAL LETTER ETA WITH VARIA */ +$config['1f00_1fff'][] = ['upper' => 8139, 'status' => 'C', 'lower' => [8053]]; /* GREEK CAPITAL LETTER ETA WITH OXIA */ +$config['1f00_1fff'][] = ['upper' => 8140, 'status' => 'F', 'lower' => [951, 953]]; /* GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8140, 'status' => 'S', 'lower' => [8131]]; /* GREEK CAPITAL LETTER ETA WITH PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8146, 'status' => 'F', 'lower' => [953, 776, 768]]; /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 8147, 'status' => 'F', 'lower' => [953, 776, 769]]; /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 8150, 'status' => 'F', 'lower' => [953, 834]]; /* GREEK SMALL LETTER IOTA WITH PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8151, 'status' => 'F', 'lower' => [953, 776, 834]]; /* GREEK SMALL LETTER IOTA WITH DIALYTIKA AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8152, 'status' => 'C', 'lower' => [8144]]; /* GREEK CAPITAL LETTER IOTA WITH VRACHY */ +$config['1f00_1fff'][] = ['upper' => 8153, 'status' => 'C', 'lower' => [8145]]; /* GREEK CAPITAL LETTER IOTA WITH MACRON */ +$config['1f00_1fff'][] = ['upper' => 8154, 'status' => 'C', 'lower' => [8054]]; /* GREEK CAPITAL LETTER IOTA WITH VARIA */ +$config['1f00_1fff'][] = ['upper' => 8155, 'status' => 'C', 'lower' => [8055]]; /* GREEK CAPITAL LETTER IOTA WITH OXIA */ +$config['1f00_1fff'][] = ['upper' => 8162, 'status' => 'F', 'lower' => [965, 776, 768]]; /* GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND VARIA */ +$config['1f00_1fff'][] = ['upper' => 8163, 'status' => 'F', 'lower' => [965, 776, 769]]; /* GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND OXIA */ +$config['1f00_1fff'][] = ['upper' => 8164, 'status' => 'F', 'lower' => [961, 787]]; /* GREEK SMALL LETTER RHO WITH PSILI */ +$config['1f00_1fff'][] = ['upper' => 8166, 'status' => 'F', 'lower' => [965, 834]]; /* GREEK SMALL LETTER UPSILON WITH PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8167, 'status' => 'F', 'lower' => [965, 776, 834]]; /* GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8168, 'status' => 'C', 'lower' => [8160]]; /* GREEK CAPITAL LETTER UPSILON WITH VRACHY */ +$config['1f00_1fff'][] = ['upper' => 8169, 'status' => 'C', 'lower' => [8161]]; /* GREEK CAPITAL LETTER UPSILON WITH MACRON */ +$config['1f00_1fff'][] = ['upper' => 8170, 'status' => 'C', 'lower' => [8058]]; /* GREEK CAPITAL LETTER UPSILON WITH VARIA */ +$config['1f00_1fff'][] = ['upper' => 8171, 'status' => 'C', 'lower' => [8059]]; /* GREEK CAPITAL LETTER UPSILON WITH OXIA */ +$config['1f00_1fff'][] = ['upper' => 8172, 'status' => 'C', 'lower' => [8165]]; /* GREEK CAPITAL LETTER RHO WITH DASIA */ +$config['1f00_1fff'][] = ['upper' => 8178, 'status' => 'F', 'lower' => [8060, 953]]; /* GREEK SMALL LETTER OMEGA WITH VARIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8179, 'status' => 'F', 'lower' => [969, 953]]; /* GREEK SMALL LETTER OMEGA WITH YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8180, 'status' => 'F', 'lower' => [974, 953]]; /* GREEK SMALL LETTER OMEGA WITH OXIA AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8182, 'status' => 'F', 'lower' => [969, 834]]; /* GREEK SMALL LETTER OMEGA WITH PERISPOMENI */ +$config['1f00_1fff'][] = ['upper' => 8183, 'status' => 'F', 'lower' => [969, 834, 953]]; /* GREEK SMALL LETTER OMEGA WITH PERISPOMENI AND YPOGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8184, 'status' => 'C', 'lower' => [8056]]; /* GREEK CAPITAL LETTER OMICRON WITH VARIA */ +$config['1f00_1fff'][] = ['upper' => 8185, 'status' => 'C', 'lower' => [8057]]; /* GREEK CAPITAL LETTER OMICRON WITH OXIA */ +$config['1f00_1fff'][] = ['upper' => 8186, 'status' => 'C', 'lower' => [8060]]; /* GREEK CAPITAL LETTER OMEGA WITH VARIA */ +$config['1f00_1fff'][] = ['upper' => 8187, 'status' => 'C', 'lower' => [8061]]; /* GREEK CAPITAL LETTER OMEGA WITH OXIA */ +$config['1f00_1fff'][] = ['upper' => 8188, 'status' => 'F', 'lower' => [969, 953]]; /* GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI */ +$config['1f00_1fff'][] = ['upper' => 8188, 'status' => 'S', 'lower' => [8179]]; /* GREEK CAPITAL LETTER OMEGA WITH PROSGEGRAMMENI */ diff --git a/lib/Cake/Config/unicode/casefolding/2100_214f.php b/lib/Cake/Config/unicode/casefolding/2100_214f.php index 9e409805a3..3991027e68 100644 --- a/lib/Cake/Config/unicode/casefolding/2100_214f.php +++ b/lib/Cake/Config/unicode/casefolding/2100_214f.php @@ -37,7 +37,7 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['2100_214f'][] = array('upper' => 8486, 'status' => 'C', 'lower' => array(969)); /* OHM SIGN */ -$config['2100_214f'][] = array('upper' => 8490, 'status' => 'C', 'lower' => array(107)); /* KELVIN SIGN */ -$config['2100_214f'][] = array('upper' => 8491, 'status' => 'C', 'lower' => array(229)); /* ANGSTROM SIGN */ -$config['2100_214f'][] = array('upper' => 8498, 'status' => 'C', 'lower' => array(8526)); /* TURNED CAPITAL F */ +$config['2100_214f'][] = ['upper' => 8486, 'status' => 'C', 'lower' => [969]]; /* OHM SIGN */ +$config['2100_214f'][] = ['upper' => 8490, 'status' => 'C', 'lower' => [107]]; /* KELVIN SIGN */ +$config['2100_214f'][] = ['upper' => 8491, 'status' => 'C', 'lower' => [229]]; /* ANGSTROM SIGN */ +$config['2100_214f'][] = ['upper' => 8498, 'status' => 'C', 'lower' => [8526]]; /* TURNED CAPITAL F */ diff --git a/lib/Cake/Config/unicode/casefolding/2150_218f.php b/lib/Cake/Config/unicode/casefolding/2150_218f.php index 119121e2f6..bb74b885fa 100644 --- a/lib/Cake/Config/unicode/casefolding/2150_218f.php +++ b/lib/Cake/Config/unicode/casefolding/2150_218f.php @@ -37,20 +37,20 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['2150_218f'][] = array('upper' => 8544, 'status' => 'C', 'lower' => array(8560)); /* ROMAN NUMERAL ONE */ -$config['2150_218f'][] = array('upper' => 8545, 'status' => 'C', 'lower' => array(8561)); /* ROMAN NUMERAL TWO */ -$config['2150_218f'][] = array('upper' => 8546, 'status' => 'C', 'lower' => array(8562)); /* ROMAN NUMERAL THREE */ -$config['2150_218f'][] = array('upper' => 8547, 'status' => 'C', 'lower' => array(8563)); /* ROMAN NUMERAL FOUR */ -$config['2150_218f'][] = array('upper' => 8548, 'status' => 'C', 'lower' => array(8564)); /* ROMAN NUMERAL FIVE */ -$config['2150_218f'][] = array('upper' => 8549, 'status' => 'C', 'lower' => array(8565)); /* ROMAN NUMERAL SIX */ -$config['2150_218f'][] = array('upper' => 8550, 'status' => 'C', 'lower' => array(8566)); /* ROMAN NUMERAL SEVEN */ -$config['2150_218f'][] = array('upper' => 8551, 'status' => 'C', 'lower' => array(8567)); /* ROMAN NUMERAL EIGHT */ -$config['2150_218f'][] = array('upper' => 8552, 'status' => 'C', 'lower' => array(8568)); /* ROMAN NUMERAL NINE */ -$config['2150_218f'][] = array('upper' => 8553, 'status' => 'C', 'lower' => array(8569)); /* ROMAN NUMERAL TEN */ -$config['2150_218f'][] = array('upper' => 8554, 'status' => 'C', 'lower' => array(8570)); /* ROMAN NUMERAL ELEVEN */ -$config['2150_218f'][] = array('upper' => 8555, 'status' => 'C', 'lower' => array(8571)); /* ROMAN NUMERAL TWELVE */ -$config['2150_218f'][] = array('upper' => 8556, 'status' => 'C', 'lower' => array(8572)); /* ROMAN NUMERAL FIFTY */ -$config['2150_218f'][] = array('upper' => 8557, 'status' => 'C', 'lower' => array(8573)); /* ROMAN NUMERAL ONE HUNDRED */ -$config['2150_218f'][] = array('upper' => 8558, 'status' => 'C', 'lower' => array(8574)); /* ROMAN NUMERAL FIVE HUNDRED */ -$config['2150_218f'][] = array('upper' => 8559, 'status' => 'C', 'lower' => array(8575)); /* ROMAN NUMERAL ONE THOUSAND */ -$config['2150_218f'][] = array('upper' => 8579, 'status' => 'C', 'lower' => array(8580)); /* ROMAN NUMERAL REVERSED ONE HUNDRED */ +$config['2150_218f'][] = ['upper' => 8544, 'status' => 'C', 'lower' => [8560]]; /* ROMAN NUMERAL ONE */ +$config['2150_218f'][] = ['upper' => 8545, 'status' => 'C', 'lower' => [8561]]; /* ROMAN NUMERAL TWO */ +$config['2150_218f'][] = ['upper' => 8546, 'status' => 'C', 'lower' => [8562]]; /* ROMAN NUMERAL THREE */ +$config['2150_218f'][] = ['upper' => 8547, 'status' => 'C', 'lower' => [8563]]; /* ROMAN NUMERAL FOUR */ +$config['2150_218f'][] = ['upper' => 8548, 'status' => 'C', 'lower' => [8564]]; /* ROMAN NUMERAL FIVE */ +$config['2150_218f'][] = ['upper' => 8549, 'status' => 'C', 'lower' => [8565]]; /* ROMAN NUMERAL SIX */ +$config['2150_218f'][] = ['upper' => 8550, 'status' => 'C', 'lower' => [8566]]; /* ROMAN NUMERAL SEVEN */ +$config['2150_218f'][] = ['upper' => 8551, 'status' => 'C', 'lower' => [8567]]; /* ROMAN NUMERAL EIGHT */ +$config['2150_218f'][] = ['upper' => 8552, 'status' => 'C', 'lower' => [8568]]; /* ROMAN NUMERAL NINE */ +$config['2150_218f'][] = ['upper' => 8553, 'status' => 'C', 'lower' => [8569]]; /* ROMAN NUMERAL TEN */ +$config['2150_218f'][] = ['upper' => 8554, 'status' => 'C', 'lower' => [8570]]; /* ROMAN NUMERAL ELEVEN */ +$config['2150_218f'][] = ['upper' => 8555, 'status' => 'C', 'lower' => [8571]]; /* ROMAN NUMERAL TWELVE */ +$config['2150_218f'][] = ['upper' => 8556, 'status' => 'C', 'lower' => [8572]]; /* ROMAN NUMERAL FIFTY */ +$config['2150_218f'][] = ['upper' => 8557, 'status' => 'C', 'lower' => [8573]]; /* ROMAN NUMERAL ONE HUNDRED */ +$config['2150_218f'][] = ['upper' => 8558, 'status' => 'C', 'lower' => [8574]]; /* ROMAN NUMERAL FIVE HUNDRED */ +$config['2150_218f'][] = ['upper' => 8559, 'status' => 'C', 'lower' => [8575]]; /* ROMAN NUMERAL ONE THOUSAND */ +$config['2150_218f'][] = ['upper' => 8579, 'status' => 'C', 'lower' => [8580]]; /* ROMAN NUMERAL REVERSED ONE HUNDRED */ diff --git a/lib/Cake/Config/unicode/casefolding/2460_24ff.php b/lib/Cake/Config/unicode/casefolding/2460_24ff.php index d27d0e0109..9901b0e610 100644 --- a/lib/Cake/Config/unicode/casefolding/2460_24ff.php +++ b/lib/Cake/Config/unicode/casefolding/2460_24ff.php @@ -37,29 +37,29 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['2460_24ff'][] = array('upper' => 9398, 'status' => 'C', 'lower' => array(9424)); /* CIRCLED LATIN CAPITAL LETTER A */ -$config['2460_24ff'][] = array('upper' => 9399, 'status' => 'C', 'lower' => array(9425)); /* CIRCLED LATIN CAPITAL LETTER B */ -$config['2460_24ff'][] = array('upper' => 9400, 'status' => 'C', 'lower' => array(9426)); /* CIRCLED LATIN CAPITAL LETTER C */ -$config['2460_24ff'][] = array('upper' => 9401, 'status' => 'C', 'lower' => array(9427)); /* CIRCLED LATIN CAPITAL LETTER D */ -$config['2460_24ff'][] = array('upper' => 9402, 'status' => 'C', 'lower' => array(9428)); /* CIRCLED LATIN CAPITAL LETTER E */ -$config['2460_24ff'][] = array('upper' => 9403, 'status' => 'C', 'lower' => array(9429)); /* CIRCLED LATIN CAPITAL LETTER F */ -$config['2460_24ff'][] = array('upper' => 9404, 'status' => 'C', 'lower' => array(9430)); /* CIRCLED LATIN CAPITAL LETTER G */ -$config['2460_24ff'][] = array('upper' => 9405, 'status' => 'C', 'lower' => array(9431)); /* CIRCLED LATIN CAPITAL LETTER H */ -$config['2460_24ff'][] = array('upper' => 9406, 'status' => 'C', 'lower' => array(9432)); /* CIRCLED LATIN CAPITAL LETTER I */ -$config['2460_24ff'][] = array('upper' => 9407, 'status' => 'C', 'lower' => array(9433)); /* CIRCLED LATIN CAPITAL LETTER J */ -$config['2460_24ff'][] = array('upper' => 9408, 'status' => 'C', 'lower' => array(9434)); /* CIRCLED LATIN CAPITAL LETTER K */ -$config['2460_24ff'][] = array('upper' => 9409, 'status' => 'C', 'lower' => array(9435)); /* CIRCLED LATIN CAPITAL LETTER L */ -$config['2460_24ff'][] = array('upper' => 9410, 'status' => 'C', 'lower' => array(9436)); /* CIRCLED LATIN CAPITAL LETTER M */ -$config['2460_24ff'][] = array('upper' => 9411, 'status' => 'C', 'lower' => array(9437)); /* CIRCLED LATIN CAPITAL LETTER N */ -$config['2460_24ff'][] = array('upper' => 9412, 'status' => 'C', 'lower' => array(9438)); /* CIRCLED LATIN CAPITAL LETTER O */ -$config['2460_24ff'][] = array('upper' => 9413, 'status' => 'C', 'lower' => array(9439)); /* CIRCLED LATIN CAPITAL LETTER P */ -$config['2460_24ff'][] = array('upper' => 9414, 'status' => 'C', 'lower' => array(9440)); /* CIRCLED LATIN CAPITAL LETTER Q */ -$config['2460_24ff'][] = array('upper' => 9415, 'status' => 'C', 'lower' => array(9441)); /* CIRCLED LATIN CAPITAL LETTER R */ -$config['2460_24ff'][] = array('upper' => 9416, 'status' => 'C', 'lower' => array(9442)); /* CIRCLED LATIN CAPITAL LETTER S */ -$config['2460_24ff'][] = array('upper' => 9417, 'status' => 'C', 'lower' => array(9443)); /* CIRCLED LATIN CAPITAL LETTER T */ -$config['2460_24ff'][] = array('upper' => 9418, 'status' => 'C', 'lower' => array(9444)); /* CIRCLED LATIN CAPITAL LETTER U */ -$config['2460_24ff'][] = array('upper' => 9419, 'status' => 'C', 'lower' => array(9445)); /* CIRCLED LATIN CAPITAL LETTER V */ -$config['2460_24ff'][] = array('upper' => 9420, 'status' => 'C', 'lower' => array(9446)); /* CIRCLED LATIN CAPITAL LETTER W */ -$config['2460_24ff'][] = array('upper' => 9421, 'status' => 'C', 'lower' => array(9447)); /* CIRCLED LATIN CAPITAL LETTER X */ -$config['2460_24ff'][] = array('upper' => 9422, 'status' => 'C', 'lower' => array(9448)); /* CIRCLED LATIN CAPITAL LETTER Y */ -$config['2460_24ff'][] = array('upper' => 9423, 'status' => 'C', 'lower' => array(9449)); /* CIRCLED LATIN CAPITAL LETTER Z */ +$config['2460_24ff'][] = ['upper' => 9398, 'status' => 'C', 'lower' => [9424]]; /* CIRCLED LATIN CAPITAL LETTER A */ +$config['2460_24ff'][] = ['upper' => 9399, 'status' => 'C', 'lower' => [9425]]; /* CIRCLED LATIN CAPITAL LETTER B */ +$config['2460_24ff'][] = ['upper' => 9400, 'status' => 'C', 'lower' => [9426]]; /* CIRCLED LATIN CAPITAL LETTER C */ +$config['2460_24ff'][] = ['upper' => 9401, 'status' => 'C', 'lower' => [9427]]; /* CIRCLED LATIN CAPITAL LETTER D */ +$config['2460_24ff'][] = ['upper' => 9402, 'status' => 'C', 'lower' => [9428]]; /* CIRCLED LATIN CAPITAL LETTER E */ +$config['2460_24ff'][] = ['upper' => 9403, 'status' => 'C', 'lower' => [9429]]; /* CIRCLED LATIN CAPITAL LETTER F */ +$config['2460_24ff'][] = ['upper' => 9404, 'status' => 'C', 'lower' => [9430]]; /* CIRCLED LATIN CAPITAL LETTER G */ +$config['2460_24ff'][] = ['upper' => 9405, 'status' => 'C', 'lower' => [9431]]; /* CIRCLED LATIN CAPITAL LETTER H */ +$config['2460_24ff'][] = ['upper' => 9406, 'status' => 'C', 'lower' => [9432]]; /* CIRCLED LATIN CAPITAL LETTER I */ +$config['2460_24ff'][] = ['upper' => 9407, 'status' => 'C', 'lower' => [9433]]; /* CIRCLED LATIN CAPITAL LETTER J */ +$config['2460_24ff'][] = ['upper' => 9408, 'status' => 'C', 'lower' => [9434]]; /* CIRCLED LATIN CAPITAL LETTER K */ +$config['2460_24ff'][] = ['upper' => 9409, 'status' => 'C', 'lower' => [9435]]; /* CIRCLED LATIN CAPITAL LETTER L */ +$config['2460_24ff'][] = ['upper' => 9410, 'status' => 'C', 'lower' => [9436]]; /* CIRCLED LATIN CAPITAL LETTER M */ +$config['2460_24ff'][] = ['upper' => 9411, 'status' => 'C', 'lower' => [9437]]; /* CIRCLED LATIN CAPITAL LETTER N */ +$config['2460_24ff'][] = ['upper' => 9412, 'status' => 'C', 'lower' => [9438]]; /* CIRCLED LATIN CAPITAL LETTER O */ +$config['2460_24ff'][] = ['upper' => 9413, 'status' => 'C', 'lower' => [9439]]; /* CIRCLED LATIN CAPITAL LETTER P */ +$config['2460_24ff'][] = ['upper' => 9414, 'status' => 'C', 'lower' => [9440]]; /* CIRCLED LATIN CAPITAL LETTER Q */ +$config['2460_24ff'][] = ['upper' => 9415, 'status' => 'C', 'lower' => [9441]]; /* CIRCLED LATIN CAPITAL LETTER R */ +$config['2460_24ff'][] = ['upper' => 9416, 'status' => 'C', 'lower' => [9442]]; /* CIRCLED LATIN CAPITAL LETTER S */ +$config['2460_24ff'][] = ['upper' => 9417, 'status' => 'C', 'lower' => [9443]]; /* CIRCLED LATIN CAPITAL LETTER T */ +$config['2460_24ff'][] = ['upper' => 9418, 'status' => 'C', 'lower' => [9444]]; /* CIRCLED LATIN CAPITAL LETTER U */ +$config['2460_24ff'][] = ['upper' => 9419, 'status' => 'C', 'lower' => [9445]]; /* CIRCLED LATIN CAPITAL LETTER V */ +$config['2460_24ff'][] = ['upper' => 9420, 'status' => 'C', 'lower' => [9446]]; /* CIRCLED LATIN CAPITAL LETTER W */ +$config['2460_24ff'][] = ['upper' => 9421, 'status' => 'C', 'lower' => [9447]]; /* CIRCLED LATIN CAPITAL LETTER X */ +$config['2460_24ff'][] = ['upper' => 9422, 'status' => 'C', 'lower' => [9448]]; /* CIRCLED LATIN CAPITAL LETTER Y */ +$config['2460_24ff'][] = ['upper' => 9423, 'status' => 'C', 'lower' => [9449]]; /* CIRCLED LATIN CAPITAL LETTER Z */ diff --git a/lib/Cake/Config/unicode/casefolding/2c00_2c5f.php b/lib/Cake/Config/unicode/casefolding/2c00_2c5f.php index bb1492d986..9f50a000e5 100644 --- a/lib/Cake/Config/unicode/casefolding/2c00_2c5f.php +++ b/lib/Cake/Config/unicode/casefolding/2c00_2c5f.php @@ -37,50 +37,50 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['2c00_2c5f'][] = array('upper' => 11264, 'status' => 'C', 'lower' => array(11312)); /* GLAGOLITIC CAPITAL LETTER AZU */ -$config['2c00_2c5f'][] = array('upper' => 11265, 'status' => 'C', 'lower' => array(11313)); /* GLAGOLITIC CAPITAL LETTER BUKY */ -$config['2c00_2c5f'][] = array('upper' => 11266, 'status' => 'C', 'lower' => array(11314)); /* GLAGOLITIC CAPITAL LETTER VEDE */ -$config['2c00_2c5f'][] = array('upper' => 11267, 'status' => 'C', 'lower' => array(11315)); /* GLAGOLITIC CAPITAL LETTER GLAGOLI */ -$config['2c00_2c5f'][] = array('upper' => 11268, 'status' => 'C', 'lower' => array(11316)); /* GLAGOLITIC CAPITAL LETTER DOBRO */ -$config['2c00_2c5f'][] = array('upper' => 11269, 'status' => 'C', 'lower' => array(11317)); /* GLAGOLITIC CAPITAL LETTER YESTU */ -$config['2c00_2c5f'][] = array('upper' => 11270, 'status' => 'C', 'lower' => array(11318)); /* GLAGOLITIC CAPITAL LETTER ZHIVETE */ -$config['2c00_2c5f'][] = array('upper' => 11271, 'status' => 'C', 'lower' => array(11319)); /* GLAGOLITIC CAPITAL LETTER DZELO */ -$config['2c00_2c5f'][] = array('upper' => 11272, 'status' => 'C', 'lower' => array(11320)); /* GLAGOLITIC CAPITAL LETTER ZEMLJA */ -$config['2c00_2c5f'][] = array('upper' => 11273, 'status' => 'C', 'lower' => array(11321)); /* GLAGOLITIC CAPITAL LETTER IZHE */ -$config['2c00_2c5f'][] = array('upper' => 11274, 'status' => 'C', 'lower' => array(11322)); /* GLAGOLITIC CAPITAL LETTER INITIAL IZHE */ -$config['2c00_2c5f'][] = array('upper' => 11275, 'status' => 'C', 'lower' => array(11323)); /* GLAGOLITIC CAPITAL LETTER I */ -$config['2c00_2c5f'][] = array('upper' => 11276, 'status' => 'C', 'lower' => array(11324)); /* GLAGOLITIC CAPITAL LETTER DJERVI */ -$config['2c00_2c5f'][] = array('upper' => 11277, 'status' => 'C', 'lower' => array(11325)); /* GLAGOLITIC CAPITAL LETTER KAKO */ -$config['2c00_2c5f'][] = array('upper' => 11278, 'status' => 'C', 'lower' => array(11326)); /* GLAGOLITIC CAPITAL LETTER LJUDIJE */ -$config['2c00_2c5f'][] = array('upper' => 11279, 'status' => 'C', 'lower' => array(11327)); /* GLAGOLITIC CAPITAL LETTER MYSLITE */ -$config['2c00_2c5f'][] = array('upper' => 11280, 'status' => 'C', 'lower' => array(11328)); /* GLAGOLITIC CAPITAL LETTER NASHI */ -$config['2c00_2c5f'][] = array('upper' => 11281, 'status' => 'C', 'lower' => array(11329)); /* GLAGOLITIC CAPITAL LETTER ONU */ -$config['2c00_2c5f'][] = array('upper' => 11282, 'status' => 'C', 'lower' => array(11330)); /* GLAGOLITIC CAPITAL LETTER POKOJI */ -$config['2c00_2c5f'][] = array('upper' => 11283, 'status' => 'C', 'lower' => array(11331)); /* GLAGOLITIC CAPITAL LETTER RITSI */ -$config['2c00_2c5f'][] = array('upper' => 11284, 'status' => 'C', 'lower' => array(11332)); /* GLAGOLITIC CAPITAL LETTER SLOVO */ -$config['2c00_2c5f'][] = array('upper' => 11285, 'status' => 'C', 'lower' => array(11333)); /* GLAGOLITIC CAPITAL LETTER TVRIDO */ -$config['2c00_2c5f'][] = array('upper' => 11286, 'status' => 'C', 'lower' => array(11334)); /* GLAGOLITIC CAPITAL LETTER UKU */ -$config['2c00_2c5f'][] = array('upper' => 11287, 'status' => 'C', 'lower' => array(11335)); /* GLAGOLITIC CAPITAL LETTER FRITU */ -$config['2c00_2c5f'][] = array('upper' => 11288, 'status' => 'C', 'lower' => array(11336)); /* GLAGOLITIC CAPITAL LETTER HERU */ -$config['2c00_2c5f'][] = array('upper' => 11289, 'status' => 'C', 'lower' => array(11337)); /* GLAGOLITIC CAPITAL LETTER OTU */ -$config['2c00_2c5f'][] = array('upper' => 11290, 'status' => 'C', 'lower' => array(11338)); /* GLAGOLITIC CAPITAL LETTER PE */ -$config['2c00_2c5f'][] = array('upper' => 11291, 'status' => 'C', 'lower' => array(11339)); /* GLAGOLITIC CAPITAL LETTER SHTA */ -$config['2c00_2c5f'][] = array('upper' => 11292, 'status' => 'C', 'lower' => array(11340)); /* GLAGOLITIC CAPITAL LETTER TSI */ -$config['2c00_2c5f'][] = array('upper' => 11293, 'status' => 'C', 'lower' => array(11341)); /* GLAGOLITIC CAPITAL LETTER CHRIVI */ -$config['2c00_2c5f'][] = array('upper' => 11294, 'status' => 'C', 'lower' => array(11342)); /* GLAGOLITIC CAPITAL LETTER SHA */ -$config['2c00_2c5f'][] = array('upper' => 11295, 'status' => 'C', 'lower' => array(11343)); /* GLAGOLITIC CAPITAL LETTER YERU */ -$config['2c00_2c5f'][] = array('upper' => 11296, 'status' => 'C', 'lower' => array(11344)); /* GLAGOLITIC CAPITAL LETTER YERI */ -$config['2c00_2c5f'][] = array('upper' => 11297, 'status' => 'C', 'lower' => array(11345)); /* GLAGOLITIC CAPITAL LETTER YATI */ -$config['2c00_2c5f'][] = array('upper' => 11298, 'status' => 'C', 'lower' => array(11346)); /* GLAGOLITIC CAPITAL LETTER SPIDERY HA */ -$config['2c00_2c5f'][] = array('upper' => 11299, 'status' => 'C', 'lower' => array(11347)); /* GLAGOLITIC CAPITAL LETTER YU */ -$config['2c00_2c5f'][] = array('upper' => 11300, 'status' => 'C', 'lower' => array(11348)); /* GLAGOLITIC CAPITAL LETTER SMALL YUS */ -$config['2c00_2c5f'][] = array('upper' => 11301, 'status' => 'C', 'lower' => array(11349)); /* GLAGOLITIC CAPITAL LETTER SMALL YUS WITH TAIL */ -$config['2c00_2c5f'][] = array('upper' => 11302, 'status' => 'C', 'lower' => array(11350)); /* GLAGOLITIC CAPITAL LETTER YO */ -$config['2c00_2c5f'][] = array('upper' => 11303, 'status' => 'C', 'lower' => array(11351)); /* GLAGOLITIC CAPITAL LETTER IOTATED SMALL YUS */ -$config['2c00_2c5f'][] = array('upper' => 11304, 'status' => 'C', 'lower' => array(11352)); /* GLAGOLITIC CAPITAL LETTER BIG YUS */ -$config['2c00_2c5f'][] = array('upper' => 11305, 'status' => 'C', 'lower' => array(11353)); /* GLAGOLITIC CAPITAL LETTER IOTATED BIG YUS */ -$config['2c00_2c5f'][] = array('upper' => 11306, 'status' => 'C', 'lower' => array(11354)); /* GLAGOLITIC CAPITAL LETTER FITA */ -$config['2c00_2c5f'][] = array('upper' => 11307, 'status' => 'C', 'lower' => array(11355)); /* GLAGOLITIC CAPITAL LETTER IZHITSA */ -$config['2c00_2c5f'][] = array('upper' => 11308, 'status' => 'C', 'lower' => array(11356)); /* GLAGOLITIC CAPITAL LETTER SHTAPIC */ -$config['2c00_2c5f'][] = array('upper' => 11309, 'status' => 'C', 'lower' => array(11357)); /* GLAGOLITIC CAPITAL LETTER TROKUTASTI A */ -$config['2c00_2c5f'][] = array('upper' => 11310, 'status' => 'C', 'lower' => array(11358)); /* GLAGOLITIC CAPITAL LETTER LATINATE MYSLITE */ +$config['2c00_2c5f'][] = ['upper' => 11264, 'status' => 'C', 'lower' => [11312]]; /* GLAGOLITIC CAPITAL LETTER AZU */ +$config['2c00_2c5f'][] = ['upper' => 11265, 'status' => 'C', 'lower' => [11313]]; /* GLAGOLITIC CAPITAL LETTER BUKY */ +$config['2c00_2c5f'][] = ['upper' => 11266, 'status' => 'C', 'lower' => [11314]]; /* GLAGOLITIC CAPITAL LETTER VEDE */ +$config['2c00_2c5f'][] = ['upper' => 11267, 'status' => 'C', 'lower' => [11315]]; /* GLAGOLITIC CAPITAL LETTER GLAGOLI */ +$config['2c00_2c5f'][] = ['upper' => 11268, 'status' => 'C', 'lower' => [11316]]; /* GLAGOLITIC CAPITAL LETTER DOBRO */ +$config['2c00_2c5f'][] = ['upper' => 11269, 'status' => 'C', 'lower' => [11317]]; /* GLAGOLITIC CAPITAL LETTER YESTU */ +$config['2c00_2c5f'][] = ['upper' => 11270, 'status' => 'C', 'lower' => [11318]]; /* GLAGOLITIC CAPITAL LETTER ZHIVETE */ +$config['2c00_2c5f'][] = ['upper' => 11271, 'status' => 'C', 'lower' => [11319]]; /* GLAGOLITIC CAPITAL LETTER DZELO */ +$config['2c00_2c5f'][] = ['upper' => 11272, 'status' => 'C', 'lower' => [11320]]; /* GLAGOLITIC CAPITAL LETTER ZEMLJA */ +$config['2c00_2c5f'][] = ['upper' => 11273, 'status' => 'C', 'lower' => [11321]]; /* GLAGOLITIC CAPITAL LETTER IZHE */ +$config['2c00_2c5f'][] = ['upper' => 11274, 'status' => 'C', 'lower' => [11322]]; /* GLAGOLITIC CAPITAL LETTER INITIAL IZHE */ +$config['2c00_2c5f'][] = ['upper' => 11275, 'status' => 'C', 'lower' => [11323]]; /* GLAGOLITIC CAPITAL LETTER I */ +$config['2c00_2c5f'][] = ['upper' => 11276, 'status' => 'C', 'lower' => [11324]]; /* GLAGOLITIC CAPITAL LETTER DJERVI */ +$config['2c00_2c5f'][] = ['upper' => 11277, 'status' => 'C', 'lower' => [11325]]; /* GLAGOLITIC CAPITAL LETTER KAKO */ +$config['2c00_2c5f'][] = ['upper' => 11278, 'status' => 'C', 'lower' => [11326]]; /* GLAGOLITIC CAPITAL LETTER LJUDIJE */ +$config['2c00_2c5f'][] = ['upper' => 11279, 'status' => 'C', 'lower' => [11327]]; /* GLAGOLITIC CAPITAL LETTER MYSLITE */ +$config['2c00_2c5f'][] = ['upper' => 11280, 'status' => 'C', 'lower' => [11328]]; /* GLAGOLITIC CAPITAL LETTER NASHI */ +$config['2c00_2c5f'][] = ['upper' => 11281, 'status' => 'C', 'lower' => [11329]]; /* GLAGOLITIC CAPITAL LETTER ONU */ +$config['2c00_2c5f'][] = ['upper' => 11282, 'status' => 'C', 'lower' => [11330]]; /* GLAGOLITIC CAPITAL LETTER POKOJI */ +$config['2c00_2c5f'][] = ['upper' => 11283, 'status' => 'C', 'lower' => [11331]]; /* GLAGOLITIC CAPITAL LETTER RITSI */ +$config['2c00_2c5f'][] = ['upper' => 11284, 'status' => 'C', 'lower' => [11332]]; /* GLAGOLITIC CAPITAL LETTER SLOVO */ +$config['2c00_2c5f'][] = ['upper' => 11285, 'status' => 'C', 'lower' => [11333]]; /* GLAGOLITIC CAPITAL LETTER TVRIDO */ +$config['2c00_2c5f'][] = ['upper' => 11286, 'status' => 'C', 'lower' => [11334]]; /* GLAGOLITIC CAPITAL LETTER UKU */ +$config['2c00_2c5f'][] = ['upper' => 11287, 'status' => 'C', 'lower' => [11335]]; /* GLAGOLITIC CAPITAL LETTER FRITU */ +$config['2c00_2c5f'][] = ['upper' => 11288, 'status' => 'C', 'lower' => [11336]]; /* GLAGOLITIC CAPITAL LETTER HERU */ +$config['2c00_2c5f'][] = ['upper' => 11289, 'status' => 'C', 'lower' => [11337]]; /* GLAGOLITIC CAPITAL LETTER OTU */ +$config['2c00_2c5f'][] = ['upper' => 11290, 'status' => 'C', 'lower' => [11338]]; /* GLAGOLITIC CAPITAL LETTER PE */ +$config['2c00_2c5f'][] = ['upper' => 11291, 'status' => 'C', 'lower' => [11339]]; /* GLAGOLITIC CAPITAL LETTER SHTA */ +$config['2c00_2c5f'][] = ['upper' => 11292, 'status' => 'C', 'lower' => [11340]]; /* GLAGOLITIC CAPITAL LETTER TSI */ +$config['2c00_2c5f'][] = ['upper' => 11293, 'status' => 'C', 'lower' => [11341]]; /* GLAGOLITIC CAPITAL LETTER CHRIVI */ +$config['2c00_2c5f'][] = ['upper' => 11294, 'status' => 'C', 'lower' => [11342]]; /* GLAGOLITIC CAPITAL LETTER SHA */ +$config['2c00_2c5f'][] = ['upper' => 11295, 'status' => 'C', 'lower' => [11343]]; /* GLAGOLITIC CAPITAL LETTER YERU */ +$config['2c00_2c5f'][] = ['upper' => 11296, 'status' => 'C', 'lower' => [11344]]; /* GLAGOLITIC CAPITAL LETTER YERI */ +$config['2c00_2c5f'][] = ['upper' => 11297, 'status' => 'C', 'lower' => [11345]]; /* GLAGOLITIC CAPITAL LETTER YATI */ +$config['2c00_2c5f'][] = ['upper' => 11298, 'status' => 'C', 'lower' => [11346]]; /* GLAGOLITIC CAPITAL LETTER SPIDERY HA */ +$config['2c00_2c5f'][] = ['upper' => 11299, 'status' => 'C', 'lower' => [11347]]; /* GLAGOLITIC CAPITAL LETTER YU */ +$config['2c00_2c5f'][] = ['upper' => 11300, 'status' => 'C', 'lower' => [11348]]; /* GLAGOLITIC CAPITAL LETTER SMALL YUS */ +$config['2c00_2c5f'][] = ['upper' => 11301, 'status' => 'C', 'lower' => [11349]]; /* GLAGOLITIC CAPITAL LETTER SMALL YUS WITH TAIL */ +$config['2c00_2c5f'][] = ['upper' => 11302, 'status' => 'C', 'lower' => [11350]]; /* GLAGOLITIC CAPITAL LETTER YO */ +$config['2c00_2c5f'][] = ['upper' => 11303, 'status' => 'C', 'lower' => [11351]]; /* GLAGOLITIC CAPITAL LETTER IOTATED SMALL YUS */ +$config['2c00_2c5f'][] = ['upper' => 11304, 'status' => 'C', 'lower' => [11352]]; /* GLAGOLITIC CAPITAL LETTER BIG YUS */ +$config['2c00_2c5f'][] = ['upper' => 11305, 'status' => 'C', 'lower' => [11353]]; /* GLAGOLITIC CAPITAL LETTER IOTATED BIG YUS */ +$config['2c00_2c5f'][] = ['upper' => 11306, 'status' => 'C', 'lower' => [11354]]; /* GLAGOLITIC CAPITAL LETTER FITA */ +$config['2c00_2c5f'][] = ['upper' => 11307, 'status' => 'C', 'lower' => [11355]]; /* GLAGOLITIC CAPITAL LETTER IZHITSA */ +$config['2c00_2c5f'][] = ['upper' => 11308, 'status' => 'C', 'lower' => [11356]]; /* GLAGOLITIC CAPITAL LETTER SHTAPIC */ +$config['2c00_2c5f'][] = ['upper' => 11309, 'status' => 'C', 'lower' => [11357]]; /* GLAGOLITIC CAPITAL LETTER TROKUTASTI A */ +$config['2c00_2c5f'][] = ['upper' => 11310, 'status' => 'C', 'lower' => [11358]]; /* GLAGOLITIC CAPITAL LETTER LATINATE MYSLITE */ diff --git a/lib/Cake/Config/unicode/casefolding/2c60_2c7f.php b/lib/Cake/Config/unicode/casefolding/2c60_2c7f.php index 57f82927e2..71208b4519 100644 --- a/lib/Cake/Config/unicode/casefolding/2c60_2c7f.php +++ b/lib/Cake/Config/unicode/casefolding/2c60_2c7f.php @@ -37,11 +37,11 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['2c60_2c7f'][] = array('upper' => 11360, 'status' => 'C', 'lower' => array(11361)); /* LATIN CAPITAL LETTER L WITH DOUBLE BAR */ -$config['2c60_2c7f'][] = array('upper' => 11362, 'status' => 'C', 'lower' => array(619)); /* LATIN CAPITAL LETTER L WITH MIDDLE TILDE */ -$config['2c60_2c7f'][] = array('upper' => 11363, 'status' => 'C', 'lower' => array(7549)); /* LATIN CAPITAL LETTER P WITH STROKE */ -$config['2c60_2c7f'][] = array('upper' => 11364, 'status' => 'C', 'lower' => array(637)); /* LATIN CAPITAL LETTER R WITH TAIL */ -$config['2c60_2c7f'][] = array('upper' => 11367, 'status' => 'C', 'lower' => array(11368)); /* LATIN CAPITAL LETTER H WITH DESCENDER */ -$config['2c60_2c7f'][] = array('upper' => 11369, 'status' => 'C', 'lower' => array(11370)); /* LATIN CAPITAL LETTER K WITH DESCENDER */ -$config['2c60_2c7f'][] = array('upper' => 11371, 'status' => 'C', 'lower' => array(11372)); /* LATIN CAPITAL LETTER Z WITH DESCENDER */ -$config['2c60_2c7f'][] = array('upper' => 11381, 'status' => 'C', 'lower' => array(11382)); /* LATIN CAPITAL LETTER HALF H */ +$config['2c60_2c7f'][] = ['upper' => 11360, 'status' => 'C', 'lower' => [11361]]; /* LATIN CAPITAL LETTER L WITH DOUBLE BAR */ +$config['2c60_2c7f'][] = ['upper' => 11362, 'status' => 'C', 'lower' => [619]]; /* LATIN CAPITAL LETTER L WITH MIDDLE TILDE */ +$config['2c60_2c7f'][] = ['upper' => 11363, 'status' => 'C', 'lower' => [7549]]; /* LATIN CAPITAL LETTER P WITH STROKE */ +$config['2c60_2c7f'][] = ['upper' => 11364, 'status' => 'C', 'lower' => [637]]; /* LATIN CAPITAL LETTER R WITH TAIL */ +$config['2c60_2c7f'][] = ['upper' => 11367, 'status' => 'C', 'lower' => [11368]]; /* LATIN CAPITAL LETTER H WITH DESCENDER */ +$config['2c60_2c7f'][] = ['upper' => 11369, 'status' => 'C', 'lower' => [11370]]; /* LATIN CAPITAL LETTER K WITH DESCENDER */ +$config['2c60_2c7f'][] = ['upper' => 11371, 'status' => 'C', 'lower' => [11372]]; /* LATIN CAPITAL LETTER Z WITH DESCENDER */ +$config['2c60_2c7f'][] = ['upper' => 11381, 'status' => 'C', 'lower' => [11382]]; /* LATIN CAPITAL LETTER HALF H */ diff --git a/lib/Cake/Config/unicode/casefolding/2c80_2cff.php b/lib/Cake/Config/unicode/casefolding/2c80_2cff.php index 35766fa428..5ac429ba48 100644 --- a/lib/Cake/Config/unicode/casefolding/2c80_2cff.php +++ b/lib/Cake/Config/unicode/casefolding/2c80_2cff.php @@ -37,53 +37,53 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['2c80_2cff'][] = array('upper' => 11392, 'status' => 'C', 'lower' => array(11393)); /* COPTIC CAPITAL LETTER ALFA */ -$config['2c80_2cff'][] = array('upper' => 11394, 'status' => 'C', 'lower' => array(11395)); /* COPTIC CAPITAL LETTER VIDA */ -$config['2c80_2cff'][] = array('upper' => 11396, 'status' => 'C', 'lower' => array(11397)); /* COPTIC CAPITAL LETTER GAMMA */ -$config['2c80_2cff'][] = array('upper' => 11398, 'status' => 'C', 'lower' => array(11399)); /* COPTIC CAPITAL LETTER DALDA */ -$config['2c80_2cff'][] = array('upper' => 11400, 'status' => 'C', 'lower' => array(11401)); /* COPTIC CAPITAL LETTER EIE */ -$config['2c80_2cff'][] = array('upper' => 11402, 'status' => 'C', 'lower' => array(11403)); /* COPTIC CAPITAL LETTER SOU */ -$config['2c80_2cff'][] = array('upper' => 11404, 'status' => 'C', 'lower' => array(11405)); /* COPTIC CAPITAL LETTER ZATA */ -$config['2c80_2cff'][] = array('upper' => 11406, 'status' => 'C', 'lower' => array(11407)); /* COPTIC CAPITAL LETTER HATE */ -$config['2c80_2cff'][] = array('upper' => 11408, 'status' => 'C', 'lower' => array(11409)); /* COPTIC CAPITAL LETTER THETHE */ -$config['2c80_2cff'][] = array('upper' => 11410, 'status' => 'C', 'lower' => array(11411)); /* COPTIC CAPITAL LETTER IAUDA */ -$config['2c80_2cff'][] = array('upper' => 11412, 'status' => 'C', 'lower' => array(11413)); /* COPTIC CAPITAL LETTER KAPA */ -$config['2c80_2cff'][] = array('upper' => 11414, 'status' => 'C', 'lower' => array(11415)); /* COPTIC CAPITAL LETTER LAULA */ -$config['2c80_2cff'][] = array('upper' => 11416, 'status' => 'C', 'lower' => array(11417)); /* COPTIC CAPITAL LETTER MI */ -$config['2c80_2cff'][] = array('upper' => 11418, 'status' => 'C', 'lower' => array(11419)); /* COPTIC CAPITAL LETTER NI */ -$config['2c80_2cff'][] = array('upper' => 11420, 'status' => 'C', 'lower' => array(11421)); /* COPTIC CAPITAL LETTER KSI */ -$config['2c80_2cff'][] = array('upper' => 11422, 'status' => 'C', 'lower' => array(11423)); /* COPTIC CAPITAL LETTER O */ -$config['2c80_2cff'][] = array('upper' => 11424, 'status' => 'C', 'lower' => array(11425)); /* COPTIC CAPITAL LETTER PI */ -$config['2c80_2cff'][] = array('upper' => 11426, 'status' => 'C', 'lower' => array(11427)); /* COPTIC CAPITAL LETTER RO */ -$config['2c80_2cff'][] = array('upper' => 11428, 'status' => 'C', 'lower' => array(11429)); /* COPTIC CAPITAL LETTER SIMA */ -$config['2c80_2cff'][] = array('upper' => 11430, 'status' => 'C', 'lower' => array(11431)); /* COPTIC CAPITAL LETTER TAU */ -$config['2c80_2cff'][] = array('upper' => 11432, 'status' => 'C', 'lower' => array(11433)); /* COPTIC CAPITAL LETTER UA */ -$config['2c80_2cff'][] = array('upper' => 11434, 'status' => 'C', 'lower' => array(11435)); /* COPTIC CAPITAL LETTER FI */ -$config['2c80_2cff'][] = array('upper' => 11436, 'status' => 'C', 'lower' => array(11437)); /* COPTIC CAPITAL LETTER KHI */ -$config['2c80_2cff'][] = array('upper' => 11438, 'status' => 'C', 'lower' => array(11439)); /* COPTIC CAPITAL LETTER PSI */ -$config['2c80_2cff'][] = array('upper' => 11440, 'status' => 'C', 'lower' => array(11441)); /* COPTIC CAPITAL LETTER OOU */ -$config['2c80_2cff'][] = array('upper' => 11442, 'status' => 'C', 'lower' => array(11443)); /* COPTIC CAPITAL LETTER DIALECT-P ALEF */ -$config['2c80_2cff'][] = array('upper' => 11444, 'status' => 'C', 'lower' => array(11445)); /* COPTIC CAPITAL LETTER OLD COPTIC AIN */ -$config['2c80_2cff'][] = array('upper' => 11446, 'status' => 'C', 'lower' => array(11447)); /* COPTIC CAPITAL LETTER CRYPTOGRAMMIC EIE */ -$config['2c80_2cff'][] = array('upper' => 11448, 'status' => 'C', 'lower' => array(11449)); /* COPTIC CAPITAL LETTER DIALECT-P KAPA */ -$config['2c80_2cff'][] = array('upper' => 11450, 'status' => 'C', 'lower' => array(11451)); /* COPTIC CAPITAL LETTER DIALECT-P NI */ -$config['2c80_2cff'][] = array('upper' => 11452, 'status' => 'C', 'lower' => array(11453)); /* COPTIC CAPITAL LETTER CRYPTOGRAMMIC NI */ -$config['2c80_2cff'][] = array('upper' => 11454, 'status' => 'C', 'lower' => array(11455)); /* COPTIC CAPITAL LETTER OLD COPTIC OOU */ -$config['2c80_2cff'][] = array('upper' => 11456, 'status' => 'C', 'lower' => array(11457)); /* COPTIC CAPITAL LETTER SAMPI */ -$config['2c80_2cff'][] = array('upper' => 11458, 'status' => 'C', 'lower' => array(11459)); /* COPTIC CAPITAL LETTER CROSSED SHEI */ -$config['2c80_2cff'][] = array('upper' => 11460, 'status' => 'C', 'lower' => array(11461)); /* COPTIC CAPITAL LETTER OLD COPTIC SHEI */ -$config['2c80_2cff'][] = array('upper' => 11462, 'status' => 'C', 'lower' => array(11463)); /* COPTIC CAPITAL LETTER OLD COPTIC ESH */ -$config['2c80_2cff'][] = array('upper' => 11464, 'status' => 'C', 'lower' => array(11465)); /* COPTIC CAPITAL LETTER AKHMIMIC KHEI */ -$config['2c80_2cff'][] = array('upper' => 11466, 'status' => 'C', 'lower' => array(11467)); /* COPTIC CAPITAL LETTER DIALECT-P HORI */ -$config['2c80_2cff'][] = array('upper' => 11468, 'status' => 'C', 'lower' => array(11469)); /* COPTIC CAPITAL LETTER OLD COPTIC HORI */ -$config['2c80_2cff'][] = array('upper' => 11470, 'status' => 'C', 'lower' => array(11471)); /* COPTIC CAPITAL LETTER OLD COPTIC HA */ -$config['2c80_2cff'][] = array('upper' => 11472, 'status' => 'C', 'lower' => array(11473)); /* COPTIC CAPITAL LETTER L-SHAPED HA */ -$config['2c80_2cff'][] = array('upper' => 11474, 'status' => 'C', 'lower' => array(11475)); /* COPTIC CAPITAL LETTER OLD COPTIC HEI */ -$config['2c80_2cff'][] = array('upper' => 11476, 'status' => 'C', 'lower' => array(11477)); /* COPTIC CAPITAL LETTER OLD COPTIC HAT */ -$config['2c80_2cff'][] = array('upper' => 11478, 'status' => 'C', 'lower' => array(11479)); /* COPTIC CAPITAL LETTER OLD COPTIC GANGIA */ -$config['2c80_2cff'][] = array('upper' => 11480, 'status' => 'C', 'lower' => array(11481)); /* COPTIC CAPITAL LETTER OLD COPTIC DJA */ -$config['2c80_2cff'][] = array('upper' => 11482, 'status' => 'C', 'lower' => array(11483)); /* COPTIC CAPITAL LETTER OLD COPTIC SHIMA */ -$config['2c80_2cff'][] = array('upper' => 11484, 'status' => 'C', 'lower' => array(11485)); /* COPTIC CAPITAL LETTER OLD NUBIAN SHIMA */ -$config['2c80_2cff'][] = array('upper' => 11486, 'status' => 'C', 'lower' => array(11487)); /* COPTIC CAPITAL LETTER OLD NUBIAN NGI */ -$config['2c80_2cff'][] = array('upper' => 11488, 'status' => 'C', 'lower' => array(11489)); /* COPTIC CAPITAL LETTER OLD NUBIAN NYI */ -$config['2c80_2cff'][] = array('upper' => 11490, 'status' => 'C', 'lower' => array(11491)); /* COPTIC CAPITAL LETTER OLD NUBIAN WAU */ +$config['2c80_2cff'][] = ['upper' => 11392, 'status' => 'C', 'lower' => [11393]]; /* COPTIC CAPITAL LETTER ALFA */ +$config['2c80_2cff'][] = ['upper' => 11394, 'status' => 'C', 'lower' => [11395]]; /* COPTIC CAPITAL LETTER VIDA */ +$config['2c80_2cff'][] = ['upper' => 11396, 'status' => 'C', 'lower' => [11397]]; /* COPTIC CAPITAL LETTER GAMMA */ +$config['2c80_2cff'][] = ['upper' => 11398, 'status' => 'C', 'lower' => [11399]]; /* COPTIC CAPITAL LETTER DALDA */ +$config['2c80_2cff'][] = ['upper' => 11400, 'status' => 'C', 'lower' => [11401]]; /* COPTIC CAPITAL LETTER EIE */ +$config['2c80_2cff'][] = ['upper' => 11402, 'status' => 'C', 'lower' => [11403]]; /* COPTIC CAPITAL LETTER SOU */ +$config['2c80_2cff'][] = ['upper' => 11404, 'status' => 'C', 'lower' => [11405]]; /* COPTIC CAPITAL LETTER ZATA */ +$config['2c80_2cff'][] = ['upper' => 11406, 'status' => 'C', 'lower' => [11407]]; /* COPTIC CAPITAL LETTER HATE */ +$config['2c80_2cff'][] = ['upper' => 11408, 'status' => 'C', 'lower' => [11409]]; /* COPTIC CAPITAL LETTER THETHE */ +$config['2c80_2cff'][] = ['upper' => 11410, 'status' => 'C', 'lower' => [11411]]; /* COPTIC CAPITAL LETTER IAUDA */ +$config['2c80_2cff'][] = ['upper' => 11412, 'status' => 'C', 'lower' => [11413]]; /* COPTIC CAPITAL LETTER KAPA */ +$config['2c80_2cff'][] = ['upper' => 11414, 'status' => 'C', 'lower' => [11415]]; /* COPTIC CAPITAL LETTER LAULA */ +$config['2c80_2cff'][] = ['upper' => 11416, 'status' => 'C', 'lower' => [11417]]; /* COPTIC CAPITAL LETTER MI */ +$config['2c80_2cff'][] = ['upper' => 11418, 'status' => 'C', 'lower' => [11419]]; /* COPTIC CAPITAL LETTER NI */ +$config['2c80_2cff'][] = ['upper' => 11420, 'status' => 'C', 'lower' => [11421]]; /* COPTIC CAPITAL LETTER KSI */ +$config['2c80_2cff'][] = ['upper' => 11422, 'status' => 'C', 'lower' => [11423]]; /* COPTIC CAPITAL LETTER O */ +$config['2c80_2cff'][] = ['upper' => 11424, 'status' => 'C', 'lower' => [11425]]; /* COPTIC CAPITAL LETTER PI */ +$config['2c80_2cff'][] = ['upper' => 11426, 'status' => 'C', 'lower' => [11427]]; /* COPTIC CAPITAL LETTER RO */ +$config['2c80_2cff'][] = ['upper' => 11428, 'status' => 'C', 'lower' => [11429]]; /* COPTIC CAPITAL LETTER SIMA */ +$config['2c80_2cff'][] = ['upper' => 11430, 'status' => 'C', 'lower' => [11431]]; /* COPTIC CAPITAL LETTER TAU */ +$config['2c80_2cff'][] = ['upper' => 11432, 'status' => 'C', 'lower' => [11433]]; /* COPTIC CAPITAL LETTER UA */ +$config['2c80_2cff'][] = ['upper' => 11434, 'status' => 'C', 'lower' => [11435]]; /* COPTIC CAPITAL LETTER FI */ +$config['2c80_2cff'][] = ['upper' => 11436, 'status' => 'C', 'lower' => [11437]]; /* COPTIC CAPITAL LETTER KHI */ +$config['2c80_2cff'][] = ['upper' => 11438, 'status' => 'C', 'lower' => [11439]]; /* COPTIC CAPITAL LETTER PSI */ +$config['2c80_2cff'][] = ['upper' => 11440, 'status' => 'C', 'lower' => [11441]]; /* COPTIC CAPITAL LETTER OOU */ +$config['2c80_2cff'][] = ['upper' => 11442, 'status' => 'C', 'lower' => [11443]]; /* COPTIC CAPITAL LETTER DIALECT-P ALEF */ +$config['2c80_2cff'][] = ['upper' => 11444, 'status' => 'C', 'lower' => [11445]]; /* COPTIC CAPITAL LETTER OLD COPTIC AIN */ +$config['2c80_2cff'][] = ['upper' => 11446, 'status' => 'C', 'lower' => [11447]]; /* COPTIC CAPITAL LETTER CRYPTOGRAMMIC EIE */ +$config['2c80_2cff'][] = ['upper' => 11448, 'status' => 'C', 'lower' => [11449]]; /* COPTIC CAPITAL LETTER DIALECT-P KAPA */ +$config['2c80_2cff'][] = ['upper' => 11450, 'status' => 'C', 'lower' => [11451]]; /* COPTIC CAPITAL LETTER DIALECT-P NI */ +$config['2c80_2cff'][] = ['upper' => 11452, 'status' => 'C', 'lower' => [11453]]; /* COPTIC CAPITAL LETTER CRYPTOGRAMMIC NI */ +$config['2c80_2cff'][] = ['upper' => 11454, 'status' => 'C', 'lower' => [11455]]; /* COPTIC CAPITAL LETTER OLD COPTIC OOU */ +$config['2c80_2cff'][] = ['upper' => 11456, 'status' => 'C', 'lower' => [11457]]; /* COPTIC CAPITAL LETTER SAMPI */ +$config['2c80_2cff'][] = ['upper' => 11458, 'status' => 'C', 'lower' => [11459]]; /* COPTIC CAPITAL LETTER CROSSED SHEI */ +$config['2c80_2cff'][] = ['upper' => 11460, 'status' => 'C', 'lower' => [11461]]; /* COPTIC CAPITAL LETTER OLD COPTIC SHEI */ +$config['2c80_2cff'][] = ['upper' => 11462, 'status' => 'C', 'lower' => [11463]]; /* COPTIC CAPITAL LETTER OLD COPTIC ESH */ +$config['2c80_2cff'][] = ['upper' => 11464, 'status' => 'C', 'lower' => [11465]]; /* COPTIC CAPITAL LETTER AKHMIMIC KHEI */ +$config['2c80_2cff'][] = ['upper' => 11466, 'status' => 'C', 'lower' => [11467]]; /* COPTIC CAPITAL LETTER DIALECT-P HORI */ +$config['2c80_2cff'][] = ['upper' => 11468, 'status' => 'C', 'lower' => [11469]]; /* COPTIC CAPITAL LETTER OLD COPTIC HORI */ +$config['2c80_2cff'][] = ['upper' => 11470, 'status' => 'C', 'lower' => [11471]]; /* COPTIC CAPITAL LETTER OLD COPTIC HA */ +$config['2c80_2cff'][] = ['upper' => 11472, 'status' => 'C', 'lower' => [11473]]; /* COPTIC CAPITAL LETTER L-SHAPED HA */ +$config['2c80_2cff'][] = ['upper' => 11474, 'status' => 'C', 'lower' => [11475]]; /* COPTIC CAPITAL LETTER OLD COPTIC HEI */ +$config['2c80_2cff'][] = ['upper' => 11476, 'status' => 'C', 'lower' => [11477]]; /* COPTIC CAPITAL LETTER OLD COPTIC HAT */ +$config['2c80_2cff'][] = ['upper' => 11478, 'status' => 'C', 'lower' => [11479]]; /* COPTIC CAPITAL LETTER OLD COPTIC GANGIA */ +$config['2c80_2cff'][] = ['upper' => 11480, 'status' => 'C', 'lower' => [11481]]; /* COPTIC CAPITAL LETTER OLD COPTIC DJA */ +$config['2c80_2cff'][] = ['upper' => 11482, 'status' => 'C', 'lower' => [11483]]; /* COPTIC CAPITAL LETTER OLD COPTIC SHIMA */ +$config['2c80_2cff'][] = ['upper' => 11484, 'status' => 'C', 'lower' => [11485]]; /* COPTIC CAPITAL LETTER OLD NUBIAN SHIMA */ +$config['2c80_2cff'][] = ['upper' => 11486, 'status' => 'C', 'lower' => [11487]]; /* COPTIC CAPITAL LETTER OLD NUBIAN NGI */ +$config['2c80_2cff'][] = ['upper' => 11488, 'status' => 'C', 'lower' => [11489]]; /* COPTIC CAPITAL LETTER OLD NUBIAN NYI */ +$config['2c80_2cff'][] = ['upper' => 11490, 'status' => 'C', 'lower' => [11491]]; /* COPTIC CAPITAL LETTER OLD NUBIAN WAU */ diff --git a/lib/Cake/Config/unicode/casefolding/ff00_ffef.php b/lib/Cake/Config/unicode/casefolding/ff00_ffef.php index 9bf25e3707..f35d45cb46 100644 --- a/lib/Cake/Config/unicode/casefolding/ff00_ffef.php +++ b/lib/Cake/Config/unicode/casefolding/ff00_ffef.php @@ -37,29 +37,29 @@ * Note that the Turkic mappings do not maintain canonical equivalence without additional processing. * See the discussions of case mapping in the Unicode Standard for more information. */ -$config['ff00_ffef'][] = array('upper' => 65313, 'status' => 'C', 'lower' => array(65345)); /* FULLWIDTH LATIN CAPITAL LETTER A */ -$config['ff00_ffef'][] = array('upper' => 65314, 'status' => 'C', 'lower' => array(65346)); /* FULLWIDTH LATIN CAPITAL LETTER B */ -$config['ff00_ffef'][] = array('upper' => 65315, 'status' => 'C', 'lower' => array(65347)); /* FULLWIDTH LATIN CAPITAL LETTER C */ -$config['ff00_ffef'][] = array('upper' => 65316, 'status' => 'C', 'lower' => array(65348)); /* FULLWIDTH LATIN CAPITAL LETTER D */ -$config['ff00_ffef'][] = array('upper' => 65317, 'status' => 'C', 'lower' => array(65349)); /* FULLWIDTH LATIN CAPITAL LETTER E */ -$config['ff00_ffef'][] = array('upper' => 65318, 'status' => 'C', 'lower' => array(65350)); /* FULLWIDTH LATIN CAPITAL LETTER F */ -$config['ff00_ffef'][] = array('upper' => 65319, 'status' => 'C', 'lower' => array(65351)); /* FULLWIDTH LATIN CAPITAL LETTER G */ -$config['ff00_ffef'][] = array('upper' => 65320, 'status' => 'C', 'lower' => array(65352)); /* FULLWIDTH LATIN CAPITAL LETTER H */ -$config['ff00_ffef'][] = array('upper' => 65321, 'status' => 'C', 'lower' => array(65353)); /* FULLWIDTH LATIN CAPITAL LETTER I */ -$config['ff00_ffef'][] = array('upper' => 65322, 'status' => 'C', 'lower' => array(65354)); /* FULLWIDTH LATIN CAPITAL LETTER J */ -$config['ff00_ffef'][] = array('upper' => 65323, 'status' => 'C', 'lower' => array(65355)); /* FULLWIDTH LATIN CAPITAL LETTER K */ -$config['ff00_ffef'][] = array('upper' => 65324, 'status' => 'C', 'lower' => array(65356)); /* FULLWIDTH LATIN CAPITAL LETTER L */ -$config['ff00_ffef'][] = array('upper' => 65325, 'status' => 'C', 'lower' => array(65357)); /* FULLWIDTH LATIN CAPITAL LETTER M */ -$config['ff00_ffef'][] = array('upper' => 65326, 'status' => 'C', 'lower' => array(65358)); /* FULLWIDTH LATIN CAPITAL LETTER N */ -$config['ff00_ffef'][] = array('upper' => 65327, 'status' => 'C', 'lower' => array(65359)); /* FULLWIDTH LATIN CAPITAL LETTER O */ -$config['ff00_ffef'][] = array('upper' => 65328, 'status' => 'C', 'lower' => array(65360)); /* FULLWIDTH LATIN CAPITAL LETTER P */ -$config['ff00_ffef'][] = array('upper' => 65329, 'status' => 'C', 'lower' => array(65361)); /* FULLWIDTH LATIN CAPITAL LETTER Q */ -$config['ff00_ffef'][] = array('upper' => 65330, 'status' => 'C', 'lower' => array(65362)); /* FULLWIDTH LATIN CAPITAL LETTER R */ -$config['ff00_ffef'][] = array('upper' => 65331, 'status' => 'C', 'lower' => array(65363)); /* FULLWIDTH LATIN CAPITAL LETTER S */ -$config['ff00_ffef'][] = array('upper' => 65332, 'status' => 'C', 'lower' => array(65364)); /* FULLWIDTH LATIN CAPITAL LETTER T */ -$config['ff00_ffef'][] = array('upper' => 65333, 'status' => 'C', 'lower' => array(65365)); /* FULLWIDTH LATIN CAPITAL LETTER U */ -$config['ff00_ffef'][] = array('upper' => 65334, 'status' => 'C', 'lower' => array(65366)); /* FULLWIDTH LATIN CAPITAL LETTER V */ -$config['ff00_ffef'][] = array('upper' => 65335, 'status' => 'C', 'lower' => array(65367)); /* FULLWIDTH LATIN CAPITAL LETTER W */ -$config['ff00_ffef'][] = array('upper' => 65336, 'status' => 'C', 'lower' => array(65368)); /* FULLWIDTH LATIN CAPITAL LETTER X */ -$config['ff00_ffef'][] = array('upper' => 65337, 'status' => 'C', 'lower' => array(65369)); /* FULLWIDTH LATIN CAPITAL LETTER Y */ -$config['ff00_ffef'][] = array('upper' => 65338, 'status' => 'C', 'lower' => array(65370)); /* FULLWIDTH LATIN CAPITAL LETTER Z */ +$config['ff00_ffef'][] = ['upper' => 65313, 'status' => 'C', 'lower' => [65345]]; /* FULLWIDTH LATIN CAPITAL LETTER A */ +$config['ff00_ffef'][] = ['upper' => 65314, 'status' => 'C', 'lower' => [65346]]; /* FULLWIDTH LATIN CAPITAL LETTER B */ +$config['ff00_ffef'][] = ['upper' => 65315, 'status' => 'C', 'lower' => [65347]]; /* FULLWIDTH LATIN CAPITAL LETTER C */ +$config['ff00_ffef'][] = ['upper' => 65316, 'status' => 'C', 'lower' => [65348]]; /* FULLWIDTH LATIN CAPITAL LETTER D */ +$config['ff00_ffef'][] = ['upper' => 65317, 'status' => 'C', 'lower' => [65349]]; /* FULLWIDTH LATIN CAPITAL LETTER E */ +$config['ff00_ffef'][] = ['upper' => 65318, 'status' => 'C', 'lower' => [65350]]; /* FULLWIDTH LATIN CAPITAL LETTER F */ +$config['ff00_ffef'][] = ['upper' => 65319, 'status' => 'C', 'lower' => [65351]]; /* FULLWIDTH LATIN CAPITAL LETTER G */ +$config['ff00_ffef'][] = ['upper' => 65320, 'status' => 'C', 'lower' => [65352]]; /* FULLWIDTH LATIN CAPITAL LETTER H */ +$config['ff00_ffef'][] = ['upper' => 65321, 'status' => 'C', 'lower' => [65353]]; /* FULLWIDTH LATIN CAPITAL LETTER I */ +$config['ff00_ffef'][] = ['upper' => 65322, 'status' => 'C', 'lower' => [65354]]; /* FULLWIDTH LATIN CAPITAL LETTER J */ +$config['ff00_ffef'][] = ['upper' => 65323, 'status' => 'C', 'lower' => [65355]]; /* FULLWIDTH LATIN CAPITAL LETTER K */ +$config['ff00_ffef'][] = ['upper' => 65324, 'status' => 'C', 'lower' => [65356]]; /* FULLWIDTH LATIN CAPITAL LETTER L */ +$config['ff00_ffef'][] = ['upper' => 65325, 'status' => 'C', 'lower' => [65357]]; /* FULLWIDTH LATIN CAPITAL LETTER M */ +$config['ff00_ffef'][] = ['upper' => 65326, 'status' => 'C', 'lower' => [65358]]; /* FULLWIDTH LATIN CAPITAL LETTER N */ +$config['ff00_ffef'][] = ['upper' => 65327, 'status' => 'C', 'lower' => [65359]]; /* FULLWIDTH LATIN CAPITAL LETTER O */ +$config['ff00_ffef'][] = ['upper' => 65328, 'status' => 'C', 'lower' => [65360]]; /* FULLWIDTH LATIN CAPITAL LETTER P */ +$config['ff00_ffef'][] = ['upper' => 65329, 'status' => 'C', 'lower' => [65361]]; /* FULLWIDTH LATIN CAPITAL LETTER Q */ +$config['ff00_ffef'][] = ['upper' => 65330, 'status' => 'C', 'lower' => [65362]]; /* FULLWIDTH LATIN CAPITAL LETTER R */ +$config['ff00_ffef'][] = ['upper' => 65331, 'status' => 'C', 'lower' => [65363]]; /* FULLWIDTH LATIN CAPITAL LETTER S */ +$config['ff00_ffef'][] = ['upper' => 65332, 'status' => 'C', 'lower' => [65364]]; /* FULLWIDTH LATIN CAPITAL LETTER T */ +$config['ff00_ffef'][] = ['upper' => 65333, 'status' => 'C', 'lower' => [65365]]; /* FULLWIDTH LATIN CAPITAL LETTER U */ +$config['ff00_ffef'][] = ['upper' => 65334, 'status' => 'C', 'lower' => [65366]]; /* FULLWIDTH LATIN CAPITAL LETTER V */ +$config['ff00_ffef'][] = ['upper' => 65335, 'status' => 'C', 'lower' => [65367]]; /* FULLWIDTH LATIN CAPITAL LETTER W */ +$config['ff00_ffef'][] = ['upper' => 65336, 'status' => 'C', 'lower' => [65368]]; /* FULLWIDTH LATIN CAPITAL LETTER X */ +$config['ff00_ffef'][] = ['upper' => 65337, 'status' => 'C', 'lower' => [65369]]; /* FULLWIDTH LATIN CAPITAL LETTER Y */ +$config['ff00_ffef'][] = ['upper' => 65338, 'status' => 'C', 'lower' => [65370]]; /* FULLWIDTH LATIN CAPITAL LETTER Z */ diff --git a/lib/Cake/Configure/IniReader.php b/lib/Cake/Configure/IniReader.php index 2c7bc76337..d52e640467 100644 --- a/lib/Cake/Configure/IniReader.php +++ b/lib/Cake/Configure/IniReader.php @@ -63,26 +63,21 @@ class IniReader implements ConfigReaderInterface { protected $_path; /** - * The section to read, if null all sections will be read. - * - * @var string - */ - protected $_section; - -/** - * Build and construct a new ini file parser. The parser can be used to read - * ini files that are on the filesystem. - * - * @param string $path Path to load ini config files from. Defaults to CONFIG - * @param string $section Only get one section, leave null to parse and fetch - * all sections in the ini file. - */ - public function __construct($path = null, $section = null) { + * Build and construct a new ini file parser. The parser can be used to read + * ini files that are on the filesystem. + * + * @param string $path Path to load ini config files from. Defaults to CONFIG + * @param string $_section Only get one section, leave null to parse and fetch + * all sections in the ini file. + */ + public function __construct($path = null, /** + * The section to read, if null all sections will be read. + */ + protected $_section = null) { if (!$path) { $path = CONFIG; } $this->_path = $path; - $this->_section = $section; } /** @@ -97,7 +92,7 @@ public function __construct($path = null, $section = null) { * Or when files contain '..' as this could lead to abusive reads. */ public function read($key) { - if (strpos($key, '..') !== false) { + if (str_contains($key, '..')) { throw new ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.')); } @@ -110,12 +105,12 @@ public function read($key) { if (!empty($this->_section) && isset($contents[$this->_section])) { $values = $this->_parseNestedValues($contents[$this->_section]); } else { - $values = array(); + $values = []; foreach ($contents as $section => $attribs) { if (is_array($attribs)) { $values[$section] = $this->_parseNestedValues($attribs); } else { - $parse = $this->_parseNestedValues(array($attribs)); + $parse = $this->_parseNestedValues([$attribs]); $values[$section] = array_shift($parse); } } @@ -138,7 +133,7 @@ protected function _parseNestedValues($values) { $value = false; } unset($values[$key]); - if (strpos($key, '.') !== false) { + if (str_contains($key, '.')) { $values = Hash::insert($values, $key, $value); } else { $values[$key] = $value; @@ -156,7 +151,7 @@ protected function _parseNestedValues($values) { * @return int Bytes saved. */ public function dump($key, $data) { - $result = array(); + $result = []; foreach ($data as $k => $value) { $isSection = false; if ($k[0] !== '[') { @@ -206,15 +201,15 @@ protected function _value($val) { * @return string Full file path */ protected function _getFilePath($key) { - if (substr($key, -8) === '.ini.php') { + if (str_ends_with($key, '.ini.php')) { $key = substr($key, 0, -8); - list($plugin, $key) = pluginSplit($key); + [$plugin, $key] = pluginSplit($key); $key .= '.ini.php'; } else { - if (substr($key, -4) === '.ini') { + if (str_ends_with($key, '.ini')) { $key = substr($key, 0, -4); } - list($plugin, $key) = pluginSplit($key); + [$plugin, $key] = pluginSplit($key); $key .= '.ini'; } diff --git a/lib/Cake/Configure/PhpReader.php b/lib/Cake/Configure/PhpReader.php index 40176ce9f8..07a050d030 100644 --- a/lib/Cake/Configure/PhpReader.php +++ b/lib/Cake/Configure/PhpReader.php @@ -60,7 +60,7 @@ public function __construct($path = null) { * Or when files contain '..' as this could lead to abusive reads. */ public function read($key) { - if (strpos($key, '..') !== false) { + if (str_contains($key, '..')) { throw new ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.')); } @@ -100,10 +100,10 @@ public function dump($key, $data) { * @return string Full file path */ protected function _getFilePath($key) { - if (substr($key, -4) === '.php') { + if (str_ends_with($key, '.php')) { $key = substr($key, 0, -4); } - list($plugin, $key) = pluginSplit($key); + [$plugin, $key] = pluginSplit($key); $key .= '.php'; if ($plugin) { diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index 10db318eb2..dc00c8847b 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -56,7 +56,7 @@ class AclShell extends AppShell { * * @var array */ - public $tasks = array('DbConfig'); + public $tasks = ['DbConfig']; /** * Override startup of the Shell @@ -70,9 +70,9 @@ public function startup() { } $class = Configure::read('Acl.classname'); - list($plugin, $class) = pluginSplit($class, true); + [$plugin, $class] = pluginSplit($class, true); App::uses($class, $plugin . 'Controller/Component/Acl'); - if (!in_array($class, array('DbAcl', 'DB_ACL')) && !is_subclass_of($class, 'DbAcl')) { + if (!in_array($class, ['DbAcl', 'DB_ACL']) && !is_subclass_of($class, 'DbAcl')) { $out = "--------------------------------------------------\n"; $out .= __d('cake_console', 'Error: Your current CakePHP configuration is set to an ACL implementation other than DB.') . "\n"; $out .= __d('cake_console', 'Please change your core config to reflect your decision to use DbAcl before attempting to use this script') . "\n"; @@ -91,7 +91,7 @@ public function startup() { } require_once CONFIG . 'database.php'; - if (!in_array($this->command, array('initdb'))) { + if (!in_array($this->command, ['initdb'])) { $collection = new ComponentCollection(); $this->Acl = new AclComponent($collection); $controller = new Controller(); @@ -128,7 +128,7 @@ public function create() { $data = $this->parseIdentifier($this->args[2]); if (is_string($data) && $data !== '/') { - $data = array('alias' => $data); + $data = ['alias' => $data]; } elseif (is_string($data)) { $this->error(__d('cake_console', '/ can not be used as an alias!') . __d('cake_console', " / is the root, please supply a sub alias")); } @@ -153,10 +153,10 @@ public function delete() { $identifier = $this->parseIdentifier($this->args[1]); if (is_string($identifier)) { - $identifier = array('alias' => $identifier); + $identifier = ['alias' => $identifier]; } - if ($this->Acl->{$class}->find('all', array('conditions' => $identifier))) { + if ($this->Acl->{$class}->find('all', ['conditions' => $identifier])) { if (!$this->Acl->{$class}->deleteAll($identifier)) { $this->error(__d('cake_console', 'Node Not Deleted. ') . __d('cake_console', 'There was an error deleting the %s.', $class) . "\n"); } @@ -176,12 +176,12 @@ public function setParent() { $target = $this->parseIdentifier($this->args[1]); $parent = $this->parseIdentifier($this->args[2]); - $data = array( - $class => array( + $data = [ + $class => [ 'id' => $this->_getNodeId($class, $target), 'parent_id' => $this->_getNodeId($class, $parent) - ) - ); + ] + ]; $this->Acl->{$class}->create(); if (!$this->Acl->{$class}->save($data)) { $this->out(__d('cake_console', 'Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.')); @@ -304,19 +304,19 @@ public function view() { if (isset($this->args[1])) { $identity = $this->parseIdentifier($this->args[1]); - $topNode = $this->Acl->{$class}->find('first', array( - 'conditions' => array($class . '.id' => $this->_getNodeId($class, $identity)) - )); + $topNode = $this->Acl->{$class}->find('first', [ + 'conditions' => [$class . '.id' => $this->_getNodeId($class, $identity)] + ]); - $nodes = $this->Acl->{$class}->find('all', array( - 'conditions' => array( + $nodes = $this->Acl->{$class}->find('all', [ + 'conditions' => [ $class . '.lft >=' => $topNode[$class]['lft'], $class . '.lft <=' => $topNode[$class]['rght'] - ), + ], 'order' => $class . '.lft ASC' - )); + ]); } else { - $nodes = $this->Acl->{$class}->find('all', array('order' => $class . '.lft ASC')); + $nodes = $this->Acl->{$class}->find('all', ['order' => $class . '.lft ASC']); } if (empty($nodes)) { @@ -329,7 +329,7 @@ public function view() { $this->out($class . ' tree:'); $this->hr(); - $stack = array(); + $stack = []; $last = null; foreach ($nodes as $n) { @@ -370,138 +370,138 @@ public function initdb() { public function getOptionParser() { $parser = parent::getOptionParser(); - $type = array( - 'choices' => array('aro', 'aco'), + $type = [ + 'choices' => ['aro', 'aco'], 'required' => true, 'help' => __d('cake_console', 'Type of node to create.') - ); + ]; $parser->description( __d('cake_console', 'A console tool for managing the DbAcl') - )->addSubcommand('create', array( + )->addSubcommand('create', [ 'help' => __d('cake_console', 'Create a new ACL node'), - 'parser' => array( + 'parser' => [ 'description' => __d('cake_console', 'Creates a new ACL object under the parent'), 'epilog' => __d('cake_console', 'You can use `root` as the parent when creating nodes to create top level nodes.'), - 'arguments' => array( + 'arguments' => [ 'type' => $type, - 'parent' => array( + 'parent' => [ 'help' => __d('cake_console', 'The node selector for the parent.'), 'required' => true - ), - 'alias' => array( + ], + 'alias' => [ 'help' => __d('cake_console', 'The alias to use for the newly created node.'), 'required' => true - ) - ) - ) - ))->addSubcommand('delete', array( + ] + ] + ] + ])->addSubcommand('delete', [ 'help' => __d('cake_console', 'Deletes the ACL object with the given reference'), - 'parser' => array( + 'parser' => [ 'description' => __d('cake_console', 'Delete an ACL node.'), - 'arguments' => array( + 'arguments' => [ 'type' => $type, - 'node' => array( + 'node' => [ 'help' => __d('cake_console', 'The node identifier to delete.'), 'required' => true, - ) - ) - ) - ))->addSubcommand('setparent', array( + ] + ] + ] + ])->addSubcommand('setparent', [ 'help' => __d('cake_console', 'Moves the ACL node under a new parent.'), - 'parser' => array( + 'parser' => [ 'description' => __d('cake_console', 'Moves the ACL object specified by beneath '), - 'arguments' => array( + 'arguments' => [ 'type' => $type, - 'node' => array( + 'node' => [ 'help' => __d('cake_console', 'The node to move'), 'required' => true, - ), - 'parent' => array( + ], + 'parent' => [ 'help' => __d('cake_console', 'The new parent for .'), 'required' => true - ) - ) - ) - ))->addSubcommand('getpath', array( + ] + ] + ] + ])->addSubcommand('getpath', [ 'help' => __d('cake_console', 'Print out the path to an ACL node.'), - 'parser' => array( - 'description' => array( + 'parser' => [ + 'description' => [ __d('cake_console', "Returns the path to the ACL object specified by ."), __d('cake_console', "This command is useful in determining the inheritance of permissions for a certain object in the tree.") - ), - 'arguments' => array( + ], + 'arguments' => [ 'type' => $type, - 'node' => array( + 'node' => [ 'help' => __d('cake_console', 'The node to get the path of'), 'required' => true, - ) - ) - ) - ))->addSubcommand('check', array( + ] + ] + ] + ])->addSubcommand('check', [ 'help' => __d('cake_console', 'Check the permissions between an ACO and ARO.'), - 'parser' => array( - 'description' => array( + 'parser' => [ + 'description' => [ __d('cake_console', 'Use this command to check ACL permissions.') - ), - 'arguments' => array( - 'aro' => array('help' => __d('cake_console', 'ARO to check.'), 'required' => true), - 'aco' => array('help' => __d('cake_console', 'ACO to check.'), 'required' => true), - 'action' => array('help' => __d('cake_console', 'Action to check'), 'default' => 'all') - ) - ) - ))->addSubcommand('grant', array( + ], + 'arguments' => [ + 'aro' => ['help' => __d('cake_console', 'ARO to check.'), 'required' => true], + 'aco' => ['help' => __d('cake_console', 'ACO to check.'), 'required' => true], + 'action' => ['help' => __d('cake_console', 'Action to check'), 'default' => 'all'] + ] + ] + ])->addSubcommand('grant', [ 'help' => __d('cake_console', 'Grant an ARO permissions to an ACO.'), - 'parser' => array( - 'description' => array( + 'parser' => [ + 'description' => [ __d('cake_console', 'Use this command to grant ACL permissions. Once executed, the ARO specified (and its children, if any) will have ALLOW access to the specified ACO action (and the ACO\'s children, if any).') - ), - 'arguments' => array( - 'aro' => array('help' => __d('cake_console', 'ARO to grant permission to.'), 'required' => true), - 'aco' => array('help' => __d('cake_console', 'ACO to grant access to.'), 'required' => true), - 'action' => array('help' => __d('cake_console', 'Action to grant'), 'default' => 'all') - ) - ) - ))->addSubcommand('deny', array( + ], + 'arguments' => [ + 'aro' => ['help' => __d('cake_console', 'ARO to grant permission to.'), 'required' => true], + 'aco' => ['help' => __d('cake_console', 'ACO to grant access to.'), 'required' => true], + 'action' => ['help' => __d('cake_console', 'Action to grant'), 'default' => 'all'] + ] + ] + ])->addSubcommand('deny', [ 'help' => __d('cake_console', 'Deny an ARO permissions to an ACO.'), - 'parser' => array( - 'description' => array( + 'parser' => [ + 'description' => [ __d('cake_console', 'Use this command to deny ACL permissions. Once executed, the ARO specified (and its children, if any) will have DENY access to the specified ACO action (and the ACO\'s children, if any).') - ), - 'arguments' => array( - 'aro' => array('help' => __d('cake_console', 'ARO to deny.'), 'required' => true), - 'aco' => array('help' => __d('cake_console', 'ACO to deny.'), 'required' => true), - 'action' => array('help' => __d('cake_console', 'Action to deny'), 'default' => 'all') - ) - ) - ))->addSubcommand('inherit', array( + ], + 'arguments' => [ + 'aro' => ['help' => __d('cake_console', 'ARO to deny.'), 'required' => true], + 'aco' => ['help' => __d('cake_console', 'ACO to deny.'), 'required' => true], + 'action' => ['help' => __d('cake_console', 'Action to deny'), 'default' => 'all'] + ] + ] + ])->addSubcommand('inherit', [ 'help' => __d('cake_console', 'Inherit an ARO\'s parent permissions.'), - 'parser' => array( - 'description' => array( + 'parser' => [ + 'description' => [ __d('cake_console', "Use this command to force a child ARO object to inherit its permissions settings from its parent.") - ), - 'arguments' => array( - 'aro' => array('help' => __d('cake_console', 'ARO to have permissions inherit.'), 'required' => true), - 'aco' => array('help' => __d('cake_console', 'ACO to inherit permissions on.'), 'required' => true), - 'action' => array('help' => __d('cake_console', 'Action to inherit'), 'default' => 'all') - ) - ) - ))->addSubcommand('view', array( + ], + 'arguments' => [ + 'aro' => ['help' => __d('cake_console', 'ARO to have permissions inherit.'), 'required' => true], + 'aco' => ['help' => __d('cake_console', 'ACO to inherit permissions on.'), 'required' => true], + 'action' => ['help' => __d('cake_console', 'Action to inherit'), 'default' => 'all'] + ] + ] + ])->addSubcommand('view', [ 'help' => __d('cake_console', 'View a tree or a single node\'s subtree.'), - 'parser' => array( - 'description' => array( + 'parser' => [ + 'description' => [ __d('cake_console', "The view command will return the ARO or ACO tree."), __d('cake_console', "The optional node parameter allows you to return"), __d('cake_console', "only a portion of the requested tree.") - ), - 'arguments' => array( + ], + 'arguments' => [ 'type' => $type, - 'node' => array('help' => __d('cake_console', 'The optional node to view the subtree of.')) - ) - ) - ))->addSubcommand('initdb', array( + 'node' => ['help' => __d('cake_console', 'The optional node to view the subtree of.')] + ] + ] + ])->addSubcommand('initdb', [ 'help' => __d('cake_console', 'Initialize the DbAcl tables. Uses this command : cake schema create DbAcl') - ))->epilog(array( + ])->epilog([ 'Node and parent arguments can be in one of the following formats:', '', ' - . - The node will be bound to a specific record of the given model.', @@ -511,7 +511,7 @@ public function getOptionParser() { " i.e. //.", '', "To add a node at the root level, enter 'root' or '/' as the parameter." - )); + ]); return $parser; } @@ -528,7 +528,7 @@ public function nodeExists() { $dataVars = $this->_dataVars($this->args[0]); extract($dataVars); $key = is_numeric($this->args[1]) ? $dataVars['secondary_id'] : 'alias'; - $conditions = array($class . '.' . $key => $this->args[1]); + $conditions = [$class . '.' . $key => $this->args[1]]; $possibility = $this->Acl->{$class}->find('all', compact('conditions')); if (empty($possibility)) { $this->error(__d('cake_console', '%s not found', $this->args[1]), __d('cake_console', 'No tree returned.')); @@ -545,10 +545,10 @@ public function nodeExists() { */ public function parseIdentifier($identifier) { if (preg_match('/^([\w]+)\.(.*)$/', $identifier, $matches)) { - return array( + return [ 'model' => $matches[1], 'foreign_key' => $matches[2], - ); + ]; } return $identifier; } @@ -591,7 +591,7 @@ protected function _getParams() { $aco = $this->parseIdentifier($aco); } $action = '*'; - if (isset($this->args[2]) && !in_array($this->args[2], array('', 'all'))) { + if (isset($this->args[2]) && !in_array($this->args[2], ['', 'all'])) { $action = $this->args[2]; } return compact('aro', 'aco', 'action', 'aroName', 'acoName'); @@ -607,7 +607,7 @@ protected function _dataVars($type = null) { if (!$type) { $type = $this->args[0]; } - $vars = array(); + $vars = []; $class = ucwords($type); $vars['secondary_id'] = (strtolower($class) === 'aro') ? 'foreign_key' : 'object_id'; $vars['data_name'] = $type; diff --git a/lib/Cake/Console/Command/ApiShell.php b/lib/Cake/Console/Command/ApiShell.php index 3c3dd1cefb..8d91e90675 100644 --- a/lib/Cake/Console/Command/ApiShell.php +++ b/lib/Cake/Console/Command/ApiShell.php @@ -34,7 +34,7 @@ class ApiShell extends AppShell { * * @var array */ - public $paths = array(); + public $paths = []; /** * Override initialize of the Shell @@ -42,7 +42,7 @@ class ApiShell extends AppShell { * @return void */ public function initialize() { - $this->paths = array_merge($this->paths, array( + $this->paths = array_merge($this->paths, [ 'behavior' => CAKE . 'Model' . DS . 'Behavior' . DS, 'cache' => CAKE . 'Cache' . DS, 'controller' => CAKE . 'Controller' . DS, @@ -51,7 +51,7 @@ public function initialize() { 'model' => CAKE . 'Model' . DS, 'view' => CAKE . 'View' . DS, 'core' => CAKE - )); + ]); } /** @@ -82,7 +82,7 @@ public function main() { } $objects = App::objects('class', $path); if (in_array($class, $objects)) { - if (in_array($type, array('behavior', 'component', 'helper')) && $type !== $file) { + if (in_array($type, ['behavior', 'component', 'helper']) && $type !== $file) { if (!preg_match('/' . Inflector::camelize($type) . '$/', $class)) { $class .= Inflector::camelize($type); } @@ -146,14 +146,14 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Lookup doc block comments for classes in CakePHP.') - )->addArgument('type', array( + )->addArgument('type', [ 'help' => __d('cake_console', 'Either a full path or type of class (model, behavior, controller, component, view, helper)') - ))->addArgument('className', array( + ])->addArgument('className', [ 'help' => __d('cake_console', 'A CakePHP core class name (e.g: Component, HtmlHelper).') - ))->addOption('method', array( + ])->addOption('method', [ 'short' => 'm', 'help' => __d('cake_console', 'The specific method you want help on.') - )); + ]); return $parser; } @@ -168,7 +168,7 @@ public function help() { $head .= "-----------------------------------------------\n"; $head .= "Parameters:\n\n"; - $commands = array( + $commands = [ 'path' => "\t\n" . "\t\tEither a full path or type of class (model, behavior, controller, component, view, helper).\n" . "\t\tAvailable values:\n\n" . @@ -181,7 +181,7 @@ public function help() { "\t\tview\tLook for class in CakePHP view path\n", 'className' => "\t\n" . "\t\tA CakePHP core class name (e.g: Component, HtmlHelper).\n" - ); + ]; $this->out($head); if (!isset($this->args[1])) { @@ -204,7 +204,7 @@ public function help() { * @return array Methods and signatures indexed by method name */ protected function _parseClass($path, $class) { - $parsed = array(); + $parsed = []; if (!class_exists($class)) { if (!include_once $path) { @@ -215,13 +215,13 @@ protected function _parseClass($path, $class) { $reflection = new ReflectionClass($class); foreach ($reflection->getMethods() as $method) { - if (!$method->isPublic() || strpos($method->getName(), '_') === 0) { + if (!$method->isPublic() || str_starts_with($method->getName(), '_')) { continue; } if ($method->getDeclaringClass()->getName() != $class) { continue; } - $args = array(); + $args = []; foreach ($method->getParameters() as $param) { $paramString = '$' . $param->getName(); if ($param->isDefaultValueAvailable()) { @@ -229,11 +229,11 @@ protected function _parseClass($path, $class) { } $args[] = $paramString; } - $parsed[$method->getName()] = array( - 'comment' => str_replace(array('/*', '*/', '*'), '', $method->getDocComment()), + $parsed[$method->getName()] = [ + 'comment' => str_replace(['/*', '*/', '*'], '', $method->getDocComment()), 'method' => $method->getName(), 'parameters' => '(' . implode(', ', $args) . ')' - ); + ]; } ksort($parsed); return $parsed; diff --git a/lib/Cake/Console/Command/BakeShell.php b/lib/Cake/Console/Command/BakeShell.php index e0db7bc0c2..d54a18342b 100644 --- a/lib/Cake/Console/Command/BakeShell.php +++ b/lib/Cake/Console/Command/BakeShell.php @@ -39,7 +39,7 @@ class BakeShell extends AppShell { * * @var array */ - public $tasks = array('Project', 'DbConfig', 'Model', 'Controller', 'View', 'Plugin', 'Fixture', 'Test'); + public $tasks = ['Project', 'DbConfig', 'Model', 'Controller', 'View', 'Plugin', 'Fixture', 'Test']; /** * The connection being used. @@ -59,7 +59,7 @@ public function startup() { Configure::write('Cache.disable', 1); $task = Inflector::classify($this->command); - if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) { + if (isset($this->{$task}) && !in_array($task, ['Project', 'DbConfig'])) { if (isset($this->params['connection'])) { $this->{$task}->connection = $this->params['connection']; } @@ -100,7 +100,7 @@ public function main() { $this->out(__d('cake_console', '[T]est case')); $this->out(__d('cake_console', '[Q]uit')); - $classToBake = strtoupper($this->in(__d('cake_console', 'What would you like to Bake?'), array('D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q'))); + $classToBake = strtoupper($this->in(__d('cake_console', 'What would you like to Bake?'), ['D', 'M', 'V', 'C', 'P', 'F', 'T', 'Q'])); switch ($classToBake) { case 'D': $this->DbConfig->execute(); @@ -150,7 +150,7 @@ public function all() { $name = $this->Model->getName($this->connection); } - foreach (array('Model', 'Controller', 'View') as $task) { + foreach (['Model', 'Controller', 'View'] as $task) { $this->{$task}->connection = $this->connection; $this->{$task}->interactive = false; } @@ -168,7 +168,7 @@ public function all() { $object = new $model(); $modelExists = true; } else { - $object = new Model(array('name' => $name, 'ds' => $this->connection)); + $object = new Model(['name' => $name, 'ds' => $this->connection]); } $modelBaked = $this->Model->bake($object, false); @@ -190,7 +190,7 @@ public function all() { } App::uses($controller . 'Controller', 'Controller'); if (class_exists($controller . 'Controller')) { - $this->View->args = array($name); + $this->View->args = [$name]; $this->View->execute(); } $this->out('', 1, Shell::QUIET); @@ -214,40 +214,40 @@ public function getOptionParser() { __d('cake_console', 'The Bake script generates controllers, views and models for your application.' . ' If run with no command line arguments, Bake guides the user through the class creation process.' . ' You can customize the generation process by telling Bake where different parts of your application are using command line arguments.') - )->addSubcommand('all', array( + )->addSubcommand('all', [ 'help' => __d('cake_console', 'Bake a complete MVC. optional of a Model') - ))->addSubcommand('project', array( + ])->addSubcommand('project', [ 'help' => __d('cake_console', 'Bake a new app folder in the path supplied or in current directory if no path is specified'), 'parser' => $this->Project->getOptionParser() - ))->addSubcommand('plugin', array( + ])->addSubcommand('plugin', [ 'help' => __d('cake_console', 'Bake a new plugin folder in the path supplied or in current directory if no path is specified.'), 'parser' => $this->Plugin->getOptionParser() - ))->addSubcommand('db_config', array( + ])->addSubcommand('db_config', [ 'help' => __d('cake_console', 'Bake a database.php file in config directory.'), 'parser' => $this->DbConfig->getOptionParser() - ))->addSubcommand('model', array( + ])->addSubcommand('model', [ 'help' => __d('cake_console', 'Bake a model.'), 'parser' => $this->Model->getOptionParser() - ))->addSubcommand('view', array( + ])->addSubcommand('view', [ 'help' => __d('cake_console', 'Bake views for controllers.'), 'parser' => $this->View->getOptionParser() - ))->addSubcommand('controller', array( + ])->addSubcommand('controller', [ 'help' => __d('cake_console', 'Bake a controller.'), 'parser' => $this->Controller->getOptionParser() - ))->addSubcommand('fixture', array( + ])->addSubcommand('fixture', [ 'help' => __d('cake_console', 'Bake a fixture.'), 'parser' => $this->Fixture->getOptionParser() - ))->addSubcommand('test', array( + ])->addSubcommand('test', [ 'help' => __d('cake_console', 'Bake a unit test.'), 'parser' => $this->Test->getOptionParser() - ))->addOption('connection', array( + ])->addOption('connection', [ 'help' => __d('cake_console', 'Database connection to use in conjunction with `bake all`.'), 'short' => 'c', 'default' => 'default' - ))->addOption('theme', array( + ])->addOption('theme', [ 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') - )); + ]); return $parser; } diff --git a/lib/Cake/Console/Command/CommandListShell.php b/lib/Cake/Console/Command/CommandListShell.php index 49b9877839..b72bd9582d 100644 --- a/lib/Cake/Console/Command/CommandListShell.php +++ b/lib/Cake/Console/Command/CommandListShell.php @@ -29,7 +29,7 @@ class CommandListShell extends AppShell { * * @var array */ - public $tasks = array('Command'); + public $tasks = ['Command']; /** * startup @@ -130,13 +130,13 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Get the list of available shells for this CakePHP application.') - )->addOption('sort', array( + )->addOption('sort', [ 'help' => __d('cake_console', 'Does nothing (deprecated)'), 'boolean' => true - ))->addOption('xml', array( + ])->addOption('xml', [ 'help' => __d('cake_console', 'Get the listing as XML.'), 'boolean' => true - )); + ]); return $parser; } diff --git a/lib/Cake/Console/Command/CompletionShell.php b/lib/Cake/Console/Command/CompletionShell.php index 21ee0e7612..f7044133b4 100644 --- a/lib/Cake/Console/Command/CompletionShell.php +++ b/lib/Cake/Console/Command/CompletionShell.php @@ -28,7 +28,7 @@ class CompletionShell extends AppShell { * * @var array */ - public $tasks = array('Command'); + public $tasks = ['Command']; /** * Echo no header by overriding the startup method @@ -105,36 +105,36 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Used by shells like bash to autocomplete command name, options and arguments') - )->addSubcommand('commands', array( + )->addSubcommand('commands', [ 'help' => __d('cake_console', 'Output a list of available commands'), - 'parser' => array( + 'parser' => [ 'description' => __d('cake_console', 'List all availables'), - 'arguments' => array( - ) - ) - ))->addSubcommand('subcommands', array( + 'arguments' => [ + ] + ] + ])->addSubcommand('subcommands', [ 'help' => __d('cake_console', 'Output a list of available subcommands'), - 'parser' => array( + 'parser' => [ 'description' => __d('cake_console', 'List subcommands for a command'), - 'arguments' => array( - 'command' => array( + 'arguments' => [ + 'command' => [ 'help' => __d('cake_console', 'The command name'), 'required' => true, - ) - ) - ) - ))->addSubcommand('options', array( + ] + ] + ] + ])->addSubcommand('options', [ 'help' => __d('cake_console', 'Output a list of available options'), - 'parser' => array( + 'parser' => [ 'description' => __d('cake_console', 'List options'), - 'arguments' => array( - 'command' => array( + 'arguments' => [ + 'command' => [ 'help' => __d('cake_console', 'The command name'), 'required' => false, - ) - ) - ) - ))->epilog( + ] + ] + ] + ])->epilog( __d('cake_console', 'This command is not intended to be called manually') ); @@ -147,7 +147,7 @@ public function getOptionParser() { * @param array $options The options to output * @return void */ - protected function _output($options = array()) { + protected function _output($options = []) { if ($options) { return $this->out(implode(' ', $options)); } diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index e157ff8695..c4fa49fb0e 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -28,21 +28,21 @@ class ConsoleShell extends AppShell { * * @var array */ - public $associations = array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany'); + public $associations = ['hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany']; /** * Chars that describe invalid commands * * @var array */ - public $badCommandChars = array('$', ';'); + public $badCommandChars = ['$', ';']; /** * Available models * * @var array */ - public $models = array(); + public $models = []; /** * _finished @@ -58,7 +58,7 @@ class ConsoleShell extends AppShell { * * @var array */ - protected $_methodPatterns = array( + protected $_methodPatterns = [ 'help' => '/^(help|\?)/', '_exit' => '/^(quit|exit)/', '_models' => '/^models/i', @@ -71,7 +71,7 @@ class ConsoleShell extends AppShell { '_routesShow' => '/^routes\s+show/i', '_routeToString' => '/^route\s+(\(.*\))$/i', '_routeToArray' => '/^route\s+(.*)$/i', - ); + ]; /** * Override startup of the Shell @@ -112,12 +112,12 @@ public function startup() { public function getOptionParser() { $parser = parent::getOptionParser(); - $parser->description(array( + $parser->description([ 'The interactive console is a tool for testing parts of your', 'app before you write code.', '', 'See below for a list of supported commands.' - ))->epilog(array( + ])->epilog([ 'Model testing', '', 'To test model results, use the name of your model without a leading $', @@ -176,7 +176,7 @@ public function getOptionParser() { 'To show all connected routes, do the following:', '', "\tRoutes show", - )); + ]); return $parser; } @@ -272,7 +272,7 @@ protected function _bind($command) { $modelB = $tmp[3]; if ($this->_isValidModel($modelA) && $this->_isValidModel($modelB) && in_array($association, $this->associations)) { - $this->{$modelA}->bindModel(array($association => array($modelB => array('className' => $modelB))), false); + $this->{$modelA}->bindModel([$association => [$modelB => ['className' => $modelB]]], false); $this->out(__d('cake_console', "Created %s association between %s and %s", $association, $modelA, $modelB)); } else { @@ -309,7 +309,7 @@ protected function _unbind($command) { } if ($this->_isValidModel($modelA) && $this->_isValidModel($modelB) && in_array($association, $this->associations) && $validCurrentAssociation) { - $this->{$modelA}->unbindModel(array($association => array($modelB))); + $this->{$modelA}->unbindModel([$association => [$modelB]]); $this->out(__d('cake_console', "Removed %s association between %s and %s", $association, $modelA, $modelB)); } else { @@ -328,7 +328,7 @@ protected function _find($command) { $command = str_replace($this->badCommandChars, "", $command); // Do we have a valid model? - list($modelToCheck) = explode('->', $command); + [$modelToCheck] = explode('->', $command); if ($this->_isValidModel($modelToCheck)) { $findCommand = "\$data = \$this->$command;"; @@ -389,11 +389,11 @@ protected function _save($command) { // Validate the model we're trying to save here $command = strip_tags($command); $command = str_replace($this->badCommandChars, "", $command); - list($modelToSave) = explode("->", $command); + [$modelToSave] = explode("->", $command); if ($this->_isValidModel($modelToSave)) { // Extract the array of data we are trying to build - list(, $data) = explode("->save", $command); + [, $data] = explode("->save", $command); $data = preg_replace('/^\(*(array)?\(*(.+?)\)*$/i', '\\2', $data); $saveCommand = "\$this->{$modelToSave}->save(array('{$modelToSave}' => array({$data})));"; //@codingStandardsIgnoreStart diff --git a/lib/Cake/Console/Command/I18nShell.php b/lib/Cake/Console/Command/I18nShell.php index 79344a9bbc..4c77b4b576 100644 --- a/lib/Cake/Console/Command/I18nShell.php +++ b/lib/Cake/Console/Command/I18nShell.php @@ -36,7 +36,7 @@ class I18nShell extends AppShell { * * @var array */ - public $tasks = array('DbConfig', 'Extract'); + public $tasks = ['DbConfig', 'Extract']; /** * Override startup of the Shell @@ -49,7 +49,7 @@ public function startup() { $this->dataSource = $this->params['datasource']; } - if ($this->command && !in_array($this->command, array('help'))) { + if ($this->command && !in_array($this->command, ['help'])) { if (!config('database')) { $this->out(__d('cake_console', 'Your database configuration was not found. Take a moment to create one.')); return $this->DbConfig->execute(); @@ -70,7 +70,7 @@ public function main() { $this->out(__d('cake_console', '[H]elp')); $this->out(__d('cake_console', '[Q]uit')); - $choice = strtolower($this->in(__d('cake_console', 'What would you like to do?'), array('E', 'I', 'H', 'Q'))); + $choice = strtolower($this->in(__d('cake_console', 'What would you like to do?'), ['E', 'I', 'H', 'Q'])); switch ($choice) { case 'e': $this->Extract->execute(); @@ -109,12 +109,12 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'I18n Shell initializes i18n database table for your application and generates .pot files(s) with translations.') - )->addSubcommand('initdb', array( + )->addSubcommand('initdb', [ 'help' => __d('cake_console', 'Initialize the i18n table.') - ))->addSubcommand('extract', array( + ])->addSubcommand('extract', [ 'help' => __d('cake_console', 'Extract the po translations from your application'), 'parser' => $this->Extract->getOptionParser() - )); + ]); return $parser; } diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 6a704bda81..54a58d6cb0 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -63,7 +63,7 @@ public function startup() { } if (strpos($name, '.')) { - list($this->params['plugin'], $splitName) = pluginSplit($name); + [$this->params['plugin'], $splitName] = pluginSplit($name); $name = $this->params['name'] = $splitName; } if ($name && empty($this->params['file'])) { @@ -71,7 +71,7 @@ public function startup() { } elseif (empty($this->params['file'])) { $this->params['file'] = 'schema.php'; } - if (strpos($this->params['file'], '.php') === false) { + if (!str_contains($this->params['file'], '.php')) { $this->params['file'] .= '.php'; } $file = $this->params['file']; @@ -118,7 +118,7 @@ public function view() { */ public function generate() { $this->out(__d('cake_console', 'Generating Schema...')); - $options = array(); + $options = []; if ($this->params['force']) { $options['models'] = false; } elseif (!empty($this->params['models'])) { @@ -133,7 +133,7 @@ public function generate() { if (!$snapshot && file_exists($this->Schema->path . DS . $this->params['file'])) { $snapshot = true; $prompt = __d('cake_console', "Schema file exists.\n [O]verwrite\n [S]napshot\n [Q]uit\nWould you like to do?"); - $result = strtolower($this->in($prompt, array('o', 's', 'q'), 's')); + $result = strtolower($this->in($prompt, ['o', 's', 'q'], 's')); if ($result === 'q') { return $this->_stop(); } @@ -220,10 +220,10 @@ public function dump() { $contents = "\n\n" . $db->dropSchema($Schema) . "\n\n" . $db->createSchema($Schema); if ($write) { - if (strpos($write, '.sql') === false) { + if (!str_contains($write, '.sql')) { $write .= '.sql'; } - if (strpos($write, DS) !== false) { + if (str_contains($write, DS)) { $File = new File($write, true); } else { $File = new File($this->Schema->path . DS . $write, true); @@ -246,7 +246,7 @@ public function dump() { * @return void */ public function create() { - list($Schema, $table) = $this->_loadSchema(); + [$Schema, $table] = $this->_loadSchema(); $this->_create($Schema, $table); } @@ -256,7 +256,7 @@ public function create() { * @return void */ public function update() { - list($Schema, $table) = $this->_loadSchema(); + [$Schema, $table] = $this->_loadSchema(); $this->_update($Schema, $table); } @@ -279,11 +279,11 @@ protected function _loadSchema() { $this->out(__d('cake_console', 'Performing a dry run.')); } - $options = array( + $options = [ 'name' => $name, 'plugin' => $plugin, 'connection' => $this->params['connection'], - ); + ]; if (!empty($this->params['snapshot'])) { $fileName = basename($this->Schema->file, '.php'); $options['file'] = $fileName . '_' . $this->params['snapshot'] . '.php'; @@ -301,7 +301,7 @@ protected function _loadSchema() { if (isset($this->args[1])) { $table = $this->args[1]; } - return array(&$Schema, $table); + return [&$Schema, $table]; } /** @@ -315,7 +315,7 @@ protected function _loadSchema() { protected function _create(CakeSchema $Schema, $table = null) { $db = ConnectionManager::getDataSource($this->Schema->connection); - $drop = $create = array(); + $drop = $create = []; if (!$table) { foreach ($Schema->tables as $table => $fields) { @@ -335,7 +335,7 @@ protected function _create(CakeSchema $Schema, $table = null) { $this->out(array_keys($drop)); if (!empty($this->params['yes']) || - $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), array('y', 'n'), 'n') === 'y' + $this->in(__d('cake_console', 'Are you sure you want to drop the table(s)?'), ['y', 'n'], 'n') === 'y' ) { $this->out(__d('cake_console', 'Dropping table(s).')); $this->_run($drop, 'drop', $Schema); @@ -345,7 +345,7 @@ protected function _create(CakeSchema $Schema, $table = null) { $this->out(array_keys($create)); if (!empty($this->params['yes']) || - $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), array('y', 'n'), 'y') === 'y' + $this->in(__d('cake_console', 'Are you sure you want to create the table(s)?'), ['y', 'n'], 'y') === 'y' ) { $this->out(__d('cake_console', 'Creating table(s).')); $this->_run($create, 'create', $Schema); @@ -365,28 +365,28 @@ protected function _update(&$Schema, $table = null) { $db = ConnectionManager::getDataSource($this->Schema->connection); $this->out(__d('cake_console', 'Comparing Database to Schema...')); - $options = array(); + $options = []; if (isset($this->params['force'])) { $options['models'] = false; } $Old = $this->Schema->read($options); $compare = $this->Schema->compare($Old, $Schema); - $contents = array(); + $contents = []; if (empty($table)) { foreach ($compare as $table => $changes) { if (isset($compare[$table]['create'])) { $contents[$table] = $db->createSchema($Schema, $table); } else { - $contents[$table] = $db->alterSchema(array($table => $compare[$table]), $table); + $contents[$table] = $db->alterSchema([$table => $compare[$table]], $table); } } } elseif (isset($compare[$table])) { if (isset($compare[$table]['create'])) { $contents[$table] = $db->createSchema($Schema, $table); } else { - $contents[$table] = $db->alterSchema(array($table => $compare[$table]), $table); + $contents[$table] = $db->alterSchema([$table => $compare[$table]], $table); } } @@ -398,7 +398,7 @@ protected function _update(&$Schema, $table = null) { $this->out("\n" . __d('cake_console', 'The following statements will run.')); $this->out(array_map('trim', $contents)); if (!empty($this->params['yes']) || - $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), array('y', 'n'), 'n') === 'y' + $this->in(__d('cake_console', 'Are you sure you want to alter the tables?'), ['y', 'n'], 'n') === 'y' ) { $this->out(); $this->out(__d('cake_console', 'Updating Database...')); @@ -435,7 +435,7 @@ protected function _run($contents, $event, CakeSchema $Schema) { $this->out(__d('cake_console', 'Dry run for %s :', $table)); $this->out($sql); } else { - if (!$Schema->before(array($event => $table))) { + if (!$Schema->before([$event => $table])) { return false; } $error = null; @@ -445,7 +445,7 @@ protected function _run($contents, $event, CakeSchema $Schema) { $error = $table . ': ' . $e->getMessage(); } - $Schema->after(array($event => $table, 'errors' => $error)); + $Schema->after([$event => $table, 'errors' => $error]); if (!empty($error)) { $this->err($error); @@ -465,107 +465,107 @@ protected function _run($contents, $event, CakeSchema $Schema) { public function getOptionParser() { $parser = parent::getOptionParser(); - $plugin = array( + $plugin = [ 'short' => 'p', 'help' => __d('cake_console', 'The plugin to use.'), - ); - $connection = array( + ]; + $connection = [ 'short' => 'c', 'help' => __d('cake_console', 'Set the db config to use.'), 'default' => 'default' - ); - $path = array( + ]; + $path = [ 'help' => __d('cake_console', 'Path to read and write schema.php'), 'default' => CONFIG . 'Schema' - ); - $file = array( + ]; + $file = [ 'help' => __d('cake_console', 'File name to read and write.'), - ); - $name = array( + ]; + $name = [ 'help' => __d('cake_console', 'Classname to use. If its Plugin.class, both name and plugin options will be set.' ) - ); - $snapshot = array( + ]; + $snapshot = [ 'short' => 's', 'help' => __d('cake_console', 'Snapshot number to use/make.') - ); - $models = array( + ]; + $models = [ 'short' => 'm', 'help' => __d('cake_console', 'Specify models as comma separated list.'), - ); - $dry = array( + ]; + $dry = [ 'help' => __d('cake_console', 'Perform a dry run on create and update commands. Queries will be output instead of run.' ), 'boolean' => true - ); - $force = array( + ]; + $force = [ 'short' => 'f', 'help' => __d('cake_console', 'Force "generate" to create a new schema'), 'boolean' => true - ); - $write = array( + ]; + $write = [ 'help' => __d('cake_console', 'Write the dumped SQL to a file.') - ); - $exclude = array( + ]; + $exclude = [ 'help' => __d('cake_console', 'Tables to exclude as comma separated list.') - ); - $yes = array( + ]; + $yes = [ 'short' => 'y', 'help' => __d('cake_console', 'Do not prompt for confirmation. Be careful!'), 'boolean' => true - ); + ]; $parser->description( __d('cake_console', 'The Schema Shell generates a schema object from the database and updates the database from the schema.') - )->addSubcommand('view', array( + )->addSubcommand('view', [ 'help' => __d('cake_console', 'Read and output the contents of a schema file'), - 'parser' => array( + 'parser' => [ 'options' => compact('plugin', 'path', 'file', 'name', 'connection'), 'arguments' => compact('name') - ) - ))->addSubcommand('generate', array( + ] + ])->addSubcommand('generate', [ 'help' => __d('cake_console', 'Reads from --connection and writes to --path. Generate snapshots with -s'), - 'parser' => array( + 'parser' => [ 'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'snapshot', 'force', 'models', 'exclude'), - 'arguments' => array( - 'snapshot' => array('help' => __d('cake_console', 'Generate a snapshot.')) - ) - ) - ))->addSubcommand('dump', array( + 'arguments' => [ + 'snapshot' => ['help' => __d('cake_console', 'Generate a snapshot.')] + ] + ] + ])->addSubcommand('dump', [ 'help' => __d('cake_console', 'Dump database SQL based on a schema file to stdout.'), - 'parser' => array( + 'parser' => [ 'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'write'), 'arguments' => compact('name') - ) - ))->addSubcommand('create', array( + ] + ])->addSubcommand('create', [ 'help' => __d('cake_console', 'Drop and create tables based on the schema file.'), - 'parser' => array( + 'parser' => [ 'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'dry', 'snapshot', 'yes'), - 'args' => array( - 'name' => array( + 'args' => [ + 'name' => [ 'help' => __d('cake_console', 'Name of schema to use.') - ), - 'table' => array( + ], + 'table' => [ 'help' => __d('cake_console', 'Only create the specified table.') - ) - ) - ) - ))->addSubcommand('update', array( + ] + ] + ] + ])->addSubcommand('update', [ 'help' => __d('cake_console', 'Alter the tables based on the schema file.'), - 'parser' => array( + 'parser' => [ 'options' => compact('plugin', 'path', 'file', 'name', 'connection', 'dry', 'snapshot', 'force', 'yes'), - 'args' => array( - 'name' => array( + 'args' => [ + 'name' => [ 'help' => __d('cake_console', 'Name of schema to use.') - ), - 'table' => array( + ], + 'table' => [ 'help' => __d('cake_console', 'Only create the specified table.') - ) - ) - ) - )); + ] + ] + ] + ]); return $parser; } diff --git a/lib/Cake/Console/Command/ServerShell.php b/lib/Cake/Console/Command/ServerShell.php index 014d3978a7..805c78a0fd 100644 --- a/lib/Cake/Console/Command/ServerShell.php +++ b/lib/Cake/Console/Command/ServerShell.php @@ -148,19 +148,19 @@ public function main() { public function getOptionParser() { $parser = parent::getOptionParser(); - $parser->description(array( + $parser->description([ __d('cake_console', 'PHP Built-in Server for CakePHP'), __d('cake_console', '[WARN] Don\'t use this at the production environment') - ))->addOption('host', array( + ])->addOption('host', [ 'short' => 'H', 'help' => __d('cake_console', 'ServerHost') - ))->addOption('port', array( + ])->addOption('port', [ 'short' => 'p', 'help' => __d('cake_console', 'ListenPort') - ))->addOption('document_root', array( + ])->addOption('document_root', [ 'short' => 'd', 'help' => __d('cake_console', 'DocumentRoot') - )); + ]); return $parser; } diff --git a/lib/Cake/Console/Command/Task/BakeTask.php b/lib/Cake/Console/Command/Task/BakeTask.php index c886c95e63..64a428950d 100644 --- a/lib/Cake/Console/Command/Task/BakeTask.php +++ b/lib/Cake/Console/Command/Task/BakeTask.php @@ -80,7 +80,7 @@ public function getPath() { public function execute() { foreach ($this->args as $i => $arg) { if (strpos($arg, '.')) { - list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg); + [$this->params['plugin'], $this->args[$i]] = pluginSplit($arg); break; } } diff --git a/lib/Cake/Console/Command/Task/CommandTask.php b/lib/Cake/Console/Command/Task/CommandTask.php index 99c888f8e8..d089189c3f 100644 --- a/lib/Cake/Console/Command/Task/CommandTask.php +++ b/lib/Cake/Console/Command/Task/CommandTask.php @@ -28,10 +28,10 @@ class CommandTask extends AppShell { * @return array */ public function getShellList() { - $skipFiles = array('AppShell'); + $skipFiles = ['AppShell']; $plugins = CakePlugin::loaded(); - $shellList = array_fill_keys($plugins, null) + array('CORE' => null, 'app' => null); + $shellList = array_fill_keys($plugins, null) + ['CORE' => null, 'app' => null]; $corePath = App::core('Console/Command'); $shells = App::objects('file', $corePath[0]); @@ -72,10 +72,10 @@ protected function _appendShells($type, $shells, &$shellList) { public function commands() { $shellList = $this->getShellList(); - $options = array(); + $options = []; foreach ($shellList as $type => $commands) { $prefix = ''; - if (!in_array(strtolower($type), array('app', 'core'))) { + if (!in_array(strtolower($type), ['app', 'core'])) { $prefix = $type . '.'; } @@ -97,7 +97,7 @@ public function subCommands($commandName) { $Shell = $this->getShell($commandName); if (!$Shell) { - return array(); + return []; } $taskMap = TaskCollection::normalizeObjectArray((array)$Shell->tasks); @@ -106,14 +106,14 @@ public function subCommands($commandName) { $ShellReflection = new ReflectionClass('AppShell'); $shellMethods = $ShellReflection->getMethods(ReflectionMethod::IS_PUBLIC); - $shellMethodNames = array('main', 'help'); + $shellMethodNames = ['main', 'help']; foreach ($shellMethods as $method) { $shellMethodNames[] = $method->getName(); } $Reflection = new ReflectionClass($Shell); $methods = $Reflection->getMethods(ReflectionMethod::IS_PUBLIC); - $methodNames = array(); + $methodNames = []; foreach ($methods as $method) { $methodNames[] = $method->getName(); } @@ -131,9 +131,9 @@ public function subCommands($commandName) { * @return mixed */ public function getShell($commandName) { - list($pluginDot, $name) = pluginSplit($commandName, true); + [$pluginDot, $name] = pluginSplit($commandName, true); - if (in_array(strtolower($pluginDot), array('app.', 'core.'))) { + if (in_array(strtolower($pluginDot), ['app.', 'core.'])) { $commandName = $name; $pluginDot = ''; } @@ -168,7 +168,7 @@ public function options($commandName) { $parser = $Shell->getOptionParser(); } - $options = array(); + $options = []; $array = $parser->options(); foreach ($array as $name => $obj) { $options[] = "--$name"; diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index 433329d6fa..6a28255101 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -31,7 +31,7 @@ class ControllerTask extends BakeTask { * * @var array */ - public $tasks = array('Model', 'Test', 'Template', 'DbConfig', 'Project'); + public $tasks = ['Model', 'Test', 'Template', 'DbConfig', 'Project']; /** * path to Controller directory @@ -101,8 +101,8 @@ public function execute() { */ public function all() { $this->interactive = false; - $this->listAll($this->connection, false); - ClassRegistry::config('Model', array('ds' => $this->connection)); + $this->listAll($this->connection); + ClassRegistry::config('Model', ['ds' => $this->connection]); $unitTestExists = $this->_checkUnitTest(); $admin = false; @@ -153,7 +153,7 @@ protected function _interactive() { $this->out(__d('cake_console', 'Baking %sController', $controllerName)); $this->hr(); - $helpers = $components = array(); + $helpers = $components = []; $actions = ''; $wannaUseSession = 'y'; $wannaBakeAdminCrud = 'n'; @@ -164,25 +164,25 @@ protected function _interactive() { if (file_exists($this->path . $controllerName . 'Controller.php')) { $question[] = __d('cake_console', "Warning: Choosing no will overwrite the %sController.", $controllerName); } - $doItInteractive = $this->in(implode("\n", $question), array('y', 'n'), 'y'); + $doItInteractive = $this->in(implode("\n", $question), ['y', 'n'], 'y'); if (strtolower($doItInteractive) === 'y') { $this->interactive = true; $useDynamicScaffold = $this->in( - __d('cake_console', "Would you like to use dynamic scaffolding?"), array('y', 'n'), 'n' + __d('cake_console', "Would you like to use dynamic scaffolding?"), ['y', 'n'], 'n' ); if (strtolower($useDynamicScaffold) === 'y') { $wannaBakeCrud = 'n'; $actions = 'scaffold'; } else { - list($wannaBakeCrud, $wannaBakeAdminCrud) = $this->_askAboutMethods(); + [$wannaBakeCrud, $wannaBakeAdminCrud] = $this->_askAboutMethods(); $helpers = $this->doHelpers(); $components = $this->doComponents(); $wannaUseSession = $this->in( - __d('cake_console', "Would you like to use the FlashComponent to display flash messages?"), array('y', 'n'), 'y' + __d('cake_console', "Would you like to use the FlashComponent to display flash messages?"), ['y', 'n'], 'y' ); if (strtolower($wannaUseSession) === 'y') { @@ -191,7 +191,7 @@ protected function _interactive() { array_unique($components); } } else { - list($wannaBakeCrud, $wannaBakeAdminCrud) = $this->_askAboutMethods(); + [$wannaBakeCrud, $wannaBakeAdminCrud] = $this->_askAboutMethods(); } if (strtolower($wannaBakeCrud) === 'y') { @@ -205,7 +205,7 @@ protected function _interactive() { $baked = false; if ($this->interactive === true) { $this->confirmController($controllerName, $useDynamicScaffold, $helpers, $components); - $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); + $looksGood = $this->in(__d('cake_console', 'Look okay?'), ['y', 'n'], 'y'); if (strtolower($looksGood) === 'y') { $baked = $this->bake($controllerName, $actions, $helpers, $components); @@ -242,10 +242,10 @@ public function confirmController($controllerName, $useDynamicScaffold, $helpers $this->out("public \$scaffold;"); } - $properties = array( + $properties = [ 'helpers' => __d('cake_console', 'Helpers:'), 'components' => __d('cake_console', 'Components:'), - ); + ]; foreach ($properties as $var => $title) { if (count(${$var})) { @@ -272,13 +272,13 @@ public function confirmController($controllerName, $useDynamicScaffold, $helpers protected function _askAboutMethods() { $wannaBakeCrud = $this->in( __d('cake_console', "Would you like to create some basic class methods \n(index(), add(), view(), edit())?"), - array('y', 'n'), 'n' + ['y', 'n'], 'n' ); $wannaBakeAdminCrud = $this->in( __d('cake_console', "Would you like to create the basic class methods for admin routing?"), - array('y', 'n'), 'n' + ['y', 'n'], 'n' ); - return array($wannaBakeCrud, $wannaBakeAdminCrud); + return [$wannaBakeCrud, $wannaBakeAdminCrud]; } /** @@ -332,17 +332,17 @@ public function bake($controllerName, $actions = '', $helpers = null, $component $this->out("\n" . __d('cake_console', 'Baking controller class for %s...', $controllerName), 1, Shell::QUIET); if ($helpers === null) { - $helpers = array(); + $helpers = []; } if ($components === null) { - $components = array(); + $components = []; } $isScaffold = ($actions === 'scaffold') ? true : false; - $this->Template->set(array( + $this->Template->set([ 'plugin' => $this->plugin, 'pluginPath' => empty($this->plugin) ? '' : $this->plugin . '.' - )); + ]); if (!in_array('Paginator', (array)$components)) { $components[] = 'Paginator'; @@ -390,7 +390,7 @@ public function doHelpers() { * @return array Components the user wants to use. */ public function doComponents() { - $components = array('Paginator'); + $components = ['Paginator']; return array_merge($components, $this->_doPropertyChoices( __d('cake_console', "Would you like this controller to use other components\nbesides PaginatorComponent?"), __d('cake_console', "Please provide a comma separated list of the component names you'd like to use.\nExample: 'Acl, Security, RequestHandler'") @@ -405,8 +405,8 @@ public function doComponents() { * @return array Array of values for property. */ protected function _doPropertyChoices($prompt, $example) { - $proceed = $this->in($prompt, array('y', 'n'), 'n'); - $property = array(); + $proceed = $this->in($prompt, ['y', 'n'], 'n'); + $property = []; if (strtolower($proceed) === 'y') { $propertyList = $this->in($example); $propertyListTrimmed = str_replace(' ', '', $propertyList); @@ -430,7 +430,7 @@ public function listAll($useDbConfig = null) { if ($this->interactive) { $this->out(__d('cake_console', 'Possible Controllers based on your current database:')); $this->hr(); - $this->_controllerNames = array(); + $this->_controllerNames = []; $count = count($this->__tables); for ($i = 0; $i < $count; $i++) { $this->_controllerNames[] = $this->_controllerName($this->_modelName($this->__tables[$i])); @@ -482,29 +482,29 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Bake a controller for a model. Using options you can bake public, admin or both.' - ))->addArgument('name', array( + ))->addArgument('name', [ 'help' => __d('cake_console', 'Name of the controller to bake. Can use Plugin.name to bake controllers into plugins.') - ))->addOption('public', array( + ])->addOption('public', [ 'help' => __d('cake_console', 'Bake a controller with basic crud actions (index, view, add, edit, delete).'), 'boolean' => true - ))->addOption('admin', array( + ])->addOption('admin', [ 'help' => __d('cake_console', 'Bake a controller with crud actions for one of the Routing.prefixes.'), 'boolean' => true - ))->addOption('plugin', array( + ])->addOption('plugin', [ 'short' => 'p', 'help' => __d('cake_console', 'Plugin to bake the controller into.') - ))->addOption('connection', array( + ])->addOption('connection', [ 'short' => 'c', 'help' => __d('cake_console', 'The connection the controller\'s model is on.') - ))->addOption('theme', array( + ])->addOption('theme', [ 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') - ))->addOption('force', array( + ])->addOption('force', [ 'short' => 'f', 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') - ))->addSubcommand('all', array( + ])->addSubcommand('all', [ 'help' => __d('cake_console', 'Bake all controllers with CRUD methods.') - ))->epilog( + ])->epilog( __d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.') ); diff --git a/lib/Cake/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index c76b87bcdb..6a2c734f91 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -36,7 +36,7 @@ class DbConfigTask extends AppShell { * * @var array */ - protected $_defaultConfig = array( + protected $_defaultConfig = [ 'name' => 'default', 'datasource' => 'Database/Mysql', 'persistent' => 'false', @@ -48,7 +48,7 @@ class DbConfigTask extends AppShell { 'prefix' => null, 'encoding' => null, 'port' => null - ); + ]; /** * String name of the database config class name. @@ -89,7 +89,7 @@ protected function _interactive() { $this->out(__d('cake_console', 'Database Configuration:')); $this->hr(); $done = false; - $dbConfigs = array(); + $dbConfigs = []; while (!$done) { $name = ''; @@ -105,9 +105,9 @@ protected function _interactive() { } } - $datasource = $this->in(__d('cake_console', 'Datasource:'), array('Mysql', 'Postgres', 'Sqlite', 'Sqlserver'), 'Mysql'); + $datasource = $this->in(__d('cake_console', 'Datasource:'), ['Mysql', 'Postgres', 'Sqlite', 'Sqlserver'], 'Mysql'); - $persistent = $this->in(__d('cake_console', 'Persistent Connection?'), array('y', 'n'), 'n'); + $persistent = $this->in(__d('cake_console', 'Persistent Connection?'), ['y', 'n'], 'n'); if (strtolower($persistent) === 'n') { $persistent = 'false'; } else { @@ -139,7 +139,7 @@ protected function _interactive() { $password = $this->in(__d('cake_console', 'Password:')); if (!$password) { - $blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), array('y', 'n'), 'n'); + $blank = $this->in(__d('cake_console', 'The password you supplied was empty. Use an empty password?'), ['y', 'n'], 'n'); if ($blank === 'y') { $blankPassword = true; } @@ -235,7 +235,7 @@ protected function _verify($config) { } $this->hr(); - $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); + $looksGood = $this->in(__d('cake_console', 'Look okay?'), ['y', 'n'], 'y'); if (strtolower($looksGood) === 'y') { return $config; @@ -256,12 +256,12 @@ public function bake($configs) { } $filename = $this->path . 'database.php'; - $oldConfigs = array(); + $oldConfigs = []; if (file_exists($filename)) { config('database'); $db = new $this->databaseClassName; - $temp = get_class_vars(get_class($db)); + $temp = get_class_vars($db::class); foreach ($temp as $configName => $info) { $info += $this->_defaultConfig; @@ -278,7 +278,7 @@ public function bake($configs) { $info['persistent'] = var_export((bool)$info['persistent'], true); - $oldConfigs[] = array( + $oldConfigs[] = [ 'name' => $configName, 'datasource' => $info['datasource'], 'persistent' => $info['persistent'], @@ -290,7 +290,7 @@ public function bake($configs) { 'prefix' => $info['prefix'], 'schema' => $info['schema'], 'encoding' => $info['encoding'] - ); + ]; } } @@ -310,7 +310,7 @@ public function bake($configs) { $config += $this->_defaultConfig; extract($config); - if (strpos($datasource, 'Database/') === false) { + if (!str_contains($datasource, 'Database/')) { $datasource = "Database/{$datasource}"; } $out .= "\tpublic \${$name} = array(\n"; diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index eaa691e318..91480e0083 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -32,14 +32,14 @@ class ExtractTask extends AppShell { * * @var string */ - protected $_paths = array(); + protected $_paths = []; /** * Files from where to extract * * @var array */ - protected $_files = array(); + protected $_files = []; /** * Merge all domain and category strings into the default.pot file @@ -60,21 +60,21 @@ class ExtractTask extends AppShell { * * @var string */ - protected $_storage = array(); + protected $_storage = []; /** * Extracted tokens * * @var array */ - protected $_tokens = array(); + protected $_tokens = []; /** * Extracted strings indexed by category, domain, msgid and context. * * @var array */ - protected $_translations = array(); + protected $_translations = []; /** * Destination path @@ -88,7 +88,7 @@ class ExtractTask extends AppShell { * * @var array */ - protected $_exclude = array(); + protected $_exclude = []; /** * Holds whether this call should extract model validation messages @@ -119,7 +119,7 @@ class ExtractTask extends AppShell { protected function _getPaths() { $defaultPath = APP; while (true) { - $currentPaths = count($this->_paths) > 0 ? $this->_paths : array('None'); + $currentPaths = count($this->_paths) > 0 ? $this->_paths : ['None']; $message = __d( 'cake_console', "Current paths: %s\nWhat is the path you would like to extract?\n[Q]uit [D]one", @@ -163,7 +163,7 @@ public function execute() { if (!CakePlugin::loaded($plugin)) { CakePlugin::load($plugin); } - $this->_paths = array(CakePlugin::path($plugin)); + $this->_paths = [CakePlugin::path($plugin)]; $this->params['plugin'] = $plugin; } else { $this->_getPaths(); @@ -172,7 +172,7 @@ public function execute() { if (isset($this->params['extract-core'])) { $this->_extractCore = !(strtolower($this->params['extract-core']) === 'no'); } else { - $response = $this->in(__d('cake_console', 'Would you like to extract the messages from the CakePHP core?'), array('y', 'n'), 'n'); + $response = $this->in(__d('cake_console', 'Would you like to extract the messages from the CakePHP core?'), ['y', 'n'], 'n'); $this->_extractCore = strtolower($response) === 'y'; } @@ -189,10 +189,10 @@ public function execute() { if ($this->_extractCore) { $this->_paths[] = CAKE; - $this->_exclude = array_merge($this->_exclude, array( + $this->_exclude = array_merge($this->_exclude, [ CAKE . 'Test', CAKE . 'Console' . DS . 'Templates' - )); + ]); } if (isset($this->params['output'])) { @@ -220,7 +220,7 @@ public function execute() { $this->_merge = !(strtolower($this->params['merge']) === 'no'); } else { $this->out(); - $response = $this->in(__d('cake_console', 'Would you like to merge all domain and category strings into the default.pot file?'), array('y', 'n'), 'n'); + $response = $this->in(__d('cake_console', 'Would you like to merge all domain and category strings into the default.pot file?'), ['y', 'n'], 'n'); $this->_merge = strtolower($response) === 'y'; } @@ -248,16 +248,16 @@ public function execute() { * @param array $details The file and line references * @return void */ - protected function _addTranslation($category, $domain, $msgid, $details = array()) { + protected function _addTranslation($category, $domain, $msgid, $details = []) { $context = ''; if (isset($details['msgctxt'])) { $context = $details['msgctxt']; } if (empty($this->_translations[$category][$domain][$msgid][$context])) { - $this->_translations[$category][$domain][$msgid][$context] = array( + $this->_translations[$category][$domain][$msgid][$context] = [ 'msgid_plural' => false, - ); + ]; } if (isset($details['msgid_plural'])) { @@ -292,8 +292,8 @@ protected function _extract() { $this->_extractValidationMessages(); $this->_buildFiles(); $this->_writeFiles(); - $this->_paths = $this->_files = $this->_storage = array(); - $this->_translations = $this->_tokens = array(); + $this->_paths = $this->_files = $this->_storage = []; + $this->_translations = $this->_tokens = []; $this->_extractValidation = true; $this->out(); $this->out(__d('cake_console', 'Done.')); @@ -309,48 +309,48 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'CakePHP Language String Extraction:') - )->addOption('app', array( + )->addOption('app', [ 'help' => __d('cake_console', 'Directory where your application is located.') - ))->addOption('paths', array( + ])->addOption('paths', [ 'help' => __d('cake_console', 'Comma separated list of paths.') - ))->addOption('merge', array( + ])->addOption('merge', [ 'help' => __d('cake_console', 'Merge all domain and category strings into the default.po file.'), - 'choices' => array('yes', 'no') - ))->addOption('no-location', array( + 'choices' => ['yes', 'no'] + ])->addOption('no-location', [ 'boolean' => true, 'default' => false, 'help' => __d('cake_console', 'Do not write lines with locations'), - ))->addOption('output', array( + ])->addOption('output', [ 'help' => __d('cake_console', 'Full path to output directory.') - ))->addOption('files', array( + ])->addOption('files', [ 'help' => __d('cake_console', 'Comma separated list of files.') - ))->addOption('exclude-plugins', array( + ])->addOption('exclude-plugins', [ 'boolean' => true, 'default' => true, 'help' => __d('cake_console', 'Ignores all files in plugins if this command is run inside from the same app directory.') - ))->addOption('plugin', array( + ])->addOption('plugin', [ 'help' => __d('cake_console', 'Extracts tokens only from the plugin specified and puts the result in the plugin\'s Locale directory.') - ))->addOption('ignore-model-validation', array( + ])->addOption('ignore-model-validation', [ 'boolean' => true, 'default' => false, 'help' => __d('cake_console', 'Ignores validation messages in the $validate property.' . ' If this flag is not set and the command is run from the same app directory,' . ' all messages in model validation rules will be extracted as tokens.' ) - ))->addOption('validation-domain', array( + ])->addOption('validation-domain', [ 'help' => __d('cake_console', 'If set to a value, the localization domain to be used for model validation messages.') - ))->addOption('exclude', array( + ])->addOption('exclude', [ 'help' => __d('cake_console', 'Comma separated list of directories to exclude.' . ' Any path containing a path segment with the provided values will be skipped. E.g. test,vendors' ) - ))->addOption('overwrite', array( + ])->addOption('overwrite', [ 'boolean' => true, 'default' => false, 'help' => __d('cake_console', 'Always overwrite existing .pot files.') - ))->addOption('extract-core', array( + ])->addOption('extract-core', [ 'help' => __d('cake_console', 'Extract messages from the CakePHP core libs.'), - 'choices' => array('yes', 'no') - )); + 'choices' => ['yes', 'no'] + ]); return $parser; } @@ -368,28 +368,28 @@ protected function _extractTokens() { $code = file_get_contents($file); $allTokens = token_get_all($code); - $this->_tokens = array(); + $this->_tokens = []; foreach ($allTokens as $token) { if (!is_array($token) || ($token[0] !== T_WHITESPACE && $token[0] !== T_INLINE_HTML)) { $this->_tokens[] = $token; } } unset($allTokens); - $this->_parse('__', array('singular')); - $this->_parse('__n', array('singular', 'plural')); - $this->_parse('__d', array('domain', 'singular')); - $this->_parse('__c', array('singular', 'category')); - $this->_parse('__dc', array('domain', 'singular', 'category')); - $this->_parse('__dn', array('domain', 'singular', 'plural')); - $this->_parse('__dcn', array('domain', 'singular', 'plural', 'count', 'category')); - - $this->_parse('__x', array('context', 'singular')); - $this->_parse('__xn', array('context', 'singular', 'plural')); - $this->_parse('__dx', array('domain', 'context', 'singular')); - $this->_parse('__dxc', array('domain', 'context', 'singular', 'category')); - $this->_parse('__dxn', array('domain', 'context', 'singular', 'plural')); - $this->_parse('__dxcn', array('domain', 'context', 'singular', 'plural', 'count', 'category')); - $this->_parse('__xc', array('context', 'singular', 'category')); + $this->_parse('__', ['singular']); + $this->_parse('__n', ['singular', 'plural']); + $this->_parse('__d', ['domain', 'singular']); + $this->_parse('__c', ['singular', 'category']); + $this->_parse('__dc', ['domain', 'singular', 'category']); + $this->_parse('__dn', ['domain', 'singular', 'plural']); + $this->_parse('__dcn', ['domain', 'singular', 'plural', 'count', 'category']); + + $this->_parse('__x', ['context', 'singular']); + $this->_parse('__xn', ['context', 'singular', 'plural']); + $this->_parse('__dx', ['domain', 'context', 'singular']); + $this->_parse('__dxc', ['domain', 'context', 'singular', 'category']); + $this->_parse('__dxn', ['domain', 'context', 'singular', 'plural']); + $this->_parse('__dxcn', ['domain', 'context', 'singular', 'plural', 'count', 'category']); + $this->_parse('__xc', ['context', 'singular', 'category']); } } @@ -403,7 +403,7 @@ protected function _extractTokens() { */ protected function _parse($functionName, $map) { $count = 0; - $categories = array('LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES'); + $categories = ['LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES']; $tokenCount = count($this->_tokens); while (($tokenCount - $count) > 1) { @@ -414,7 +414,7 @@ protected function _parse($functionName, $map) { continue; } - list($type, $string, $line) = $countToken; + [$type, $string, $line] = $countToken; if (($type == T_STRING) && ($string === $functionName) && ($firstParenthesis === '(')) { $position = $count; $depth = 0; @@ -433,15 +433,15 @@ protected function _parse($functionName, $map) { if ($mapCount === count($strings)) { extract(array_combine($map, $strings)); - $category = isset($category) ? $category : 6; + $category ??= 6; $category = (int)$category; $categoryName = $categories[$category]; - $domain = isset($domain) ? $domain : 'default'; - $details = array( + $domain ??= 'default'; + $details = [ 'file' => $this->_file, 'line' => $line, - ); + ]; if (isset($plural)) { $details['msgid_plural'] = $plural; } @@ -471,7 +471,7 @@ protected function _extractValidationMessages() { return; } - $plugins = array(null); + $plugins = [null]; if (empty($this->params['exclude-plugins'])) { $plugins = array_merge($plugins, App::objects('plugin', null, false)); } @@ -538,7 +538,7 @@ protected function _processValidationRules($field, $rules, $file, $domain, $cate $dims = Hash::dimensions($rules); if ($dims === 1 || ($dims === 2 && isset($rules['message']))) { - $rules = array($rules); + $rules = [$rules]; } foreach ($rules as $rule => $validateProp) { @@ -554,10 +554,10 @@ protected function _processValidationRules($field, $rules, $file, $domain, $cate } if ($msgid) { $msgid = $this->_formatString(sprintf("'%s'", $msgid)); - $details = array( + $details = [ 'file' => $file, 'line' => 'validation for field ' . $field - ); + ]; $this->_addTranslation($category, $domain, $msgid, $details); } } @@ -572,9 +572,7 @@ protected function _buildFiles() { $paths = $this->_paths; $paths[] = realpath(APP) . DS; - usort($paths, function ($a, $b) { - return strlen($b) - strlen($a); - }); + usort($paths, fn($a, $b) => strlen($b) - strlen($a)); foreach ($this->_translations as $category => $domains) { foreach ($domains as $domain => $translations) { @@ -584,7 +582,7 @@ protected function _buildFiles() { $header = ''; if (empty($this->params['no-location'])) { $files = $details['references']; - $occurrences = array(); + $occurrences = []; foreach ($files as $file => $lines) { $lines = array_unique($lines); $occurrences[] = $file . ':' . implode(';', $lines); @@ -628,10 +626,10 @@ protected function _buildFiles() { */ protected function _store($category, $domain, $header, $sentence) { if (!isset($this->_storage[$category])) { - $this->_storage[$category] = array(); + $this->_storage[$category] = []; } if (!isset($this->_storage[$category][$domain])) { - $this->_storage[$category][$domain] = array(); + $this->_storage[$category][$domain] = []; } if (!isset($this->_storage[$category][$domain][$sentence])) { $this->_storage[$category][$domain][$sentence] = $header; @@ -669,7 +667,7 @@ protected function _writeFiles() { $this->out(); $response = $this->in( __d('cake_console', 'Error: %s already exists in this location. Overwrite? [Y]es, [N]o, [A]ll', $filename), - array('y', 'n', 'a'), + ['y', 'n', 'a'], 'y' ); if (strtoupper($response) === 'N') { @@ -720,7 +718,7 @@ protected function _writeHeader() { * @return array Strings extracted */ protected function _getStrings(&$position, $target) { - $strings = array(); + $strings = []; $count = count($strings); while ($count < $target && ($this->_tokens[$position] === ',' || $this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING || $this->_tokens[$position][0] == T_LNUMBER)) { $count = count($strings); @@ -755,7 +753,7 @@ protected function _formatString($string) { if ($quote === '"') { $string = stripcslashes($string); } else { - $string = strtr($string, array("\\'" => "'", "\\\\" => "\\")); + $string = strtr($string, ["\\'" => "'", "\\\\" => "\\"]); } $string = str_replace("\r\n", "\n", $string); return addcslashes($string, "\0..\37\\\""); @@ -802,7 +800,7 @@ protected function _markerError($file, $line, $marker, $count) { protected function _searchFiles() { $pattern = false; if (!empty($this->_exclude)) { - $exclude = array(); + $exclude = []; foreach ($this->_exclude as $e) { if (DS !== '\\' && $e[0] !== DS) { $e = DS . $e; @@ -831,7 +829,7 @@ protected function _searchFiles() { * @return bool */ protected function _isExtractingApp() { - return $this->_paths === array(APP); + return $this->_paths === [APP]; } /** diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index 70a55ed6ec..2387dd3fc9 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -31,7 +31,7 @@ class FixtureTask extends BakeTask { * * @var array */ - public $tasks = array('DbConfig', 'Model', 'Template'); + public $tasks = ['DbConfig', 'Model', 'Template']; /** * path to fixtures directory @@ -69,35 +69,35 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Generate fixtures for use with the test suite. You can use `bake fixture all` to bake all fixtures.') - )->addArgument('name', array( + )->addArgument('name', [ 'help' => __d('cake_console', 'Name of the fixture to bake. Can use Plugin.name to bake plugin fixtures.') - ))->addOption('count', array( + ])->addOption('count', [ 'help' => __d('cake_console', 'When using generated data, the number of records to include in the fixture(s).'), 'short' => 'n', 'default' => 1 - ))->addOption('connection', array( + ])->addOption('connection', [ 'help' => __d('cake_console', 'Which database configuration to use for baking.'), 'short' => 'c', 'default' => 'default' - ))->addOption('plugin', array( + ])->addOption('plugin', [ 'help' => __d('cake_console', 'CamelCased name of the plugin to bake fixtures for.'), 'short' => 'p' - ))->addOption('schema', array( + ])->addOption('schema', [ 'help' => __d('cake_console', 'Importing schema for fixtures rather than hardcoding it.'), 'short' => 's', 'boolean' => true - ))->addOption('theme', array( + ])->addOption('theme', [ 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') - ))->addOption('force', array( + ])->addOption('force', [ 'short' => 'f', 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') - ))->addOption('records', array( + ])->addOption('records', [ 'help' => __d('cake_console', 'Used with --count and /all commands to pull [n] records from the live tables, ' . 'where [n] is either --count or the default of 10.'), 'short' => 'r', 'boolean' => true - ))->epilog( + ])->epilog( __d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.') ); @@ -142,7 +142,7 @@ public function all() { foreach ($tables as $table) { $model = $this->_modelName($table); - $importOptions = array(); + $importOptions = []; if (!empty($this->params['schema'])) { $importOptions['schema'] = $model; } @@ -177,7 +177,7 @@ protected function _interactive() { * @return array Array of import options. */ public function importOptions($modelName) { - $options = array(); + $options = []; $plugin = ''; if (isset($this->params['plugin'])) { $plugin = $this->params['plugin'] . '.'; @@ -186,7 +186,7 @@ public function importOptions($modelName) { if (!empty($this->params['schema'])) { $options['schema'] = $plugin . $modelName; } elseif ($this->interactive) { - $doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), array('y', 'n'), 'n'); + $doSchema = $this->in(__d('cake_console', 'Would you like to import schema for this fixture?'), ['y', 'n'], 'n'); if ($doSchema === 'y') { $options['schema'] = $modelName; } @@ -195,14 +195,14 @@ public function importOptions($modelName) { if (!empty($this->params['records'])) { $options['fromTable'] = true; } elseif ($this->interactive) { - $doRecords = $this->in(__d('cake_console', 'Would you like to use record importing for this fixture?'), array('y', 'n'), 'n'); + $doRecords = $this->in(__d('cake_console', 'Would you like to use record importing for this fixture?'), ['y', 'n'], 'n'); if ($doRecords === 'y') { $options['records'] = true; } } if (!isset($options['records']) && $this->interactive) { $prompt = __d('cake_console', "Would you like to build this fixture with data from %s's table?", $modelName); - $fromTable = $this->in($prompt, array('y', 'n'), 'n'); + $fromTable = $this->in($prompt, ['y', 'n'], 'n'); if (strtolower($fromTable) === 'y') { $options['fromTable'] = true; } @@ -218,10 +218,10 @@ public function importOptions($modelName) { * @param array $importOptions Options for public $import * @return string|null Baked fixture content, otherwise null. */ - public function bake($model, $useTable = false, $importOptions = array()) { + public function bake($model, $useTable = false, $importOptions = []) { App::uses('CakeSchema', 'Model'); $table = $schema = $records = $import = $modelImport = null; - $importBits = array(); + $importBits = []; if (!$useTable) { $useTable = Inflector::tableize($model); @@ -246,7 +246,7 @@ public function bake($model, $useTable = false, $importOptions = array()) { } $this->_Schema = new CakeSchema(); - $data = $this->_Schema->read(array('models' => false, 'connection' => $this->connection)); + $data = $this->_Schema->read(['models' => false, 'connection' => $this->connection]); if (!isset($data['tables'][$useTable])) { $this->err("Warning: Could not find the '{$useTable}' table for {$model}."); return null; @@ -279,7 +279,7 @@ public function bake($model, $useTable = false, $importOptions = array()) { * @return string Content saved into fixture file. */ public function generateFixtureFile($model, $otherVars) { - $defaults = array('table' => null, 'schema' => null, 'records' => null, 'import' => null, 'fields' => null); + $defaults = ['table' => null, 'schema' => null, 'records' => null, 'import' => null, 'fields' => null]; $vars = array_merge($defaults, $otherVars); $path = $this->getPath(); @@ -326,9 +326,9 @@ protected function _generateSchema($tableInfo) { * @return array Array of records to use in the fixture. */ protected function _generateRecords($tableInfo, $recordCount = 1) { - $records = array(); + $records = []; for ($i = 0; $i < $recordCount; $i++) { - $record = array(); + $record = []; foreach ($tableInfo as $field => $fieldInfo) { if (empty($fieldInfo['type'])) { continue; @@ -398,7 +398,7 @@ protected function _generateRecords($tableInfo, $recordCount = 1) { protected function _makeRecordString($records) { $out = "array(\n"; foreach ($records as $record) { - $values = array(); + $values = []; foreach ($record as $field => $value) { $val = var_export($value, true); if ($val === 'NULL') { @@ -423,7 +423,7 @@ protected function _makeRecordString($records) { * @return array Array of records. */ protected function _getRecordsFromTable($modelName, $useTable = null) { - $modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection)); + $modelObject = new Model(['name' => $modelName, 'table' => $useTable, 'ds' => $this->connection]); if ($this->interactive) { $condition = null; $prompt = __d('cake_console', "Please provide a SQL fragment to use as conditions\nExample: WHERE 1=1"); @@ -431,28 +431,28 @@ protected function _getRecordsFromTable($modelName, $useTable = null) { $condition = $this->in($prompt, null, 'WHERE 1=1'); } - $recordsFound = $modelObject->find('count', array( + $recordsFound = $modelObject->find('count', [ 'conditions' => $condition, 'recursive' => -1, - )); + ]); $prompt = __d('cake_console', "How many records do you want to import?"); $recordCount = $this->in($prompt, null, ($recordsFound < 10 ) ? $recordsFound : 10); } else { $condition = 'WHERE 1=1'; - $recordCount = (isset($this->params['count']) ? $this->params['count'] : 10); + $recordCount = ($this->params['count'] ?? 10); } - $records = $modelObject->find('all', array( + $records = $modelObject->find('all', [ 'conditions' => $condition, 'recursive' => -1, 'limit' => $recordCount - )); + ]); $schema = $modelObject->schema(true); - $out = array(); + $out = []; foreach ($records as $record) { - $row = array(); + $row = []; foreach ($record[$modelObject->alias] as $field => $value) { if ($schema[$field]['type'] === 'boolean') { $value = (int)(bool)$value; diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 3473e3f410..f99f235631 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -40,35 +40,35 @@ class ModelTask extends BakeTask { * * @var array */ - public $tasks = array('DbConfig', 'Fixture', 'Test', 'Template'); + public $tasks = ['DbConfig', 'Fixture', 'Test', 'Template']; /** * Tables to skip when running all() * * @var array */ - public $skipTables = array('i18n'); + public $skipTables = ['i18n']; /** * Holds tables found on connection. * * @var array */ - protected $_tables = array(); + protected $_tables = []; /** * Holds the model names * * @var array */ - protected $_modelNames = array(); + protected $_modelNames = []; /** * Holds validation method map. * * @var array */ - protected $_validations = array(); + protected $_validations = []; /** * Override initialize @@ -118,7 +118,7 @@ public function execute() { * @return void */ public function all() { - $this->listAll($this->connection, false); + $this->listAll($this->connection); $unitTestExists = $this->_checkUnitTest(); foreach ($this->_tables as $table) { if (in_array($table, $this->skipTables)) { @@ -145,7 +145,7 @@ protected function _getModelObject($className, $table = null) { if (!$table) { $table = Inflector::tableize($className); } - $object = new Model(array('name' => $className, 'table' => $table, 'ds' => $this->connection)); + $object = new Model(['name' => $className, 'table' => $table, 'ds' => $this->connection]); $fields = $object->schema(true); foreach ($fields as $name => $field) { if (isset($field['key']) && $field['key'] === 'primary') { @@ -195,7 +195,7 @@ protected function _interactive() { $this->interactive = true; $primaryKey = 'id'; - $validate = $associations = array(); + $validate = $associations = []; if (empty($this->connection)) { $this->connection = $this->DbConfig->getConfig(); @@ -206,39 +206,39 @@ protected function _interactive() { $fullTableName = $db->fullTableName($useTable); if (!in_array($useTable, $this->_tables)) { $prompt = __d('cake_console', "The table %s doesn't exist or could not be automatically detected\ncontinue anyway?", $useTable); - $continue = $this->in($prompt, array('y', 'n')); + $continue = $this->in($prompt, ['y', 'n']); if (strtolower($continue) === 'n') { return false; } } - $tempModel = new Model(array('name' => $currentModelName, 'table' => $useTable, 'ds' => $this->connection)); + $tempModel = new Model(['name' => $currentModelName, 'table' => $useTable, 'ds' => $this->connection]); $knownToExist = false; try { $fields = $tempModel->schema(true); $knownToExist = true; - } catch (Exception $e) { - $fields = array($tempModel->primaryKey); + } catch (Exception) { + $fields = [$tempModel->primaryKey]; } if (!array_key_exists('id', $fields)) { $primaryKey = $this->findPrimaryKey($fields); } $displayField = null; if ($knownToExist) { - $displayField = $tempModel->hasField(array('name', 'title')); + $displayField = $tempModel->hasField(['name', 'title']); if (!$displayField) { $displayField = $this->findDisplayField($tempModel->schema()); } $prompt = __d('cake_console', "Would you like to supply validation criteria \nfor the fields in your model?"); - $wannaDoValidation = $this->in($prompt, array('y', 'n'), 'y'); + $wannaDoValidation = $this->in($prompt, ['y', 'n'], 'y'); if (array_search($useTable, $this->_tables) !== false && strtolower($wannaDoValidation) === 'y') { $validate = $this->doValidation($tempModel); } $prompt = __d('cake_console', "Would you like to define model associations\n(hasMany, hasOne, belongsTo, etc.)?"); - $wannaDoAssoc = $this->in($prompt, array('y', 'n'), 'y'); + $wannaDoAssoc = $this->in($prompt, ['y', 'n'], 'y'); if (strtolower($wannaDoAssoc) === 'y') { $associations = $this->doAssociations($tempModel); } @@ -264,14 +264,14 @@ protected function _interactive() { } if (!empty($associations)) { $this->out(__d('cake_console', 'Associations:')); - $assocKeys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); + $assocKeys = ['belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany']; foreach ($assocKeys as $assocKey) { $this->_printAssociation($currentModelName, $assocKey, $associations); } } $this->hr(); - $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); + $looksGood = $this->in(__d('cake_console', 'Look okay?'), ['y', 'n'], 'y'); if (strtolower($looksGood) === 'y') { $vars = compact('associations', 'validate', 'primaryKey', 'useTable', 'displayField'); @@ -279,7 +279,7 @@ protected function _interactive() { if ($this->bake($currentModelName, $vars)) { if ($this->_checkUnitTest()) { $this->bakeFixture($currentModelName, $useTable); - $this->bakeTest($currentModelName, $useTable, $associations); + $this->bakeTest($currentModelName); } } } else { @@ -329,7 +329,7 @@ public function findPrimaryKey($fields) { public function findDisplayField($fields) { $fieldNames = array_keys($fields); $prompt = __d('cake_console', "A displayField could not be automatically detected\nwould you like to choose one?"); - $continue = $this->in($prompt, array('y', 'n')); + $continue = $this->in($prompt, ['y', 'n']); if (strtolower($continue) === 'n') { return false; } @@ -355,7 +355,7 @@ public function doValidation($model) { } $skipFields = false; - $validate = array(); + $validate = []; $this->initValidations(); foreach ($fields as $fieldName => $field) { $validation = $this->fieldValidation($fieldName, $field, $model->primaryKey); @@ -379,11 +379,11 @@ public function doValidation($model) { * @return void */ public function initValidations() { - $options = $choices = array(); + $options = $choices = []; if (class_exists('Validation')) { $options = get_class_methods('Validation'); } - $deprecatedOptions = array('notEmpty', 'between', 'ssn'); + $deprecatedOptions = ['notEmpty', 'between', 'ssn']; $options = array_diff($options, $deprecatedOptions); sort($options); $default = 1; @@ -408,7 +408,7 @@ public function initValidations() { */ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { $defaultChoice = count($this->_validations); - $validate = $alreadyChosen = array(); + $validate = $alreadyChosen = []; $prompt = __d('cake_console', "or enter in a valid regex validation string.\nAlternatively [s] skip the rest of the fields.\n" @@ -439,7 +439,7 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { } $guess = $defaultChoice; - if ($metaData['null'] != 1 && !in_array($fieldName, array($primaryKey, 'created', 'modified', 'updated'))) { + if ($metaData['null'] != 1 && !in_array($fieldName, [$primaryKey, 'created', 'modified', 'updated'])) { if ($fieldName === 'email') { $guess = $methods['email']; } elseif ($metaData['type'] === 'string' && $metaData['length'] == 36) { @@ -505,7 +505,7 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { $anotherValidator = 'n'; if ($this->interactive && $choice != $defaultChoice) { $anotherValidator = $this->in(__d('cake_console', "Would you like to add another validation rule\n" . - "or skip the rest of the fields?"), array('y', 'n', 's'), 'n'); + "or skip the rest of the fields?"), ['y', 'n', 's'], 'n'); if ($anotherValidator === 's') { $validate['_skipFields'] = true; return $validate; @@ -531,19 +531,19 @@ public function doAssociations($model) { $fields = $model->schema(true); if (empty($fields)) { - return array(); + return []; } if (empty($this->_tables)) { $this->_tables = (array)$this->getAllTables(); } - $associations = array( - 'belongsTo' => array(), - 'hasMany' => array(), - 'hasOne' => array(), - 'hasAndBelongsToMany' => array() - ); + $associations = [ + 'belongsTo' => [], + 'hasMany' => [], + 'hasOne' => [], + 'hasAndBelongsToMany' => [] + ]; $associations = $this->findBelongsTo($model, $associations); $associations = $this->findHasOneAndMany($model, $associations); @@ -577,10 +577,10 @@ public function doActsAs($model) { if (!$model instanceof Model) { return false; } - $behaviors = array(); + $behaviors = []; $fields = $model->schema(true); if (empty($fields)) { - return array(); + return []; } if (isset($fields['lft']) && $fields['lft']['type'] === 'integer' && @@ -601,20 +601,20 @@ public function doActsAs($model) { public function findBelongsTo(Model $model, $associations) { $fieldNames = array_keys($model->schema(true)); foreach ($fieldNames as $fieldName) { - $offset = substr($fieldName, -3) === '_id'; + $offset = str_ends_with($fieldName, '_id'); if ($fieldName != $model->primaryKey && $fieldName !== 'parent_id' && $offset !== false) { $tmpModelName = $this->_modelNameFromKey($fieldName); - $associations['belongsTo'][] = array( + $associations['belongsTo'][] = [ 'alias' => $tmpModelName, 'className' => $tmpModelName, 'foreignKey' => $fieldName, - ); + ]; } elseif ($fieldName === 'parent_id') { - $associations['belongsTo'][] = array( + $associations['belongsTo'][] = [ 'alias' => 'Parent' . $model->name, 'className' => $model->name, 'foreignKey' => $fieldName, - ); + ]; } } return $associations; @@ -641,17 +641,17 @@ public function findHasOneAndMany(Model $model, $associations) { foreach ($tempFieldNames as $fieldName) { $assoc = false; if ($fieldName !== $model->primaryKey && $fieldName === $foreignKey) { - $assoc = array( + $assoc = [ 'alias' => $tempOtherModel->name, 'className' => $tempOtherModel->name, 'foreignKey' => $fieldName - ); + ]; } elseif ($otherTable === $model->table && $fieldName === 'parent_id') { - $assoc = array( + $assoc = [ 'alias' => 'Child' . $model->name, 'className' => $model->name, 'foreignKey' => $fieldName - ); + ]; } if ($assoc) { $associations['hasOne'][] = $assoc; @@ -684,13 +684,13 @@ public function findHasAndBelongsToMany(Model $model, $associations) { } if ($tableName && in_array($tableName, $this->_tables)) { $habtmName = $this->_modelName($tableName); - $associations['hasAndBelongsToMany'][] = array( + $associations['hasAndBelongsToMany'][] = [ 'alias' => $habtmName, 'className' => $habtmName, 'foreignKey' => $foreignKey, 'associationForeignKey' => $this->_modelKey($habtmName), 'joinTable' => $otherTable - ); + ]; } } return $associations; @@ -708,7 +708,7 @@ public function confirmAssociations(Model $model, $associations) { if (!empty($associations[$type])) { foreach ($associations[$type] as $i => $assoc) { $prompt = "{$model->name} {$type} {$assoc['alias']}?"; - $response = $this->in($prompt, array('y', 'n'), 'y'); + $response = $this->in($prompt, ['y', 'n'], 'y'); if (strtolower($response) === 'n') { unset($associations[$type][$i]); @@ -731,10 +731,10 @@ public function confirmAssociations(Model $model, $associations) { */ public function doMoreAssociations(Model $model, $associations) { $prompt = __d('cake_console', 'Would you like to define some additional model associations?'); - $wannaDoMoreAssoc = $this->in($prompt, array('y', 'n'), 'n'); + $wannaDoMoreAssoc = $this->in($prompt, ['y', 'n'], 'n'); $possibleKeys = $this->_generatePossibleKeys(); while (strtolower($wannaDoMoreAssoc) === 'y') { - $assocs = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); + $assocs = ['belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany']; $this->out(__d('cake_console', 'What is the association type?')); $assocType = (int)$this->inOptions($assocs, __d('cake_console', 'Enter a number')); @@ -792,7 +792,7 @@ public function doMoreAssociations(Model $model, $associations) { $associations[$assocs[$assocType]][$i]['associationForeignKey'] = $associationForeignKey; $associations[$assocs[$assocType]][$i]['joinTable'] = $joinTable; } - $wannaDoMoreAssoc = $this->in(__d('cake_console', 'Define another association?'), array('y', 'n'), 'y'); + $wannaDoMoreAssoc = $this->in(__d('cake_console', 'Define another association?'), ['y', 'n'], 'y'); } return $associations; } @@ -803,9 +803,9 @@ public function doMoreAssociations(Model $model, $associations) { * @return array Array of tables and possible keys */ protected function _generatePossibleKeys() { - $possible = array(); + $possible = []; foreach ($this->_tables as $otherTable) { - $tempOtherModel = new Model(array('table' => $otherTable, 'ds' => $this->connection)); + $tempOtherModel = new Model(['table' => $otherTable, 'ds' => $this->connection]); $modelFieldsTemp = $tempOtherModel->schema(true); foreach ($modelFieldsTemp as $fieldName => $field) { if ($field['type'] === 'integer' || $field['type'] === 'string') { @@ -823,10 +823,10 @@ protected function _generatePossibleKeys() { * @param array|bool $data if array and $name is not an object assume bake data, otherwise boolean. * @return string */ - public function bake($name, $data = array()) { + public function bake($name, $data = []) { if ($name instanceof Model) { if (!$data) { - $data = array(); + $data = []; $data['associations'] = $this->doAssociations($name); $data['validate'] = $this->doValidation($name); $data['actsAs'] = $this->doActsAs($name); @@ -839,15 +839,15 @@ public function bake($name, $data = array()) { $data['name'] = $name; } - $defaults = array( - 'associations' => array(), - 'actsAs' => array(), - 'validate' => array(), + $defaults = [ + 'associations' => [], + 'actsAs' => [], + 'validate' => [], 'primaryKey' => 'id', 'useTable' => null, 'useDbConfig' => 'default', 'displayField' => null - ); + ]; $data = array_merge($defaults, $data); $pluginPath = ''; @@ -856,10 +856,10 @@ public function bake($name, $data = array()) { } $this->Template->set($data); - $this->Template->set(array( + $this->Template->set([ 'plugin' => $this->plugin, 'pluginPath' => $pluginPath - )); + ]); $out = $this->Template->generate('classes', 'model'); $path = $this->getPath(); @@ -892,7 +892,7 @@ public function bakeTest($className) { public function listAll($useDbConfig = null) { $this->_tables = $this->getAllTables($useDbConfig); - $this->_modelNames = array(); + $this->_modelNames = []; $count = count($this->_tables); for ($i = 0; $i < $count; $i++) { $this->_modelNames[] = $this->_modelName($this->_tables[$i]); @@ -931,7 +931,7 @@ public function getTable($modelName, $useDbConfig = null) { if (array_search($useTable, $this->_tables) === false) { $this->out(); $this->out(__d('cake_console', "Given your model named '%s',\nCake would expect a database table named '%s'", $modelName, $fullTableName)); - $tableIsGood = $this->in(__d('cake_console', 'Do you want to use this table?'), array('y', 'n'), 'y'); + $tableIsGood = $this->in(__d('cake_console', 'Do you want to use this table?'), ['y', 'n'], 'y'); } if (strtolower($tableIsGood) === 'n') { $useTable = $this->in(__d('cake_console', 'What is the name of the table (without prefix)?')); @@ -952,7 +952,7 @@ public function getAllTables($useDbConfig = null) { $useDbConfig = $this->connection; } - $tables = array(); + $tables = []; $db = ConnectionManager::getDataSource($useDbConfig); $db->cacheSources = false; $usePrefix = empty($db->config['prefix']) ? '' : $db->config['prefix']; @@ -1016,23 +1016,23 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Bake models.') - )->addArgument('name', array( + )->addArgument('name', [ 'help' => __d('cake_console', 'Name of the model to bake. Can use Plugin.name to bake plugin models.') - ))->addSubcommand('all', array( + ])->addSubcommand('all', [ 'help' => __d('cake_console', 'Bake all model files with associations and validation.') - ))->addOption('plugin', array( + ])->addOption('plugin', [ 'short' => 'p', 'help' => __d('cake_console', 'Plugin to bake the model into.') - ))->addOption('theme', array( + ])->addOption('theme', [ 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') - ))->addOption('connection', array( + ])->addOption('connection', [ 'short' => 'c', 'help' => __d('cake_console', 'The connection the model table is on.') - ))->addOption('force', array( + ])->addOption('force', [ 'short' => 'f', 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') - ))->epilog( + ])->epilog( __d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.') ); diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index 10a00864a4..4495e76dc6 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -100,11 +100,11 @@ public function bake($plugin) { $this->out(__d('cake_console', "Plugin Directory: %s", $this->path . $plugin)); $this->hr(); - $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n', 'q'), 'y'); + $looksGood = $this->in(__d('cake_console', 'Look okay?'), ['y', 'n', 'q'], 'y'); if (strtolower($looksGood) === 'y') { $Folder = new Folder($this->path . $plugin); - $directories = array( + $directories = [ 'Config' . DS . 'Schema', 'Console' . DS . 'Command' . DS . 'Task', 'Console' . DS . 'Templates', @@ -125,7 +125,7 @@ public function bake($plugin) { 'webroot' . DS . 'css', 'webroot' . DS . 'js', 'webroot' . DS . 'img', - ); + ]; foreach ($directories as $directory) { $dirPath = $this->path . $plugin . DS . $directory; @@ -226,9 +226,9 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Create the directory structure, AppModel and AppController classes for a new plugin. ' . 'Can create plugins in any of your bootstrapped plugin paths.') - )->addArgument('name', array( + )->addArgument('name', [ 'help' => __d('cake_console', 'CamelCased name of the plugin to create.') - )); + ]); return $parser; } diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index ed38f6855b..25650a7279 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -46,7 +46,7 @@ public function execute() { if (isset($this->args[0])) { $project = $this->args[0]; } else { - $appContents = array_diff(scandir(APP), array('.', '..')); + $appContents = array_diff(scandir(APP), ['.', '..']); if (empty($appContents)) { $suggestedPath = rtrim(APP, DS); } else { @@ -66,7 +66,7 @@ public function execute() { $response = false; while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'core.php')) { $prompt = __d('cake_console', 'A project already exists in this location: %s Overwrite?', $project); - $response = $this->in($prompt, array('y', 'n'), 'n'); + $response = $this->in($prompt, ['y', 'n'], 'n'); if (strtolower($response) === 'n') { $response = $project = false; } @@ -164,7 +164,7 @@ public function cakeOnIncludePath() { * @param string $skip array of directories to skip when copying * @return mixed */ - public function bake($path, $skel = null, $skip = array('empty')) { + public function bake($path, $skel = null, $skip = ['empty']) { if (!$skel && !empty($this->params['skel'])) { $skel = $this->params['skel']; } @@ -193,16 +193,16 @@ public function bake($path, $skel = null, $skip = array('empty')) { $this->out(__d('cake_console', 'Will be copied to: ') . $path); $this->hr(); - $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n', 'q'), 'y'); + $looksGood = $this->in(__d('cake_console', 'Look okay?'), ['y', 'n', 'q'], 'y'); switch (strtolower($looksGood)) { case 'y': $Folder = new Folder($skel); if (!empty($this->params['empty'])) { - $skip = array(); + $skip = []; } - if ($Folder->copy(array('to' => $path, 'skip' => $skip))) { + if ($Folder->copy(['to' => $path, 'skip' => $skip])) { $this->hr(); $this->out(__d('cake_console', 'Created: %s in %s', $app, $path)); $this->hr(); @@ -237,7 +237,7 @@ public function consolePath($path) { $File = new File($path . 'Console' . DS . 'cake.php'); $contents = $File->read(); if (preg_match('/(__CAKE_PATH__)/', $contents, $match)) { - $root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'"; + $root = str_starts_with(CAKE_CORE_INCLUDE_PATH, '/') ? " DS . '" : "'"; $replacement = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'"; $result = str_replace($match[0], $replacement, $contents); if ($File->write($result)) { @@ -337,7 +337,7 @@ public function corePath($path, $hardCode = true) { protected function _replaceCorePath($filename, $hardCode) { $contents = file_get_contents($filename); - $root = strpos(CAKE_CORE_INCLUDE_PATH, '/') === 0 ? " DS . '" : "'"; + $root = str_starts_with(CAKE_CORE_INCLUDE_PATH, '/') ? " DS . '" : "'"; $corePath = $root . str_replace(DS, "' . DS . '", trim(CAKE_CORE_INCLUDE_PATH, DS)) . "'"; $composer = ROOT . DS . APP_DIR . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; @@ -368,7 +368,7 @@ public function cakeAdmin($name) { if (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(]*\);)%', $contents, $match)) { $result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', array(\'' . $name . '\'));', $contents); if ($File->write($result)) { - Configure::write('Routing.prefixes', array($name)); + Configure::write('Routing.prefixes', [$name]); return true; } } @@ -391,7 +391,7 @@ public function getPrefix() { $this->out(); $this->out(__d('cake_console', 'You have more than one routing prefix configured')); } - $options = array(); + $options = []; foreach ($prefixes as $i => $prefix) { $options[] = $i + 1; if ($this->interactive) { @@ -433,19 +433,19 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Generate a new CakePHP project skeleton.') - )->addArgument('name', array( + )->addArgument('name', [ 'help' => __d('cake_console', 'Application directory to make, if it starts with "/" the path is absolute.') - ))->addOption('empty', array( + ])->addOption('empty', [ 'boolean' => true, 'help' => __d('cake_console', 'Create empty files in each of the directories. Good if you are using git') - ))->addOption('theme', array( + ])->addOption('theme', [ 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') - ))->addOption('skel', array( + ])->addOption('skel', [ 'default' => current(App::core('Console')) . 'Templates' . DS . 'skel', 'help' => __d('cake_console', 'The directory layout to use for the new application skeleton.' . ' Defaults to cake/Console/Templates/skel of CakePHP used to create the project.') - )); + ]); return $parser; } diff --git a/lib/Cake/Console/Command/Task/TemplateTask.php b/lib/Cake/Console/Command/Task/TemplateTask.php index 0691bf5c2a..d145e23cd6 100644 --- a/lib/Cake/Console/Command/Task/TemplateTask.php +++ b/lib/Cake/Console/Command/Task/TemplateTask.php @@ -31,7 +31,7 @@ class TemplateTask extends AppShell { * * @var array */ - public $templateVars = array(); + public $templateVars = []; /** * Paths to look for templates on. @@ -39,7 +39,7 @@ class TemplateTask extends AppShell { * * @var array */ - public $templatePaths = array(); + public $templatePaths = []; /** * Initialize callback. Setup paths for the template task. @@ -81,7 +81,7 @@ protected function _findThemes() { $paths[$i] = rtrim($path, DS) . DS; } - $themes = array(); + $themes = []; foreach ($paths as $path) { $Folder = new Folder($path . 'Templates', false); $contents = $Folder->read(); @@ -118,7 +118,7 @@ public function set($one, $two = null) { $data = $one; } } else { - $data = array($one => $two); + $data = [$one => $two]; } if (!$data) { @@ -178,7 +178,7 @@ public function getThemePath() { $this->hr(); $i = 1; - $indexedPaths = array(); + $indexedPaths = []; foreach ($this->templatePaths as $key => $path) { $this->out($i . '. ' . $key); $indexedPaths[$i] = $path; diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index a4c4e936b0..7ea59c5365 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -42,20 +42,20 @@ class TestTask extends BakeTask { * * @var array */ - public $tasks = array('Template'); + public $tasks = ['Template']; /** * class types that methods can be generated for * * @var array */ - public $classTypes = array( + public $classTypes = [ 'Model' => 'Model', 'Controller' => 'Controller', 'Component' => 'Controller/Component', 'Behavior' => 'Model/Behavior', 'Helper' => 'View/Helper' - ); + ]; /** * Mapping between packages, and their baseclass + package. @@ -64,20 +64,20 @@ class TestTask extends BakeTask { * * @var array */ - public $baseTypes = array( - 'Model' => array('Model', 'Model'), - 'Behavior' => array('ModelBehavior', 'Model'), - 'Controller' => array('Controller', 'Controller'), - 'Component' => array('Component', 'Controller'), - 'Helper' => array('Helper', 'View') - ); + public $baseTypes = [ + 'Model' => ['Model', 'Model'], + 'Behavior' => ['ModelBehavior', 'Model'], + 'Controller' => ['Controller', 'Controller'], + 'Component' => ['Component', 'Controller'], + 'Helper' => ['Helper', 'View'] + ]; /** * Internal list of fixtures that have been added so far. * * @var array */ - protected $_fixtures = array(); + protected $_fixtures = []; /** * Execution method always used for tasks @@ -151,16 +151,16 @@ public function bake($type, $className) { } elseif ($this->interactive) { $this->getUserFixtures(); } - list($baseClass, $baseType) = $this->getBaseType($type); + [$baseClass, $baseType] = $this->getBaseType($type); App::uses($baseClass, $baseType); App::uses($fullClassName, $realType); - $methods = array(); + $methods = []; if (class_exists($fullClassName)) { $methods = $this->getTestableMethods($fullClassName); } - $mock = $this->hasMockClass($type, $fullClassName); - list($preConstruct, $construction, $postConstruct) = $this->generateConstructor($type, $fullClassName, $plugin); + $mock = $this->hasMockClass($type); + [$preConstruct, $construction, $postConstruct] = $this->generateConstructor($type, $fullClassName, $plugin); $uses = $this->generateUses($type, $realType, $fullClassName); $this->out("\n" . __d('cake_console', 'Baking test case for %s %s ...', $className, $type), 1, Shell::QUIET); @@ -192,7 +192,7 @@ public function getObjectType() { $this->out(__d('cake_console', 'Select an object type:')); $this->hr(); - $keys = array(); + $keys = []; $i = 0; foreach ($this->classTypes as $option => $package) { $this->out(++$i . '. ' . $option); @@ -224,7 +224,7 @@ public function getClassName($objectType) { $options = App::objects($type); } $this->out(__d('cake_console', 'Choose a %s class', $objectType)); - $keys = array(); + $keys = []; foreach ($options as $key => $option) { $this->out(++$key . '. ' . $option); $keys[] = $key; @@ -250,7 +250,7 @@ public function getClassName($objectType) { */ public function typeCanDetectFixtures($type) { $type = strtolower($type); - return in_array($type, array('controller', 'model')); + return in_array($type, ['controller', 'model']); } /** @@ -262,7 +262,7 @@ public function typeCanDetectFixtures($type) { */ public function isLoadableClass($package, $class) { App::uses($class, $package); - list($plugin, $ns) = pluginSplit($package); + [$plugin, $ns] = pluginSplit($package); if ($plugin) { App::uses("{$plugin}AppController", $package); App::uses("{$plugin}AppModel", $package); @@ -358,9 +358,9 @@ public function getTestableMethods($className) { $classMethods = get_class_methods($className); $parentMethods = get_class_methods(get_parent_class($className)); $thisMethods = array_diff($classMethods, $parentMethods); - $out = array(); + $out = []; foreach ($thisMethods as $method) { - if (substr($method, 0, 1) !== '_' && $method != strtolower($className)) { + if (!str_starts_with($method, '_') && $method != strtolower($className)) { $out[] = $method; } } @@ -375,7 +375,7 @@ public function getTestableMethods($className) { * @return array Array of fixtures to be included in the test. */ public function generateFixtureList($subject) { - $this->_fixtures = array(); + $this->_fixtures = []; if ($subject instanceof Model) { $this->_processModel($subject); } elseif ($subject instanceof Controller) { @@ -401,7 +401,7 @@ protected function _processModel($subject) { } if ($type === 'hasAndBelongsToMany') { if (!empty($subject->hasAndBelongsToMany[$alias]['with'])) { - list(, $joinModel) = pluginSplit($subject->hasAndBelongsToMany[$alias]['with']); + [, $joinModel] = pluginSplit($subject->hasAndBelongsToMany[$alias]['with']); } else { $joinModel = Inflector::classify($subject->hasAndBelongsToMany[$alias]['joinTable']); } @@ -421,12 +421,12 @@ protected function _processModel($subject) { */ protected function _processController($subject) { $subject->constructClasses(); - $models = array(Inflector::classify($subject->name)); + $models = [Inflector::classify($subject->name)]; if (!empty($subject->uses)) { $models = $subject->uses; } foreach ($models as $model) { - list(, $model) = pluginSplit($model); + [, $model] = pluginSplit($model); $this->_processModel($subject->{$model}); } } @@ -454,8 +454,8 @@ protected function _addFixture($name) { * @return array Array of fixtures the user wants to add. */ public function getUserFixtures() { - $proceed = $this->in(__d('cake_console', 'Bake could not detect fixtures, would you like to add some?'), array('y', 'n'), 'n'); - $fixtures = array(); + $proceed = $this->in(__d('cake_console', 'Bake could not detect fixtures, would you like to add some?'), ['y', 'n'], 'n'); + $fixtures = []; if (strtolower($proceed) === 'y') { $fixtureList = $this->in(__d('cake_console', "Please provide a comma separated list of the fixtures names you'd like to use.\nExample: 'app.comment, app.post, plugin.forums.post'")); $fixtureListTrimmed = str_replace(' ', '', $fixtureList); @@ -502,7 +502,7 @@ public function generateConstructor($type, $fullClassName, $plugin) { $pre = "\$Collection = new ComponentCollection();\n"; $construct = "new {$fullClassName}(\$Collection);\n"; } - return array($pre, $construct, $post); + return [$pre, $construct, $post]; } /** @@ -514,17 +514,17 @@ public function generateConstructor($type, $fullClassName, $plugin) { * @return array An array containing used classes */ public function generateUses($type, $realType, $className) { - $uses = array(); + $uses = []; $type = strtolower($type); if ($type === 'component') { - $uses[] = array('ComponentCollection', 'Controller'); - $uses[] = array('Component', 'Controller'); + $uses[] = ['ComponentCollection', 'Controller']; + $uses[] = ['Component', 'Controller']; } if ($type === 'helper') { - $uses[] = array('View', 'View'); - $uses[] = array('Helper', 'View'); + $uses[] = ['View', 'View']; + $uses[] = ['Helper', 'View']; } - $uses[] = array($className, $realType); + $uses[] = [$className, $realType]; return $uses; } @@ -556,27 +556,27 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Bake test case skeletons for classes.') - )->addArgument('type', array( + )->addArgument('type', [ 'help' => __d('cake_console', 'Type of class to bake, can be any of the following: controller, model, helper, component or behavior.'), - 'choices' => array( + 'choices' => [ 'Controller', 'controller', 'Model', 'model', 'Helper', 'helper', 'Component', 'component', 'Behavior', 'behavior' - ) - ))->addArgument('name', array( + ] + ])->addArgument('name', [ 'help' => __d('cake_console', 'An existing class to bake tests for.') - ))->addOption('theme', array( + ])->addOption('theme', [ 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') - ))->addOption('plugin', array( + ])->addOption('plugin', [ 'short' => 'p', 'help' => __d('cake_console', 'CamelCased name of the plugin to bake tests for.') - ))->addOption('force', array( + ])->addOption('force', [ 'short' => 'f', 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') - ))->epilog( + ])->epilog( __d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.') ); diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index fa7ddef448..472769dbe5 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -31,7 +31,7 @@ class ViewTask extends BakeTask { * * @var array */ - public $tasks = array('Project', 'Controller', 'DbConfig', 'Template'); + public $tasks = ['Project', 'Controller', 'DbConfig', 'Template']; /** * path to View directory @@ -59,7 +59,7 @@ class ViewTask extends BakeTask { * * @var array */ - public $scaffoldActions = array('index', 'view', 'add', 'edit'); + public $scaffoldActions = ['index', 'view', 'add', 'edit']; /** * An array of action names that don't require templates. These @@ -67,7 +67,7 @@ class ViewTask extends BakeTask { * * @var array */ - public $noTemplateActions = array('delete'); + public $noTemplateActions = ['delete']; /** * Override initialize @@ -147,7 +147,7 @@ protected function _methodsToBake() { if ($scaffoldActions) { $methods[$i] = $adminRoute . $method; continue; - } elseif (strpos($method, $adminRoute) === false) { + } elseif (!str_contains($method, $adminRoute)) { unset($methods[$i]); } } @@ -169,7 +169,7 @@ public function all() { $actions = null; if (isset($this->args[1])) { - $actions = array($this->args[1]); + $actions = [$this->args[1]]; } $this->interactive = false; foreach ($tables as $table) { @@ -207,16 +207,16 @@ protected function _interactive() { $this->controllerName = $this->Controller->getName(); $prompt = __d('cake_console', "Would you like bake to build your views interactively?\nWarning: Choosing no will overwrite %s views if they exist.", $this->controllerName); - $interactive = $this->in($prompt, array('y', 'n'), 'n'); + $interactive = $this->in($prompt, ['y', 'n'], 'n'); if (strtolower($interactive) === 'n') { $this->interactive = false; } $prompt = __d('cake_console', "Would you like to create some CRUD views\n(index, add, view, edit) for this controller?\nNOTE: Before doing so, you'll need to create your controller\nand model classes (including associated models)."); - $wannaDoScaffold = $this->in($prompt, array('y', 'n'), 'y'); + $wannaDoScaffold = $this->in($prompt, ['y', 'n'], 'y'); - $wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), array('y', 'n'), 'n'); + $wannaDoAdmin = $this->in(__d('cake_console', "Would you like to create the views for admin routing?"), ['y', 'n'], 'n'); if (strtolower($wannaDoScaffold) === 'y' || strtolower($wannaDoAdmin) === 'y') { $vars = $this->_loadController(); @@ -227,7 +227,7 @@ protected function _interactive() { if (strtolower($wannaDoAdmin) === 'y') { $admin = $this->Project->getPrefix(); $regularActions = $this->scaffoldActions; - $adminActions = array(); + $adminActions = []; foreach ($regularActions as $action) { $adminActions[] = $admin . $action; } @@ -285,7 +285,7 @@ protected function _loadController() { $primaryKey = $displayField = null; $singularVar = Inflector::variable(Inflector::singularize($this->controllerName)); $singularHumanName = $this->_singularHumanName($this->controllerName); - $fields = $schema = $associations = array(); + $fields = $schema = $associations = []; } $pluralVar = Inflector::variable($this->controllerName); $pluralHumanName = $this->_pluralHumanName($this->controllerName); @@ -329,7 +329,7 @@ public function customAction() { $this->out(__d('cake_console', 'Action Name: %s', $action)); $this->out(__d('cake_console', 'Path: %s', $this->getPath() . $this->controllerName . DS . Inflector::underscore($action) . ".ctp")); $this->hr(); - $looksGood = $this->in(__d('cake_console', 'Look okay?'), array('y', 'n'), 'y'); + $looksGood = $this->in(__d('cake_console', 'Look okay?'), ['y', 'n'], 'y'); if (strtolower($looksGood) === 'y') { $this->bake($action, ' '); return $this->_stop(); @@ -399,14 +399,14 @@ public function getTemplate($action) { $template = $action; $prefixes = Configure::read('Routing.prefixes'); foreach ((array)$prefixes as $prefix) { - if (strpos($template, $prefix) !== false) { + if (str_contains($template, $prefix)) { $template = str_replace($prefix . '_', '', $template); } } - if (in_array($template, array('add', 'edit'))) { + if (in_array($template, ['add', 'edit'])) { $template = 'form'; } elseif (preg_match('@(_add|_edit)$@', $template)) { - $template = str_replace(array('_add', '_edit'), '_form', $template); + $template = str_replace(['_add', '_edit'], '_form', $template); } return $template; } @@ -421,30 +421,30 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'Bake views for a controller, using built-in or custom templates.') - )->addArgument('controller', array( + )->addArgument('controller', [ 'help' => __d('cake_console', 'Name of the controller views to bake. Can be Plugin.name as a shortcut for plugin baking.') - ))->addArgument('action', array( + ])->addArgument('action', [ 'help' => __d('cake_console', "Will bake a single action's file. core templates are (index, add, edit, view)") - ))->addArgument('alias', array( + ])->addArgument('alias', [ 'help' => __d('cake_console', 'Will bake the template in but create the filename after .') - ))->addOption('plugin', array( + ])->addOption('plugin', [ 'short' => 'p', 'help' => __d('cake_console', 'Plugin to bake the view into.') - ))->addOption('admin', array( + ])->addOption('admin', [ 'help' => __d('cake_console', 'Set to only bake views for a prefix in Routing.prefixes'), 'boolean' => true - ))->addOption('theme', array( + ])->addOption('theme', [ 'short' => 't', 'help' => __d('cake_console', 'Theme to use when baking code.') - ))->addOption('connection', array( + ])->addOption('connection', [ 'short' => 'c', 'help' => __d('cake_console', 'The connection the connected model is on.') - ))->addOption('force', array( + ])->addOption('force', [ 'short' => 'f', 'help' => __d('cake_console', 'Force overwriting existing files without prompting.') - ))->addSubcommand('all', array( + ])->addSubcommand('all', [ 'help' => __d('cake_console', 'Bake all CRUD action views for all controllers. Requires models and controllers to exist.') - ))->epilog( + ])->epilog( __d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.') ); @@ -458,12 +458,12 @@ public function getOptionParser() { * @return array associations */ protected function _associations(Model $model) { - $keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); - $associations = array(); + $keys = ['belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany']; + $associations = []; foreach ($keys as $type) { foreach ($model->{$type} as $assocKey => $assocData) { - list(, $modelClass) = pluginSplit($assocData['className']); + [, $modelClass] = pluginSplit($assocData['className']); $associations[$type][$assocKey]['primaryKey'] = $model->{$assocKey}->primaryKey; $associations[$type][$assocKey]['displayField'] = $model->{$assocKey}->displayField; $associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey']; diff --git a/lib/Cake/Console/Command/TestShell.php b/lib/Cake/Console/Command/TestShell.php index c9520cbd5a..48186cb7bb 100644 --- a/lib/Cake/Console/Command/TestShell.php +++ b/lib/Cake/Console/Command/TestShell.php @@ -47,121 +47,121 @@ public function getOptionParser() { $parser->description( __d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line') - )->addArgument('category', array( + )->addArgument('category', [ 'help' => __d('cake_console', 'The category for the test, or test file, to test.'), 'required' => false - ))->addArgument('file', array( + ])->addArgument('file', [ 'help' => __d('cake_console', 'The path to the file, or test file, to test.'), 'required' => false - ))->addOption('log-junit', array( + ])->addOption('log-junit', [ 'help' => __d('cake_console', ' Log test execution in JUnit XML format to file.'), 'default' => false - ))->addOption('log-json', array( + ])->addOption('log-json', [ 'help' => __d('cake_console', ' Log test execution in JSON format to file.'), 'default' => false - ))->addOption('log-tap', array( + ])->addOption('log-tap', [ 'help' => __d('cake_console', ' Log test execution in TAP format to file.'), 'default' => false - ))->addOption('log-dbus', array( + ])->addOption('log-dbus', [ 'help' => __d('cake_console', 'Log test execution to DBUS.'), 'default' => false - ))->addOption('coverage-html', array( + ])->addOption('coverage-html', [ 'help' => __d('cake_console', ' Generate code coverage report in HTML format.'), 'default' => false - ))->addOption('coverage-clover', array( + ])->addOption('coverage-clover', [ 'help' => __d('cake_console', ' Write code coverage data in Clover XML format.'), 'default' => false - ))->addOption('coverage-text', array( + ])->addOption('coverage-text', [ 'help' => __d('cake_console', 'Output code coverage report in Text format.'), 'boolean' => true - ))->addOption('testdox-html', array( + ])->addOption('testdox-html', [ 'help' => __d('cake_console', ' Write agile documentation in HTML format to file.'), 'default' => false - ))->addOption('testdox-text', array( + ])->addOption('testdox-text', [ 'help' => __d('cake_console', ' Write agile documentation in Text format to file.'), 'default' => false - ))->addOption('filter', array( + ])->addOption('filter', [ 'help' => __d('cake_console', ' Filter which tests to run.'), 'default' => false - ))->addOption('group', array( + ])->addOption('group', [ 'help' => __d('cake_console', ' Only runs tests from the specified group(s).'), 'default' => false - ))->addOption('exclude-group', array( + ])->addOption('exclude-group', [ 'help' => __d('cake_console', ' Exclude tests from the specified group(s).'), 'default' => false - ))->addOption('list-groups', array( + ])->addOption('list-groups', [ 'help' => __d('cake_console', 'List available test groups.'), 'boolean' => true - ))->addOption('loader', array( + ])->addOption('loader', [ 'help' => __d('cake_console', 'TestSuiteLoader implementation to use.'), 'default' => false - ))->addOption('repeat', array( + ])->addOption('repeat', [ 'help' => __d('cake_console', ' Runs the test(s) repeatedly.'), 'default' => false - ))->addOption('tap', array( + ])->addOption('tap', [ 'help' => __d('cake_console', 'Report test execution progress in TAP format.'), 'boolean' => true - ))->addOption('testdox', array( + ])->addOption('testdox', [ 'help' => __d('cake_console', 'Report test execution progress in TestDox format.'), 'default' => false, 'boolean' => true - ))->addOption('no-colors', array( + ])->addOption('no-colors', [ 'help' => __d('cake_console', 'Do not use colors in output.'), 'boolean' => true - ))->addOption('stderr', array( + ])->addOption('stderr', [ 'help' => __d('cake_console', 'Write to STDERR instead of STDOUT.'), 'boolean' => true - ))->addOption('stop-on-error', array( + ])->addOption('stop-on-error', [ 'help' => __d('cake_console', 'Stop execution upon first error or failure.'), 'boolean' => true - ))->addOption('stop-on-failure', array( + ])->addOption('stop-on-failure', [ 'help' => __d('cake_console', 'Stop execution upon first failure.'), 'boolean' => true - ))->addOption('stop-on-skipped', array( + ])->addOption('stop-on-skipped', [ 'help' => __d('cake_console', 'Stop execution upon first skipped test.'), 'boolean' => true - ))->addOption('stop-on-incomplete', array( + ])->addOption('stop-on-incomplete', [ 'help' => __d('cake_console', 'Stop execution upon first incomplete test.'), 'boolean' => true - ))->addOption('strict', array( + ])->addOption('strict', [ 'help' => __d('cake_console', 'Mark a test as incomplete if no assertions are made.'), 'boolean' => true - ))->addOption('wait', array( + ])->addOption('wait', [ 'help' => __d('cake_console', 'Waits for a keystroke after each test.'), 'boolean' => true - ))->addOption('process-isolation', array( + ])->addOption('process-isolation', [ 'help' => __d('cake_console', 'Run each test in a separate PHP process.'), 'boolean' => true - ))->addOption('no-globals-backup', array( + ])->addOption('no-globals-backup', [ 'help' => __d('cake_console', 'Do not backup and restore $GLOBALS for each test.'), 'boolean' => true - ))->addOption('static-backup', array( + ])->addOption('static-backup', [ 'help' => __d('cake_console', 'Backup and restore static attributes for each test.'), 'boolean' => true - ))->addOption('syntax-check', array( + ])->addOption('syntax-check', [ 'help' => __d('cake_console', 'Try to check source files for syntax errors.'), 'boolean' => true - ))->addOption('bootstrap', array( + ])->addOption('bootstrap', [ 'help' => __d('cake_console', ' A "bootstrap" PHP file that is run before the tests.'), 'default' => false - ))->addOption('configuration', array( + ])->addOption('configuration', [ 'help' => __d('cake_console', ' Read configuration from XML file.'), 'default' => false - ))->addOption('no-configuration', array( + ])->addOption('no-configuration', [ 'help' => __d('cake_console', 'Ignore default configuration file (phpunit.xml).'), 'boolean' => true - ))->addOption('include-path', array( + ])->addOption('include-path', [ 'help' => __d('cake_console', ' Prepend PHP include_path with given path(s).'), 'default' => false - ))->addOption('directive', array( + ])->addOption('directive', [ 'help' => __d('cake_console', 'key[=value] Sets a php.ini value.'), 'short' => 'd', 'default' => false - ))->addOption('fixture', array( + ])->addOption('fixture', [ 'help' => __d('cake_console', 'Choose a custom fixture manager.') - ))->addOption('debug', array( + ])->addOption('debug', [ 'help' => __d('cake_console', 'More verbose output.') - )); + ]); return $parser; } @@ -189,12 +189,12 @@ protected function _parseArgs() { if (empty($this->args)) { return null; } - $params = array( + $params = [ 'core' => false, 'app' => false, 'plugin' => null, 'output' => 'text', - ); + ]; if (strpos($this->args[0], '.php')) { $category = $this->_mapFileToCategory($this->args[0]); @@ -223,7 +223,7 @@ protected function _parseArgs() { * @return array Array of params for CakeTestDispatcher */ protected function _runnerOptions() { - $options = array(); + $options = []; $params = $this->params; unset($params['help']); unset($params['quiet']); @@ -275,7 +275,7 @@ public function main() { * @param array $options list of options as constructed by _runnerOptions() * @return void */ - protected function _run($runnerArgs, $options = array()) { + protected function _run($runnerArgs, $options = []) { restore_error_handler(); restore_error_handler(); @@ -291,8 +291,8 @@ protected function _run($runnerArgs, $options = array()) { public function available() { $params = $this->_parseArgs(); $testCases = CakeTestLoader::generateTestList($params); - $app = isset($params['app']) ? $params['app'] : null; - $plugin = isset($params['plugin']) ? $params['plugin'] : null; + $app = $params['app'] ?? null; + $plugin = $params['plugin'] ?? null; $title = "Core Test Cases:"; $category = 'core'; @@ -311,7 +311,7 @@ public function available() { $this->out($title); $i = 1; - $cases = array(); + $cases = []; foreach ($testCases as $testCase) { $case = str_replace('Test.php', '', $testCase); $this->out("[$i] $case"); @@ -350,7 +350,7 @@ public function available() { * @throws Exception */ protected function _mapFileToCase($file, $category, $throwOnMissingFile = true) { - if (!$category || (substr($file, -4) !== '.php')) { + if (!$category || (!str_ends_with($file, '.php'))) { return false; } @@ -362,7 +362,7 @@ protected function _mapFileToCase($file, $category, $throwOnMissingFile = true) $testFile = $testCase = null; $testCaseFolder = str_replace(APP, '', APP_TEST_CASES); if (preg_match('@Test[\\\/]@', $file)) { - if (substr($file, -8) === 'Test.php') { + if (str_ends_with($file, 'Test.php')) { $testCase = substr($file, 0, -8); $testCase = str_replace(DS, '/', $testCase); $testCaseFolderEscaped = str_replace('/', '\/', $testCaseFolder); @@ -425,7 +425,7 @@ protected function _mapFileToCategory($file) { } $file = str_replace(DS, '/', $file); - if (strpos($file, 'lib/Cake/') !== false) { + if (str_contains($file, 'lib/Cake/')) { return 'core'; } elseif (preg_match('@(?:plugins|Plugin)/([^/]*)@', $file, $match)) { return $match[1]; diff --git a/lib/Cake/Console/Command/TestsuiteShell.php b/lib/Cake/Console/Command/TestsuiteShell.php index 911f787c9a..60e4c0b4b5 100644 --- a/lib/Cake/Console/Command/TestsuiteShell.php +++ b/lib/Cake/Console/Command/TestsuiteShell.php @@ -39,10 +39,10 @@ class TestsuiteShell extends TestShell { public function getOptionParser() { $parser = parent::getOptionParser(); - $parser->description(array( + $parser->description([ __d('cake_console', 'The CakePHP Testsuite allows you to run test cases from the command line'), __d('cake_console', "This shell is for backwards-compatibility only\nuse the test shell instead") - )); + ]); return $parser; } @@ -56,12 +56,12 @@ protected function _parseArgs() { if (empty($this->args)) { return; } - $params = array( + $params = [ 'core' => false, 'app' => false, 'plugin' => null, 'output' => 'text', - ); + ]; $category = $this->args[0]; diff --git a/lib/Cake/Console/Command/UpgradeShell.php b/lib/Cake/Console/Command/UpgradeShell.php index c738f0e3d1..0df09d6d87 100644 --- a/lib/Cake/Console/Command/UpgradeShell.php +++ b/lib/Cake/Console/Command/UpgradeShell.php @@ -32,21 +32,21 @@ class UpgradeShell extends AppShell { * * @var array */ - protected $_files = array(); + protected $_files = []; /** * Paths * * @var array */ - protected $_paths = array(); + protected $_paths = []; /** * Map * * @var array */ - protected $_map = array( + protected $_map = [ 'Controller' => 'Controller', 'Component' => 'Controller/Component', 'Model' => 'Model', @@ -60,7 +60,7 @@ class UpgradeShell extends AppShell { 'Case' => 'Test/Case', 'Fixture' => 'Test/Fixture', 'Error' => 'Lib/Error', - ); + ]; /** * Shell startup, prints info message about dry run. @@ -101,17 +101,17 @@ public function all() { * @return void */ public function tests() { - $this->_paths = array(APP . 'tests' . DS); + $this->_paths = [APP . 'tests' . DS]; if (!empty($this->params['plugin'])) { - $this->_paths = array(CakePlugin::path($this->params['plugin']) . 'tests' . DS); + $this->_paths = [CakePlugin::path($this->params['plugin']) . 'tests' . DS]; } - $patterns = array( - array( + $patterns = [ + [ '*TestCase extends CakeTestCase to *Test extends CakeTestCase', '/([a-zA-Z]*Test)Case extends CakeTestCase/', '\1 extends CakeTestCase' - ), - ); + ], + ]; $this->_filesRegexpUpdate($patterns); } @@ -134,17 +134,17 @@ public function locations() { if (is_dir('plugins')) { $Folder = new Folder('plugins'); - list($plugins) = $Folder->read(); + [$plugins] = $Folder->read(); foreach ($plugins as $plugin) { chdir($cwd . DS . 'plugins' . DS . $plugin); $this->out(__d('cake_console', 'Upgrading locations for plugin %s', $plugin)); $this->locations(); } - $this->_files = array(); + $this->_files = []; chdir($cwd); $this->out(__d('cake_console', 'Upgrading locations for app directory')); } - $moves = array( + $moves = [ 'config' => 'Config', 'Config' . DS . 'schema' => 'Config' . DS . 'Schema', 'libs' => 'Lib', @@ -156,7 +156,7 @@ public function locations() { 'Test' . DS . 'cases' => 'Test' . DS . 'Case', 'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture', 'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates', - ); + ]; foreach ($moves as $old => $new) { if (is_dir($old)) { $this->out(__d('cake_console', 'Moving %s to %s', $old, $new)); @@ -175,30 +175,30 @@ public function locations() { $this->_moveViewFiles(); $this->_moveAppClasses(); - $sourceDirs = array( - '.' => array('recursive' => false), + $sourceDirs = [ + '.' => ['recursive' => false], 'Console', 'controllers', 'Controller', - 'Lib' => array('checkFolder' => false), + 'Lib' => ['checkFolder' => false], 'models', 'Model', 'tests', - 'Test' => array('regex' => '@class (\S*Test) extends CakeTestCase@'), + 'Test' => ['regex' => '@class (\S*Test) extends CakeTestCase@'], 'views', 'View', 'vendors/shells', - ); + ]; - $defaultOptions = array( + $defaultOptions = [ 'recursive' => true, 'checkFolder' => true, 'regex' => '@class (\S*) .*(\s|\v)*{@i' - ); + ]; foreach ($sourceDirs as $dir => $options) { if (is_numeric($dir)) { $dir = $options; - $options = array(); + $options = []; } $options += $defaultOptions; $this->_movePhpFiles($dir, $options); @@ -216,16 +216,16 @@ public function helpers() { $this->_paths = array_diff(App::path('views'), App::core('views')); if (!empty($this->params['plugin'])) { - $this->_paths = array(CakePlugin::path($this->params['plugin']) . 'views' . DS); + $this->_paths = [CakePlugin::path($this->params['plugin']) . 'views' . DS]; } - $patterns = array(); - App::build(array( + $patterns = []; + App::build([ 'View/Helper' => App::core('View/Helper'), - ), App::APPEND); + ], App::APPEND); $helpers = App::objects('helper'); $plugins = App::objects('plugin'); - $pluginHelpers = array(); + $pluginHelpers = []; foreach ($plugins as $plugin) { CakePlugin::load($plugin); $pluginHelpers = array_merge( @@ -238,11 +238,11 @@ public function helpers() { $helper = preg_replace('/Helper$/', '', $helper); $oldHelper = $helper; $oldHelper[0] = strtolower($oldHelper[0]); - $patterns[] = array( + $patterns[] = [ "\${$oldHelper} to \$this->{$helper}", "/\\\${$oldHelper}->/", "\\\$this->{$helper}->" - ); + ]; } $this->_filesRegexpUpdate($patterns); @@ -257,26 +257,26 @@ public function helpers() { * @return void */ public function i18n() { - $this->_paths = array( + $this->_paths = [ APP - ); + ]; if (!empty($this->params['plugin'])) { - $this->_paths = array(CakePlugin::path($this->params['plugin'])); + $this->_paths = [CakePlugin::path($this->params['plugin'])]; } - $patterns = array( - array( + $patterns = [ + [ '_filesRegexpUpdate($patterns); } @@ -296,49 +296,49 @@ public function i18n() { * @return void */ public function basics() { - $this->_paths = array( + $this->_paths = [ APP - ); + ]; if (!empty($this->params['plugin'])) { - $this->_paths = array(CakePlugin::path($this->params['plugin'])); + $this->_paths = [CakePlugin::path($this->params['plugin'])]; } - $patterns = array( - array( + $patterns = [ + [ 'a(*) -> array(*)', '/\ba\((.*)\)/', 'array(\1)' - ), - array( + ], + [ 'e(*) -> echo *', '/\be\((.*)\)/', 'echo \1' - ), - array( + ], + [ 'ife(*, *, *) -> !empty(*) ? * : *', '/ife\((.*), (.*), (.*)\)/', '!empty(\1) ? \2 : \3' - ), - array( + ], + [ 'r(*, *, *) -> str_replace(*, *, *)', '/\br\(/', 'str_replace(' - ), - array( + ], + [ 'up(*) -> strtoupper(*)', '/\bup\(/', 'strtoupper(' - ), - array( + ], + [ 'low(*) -> strtolower(*)', '/\blow\(/', 'strtolower(' - ), - array( + ], + [ 'getMicrotime() -> microtime(true)', '/getMicrotime\(\)/', 'microtime(true)' - ), - ); + ], + ]; $this->_filesRegexpUpdate($patterns); } @@ -349,56 +349,56 @@ public function basics() { */ public function request() { $views = array_diff(App::path('views'), App::core('views')); - $controllers = array_diff(App::path('controllers'), App::core('controllers'), array(APP)); + $controllers = array_diff(App::path('controllers'), App::core('controllers'), [APP]); $components = array_diff(App::path('components'), App::core('components')); $this->_paths = array_merge($views, $controllers, $components); if (!empty($this->params['plugin'])) { $pluginPath = CakePlugin::path($this->params['plugin']); - $this->_paths = array( + $this->_paths = [ $pluginPath . 'controllers' . DS, $pluginPath . 'controllers' . DS . 'components' . DS, $pluginPath . 'views' . DS, - ); + ]; } - $patterns = array( - array( + $patterns = [ + [ '$this->data -> $this->request->data', '/(\$this->data\b(?!\())/', '$this->request->data' - ), - array( + ], + [ '$this->params -> $this->request->params', '/(\$this->params\b(?!\())/', '$this->request->params' - ), - array( + ], + [ '$this->webroot -> $this->request->webroot', '/(\$this->webroot\b(?!\())/', '$this->request->webroot' - ), - array( + ], + [ '$this->base -> $this->request->base', '/(\$this->base\b(?!\())/', '$this->request->base' - ), - array( + ], + [ '$this->here -> $this->request->here', '/(\$this->here\b(?!\())/', '$this->request->here' - ), - array( + ], + [ '$this->action -> $this->request->action', '/(\$this->action\b(?!\())/', '$this->request->action' - ), - array( + ], + [ '$this->request->onlyAllow() -> $this->request->allowMethod()', '/\$this->request->onlyAllow\(/', '$this->request->allowMethod(' - ) - ); + ] + ]; $this->_filesRegexpUpdate($patterns); } @@ -408,19 +408,19 @@ public function request() { * @return void */ public function configure() { - $this->_paths = array( + $this->_paths = [ APP - ); + ]; if (!empty($this->params['plugin'])) { - $this->_paths = array(CakePlugin::path($this->params['plugin'])); + $this->_paths = [CakePlugin::path($this->params['plugin'])]; } - $patterns = array( - array( + $patterns = [ + [ "Configure::read() -> Configure::read('debug')", '/Configure::read\(\)/', 'Configure::read(\'debug\')' - ), - ); + ], + ]; $this->_filesRegexpUpdate($patterns); } @@ -430,79 +430,79 @@ public function configure() { * @return void */ public function constants() { - $this->_paths = array( + $this->_paths = [ APP - ); + ]; if (!empty($this->params['plugin'])) { - $this->_paths = array(CakePlugin::path($this->params['plugin'])); + $this->_paths = [CakePlugin::path($this->params['plugin'])]; } - $patterns = array( - array( + $patterns = [ + [ "LIBS -> CAKE", '/\bLIBS\b/', 'CAKE' - ), - array( + ], + [ "CONFIGS -> APP . 'Config' . DS", '/\bCONFIGS\b/', 'APP . \'Config\' . DS' - ), - array( + ], + [ "CONTROLLERS -> APP . 'Controller' . DS", '/\bCONTROLLERS\b/', 'APP . \'Controller\' . DS' - ), - array( + ], + [ "COMPONENTS -> APP . 'Controller' . DS . 'Component' . DS", '/\bCOMPONENTS\b/', 'APP . \'Controller\' . DS . \'Component\'' - ), - array( + ], + [ "MODELS -> APP . 'Model' . DS", '/\bMODELS\b/', 'APP . \'Model\' . DS' - ), - array( + ], + [ "BEHAVIORS -> APP . 'Model' . DS . 'Behavior' . DS", '/\bBEHAVIORS\b/', 'APP . \'Model\' . DS . \'Behavior\' . DS' - ), - array( + ], + [ "VIEWS -> APP . 'View' . DS", '/\bVIEWS\b/', 'APP . \'View\' . DS' - ), - array( + ], + [ "HELPERS -> APP . 'View' . DS . 'Helper' . DS", '/\bHELPERS\b/', 'APP . \'View\' . DS . \'Helper\' . DS' - ), - array( + ], + [ "LAYOUTS -> APP . 'View' . DS . 'Layouts' . DS", '/\bLAYOUTS\b/', 'APP . \'View\' . DS . \'Layouts\' . DS' - ), - array( + ], + [ "ELEMENTS -> APP . 'View' . DS . 'Elements' . DS", '/\bELEMENTS\b/', 'APP . \'View\' . DS . \'Elements\' . DS' - ), - array( + ], + [ "CONSOLE_LIBS -> CAKE . 'Console' . DS", '/\bCONSOLE_LIBS\b/', 'CAKE . \'Console\' . DS' - ), - array( + ], + [ "CAKE_TESTS_LIB -> CAKE . 'TestSuite' . DS", '/\bCAKE_TESTS_LIB\b/', 'CAKE . \'TestSuite\' . DS' - ), - array( + ], + [ "CAKE_TESTS -> CAKE . 'Test' . DS", '/\bCAKE_TESTS\b/', 'CAKE . \'Test\' . DS' - ) - ); + ] + ]; $this->_filesRegexpUpdate($patterns); } @@ -518,13 +518,13 @@ public function controller_redirects() { if (!empty($this->params['plugin'])) { $this->_paths = App::Path('Controller', $this->params['plugin']); } - $patterns = array( - array( + $patterns = [ + [ '$this->redirect() to return $this->redirect()', '/\t\$this-\>redirect\(/', "\t" . 'return $this->redirect(' - ), - ); + ], + ]; $this->_filesRegexpUpdate($patterns); } @@ -541,18 +541,18 @@ public function components() { if (!empty($this->params['plugin'])) { $this->_paths = App::Path('Controller/Component', $this->params['plugin']); } - $patterns = array( - array( + $patterns = [ + [ '*Component extends Object to *Component extends Component', '/([a-zA-Z]*Component extends) Object/', '\1 Component' - ), - array( + ], + [ '*Component extends CakeObject to *Component extends Component', '/([a-zA-Z]*Component extends) CakeObject/', '\1 Component' - ), - ); + ], + ]; $this->_filesRegexpUpdate($patterns); } @@ -564,35 +564,35 @@ public function components() { * @return void */ public function exceptions() { - $controllers = array_diff(App::path('controllers'), App::core('controllers'), array(APP)); + $controllers = array_diff(App::path('controllers'), App::core('controllers'), [APP]); $components = array_diff(App::path('components'), App::core('components')); $this->_paths = array_merge($controllers, $components); if (!empty($this->params['plugin'])) { $pluginPath = CakePlugin::path($this->params['plugin']); - $this->_paths = array( + $this->_paths = [ $pluginPath . 'controllers' . DS, $pluginPath . 'controllers' . DS . 'components' . DS, - ); + ]; } - $patterns = array( - array( + $patterns = [ + [ '$this->cakeError("error400") -> throw new BadRequestException()', '/(\$this->cakeError\(["\']error400["\']\));/', 'throw new BadRequestException();' - ), - array( + ], + [ '$this->cakeError("error404") -> throw new NotFoundException()', '/(\$this->cakeError\(["\']error404["\']\));/', 'throw new NotFoundException();' - ), - array( + ], + [ '$this->cakeError("error500") -> throw new InternalErrorException()', '/(\$this->cakeError\(["\']error500["\']\));/', 'throw new InternalErrorException();' - ), - ); + ], + ]; $this->_filesRegexpUpdate($patterns); } @@ -639,12 +639,12 @@ protected function _moveViewFiles() { * @return void */ protected function _moveAppClasses() { - $files = array( + $files = [ APP . 'app_controller.php' => APP . 'Controller' . DS . 'AppController.php', APP . 'controllers' . DS . 'app_controller.php' => APP . 'Controller' . DS . 'AppController.php', APP . 'app_model.php' => APP . 'Model' . DS . 'AppModel.php', APP . 'models' . DS . 'app_model.php' => APP . 'Model' . DS . 'AppModel.php', - ); + ]; foreach ($files as $old => $new) { if (file_exists($old)) { $this->out(__d('cake_console', 'Moving %s to %s', $old, $new)); @@ -679,14 +679,14 @@ protected function _movePhpFiles($path, $options) { $paths = $this->_paths; - $this->_paths = array($path); - $this->_files = array(); + $this->_paths = [$path]; + $this->_files = []; if ($options['recursive']) { $this->_findFiles('php'); } else { $this->_files = scandir($path); foreach ($this->_files as $i => $file) { - if (strlen($file) < 5 || substr($file, -4) !== '.php') { + if (strlen($file) < 5 || !str_ends_with($file, '.php')) { unset($this->_files[$i]); } } @@ -704,7 +704,7 @@ protected function _movePhpFiles($path, $options) { $class = $match[1]; - if (substr($class, 0, 3) === 'Dbo') { + if (str_starts_with($class, 'Dbo')) { $type = 'Dbo'; } else { preg_match('@([A-Z][^A-Z]*)$@', $class, $match); @@ -774,7 +774,7 @@ protected function _filesRegexpUpdate($patterns) { * @return void */ protected function _findFiles($extensions = '') { - $this->_files = array(); + $this->_files = []; foreach ($this->_paths as $path) { if (!is_dir($path)) { continue; @@ -821,71 +821,71 @@ protected function _updateFile($file, $patterns) { public function getOptionParser() { $parser = parent::getOptionParser(); - $subcommandParser = array( - 'options' => array( - 'plugin' => array( + $subcommandParser = [ + 'options' => [ + 'plugin' => [ 'short' => 'p', 'help' => __d('cake_console', 'The plugin to update. Only the specified plugin will be updated.') - ), - 'ext' => array( + ], + 'ext' => [ 'short' => 'e', 'help' => __d('cake_console', 'The extension(s) to search. A pipe delimited list, or a preg_match compatible subpattern'), 'default' => 'php|ctp|thtml|inc|tpl' - ), - 'git' => array( + ], + 'git' => [ 'short' => 'g', 'help' => __d('cake_console', 'Use git command for moving files around.'), 'boolean' => true - ), - 'dry-run' => array( + ], + 'dry-run' => [ 'short' => 'd', 'help' => __d('cake_console', 'Dry run the update, no files will actually be modified.'), 'boolean' => true - ) - ) - ); + ] + ] + ]; $parser->description( __d('cake_console', "A tool to help automate upgrading an application or plugin " . "from CakePHP 1.3 to 2.0. Be sure to have a backup of your application before " . "running these commands." - ))->addSubcommand('all', array( + ))->addSubcommand('all', [ 'help' => __d('cake_console', 'Run all upgrade commands.'), 'parser' => $subcommandParser - ))->addSubcommand('tests', array( + ])->addSubcommand('tests', [ 'help' => __d('cake_console', 'Update tests class names to FooTest rather than FooTestCase.'), 'parser' => $subcommandParser - ))->addSubcommand('locations', array( + ])->addSubcommand('locations', [ 'help' => __d('cake_console', 'Move files and folders to their new homes.'), 'parser' => $subcommandParser - ))->addSubcommand('i18n', array( + ])->addSubcommand('i18n', [ 'help' => __d('cake_console', 'Update the i18n translation method calls.'), 'parser' => $subcommandParser - ))->addSubcommand('helpers', array( + ])->addSubcommand('helpers', [ 'help' => __d('cake_console', 'Update calls to helpers.'), 'parser' => $subcommandParser - ))->addSubcommand('basics', array( + ])->addSubcommand('basics', [ 'help' => __d('cake_console', 'Update removed basics functions to PHP native functions.'), 'parser' => $subcommandParser - ))->addSubcommand('request', array( + ])->addSubcommand('request', [ 'help' => __d('cake_console', 'Update removed request access, and replace with $this->request.'), 'parser' => $subcommandParser - ))->addSubcommand('configure', array( + ])->addSubcommand('configure', [ 'help' => __d('cake_console', "Update Configure::read() to Configure::read('debug')"), 'parser' => $subcommandParser - ))->addSubcommand('constants', array( + ])->addSubcommand('constants', [ 'help' => __d('cake_console', "Replace Obsolete constants"), 'parser' => $subcommandParser - ))->addSubcommand('controller_redirects', array( + ])->addSubcommand('controller_redirects', [ 'help' => __d('cake_console', 'Return early on controller redirect calls.'), 'parser' => $subcommandParser - ))->addSubcommand('components', array( + ])->addSubcommand('components', [ 'help' => __d('cake_console', 'Update components to extend Component class.'), 'parser' => $subcommandParser - ))->addSubcommand('exceptions', array( + ])->addSubcommand('exceptions', [ 'help' => __d('cake_console', 'Replace use of cakeError with exceptions.'), 'parser' => $subcommandParser - )); + ]); return $parser; } diff --git a/lib/Cake/Console/ConsoleErrorHandler.php b/lib/Cake/Console/ConsoleErrorHandler.php index 3956e5ab89..3bec19f8de 100644 --- a/lib/Cake/Console/ConsoleErrorHandler.php +++ b/lib/Cake/Console/ConsoleErrorHandler.php @@ -79,7 +79,7 @@ public function handleError($code, $description, $file = null, $line = null, $co return; } $stderr = static::getStderr(); - list($name, $log) = ErrorHandler::mapErrorCode($code); + [$name, $log] = ErrorHandler::mapErrorCode($code); $message = __d('cake_console', '%s in [%s, line %s]', $description, $file, $line); $stderr->write(__d('cake_console', "%s Error: %s\n", $name, $message)); diff --git a/lib/Cake/Console/ConsoleInput.php b/lib/Cake/Console/ConsoleInput.php index dc416ce82c..39a61495cc 100644 --- a/lib/Cake/Console/ConsoleInput.php +++ b/lib/Cake/Console/ConsoleInput.php @@ -74,7 +74,7 @@ public function read() { * @return bool True for data available, false otherwise */ public function dataAvailable($timeout = 0) { - $readFds = array($this->_input); + $readFds = [$this->_input]; $readyFds = stream_select($readFds, $writeFds, $errorFds, $timeout); return ($readyFds > 0); } diff --git a/lib/Cake/Console/ConsoleInputArgument.php b/lib/Cake/Console/ConsoleInputArgument.php index 36f0855093..4e82879106 100644 --- a/lib/Cake/Console/ConsoleInputArgument.php +++ b/lib/Cake/Console/ConsoleInputArgument.php @@ -60,7 +60,7 @@ class ConsoleInputArgument { * @param bool $required Whether this argument is required. Missing required args will trigger exceptions * @param array $choices Valid choices for this option. */ - public function __construct($name, $help = '', $required = false, $choices = array()) { + public function __construct($name, $help = '', $required = false, $choices = []) { if (is_array($name) && isset($name['name'])) { foreach ($name as $key => $value) { $this->{'_' . $key} = $value; diff --git a/lib/Cake/Console/ConsoleInputOption.php b/lib/Cake/Console/ConsoleInputOption.php index 139c983539..1231ce0671 100644 --- a/lib/Cake/Console/ConsoleInputOption.php +++ b/lib/Cake/Console/ConsoleInputOption.php @@ -77,7 +77,7 @@ class ConsoleInputOption { * @param array $choices Valid choices for this option. * @throws ConsoleException */ - public function __construct($name, $short = null, $help = '', $boolean = false, $default = '', $choices = array()) { + public function __construct($name, $short = null, $help = '', $boolean = false, $default = '', $choices = []) { if (is_array($name) && isset($name['name'])) { foreach ($name as $key => $value) { $this->{'_' . $key} = $value; diff --git a/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index f313c41c96..f57b428a36 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -100,14 +100,14 @@ class ConsoleOptionParser { * @see ConsoleOptionParser::addOption() * @var array */ - protected $_options = array(); + protected $_options = []; /** * Map of short -> long options, generated when using addOption() * * @var string */ - protected $_shortOptions = array(); + protected $_shortOptions = []; /** * Positional argument definitions. @@ -115,7 +115,7 @@ class ConsoleOptionParser { * @see ConsoleOptionParser::addArgument() * @var array */ - protected $_args = array(); + protected $_args = []; /** * Subcommands for this Shell. @@ -123,7 +123,7 @@ class ConsoleOptionParser { * @see ConsoleOptionParser::addSubcommand() * @var array */ - protected $_subcommands = array(); + protected $_subcommands = []; /** * Command name. @@ -142,22 +142,22 @@ class ConsoleOptionParser { public function __construct($command = null, $defaultOptions = true) { $this->command($command); - $this->addOption('help', array( + $this->addOption('help', [ 'short' => 'h', 'help' => __d('cake_console', 'Display this help.'), 'boolean' => true - )); + ]); if ($defaultOptions) { - $this->addOption('verbose', array( + $this->addOption('verbose', [ 'short' => 'v', 'help' => __d('cake_console', 'Enable verbose output.'), 'boolean' => true - ))->addOption('quiet', array( + ])->addOption('quiet', [ 'short' => 'q', 'help' => __d('cake_console', 'Enable quiet output.'), 'boolean' => true - )); + ]); } } @@ -286,19 +286,19 @@ public function epilog($text = null) { * @param array $options An array of parameters that define the behavior of the option * @return self */ - public function addOption($name, $options = array()) { + public function addOption($name, $options = []) { if (is_object($name) && $name instanceof ConsoleInputOption) { $option = $name; $name = $option->name(); } else { - $defaults = array( + $defaults = [ 'name' => $name, 'short' => null, 'help' => '', 'default' => null, 'boolean' => false, - 'choices' => array() - ); + 'choices' => [] + ]; $options += $defaults; $option = new ConsoleInputOption($options); } @@ -326,18 +326,18 @@ public function addOption($name, $options = array()) { * @param array $params Parameters for the argument, see above. * @return self */ - public function addArgument($name, $params = array()) { + public function addArgument($name, $params = []) { if (is_object($name) && $name instanceof ConsoleInputArgument) { $arg = $name; $index = count($this->_args); } else { - $defaults = array( + $defaults = [ 'name' => $name, 'help' => '', 'index' => count($this->_args), 'required' => false, - 'choices' => array() - ); + 'choices' => [] + ]; $options = $params + $defaults; $index = $options['index']; unset($options['index']); @@ -393,16 +393,16 @@ public function addOptions(array $options) { * @param array $options Array of params, see above. * @return self */ - public function addSubcommand($name, $options = array()) { + public function addSubcommand($name, $options = []) { if (is_object($name) && $name instanceof ConsoleInputSubcommand) { $command = $name; $name = $command->name(); } else { - $defaults = array( + $defaults = [ 'name' => $name, 'help' => '', 'parser' => null - ); + ]; $options += $defaults; $command = new ConsoleInputSubcommand($options); } @@ -476,12 +476,12 @@ public function parse($argv, $command = null) { if (isset($this->_subcommands[$command]) && $this->_subcommands[$command]->parser()) { return $this->_subcommands[$command]->parser()->parse($argv); } - $params = $args = array(); + $params = $args = []; $this->_tokens = $argv; while (($token = array_shift($this->_tokens)) !== null) { - if (substr($token, 0, 2) === '--') { + if (str_starts_with($token, '--')) { $params = $this->_parseLongOption($token, $params); - } elseif (substr($token, 0, 1) === '-') { + } elseif (str_starts_with($token, '-')) { $params = $this->_parseShortOption($token, $params); } else { $args = $this->_parseArg($token, $args); @@ -506,7 +506,7 @@ public function parse($argv, $command = null) { $params[$name] = false; } } - return array($params, $args); + return [$params, $args]; } /** @@ -546,8 +546,8 @@ public function help($subcommand = null, $format = 'text', $width = 72) { */ protected function _parseLongOption($option, $params) { $name = substr($option, 2); - if (strpos($name, '=') !== false) { - list($name, $value) = explode('=', $name, 2); + if (str_contains($name, '=')) { + [$name, $value] = explode('=', $name, 2); array_unshift($this->_tokens, $value); } return $this->_parseOption($name, $params); @@ -607,7 +607,7 @@ protected function _parseOption($name, $params) { $params[$name] = $value; return $params; } - return array(); + return []; } /** @@ -617,7 +617,7 @@ protected function _parseOption($name, $params) { * @return bool */ protected function _optionExists($name) { - if (substr($name, 0, 2) === '--') { + if (str_starts_with($name, '--')) { return isset($this->_options[substr($name, 2)]); } if ($name[0] === '-' && $name[1] !== '-') { @@ -657,7 +657,7 @@ protected function _parseArg($argument, $args) { * @return string next token or '' */ protected function _nextToken() { - return isset($this->_tokens[0]) ? $this->_tokens[0] : ''; + return $this->_tokens[0] ?? ''; } } diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index 1f52df01bf..b867f00a24 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -99,7 +99,7 @@ class ConsoleOutput { * * @var array */ - protected static $_foregroundColors = array( + protected static $_foregroundColors = [ 'black' => 30, 'red' => 31, 'green' => 32, @@ -108,14 +108,14 @@ class ConsoleOutput { 'magenta' => 35, 'cyan' => 36, 'white' => 37 - ); + ]; /** * background colors used in colored output. * * @var array */ - protected static $_backgroundColors = array( + protected static $_backgroundColors = [ 'black' => 40, 'red' => 41, 'green' => 42, @@ -124,19 +124,19 @@ class ConsoleOutput { 'magenta' => 45, 'cyan' => 46, 'white' => 47 - ); + ]; /** * formatting options for colored output * * @var string */ - protected static $_options = array( + protected static $_options = [ 'bold' => 1, 'underline' => 4, 'blink' => 5, 'reverse' => 7, - ); + ]; /** * Styles that are available as tags in console output. @@ -144,19 +144,19 @@ class ConsoleOutput { * * @var array */ - protected static $_styles = array( - 'emergency' => array('text' => 'red', 'underline' => true), - 'alert' => array('text' => 'red', 'underline' => true), - 'critical' => array('text' => 'red', 'underline' => true), - 'error' => array('text' => 'red', 'underline' => true), - 'warning' => array('text' => 'yellow'), - 'info' => array('text' => 'cyan'), - 'debug' => array('text' => 'yellow'), - 'success' => array('text' => 'green'), - 'comment' => array('text' => 'blue'), - 'question' => array('text' => 'magenta'), - 'notice' => array('text' => 'cyan') - ); + protected static $_styles = [ + 'emergency' => ['text' => 'red', 'underline' => true], + 'alert' => ['text' => 'red', 'underline' => true], + 'critical' => ['text' => 'red', 'underline' => true], + 'error' => ['text' => 'red', 'underline' => true], + 'warning' => ['text' => 'yellow'], + 'info' => ['text' => 'cyan'], + 'debug' => ['text' => 'yellow'], + 'success' => ['text' => 'green'], + 'comment' => ['text' => 'blue'], + 'question' => ['text' => 'magenta'], + 'notice' => ['text' => 'cyan'] + ]; /** * Construct the output object. @@ -236,7 +236,7 @@ public function styleText($text) { return preg_replace('##', '', $text); } return preg_replace_callback( - '/<(?P[a-z0-9-_]+)>(?P.*?)<\/(\1)>/ims', array($this, '_replaceTags'), $text + '/<(?P[a-z0-9-_]+)>(?P.*?)<\/(\1)>/ims', [$this, '_replaceTags'], $text ); } @@ -252,7 +252,7 @@ protected function _replaceTags($matches) { return '<' . $matches['tag'] . '>' . $matches['text'] . ''; } - $styleInfo = array(); + $styleInfo = []; if (!empty($style['text']) && isset(static::$_foregroundColors[$style['text']])) { $styleInfo[] = static::$_foregroundColors[$style['text']]; } @@ -309,7 +309,7 @@ public function styles($style = null, $definition = null) { return static::$_styles; } if (is_string($style) && $definition === null) { - return isset(static::$_styles[$style]) ? static::$_styles[$style] : null; + return static::$_styles[$style] ?? null; } if ($definition === false) { unset(static::$_styles[$style]); diff --git a/lib/Cake/Console/HelpFormatter.php b/lib/Cake/Console/HelpFormatter.php index 0c4259aae3..6562830b2b 100644 --- a/lib/Cake/Console/HelpFormatter.php +++ b/lib/Cake/Console/HelpFormatter.php @@ -61,7 +61,7 @@ public function __construct(ConsoleOptionParser $parser) { */ public function text($width = 72) { $parser = $this->_parser; - $out = array(); + $out = []; $description = $parser->description(); if (!empty($description)) { $out[] = CakeText::wrap($description, $width); @@ -76,11 +76,11 @@ public function text($width = 72) { $out[] = ''; $max = $this->_getMaxLength($subcommands) + 2; foreach ($subcommands as $command) { - $out[] = CakeText::wrap($command->help($max), array( + $out[] = CakeText::wrap($command->help($max), [ 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 - )); + ]); } $out[] = ''; $out[] = __d('cake_console', 'To see help on a subcommand use `cake %s [subcommand] --help`', $parser->command()); @@ -93,11 +93,11 @@ public function text($width = 72) { $out[] = __d('cake_console', 'Options:'); $out[] = ''; foreach ($options as $option) { - $out[] = CakeText::wrap($option->help($max), array( + $out[] = CakeText::wrap($option->help($max), [ 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 - )); + ]); } $out[] = ''; } @@ -108,11 +108,11 @@ public function text($width = 72) { $out[] = __d('cake_console', 'Arguments:'); $out[] = ''; foreach ($arguments as $argument) { - $out[] = CakeText::wrap($argument->help($max), array( + $out[] = CakeText::wrap($argument->help($max), [ 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 - )); + ]); } $out[] = ''; } @@ -132,25 +132,25 @@ public function text($width = 72) { * @return string */ protected function _generateUsage() { - $usage = array('cake ' . $this->_parser->command()); + $usage = ['cake ' . $this->_parser->command()]; $subcommands = $this->_parser->subcommands(); if (!empty($subcommands)) { $usage[] = '[subcommand]'; } - $options = array(); + $options = []; foreach ($this->_parser->options() as $option) { $options[] = $option->usage(); } if (count($options) > $this->_maxOptions) { - $options = array('[options]'); + $options = ['[options]']; } $usage = array_merge($usage, $options); - $args = array(); + $args = []; foreach ($this->_parser->arguments() as $argument) { $args[] = $argument->usage(); } if (count($args) > $this->_maxArgs) { - $args = array('[arguments]'); + $args = ['[arguments]']; } $usage = array_merge($usage, $args); return implode(' ', $usage); diff --git a/lib/Cake/Console/Helper/BaseShellHelper.php b/lib/Cake/Console/Helper/BaseShellHelper.php index 96f12c1bb5..f52334073e 100644 --- a/lib/Cake/Console/Helper/BaseShellHelper.php +++ b/lib/Cake/Console/Helper/BaseShellHelper.php @@ -20,7 +20,7 @@ abstract class BaseShellHelper { * * @var array */ - protected $_defaultConfig = array(); + protected $_defaultConfig = []; /** * ConsoleOutput instance. @@ -34,7 +34,7 @@ abstract class BaseShellHelper { * * @var array */ - protected $_config = array(); + protected $_config = []; /** * Whether the config property has already been configured with defaults @@ -49,7 +49,7 @@ abstract class BaseShellHelper { * @param ConsoleOutput $consoleOutput The ConsoleOutput instance to use. * @param array $config The settings for this helper. */ - public function __construct(ConsoleOutput $consoleOutput, array $config = array()) { + public function __construct(ConsoleOutput $consoleOutput, array $config = []) { $this->_consoleOutput = $consoleOutput; $this->config($config); } diff --git a/lib/Cake/Console/Helper/ProgressShellHelper.php b/lib/Cake/Console/Helper/ProgressShellHelper.php index c5c615f720..dd91887e5e 100644 --- a/lib/Cake/Console/Helper/ProgressShellHelper.php +++ b/lib/Cake/Console/Helper/ProgressShellHelper.php @@ -55,7 +55,7 @@ class ProgressShellHelper extends BaseShellHelper { * @throws RuntimeException */ public function output($args) { - $args += array('callback' => null); + $args += ['callback' => null]; if (isset($args[0])) { $args['callback'] = $args[0]; } @@ -81,8 +81,8 @@ public function output($args) { * @param array $args The initialization data. * @return void */ - public function init(array $args = array()) { - $args += array('total' => 100, 'width' => 80); + public function init(array $args = []) { + $args += ['total' => 100, 'width' => 80]; $this->_progress = 0; $this->_width = $args['width']; $this->_total = $args['total']; diff --git a/lib/Cake/Console/Helper/TableShellHelper.php b/lib/Cake/Console/Helper/TableShellHelper.php index bfa52c0736..c1af26b012 100644 --- a/lib/Cake/Console/Helper/TableShellHelper.php +++ b/lib/Cake/Console/Helper/TableShellHelper.php @@ -25,11 +25,11 @@ class TableShellHelper extends BaseShellHelper { * * @var array */ - protected $_defaultConfig = array( + protected $_defaultConfig = [ 'headers' => true, 'rowSeparator' => false, 'headerStyle' => 'info', - ); + ]; /** * Calculate the column widths @@ -38,11 +38,11 @@ class TableShellHelper extends BaseShellHelper { * @return array */ protected function _calculateWidths($rows) { - $widths = array(); + $widths = []; foreach ($rows as $line) { for ($i = 0, $len = count($line); $i < $len; $i++) { $columnLength = mb_strlen($line[$i]); - if ($columnLength > (isset($widths[$i]) ? $widths[$i] : 0)) { + if ($columnLength > ($widths[$i] ?? 0)) { $widths[$i] = $columnLength; } } @@ -73,7 +73,7 @@ protected function _rowSeparator($widths) { * @param array $options Options to be passed. * @return void */ - protected function _render($row, $widths, $options = array()) { + protected function _render($row, $widths, $options = []) { $out = ''; foreach ($row as $i => $column) { $pad = $widths[$i] - mb_strlen($column); @@ -97,7 +97,7 @@ public function output($rows) { $widths = $this->_calculateWidths($rows); $this->_rowSeparator($widths); if ($config['headers'] === true) { - $this->_render(array_shift($rows), $widths, array('style' => $config['headerStyle'])); + $this->_render(array_shift($rows), $widths, ['style' => $config['headerStyle']]); $this->_rowSeparator($widths); } foreach ($rows as $line) { diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 2e9cebf257..de54b0eb8e 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -77,7 +77,7 @@ class Shell extends CakeObject { * * @var array */ - public $params = array(); + public $params = []; /** * The command (method/task) that is being run. @@ -91,7 +91,7 @@ class Shell extends CakeObject { * * @var array */ - public $args = array(); + public $args = []; /** * The name of the shell in camelized. @@ -114,14 +114,14 @@ class Shell extends CakeObject { * @var array * @link https://book.cakephp.org/2.0/en/console-and-shells.html#Shell::$tasks */ - public $tasks = array(); + public $tasks = []; /** * Contains the loaded tasks * * @var array */ - public $taskNames = array(); + public $taskNames = []; /** * Contains models to load and instantiate @@ -129,7 +129,7 @@ class Shell extends CakeObject { * @var array * @link https://book.cakephp.org/2.0/en/console-and-shells.html#Shell::$uses */ - public $uses = array(); + public $uses = []; /** * This shell's primary model class name, the first model in the $uses property @@ -150,7 +150,7 @@ class Shell extends CakeObject { * * @var string */ - protected $_taskMap = array(); + protected $_taskMap = []; /** * stdout object. @@ -186,7 +186,7 @@ class Shell extends CakeObject { * * @var array */ - protected $_helpers = array(); + protected $_helpers = []; /** * Constructs this Shell instance. @@ -198,21 +198,21 @@ class Shell extends CakeObject { */ public function __construct($stdout = null, $stderr = null, $stdin = null) { if (!$this->name) { - $this->name = Inflector::camelize(str_replace(array('Shell', 'Task'), '', get_class($this))); + $this->name = Inflector::camelize(str_replace(['Shell', 'Task'], '', static::class)); } $this->Tasks = new TaskCollection($this); - $this->stdout = $stdout ? $stdout : new ConsoleOutput('php://stdout'); - $this->stderr = $stderr ? $stderr : new ConsoleOutput('php://stderr'); - $this->stdin = $stdin ? $stdin : new ConsoleInput('php://stdin'); + $this->stdout = $stdout ?: new ConsoleOutput('php://stdout'); + $this->stderr = $stderr ?: new ConsoleOutput('php://stderr'); + $this->stdin = $stdin ?: new ConsoleInput('php://stdin'); $this->_useLogger(); $parent = get_parent_class($this); if ($this->tasks !== null && $this->tasks !== false) { - $this->_mergeVars(array('tasks'), $parent, true); + $this->_mergeVars(['tasks'], $parent, true); } if (!empty($this->uses)) { - $this->_mergeVars(array('uses'), $parent, false); + $this->_mergeVars(['uses'], $parent, false); } } @@ -264,7 +264,7 @@ protected function _welcome() { */ protected function _loadModels() { if (is_array($this->uses)) { - list(, $this->modelClass) = pluginSplit(current($this->uses)); + [, $this->modelClass] = pluginSplit(current($this->uses)); foreach ($this->uses as $modelClass) { $this->loadModel($modelClass); } @@ -281,7 +281,7 @@ protected function _loadModels() { public function __isset($name) { if (is_array($this->uses)) { foreach ($this->uses as $modelClass) { - list(, $class) = pluginSplit($modelClass); + [, $class] = pluginSplit($modelClass); if ($name === $class) { return $this->loadModel($modelClass); } @@ -302,19 +302,19 @@ public function loadModel($modelClass = null, $id = null) { $modelClass = $this->modelClass; } - $this->uses = ($this->uses) ? (array)$this->uses : array(); + $this->uses = ($this->uses) ? (array)$this->uses : []; if (!in_array($modelClass, $this->uses)) { $this->uses[] = $modelClass; } - list($plugin, $modelClass) = pluginSplit($modelClass, true); + [$plugin, $modelClass] = pluginSplit($modelClass, true); if (!isset($this->modelClass)) { $this->modelClass = $modelClass; } - $this->{$modelClass} = ClassRegistry::init(array( + $this->{$modelClass} = ClassRegistry::init([ 'class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id - )); + ]); if (!$this->{$modelClass}) { throw new MissingModelException($modelClass); } @@ -356,14 +356,14 @@ public function hasTask($task) { public function hasMethod(string $name) { try { $method = new ReflectionMethod($this, $name); - if (!$method->isPublic() || substr($name, 0, 1) === '_') { + if (!$method->isPublic() || str_starts_with($name, '_')) { return false; } if ($method->getDeclaringClass()->name === 'Shell') { return false; } return true; - } catch (ReflectionException $e) { + } catch (ReflectionException) { return false; } } @@ -429,7 +429,7 @@ public function runCommand(string $command, $argv) { $this->OptionParser = $this->getOptionParser(); try { - list($this->params, $this->args) = $this->OptionParser->parse($argv, $command); + [$this->params, $this->args] = $this->OptionParser->parse($argv, $command); } catch (ConsoleException $e) { $this->err(__d('cake_console', 'Error: %s', $e->getMessage())); $this->out($this->OptionParser->help($command)); @@ -549,7 +549,7 @@ public function in($prompt, $options = null, $default = null) { } elseif (strpos($options, '/')) { $options = explode('/', $options); } else { - $options = array($options); + $options = [$options]; } } if (is_array($options)) { @@ -615,7 +615,7 @@ protected function _getInput($prompt, $options, $default) { * @see CakeText::wrap() * @link https://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText */ - public function wrapText($text, $options = array()) { + public function wrapText($text, $options = []) { return CakeText::wrap($text, $options); } @@ -665,7 +665,7 @@ public function out($message = null, $newlines = 1, $level = Shell::NORMAL) { * @return int|bool Returns the number of bytes returned from writing to stdout. */ public function overwrite($message, $newlines = 1, $size = null) { - $size = $size ? $size : $this->_lastWritten; + $size = $size ?: $this->_lastWritten; // Output backspaces. $this->out(str_repeat("\x08", $size), 0); @@ -768,7 +768,7 @@ public function createFile($path, $contents) { if (is_file($path) && empty($this->params['force']) && $this->interactive === true) { $this->out(__d('cake_console', 'File `%s` exists', $path)); - $key = $this->in(__d('cake_console', 'Do you want to overwrite?'), array('y', 'n', 'q'), 'n'); + $key = $this->in(__d('cake_console', 'Do you want to overwrite?'), ['y', 'n', 'q'], 'n'); if (strtolower($key) === 'q') { $this->out(__d('cake_console', 'Quitting.'), 2); @@ -805,7 +805,7 @@ public function helper($name) { if (isset($this->_helpers[$name])) { return $this->_helpers[$name]; } - list($plugin, $helperClassName) = pluginSplit($name, true); + [$plugin, $helperClassName] = pluginSplit($name, true); $helperClassNameShellHelper = Inflector::camelize($helperClassName) . "ShellHelper"; App::uses($helperClassNameShellHelper, $plugin . "Console/Helper"); if (!class_exists($helperClassNameShellHelper)) { @@ -828,12 +828,12 @@ protected function _checkUnitTest() { } elseif (@include 'PHPUnit' . DS . 'Autoload.php') { //@codingStandardsIgnoreEnd return true; - } elseif (App::import('Vendor', 'phpunit', array('file' => 'PHPUnit' . DS . 'Autoload.php'))) { + } elseif (App::import('Vendor', 'phpunit', ['file' => 'PHPUnit' . DS . 'Autoload.php'])) { return true; } $prompt = __d('cake_console', 'PHPUnit is not installed. Do you want to bake unit test files anyway?'); - $unitTest = $this->in($prompt, array('y', 'n'), 'y'); + $unitTest = $this->in($prompt, ['y', 'n'], 'y'); $result = strtolower($unitTest) === 'y' || strtolower($unitTest) === 'yes'; if ($result) { @@ -987,11 +987,11 @@ protected function _useLogger($enable = true) { * @return void */ protected function _configureStdOutLogger() { - CakeLog::config('stdout', array( + CakeLog::config('stdout', [ 'engine' => 'Console', - 'types' => array('notice', 'info'), + 'types' => ['notice', 'info'], 'stream' => $this->stdout, - )); + ]); } /** @@ -1000,11 +1000,11 @@ protected function _configureStdOutLogger() { * @return void */ protected function _configureStdErrLogger() { - CakeLog::config('stderr', array( + CakeLog::config('stderr', [ 'engine' => 'Console', - 'types' => array('emergency', 'alert', 'critical', 'error', 'warning', 'debug'), + 'types' => ['emergency', 'alert', 'critical', 'error', 'warning', 'debug'], 'stream' => $this->stderr, - )); + ]); } /** diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index af3304c9a0..41cd8635d8 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -27,14 +27,14 @@ class ShellDispatcher { * * @var array */ - public $params = array(); + public $params = []; /** * Contains arguments parsed from the command line. * * @var array */ - public $args = array(); + public $args = []; /** * Constructor @@ -45,7 +45,7 @@ class ShellDispatcher { * @param array $args the argv from PHP * @param bool $bootstrap Should the environment be bootstrapped. */ - public function __construct($args = array(), $bootstrap = true) { + public function __construct($args = [], $bootstrap = true) { set_time_limit(0); $this->parseParams($args); @@ -79,7 +79,7 @@ protected function _initConstants() { } if (!defined('CAKE_CORE_INCLUDE_PATH')) { - define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__)))); + define('CAKE_CORE_INCLUDE_PATH', dirname(__FILE__, 3)); define('CAKEPHP_SHELL', true); if (!defined('DS')) { define('DS', DIRECTORY_SEPARATOR); @@ -156,7 +156,7 @@ protected function _bootstrap() { if (!defined('FULL_BASE_URL')) { $url = Configure::read('App.fullBaseUrl'); - define('FULL_BASE_URL', $url ? $url : 'http://localhost'); + define('FULL_BASE_URL', $url ?: 'http://localhost'); Configure::write('App.fullBaseUrl', FULL_BASE_URL); } @@ -178,11 +178,11 @@ public function setErrorHandlers() { $errorHandler = new ConsoleErrorHandler(); if (empty($error['consoleHandler'])) { - $error['consoleHandler'] = array($errorHandler, 'handleError'); + $error['consoleHandler'] = [$errorHandler, 'handleError']; Configure::write('Error', $error); } if (empty($exception['consoleHandler'])) { - $exception['consoleHandler'] = array($errorHandler, 'handleException'); + $exception['consoleHandler'] = [$errorHandler, 'handleException']; Configure::write('Exception', $exception); } set_exception_handler($exception['consoleHandler']); @@ -205,7 +205,7 @@ public function dispatch() { $this->help(); return false; } - if (in_array($shell, array('help', '--help', '-h'))) { + if (in_array($shell, ['help', '--help', '-h'])) { $this->help(); return true; } @@ -223,7 +223,7 @@ public function dispatch() { } $methods = array_diff(get_class_methods($Shell), get_class_methods('Shell')); $added = in_array($command, $methods); - $private = substr($command, 0, 1) === '_' && method_exists($Shell, $command); + $private = str_starts_with($command, '_') && method_exists($Shell, $command); if (!$private) { if ($added) { @@ -237,7 +237,7 @@ public function dispatch() { } } - throw new MissingShellMethodException(array('shell' => $shell, 'method' => $command)); + throw new MissingShellMethodException(['shell' => $shell, 'method' => $command]); } /** @@ -250,7 +250,7 @@ public function dispatch() { * @throws MissingShellException when errors are encountered. */ protected function _getShell($shell) { - list($plugin, $shell) = pluginSplit($shell, true); + [$plugin, $shell] = pluginSplit($shell, true); $plugin = Inflector::camelize($plugin); $class = Inflector::camelize($shell) . 'Shell'; @@ -265,9 +265,9 @@ protected function _getShell($shell) { } if (!class_exists($class)) { - throw new MissingShellException(array( + throw new MissingShellException([ 'class' => $class - )); + ]); } $Shell = new $class(); $Shell->plugin = trim($plugin, '.'); @@ -283,16 +283,16 @@ protected function _getShell($shell) { public function parseParams($args) { $this->_parsePaths($args); - $defaults = array( + $defaults = [ 'app' => 'app', - 'root' => dirname(dirname(dirname(dirname(__FILE__)))), + 'root' => dirname(__FILE__, 4), 'working' => null, 'webroot' => 'webroot' - ); + ]; $params = array_merge($defaults, array_intersect_key($this->params, $defaults)); $isWin = false; foreach ($defaults as $default => $value) { - if (!is_null($params[$default]) && strpos($params[$default], '\\') !== false) { + if (!is_null($params[$default]) && str_contains($params[$default], '\\')) { $isWin = true; break; } @@ -361,8 +361,8 @@ protected function _isWindowsPath($path) { * @return void */ protected function _parsePaths($args) { - $parsed = array(); - $keys = array('-working', '--working', '-app', '--app', '-root', '--root', '-webroot', '--webroot'); + $parsed = []; + $keys = ['-working', '--working', '-app', '--app', '-root', '--root', '-webroot', '--webroot']; $args = (array)$args; foreach ($keys as $key) { while (($index = array_search($key, $args)) !== false) { @@ -391,7 +391,7 @@ public function shiftArgs() { * @return void */ public function help() { - $this->args = array_merge(array('command_list'), $this->args); + $this->args = array_merge(['command_list'], $this->args); $this->dispatch(); } diff --git a/lib/Cake/Console/TaskCollection.php b/lib/Cake/Console/TaskCollection.php index 5d2e7a7a9a..57ed1ed4e1 100644 --- a/lib/Cake/Console/TaskCollection.php +++ b/lib/Cake/Console/TaskCollection.php @@ -67,12 +67,12 @@ public function __construct(Shell $Shell) { * @return AppShell A task object, Either the existing loaded task or a new one. * @throws MissingTaskException when the task could not be found */ - public function load($task, $settings = array()) { + public function load($task, $settings = []) { if (is_array($settings) && isset($settings['className'])) { $alias = $task; $task = $settings['className']; } - list($plugin, $name) = pluginSplit($task, true); + [$plugin, $name] = pluginSplit($task, true); if (!isset($alias)) { $alias = $name; } @@ -85,10 +85,10 @@ public function load($task, $settings = array()) { $exists = class_exists($taskClass); if (!$exists) { - throw new MissingTaskException(array( + throw new MissingTaskException([ 'class' => $taskClass, 'plugin' => substr($plugin, 0, -1) - )); + ]); } $this->_loaded[$alias] = new $taskClass( diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php b/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php index 12ad8ee98f..9658f8fbff 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php @@ -21,7 +21,7 @@ class DbAclSchema extends CakeSchema { * @param array $event The event data. * @return bool success */ - public function before($event = array()) { + public function before($event = []) { return true; } @@ -31,50 +31,50 @@ public function before($event = array()) { * @param array $event The event data. * @return void */ - public function after($event = array()) { + public function after($event = []) { } /** * ACO - Access Control Object - Something that is wanted */ - public $acos = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), - 'parent_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'model' => array('type' => 'string', 'null' => true), - 'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'alias' => array('type' => 'string', 'null' => true), - 'lft' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)) - ); + public $acos = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'], + 'parent_id' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'model' => ['type' => 'string', 'null' => true], + 'foreign_key' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'alias' => ['type' => 'string', 'null' => true], + 'lft' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'rght' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1]] + ]; /** * ARO - Access Request Object - Something that wants something */ - public $aros = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), - 'parent_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'model' => array('type' => 'string', 'null' => true), - 'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'alias' => array('type' => 'string', 'null' => true), - 'lft' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)) - ); + public $aros = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'], + 'parent_id' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'model' => ['type' => 'string', 'null' => true], + 'foreign_key' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'alias' => ['type' => 'string', 'null' => true], + 'lft' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'rght' => ['type' => 'integer', 'null' => true, 'default' => null, 'length' => 10], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1]] + ]; /** * Used by the Cake::Model:Permission class. * Checks if the given $aro has access to action $action in $aco. */ - public $aros_acos = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), - 'aro_id' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'), - 'aco_id' => array('type' => 'integer', 'null' => false, 'length' => 10), - '_create' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), - '_read' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), - '_update' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), - '_delete' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'ARO_ACO_KEY' => array('column' => array('aro_id', 'aco_id'), 'unique' => 1)) - ); + public $aros_acos = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'], + 'aro_id' => ['type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'], + 'aco_id' => ['type' => 'integer', 'null' => false, 'length' => 10], + '_create' => ['type' => 'string', 'null' => false, 'default' => '0', 'length' => 2], + '_read' => ['type' => 'string', 'null' => false, 'default' => '0', 'length' => 2], + '_update' => ['type' => 'string', 'null' => false, 'default' => '0', 'length' => 2], + '_delete' => ['type' => 'string', 'null' => false, 'default' => '0', 'length' => 2], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1], 'ARO_ACO_KEY' => ['column' => ['aro_id', 'aco_id'], 'unique' => 1]] + ]; } diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php b/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php index 63dc0db9f7..c71580b3a2 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php @@ -40,7 +40,7 @@ class I18nSchema extends CakeSchema { * @param array $event Schema object properties * @return bool Should process continue */ - public function before($event = array()) { + public function before($event = []) { return true; } @@ -50,7 +50,7 @@ public function before($event = array()) { * @param array $event Schema object properties * @return void */ - public function after($event = array()) { + public function after($event = []) { } /** @@ -58,14 +58,14 @@ public function after($event = array()) { * * @var array */ - public $i18n = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), - 'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'), - 'model' => array('type' => 'string', 'null' => false, 'key' => 'index'), - 'foreign_key' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'), - 'field' => array('type' => 'string', 'null' => false, 'key' => 'index'), - 'content' => array('type' => 'text', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0)) - ); + public $i18n = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'], + 'locale' => ['type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'], + 'model' => ['type' => 'string', 'null' => false, 'key' => 'index'], + 'foreign_key' => ['type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'], + 'field' => ['type' => 'string', 'null' => false, 'key' => 'index'], + 'content' => ['type' => 'text', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1], 'locale' => ['column' => 'locale', 'unique' => 0], 'model' => ['column' => 'model', 'unique' => 0], 'row_id' => ['column' => 'foreign_key', 'unique' => 0], 'field' => ['column' => 'field', 'unique' => 0]] + ]; } diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php b/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php index b766ebff0d..7586e00cab 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php @@ -37,7 +37,7 @@ class SessionsSchema extends CakeSchema { * @param array $event Schema object properties * @return bool Should process continue */ - public function before($event = array()) { + public function before($event = []) { return true; } @@ -47,7 +47,7 @@ public function before($event = array()) { * @param array $event Schema object properties * @return void */ - public function after($event = array()) { + public function after($event = []) { } /** @@ -55,11 +55,11 @@ public function after($event = array()) { * * @var array */ - public $cake_sessions = array( - 'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'), - 'data' => array('type' => 'text', 'null' => true, 'default' => null), - 'expires' => array('type' => 'integer', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)) - ); + public $cake_sessions = [ + 'id' => ['type' => 'string', 'null' => false, 'key' => 'primary'], + 'data' => ['type' => 'text', 'null' => true, 'default' => null], + 'expires' => ['type' => 'integer', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1]] + ]; } diff --git a/lib/Cake/Console/Templates/skel/Config/acl.php b/lib/Cake/Console/Templates/skel/Config/acl.php index 2fe93fea40..90d5f014b4 100644 --- a/lib/Cake/Console/Templates/skel/Config/acl.php +++ b/lib/Cake/Console/Templates/skel/Config/acl.php @@ -93,32 +93,32 @@ * The role map defines how to resolve the user record from your application * to the roles you defined in the roles configuration. */ -$config['map'] = array( +$config['map'] = [ 'User' => 'User/username', 'Role' => 'User/group_id', -); +]; /** * define aliases to map your model information to * the roles defined in your role configuration. */ -$config['alias'] = array( +$config['alias'] = [ 'Role/4' => 'Role/editor', -); +]; /** * role configuration */ -$config['roles'] = array( +$config['roles'] = [ 'Role/admin' => null, -); +]; /** * rule configuration */ -$config['rules'] = array( - 'allow' => array( +$config['rules'] = [ + 'allow' => [ '*' => 'Role/admin', - ), - 'deny' => array(), -); + ], + 'deny' => [], +]; diff --git a/lib/Cake/Console/Templates/skel/Config/bootstrap.php b/lib/Cake/Console/Templates/skel/Config/bootstrap.php index 6d05aabbb6..fb21ad8778 100644 --- a/lib/Cake/Console/Templates/skel/Config/bootstrap.php +++ b/lib/Cake/Console/Templates/skel/Config/bootstrap.php @@ -14,7 +14,7 @@ */ // Setup a 'default' cache configuration for use in the application. -Cache::config('default', array('engine' => 'File')); +Cache::config('default', ['engine' => 'File']); /** * The settings below can be used to set additional paths to models, views and controllers. @@ -74,22 +74,22 @@ * * )); */ -Configure::write('Dispatcher.filters', array( +Configure::write('Dispatcher.filters', [ 'AssetDispatcher', 'CacheDispatcher' -)); +]); /** * Configures default file logging options */ App::uses('CakeLog', 'Log'); -CakeLog::config('debug', array( +CakeLog::config('debug', [ 'engine' => 'File', - 'types' => array('notice', 'info', 'debug'), + 'types' => ['notice', 'info', 'debug'], 'file' => 'debug', -)); -CakeLog::config('error', array( +]); +CakeLog::config('error', [ 'engine' => 'File', - 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), + 'types' => ['warning', 'error', 'critical', 'alert', 'emergency'], 'file' => 'error', -)); +]); diff --git a/lib/Cake/Console/Templates/skel/Config/core.php b/lib/Cake/Console/Templates/skel/Config/core.php index 864777666a..b2e11f5f5b 100644 --- a/lib/Cake/Console/Templates/skel/Config/core.php +++ b/lib/Cake/Console/Templates/skel/Config/core.php @@ -39,11 +39,11 @@ * * @see ErrorHandler for more information on error handling and configuration. */ - Configure::write('Error', array( + Configure::write('Error', [ 'handler' => 'ErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, 'trace' => true - )); + ]); /** * Configure the Exception handler used for uncaught exceptions. By default, @@ -65,11 +65,11 @@ * * @see ErrorHandler for more information on exception handling and configuration. */ - Configure::write('Exception', array( + Configure::write('Exception', [ 'handler' => 'ErrorHandler::handleException', 'renderer' => 'ExceptionRenderer', 'log' => true - )); + ]); /** * Application wide charset encoding @@ -202,9 +202,9 @@ * To use database sessions, run the app/Config/Schema/sessions.php schema using * the cake shell command: cake schema create Sessions */ - Configure::write('Session', array( + Configure::write('Session', [ 'defaults' => 'php' - )); + ]); /** * A random string used in security hashing methods. @@ -342,22 +342,22 @@ * Configure the cache used for general framework caching. Path information, * object listings, and translation cache files are stored with this configuration. */ -Cache::config('_cake_core_', array( +Cache::config('_cake_core_', [ 'engine' => $engine, 'prefix' => $prefix . 'cake_core_', 'path' => CACHE . 'persistent' . DS, 'serialize' => ($engine === 'File'), 'duration' => $duration -)); +]); /** * Configure the cache for model and datasource caches. This cache configuration * is used to store schema descriptions, and table listings in connections. */ -Cache::config('_cake_model_', array( +Cache::config('_cake_model_', [ 'engine' => $engine, 'prefix' => $prefix . 'cake_model_', 'path' => CACHE . 'models' . DS, 'serialize' => ($engine === 'File'), 'duration' => $duration -)); +]); diff --git a/lib/Cake/Console/Templates/skel/Config/routes.php b/lib/Cake/Console/Templates/skel/Config/routes.php index ac19d9f515..25aadddeb1 100644 --- a/lib/Cake/Console/Templates/skel/Config/routes.php +++ b/lib/Cake/Console/Templates/skel/Config/routes.php @@ -16,11 +16,11 @@ * its action called 'display', and we pass a param to select the view file * to use (in this case, /app/View/Pages/home.ctp)... */ - Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); + Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']); /** * ...and connect the rest of 'Pages' controller's URLs. */ - Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); + Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']); /** * Load all plugin routes. See the CakePlugin documentation on diff --git a/lib/Cake/Console/Templates/skel/Console/cake.php b/lib/Cake/Console/Templates/skel/Console/cake.php index 280613a271..636ae1c61f 100644 --- a/lib/Cake/Console/Templates/skel/Console/cake.php +++ b/lib/Cake/Console/Templates/skel/Console/cake.php @@ -23,8 +23,8 @@ $dispatcher = 'Cake' . DS . 'Console' . DS . 'ShellDispatcher.php'; if (function_exists('ini_set')) { - $root = dirname(dirname(dirname(__FILE__))); - $appDir = basename(dirname(dirname(__FILE__))); + $root = dirname(__FILE__, 3); + $appDir = basename(dirname(__FILE__, 2)); $install = $root . DS . 'lib'; $composerInstall = $root . DS . $appDir . DS . 'Vendor' . DS . 'cakephp' . DS . 'cakephp' . DS . 'lib'; diff --git a/lib/Cake/Console/Templates/skel/Controller/PagesController.php b/lib/Cake/Console/Templates/skel/Controller/PagesController.php index 75df741de0..fac93f2d07 100644 --- a/lib/Cake/Console/Templates/skel/Controller/PagesController.php +++ b/lib/Cake/Console/Templates/skel/Controller/PagesController.php @@ -26,7 +26,7 @@ class PagesController extends AppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * Displays a view diff --git a/lib/Cake/Console/Templates/skel/webroot/index.php b/lib/Cake/Console/Templates/skel/webroot/index.php index 4f9a70955d..3d34ece9b8 100644 --- a/lib/Cake/Console/Templates/skel/webroot/index.php +++ b/lib/Cake/Console/Templates/skel/webroot/index.php @@ -33,14 +33,14 @@ * The full path to the directory which holds "app", WITHOUT a trailing DS. */ if (!defined('ROOT')) { - define('ROOT', dirname(dirname(dirname(__FILE__)))); + define('ROOT', dirname(__FILE__, 3)); } /** * The actual directory name for the "app". */ if (!defined('APP_DIR')) { - define('APP_DIR', basename(dirname(dirname(__FILE__)))); + define('APP_DIR', basename(dirname(__FILE__, 2))); } /** @@ -74,10 +74,10 @@ * Change at your own risk. */ if (!defined('WEBROOT_DIR')) { - define('WEBROOT_DIR', basename(dirname(__FILE__))); + define('WEBROOT_DIR', basename(__DIR__)); } if (!defined('WWW_ROOT')) { - define('WWW_ROOT', dirname(__FILE__) . DS); + define('WWW_ROOT', __DIR__ . DS); } // For the built-in server diff --git a/lib/Cake/Console/Templates/skel/webroot/test.php b/lib/Cake/Console/Templates/skel/webroot/test.php index caa2933165..a33c368b1e 100644 --- a/lib/Cake/Console/Templates/skel/webroot/test.php +++ b/lib/Cake/Console/Templates/skel/webroot/test.php @@ -27,14 +27,14 @@ * The full path to the directory which holds "app", WITHOUT a trailing DS. */ if (!defined('ROOT')) { - define('ROOT', dirname(dirname(dirname(__FILE__)))); + define('ROOT', dirname(__FILE__, 3)); } /** * The actual directory name for the "app". */ if (!defined('APP_DIR')) { - define('APP_DIR', basename(dirname(dirname(__FILE__)))); + define('APP_DIR', basename(dirname(__FILE__, 2))); } /** @@ -65,10 +65,10 @@ * Change at your own risk. */ if (!defined('WEBROOT_DIR')) { - define('WEBROOT_DIR', basename(dirname(__FILE__))); + define('WEBROOT_DIR', basename(__DIR__)); } if (!defined('WWW_ROOT')) { - define('WWW_ROOT', dirname(__FILE__) . DS); + define('WWW_ROOT', __DIR__ . DS); } if (!defined('CAKE_CORE_INCLUDE_PATH')) { diff --git a/lib/Cake/Console/cake.php b/lib/Cake/Console/cake.php index b825e02364..eaba611a65 100644 --- a/lib/Cake/Console/cake.php +++ b/lib/Cake/Console/cake.php @@ -33,8 +33,8 @@ } if (!$found) { - $rootInstall = dirname(dirname(dirname(__FILE__))) . DS . $dispatcher; - $composerInstall = dirname(dirname(__FILE__)) . DS . $dispatcher; + $rootInstall = dirname(__FILE__, 3) . DS . $dispatcher; + $composerInstall = dirname(__FILE__, 2) . DS . $dispatcher; if (file_exists($composerInstall)) { include $composerInstall; diff --git a/lib/Cake/Controller/CakeErrorController.php b/lib/Cake/Controller/CakeErrorController.php index 423dc27b8d..d6f502e837 100644 --- a/lib/Cake/Controller/CakeErrorController.php +++ b/lib/Cake/Controller/CakeErrorController.php @@ -34,7 +34,7 @@ class CakeErrorController extends AppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * Constructor @@ -56,7 +56,7 @@ public function __construct($request = null, $response = null) { if ($this->Components->enabled('Security')) { $this->Components->disable('Security'); } - $this->_set(array('cacheAction' => false, 'viewPath' => 'Errors')); + $this->_set(['cacheAction' => false, 'viewPath' => 'Errors']); } } diff --git a/lib/Cake/Controller/Component.php b/lib/Cake/Controller/Component.php index d13e575e25..d3a07c3fd9 100644 --- a/lib/Cake/Controller/Component.php +++ b/lib/Cake/Controller/Component.php @@ -46,26 +46,19 @@ class Component extends CakeObject { */ protected $_Collection; -/** - * Settings for this Component - * - * @var array - */ - public $settings = array(); - /** * Other Components this component uses. * * @var array */ - public $components = array(); + public $components = []; /** * A component lookup table used to lazy load component objects. * * @var array */ - protected $_componentMap = array(); + protected $_componentMap = []; /** * Constructor @@ -73,10 +66,12 @@ class Component extends CakeObject { * @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components * @param array $settings Array of configuration settings. */ - public function __construct(ComponentCollection $collection, $settings = array()) { + public function __construct(ComponentCollection $collection, /** + * Settings for this Component + */ + public $settings = []) { $this->_Collection = $collection; - $this->settings = $settings; - $this->_set($settings); + $this->_set($this->settings); if (!empty($this->components)) { $this->_componentMap = ComponentCollection::normalizeObjectArray($this->components); } @@ -90,7 +85,7 @@ public function __construct(ComponentCollection $collection, $settings = array() */ public function __get($name) { if (isset($this->_componentMap[$name]) && !isset($this->{$name})) { - $settings = (array)$this->_componentMap[$name]['settings'] + array('enabled' => false); + $settings = (array)$this->_componentMap[$name]['settings'] + ['enabled' => false]; $this->{$name} = $this->_Collection->load($this->_componentMap[$name]['class'], $settings); } if (isset($this->{$name})) { diff --git a/lib/Cake/Controller/Component/Acl/DbAcl.php b/lib/Cake/Controller/Component/Acl/DbAcl.php index dbbb30fef4..efd25f4ec3 100644 --- a/lib/Cake/Controller/Component/Acl/DbAcl.php +++ b/lib/Cake/Controller/Component/Acl/DbAcl.php @@ -44,7 +44,7 @@ class DbAcl extends CakeObject implements AclInterface { */ public function __construct() { parent::__construct(); - $this->Permission = ClassRegistry::init(array('class' => 'Permission', 'alias' => 'Permission')); + $this->Permission = ClassRegistry::init(['class' => 'Permission', 'alias' => 'Permission']); $this->Aro = $this->Permission->Aro; $this->Aco = $this->Permission->Aco; } diff --git a/lib/Cake/Controller/Component/Acl/PhpAcl.php b/lib/Cake/Controller/Component/Acl/PhpAcl.php index 04176763ae..aff2e0b038 100644 --- a/lib/Cake/Controller/Component/Acl/PhpAcl.php +++ b/lib/Cake/Controller/Component/Acl/PhpAcl.php @@ -45,7 +45,7 @@ class PhpAcl extends CakeObject implements AclInterface { * * @var array */ - public $options = array(); + public $options = []; /** * Aro Object @@ -67,10 +67,10 @@ class PhpAcl extends CakeObject implements AclInterface { * Sets a few default settings up. */ public function __construct() { - $this->options = array( + $this->options = [ 'policy' => static::DENY, 'config' => CONFIG . 'acl.php', - ); + ]; } /** @@ -108,11 +108,11 @@ public function build(array $config) { throw new AclException(__d('cake_dev', 'Neither "allow" nor "deny" rules were provided in configuration.')); } - $rules['allow'] = !empty($config['rules']['allow']) ? $config['rules']['allow'] : array(); - $rules['deny'] = !empty($config['rules']['deny']) ? $config['rules']['deny'] : array(); - $roles = !empty($config['roles']) ? $config['roles'] : array(); - $map = !empty($config['map']) ? $config['map'] : array(); - $alias = !empty($config['alias']) ? $config['alias'] : array(); + $rules['allow'] = !empty($config['rules']['allow']) ? $config['rules']['allow'] : []; + $rules['deny'] = !empty($config['rules']['deny']) ? $config['rules']['deny'] : []; + $roles = !empty($config['roles']) ? $config['roles'] : []; + $map = !empty($config['map']) ? $config['map'] : []; + $alias = !empty($config['alias']) ? $config['alias'] : []; $this->Aro = new PhpAro($roles, $map, $alias); $this->Aco = new PhpAco($rules); @@ -204,26 +204,26 @@ class PhpAco { * * @var array */ - protected $_tree = array(); + protected $_tree = []; /** * map modifiers for ACO paths to their respective PCRE pattern * * @var array */ - public static $modifiers = array( + public static $modifiers = [ '*' => '.*', - ); + ]; /** * Constructor * * @param array $rules Rules array */ - public function __construct(array $rules = array()) { - foreach (array('allow', 'deny') as $type) { + public function __construct(array $rules = []) { + foreach (['allow', 'deny'] as $type) { if (empty($rules[$type])) { - $rules[$type] = array(); + $rules[$type] = []; } } @@ -238,16 +238,16 @@ public function __construct(array $rules = array()) { */ public function path($aco) { $aco = $this->resolve($aco); - $path = array(); + $path = []; $level = 0; $root = $this->_tree; - $stack = array(array($root, 0)); + $stack = [[$root, 0]]; while (!empty($stack)) { - list($root, $level) = array_pop($stack); + [$root, $level] = array_pop($stack); if (empty($path[$level])) { - $path[$level] = array(); + $path[$level] = []; } foreach ($root as $node => $elements) { @@ -255,10 +255,10 @@ public function path($aco) { if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) { // merge allow/denies with $path of current level - foreach (array('allow', 'deny') as $policy) { + foreach (['allow', 'deny'] as $policy) { if (!empty($elements[$policy])) { if (empty($path[$level][$policy])) { - $path[$level][$policy] = array(); + $path[$level][$policy] = []; } $path[$level][$policy] = array_merge($path[$level][$policy], $elements[$policy]); } @@ -266,7 +266,7 @@ public function path($aco) { // traverse if (!empty($elements['children']) && isset($aco[$level + 1])) { - array_push($stack, array($elements['children'], $level + 1)); + array_push($stack, [$elements['children'], $level + 1]); } } } @@ -292,19 +292,19 @@ public function access($aro, $aco, $action, $type = 'deny') { foreach ($aco as $i => $node) { if (!isset($tree[$node])) { - $tree[$node] = array( - 'children' => array(), - ); + $tree[$node] = [ + 'children' => [], + ]; } if ($i < $depth - 1) { $tree = &$tree[$node]['children']; } else { if (empty($tree[$node][$type])) { - $tree[$node][$type] = array(); + $tree[$node][$type] = []; } - $tree[$node][$type] = array_merge(is_array($aro) ? $aro : array($aro), $tree[$node][$type]); + $tree[$node][$type] = array_merge(is_array($aro) ? $aro : [$aro], $tree[$node][$type]); } } @@ -336,8 +336,8 @@ public function resolve($aco) { * @param array $deny ACO deny rules * @return void */ - public function build(array $allow, array $deny = array()) { - $this->_tree = array(); + public function build(array $allow, array $deny = []) { + $this->_tree = []; foreach ($allow as $dotPath => $aros) { if (is_string($aros)) { @@ -383,24 +383,24 @@ class PhpAro { * @var array * @see app/Config/acl.php */ - public $map = array( + public $map = [ 'User' => 'User/username', 'Role' => 'User/role', - ); + ]; /** * aliases to map * * @var array */ - public $aliases = array(); + public $aliases = []; /** * internal ARO representation * * @var array */ - protected $_tree = array(); + protected $_tree = []; /** * Constructor @@ -409,7 +409,7 @@ class PhpAro { * @param array $map The identifier mappings * @param array $aliases The aliases to map. */ - public function __construct(array $aro = array(), array $map = array(), array $aliases = array()) { + public function __construct(array $aro = [], array $map = [], array $aliases = []) { if (!empty($map)) { $this->map = $map; } @@ -429,17 +429,17 @@ public function __construct(array $aro = array(), array $map = array(), array $a * @return array prioritized AROs */ public function roles($aro) { - $aros = array(); + $aros = []; $aro = $this->resolve($aro); - $stack = array(array($aro, 0)); + $stack = [[$aro, 0]]; while (!empty($stack)) { - list($element, $depth) = array_pop($stack); + [$element, $depth] = array_pop($stack); $aros[$depth][] = $element; foreach ($this->_tree as $node => $children) { if (in_array($element, $children)) { - array_push($stack, array($node, $depth + 1)); + array_push($stack, [$node, $depth + 1]); } } } @@ -456,7 +456,7 @@ public function roles($aro) { */ public function resolve($aro) { foreach ($this->map as $aroGroup => $map) { - list ($model, $field) = explode('/', $map, 2); + [$model, $field] = explode('/', $map, 2); $mapped = ''; if (is_array($aro)) { @@ -470,10 +470,10 @@ public function resolve($aro) { } elseif (is_string($aro)) { $aro = ltrim($aro, '/'); - if (strpos($aro, '/') === false) { + if (!str_contains($aro, '/')) { $mapped = $aroGroup . '/' . $aro; } else { - list($aroModel, $aroValue) = explode('/', $aro, 2); + [$aroModel, $aroValue] = explode('/', $aro, 2); $aroModel = Inflector::camelize($aroModel); @@ -504,7 +504,7 @@ public function resolve($aro) { public function addRole(array $aro) { foreach ($aro as $role => $inheritedRoles) { if (!isset($this->_tree[$role])) { - $this->_tree[$role] = array(); + $this->_tree[$role] = []; } if (!empty($inheritedRoles)) { @@ -528,7 +528,7 @@ public function addRole(array $aro) { } if (!isset($this->_tree[$dependency])) { - $this->_tree[$dependency] = array(); + $this->_tree[$dependency] = []; } $this->_tree[$dependency][] = $role; @@ -554,7 +554,7 @@ public function addAlias(array $alias) { * @return void */ public function build(array $aros) { - $this->_tree = array(); + $this->_tree = []; $this->addRole($aros); } diff --git a/lib/Cake/Controller/Component/AclComponent.php b/lib/Cake/Controller/Component/AclComponent.php index c6f3ec79d5..987dd9fbbd 100644 --- a/lib/Cake/Controller/Component/AclComponent.php +++ b/lib/Cake/Controller/Component/AclComponent.php @@ -57,11 +57,11 @@ class AclComponent extends Component { * @param array $settings Settings list. * @throws CakeException when Acl.classname could not be loaded. */ - public function __construct(ComponentCollection $collection, $settings = array()) { + public function __construct(ComponentCollection $collection, $settings = []) { parent::__construct($collection, $settings); $name = Configure::read('Acl.classname'); if (!class_exists($name)) { - list($plugin, $name) = pluginSplit($name, true); + [$plugin, $name] = pluginSplit($name, true); App::uses($name, $plugin . 'Controller/Component/Acl'); if (!class_exists($name)) { throw new CakeException(__d('cake_dev', 'Could not find %s.', $name)); diff --git a/lib/Cake/Controller/Component/Auth/AbstractPasswordHasher.php b/lib/Cake/Controller/Component/Auth/AbstractPasswordHasher.php index ddabbfb865..d407cdb7b9 100644 --- a/lib/Cake/Controller/Component/Auth/AbstractPasswordHasher.php +++ b/lib/Cake/Controller/Component/Auth/AbstractPasswordHasher.php @@ -26,14 +26,14 @@ abstract class AbstractPasswordHasher { * * @var array */ - protected $_config = array(); + protected $_config = []; /** * Constructor * * @param array $config Array of config. */ - public function __construct($config = array()) { + public function __construct($config = []) { $this->config($config); } diff --git a/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php index 965e5fbd7d..37727cfbda 100644 --- a/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/ActionsAuthorize.php @@ -34,7 +34,7 @@ class ActionsAuthorize extends BaseAuthorize { */ public function authorize($user, CakeRequest $request) { $Acl = $this->_Collection->load('Acl'); - $user = array($this->settings['userModel'] => $user); + $user = [$this->settings['userModel'] => $user]; return $Acl->check($user, $this->action($request)); } diff --git a/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php index 1c7e59e3c8..fb6d08d923 100644 --- a/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthenticate.php @@ -39,18 +39,18 @@ abstract class BaseAuthenticate implements CakeEventListener { * * @var array */ - public $settings = array( - 'fields' => array( + public $settings = [ + 'fields' => [ 'username' => 'username', 'password' => 'password' - ), + ], 'userModel' => 'User', 'userFields' => null, - 'scope' => array(), + 'scope' => [], 'recursive' => 0, 'contain' => null, 'passwordHasher' => 'Simple' - ); + ]; /** * A Component collection, used to get more components. @@ -72,7 +72,7 @@ abstract class BaseAuthenticate implements CakeEventListener { * @return array of events => callbacks. */ public function implementedEvents() { - return array(); + return []; } /** @@ -102,15 +102,15 @@ public function __construct(ComponentCollection $collection, $settings) { */ protected function _findUser($username, $password = null) { $userModel = $this->settings['userModel']; - list(, $model) = pluginSplit($userModel); + [, $model] = pluginSplit($userModel); $fields = $this->settings['fields']; if (is_array($username)) { $conditions = $username; } else { - $conditions = array( + $conditions = [ $model . '.' . $fields['username'] => $username - ); + ]; } if (!empty($this->settings['scope'])) { @@ -122,12 +122,12 @@ protected function _findUser($username, $password = null) { $userFields[] = $model . '.' . $fields['password']; } - $result = ClassRegistry::init($userModel)->find('first', array( + $result = ClassRegistry::init($userModel)->find('first', [ 'conditions' => $conditions, 'recursive' => $this->settings['recursive'], 'fields' => $userFields, 'contain' => $this->settings['contain'], - )); + ]); if (empty($result[$model])) { $this->passwordHasher()->hash($password); return false; @@ -157,7 +157,7 @@ public function passwordHasher() { return $this->_passwordHasher; } - $config = array(); + $config = []; if (is_string($this->settings['passwordHasher'])) { $class = $this->settings['passwordHasher']; } else { @@ -165,7 +165,7 @@ public function passwordHasher() { $config = $this->settings['passwordHasher']; unset($config['className']); } - list($plugin, $class) = pluginSplit($class, true); + [$plugin, $class] = pluginSplit($class, true); $className = $class . 'PasswordHasher'; App::uses($className, $plugin . 'Controller/Component/Auth'); if (!class_exists($className)) { diff --git a/lib/Cake/Controller/Component/Auth/BaseAuthorize.php b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php index feefb88c29..fe1c0d73db 100644 --- a/lib/Cake/Controller/Component/Auth/BaseAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/BaseAuthorize.php @@ -47,18 +47,18 @@ abstract class BaseAuthorize { * * @var array */ - public $settings = array( + public $settings = [ 'actionPath' => null, - 'actionMap' => array( + 'actionMap' => [ 'index' => 'read', 'add' => 'create', 'edit' => 'update', 'view' => 'read', 'delete' => 'delete', 'remove' => 'delete' - ), + ], 'userModel' => 'User' - ); + ]; /** * Constructor @@ -66,7 +66,7 @@ abstract class BaseAuthorize { * @param ComponentCollection $collection The controller for this request. * @param string $settings An array of settings. This class does not use any settings. */ - public function __construct(ComponentCollection $collection, $settings = array()) { + public function __construct(ComponentCollection $collection, $settings = []) { $this->_Collection = $collection; $controller = $collection->getController(); $this->controller($controller); @@ -111,8 +111,8 @@ public function controller(?Controller $controller = null) { public function action(CakeRequest $request, $path = '/:plugin/:controller/:action') { $plugin = empty($request['plugin']) ? null : Inflector::camelize($request['plugin']) . '/'; $path = str_replace( - array(':controller', ':action', ':plugin/'), - array(Inflector::camelize($request['controller']), $request['action'], $plugin), + [':controller', ':action', ':plugin/'], + [Inflector::camelize($request['controller']), $request['action'], $plugin], $this->settings['actionPath'] . $path ); $path = str_replace('//', '/', $path); @@ -150,7 +150,7 @@ public function action(CakeRequest $request, $path = '/:plugin/:controller/:acti * @return mixed Either the current mappings or null when setting. * @see AuthComponent::mapActions() */ - public function mapActions($map = array()) { + public function mapActions($map = []) { if (empty($map)) { return $this->settings['actionMap']; } diff --git a/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php index b19f23c934..ba6b64baf7 100644 --- a/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/BasicAuthenticate.php @@ -86,8 +86,8 @@ public function getUser(CakeRequest $request) { $pass = env('PHP_AUTH_PW'); if (!strlen($username)) { $httpAuthorization = $request->header('Authorization'); - if (strlen($httpAuthorization) > 0 && strpos($httpAuthorization, 'Basic') !== false) { - list($username, $pass) = explode(':', base64_decode(substr($httpAuthorization, 6))); + if (strlen($httpAuthorization) > 0 && str_contains($httpAuthorization, 'Basic')) { + [$username, $pass] = explode(':', base64_decode(substr($httpAuthorization, 6))); } } @@ -107,7 +107,7 @@ public function getUser(CakeRequest $request) { */ public function unauthenticated(CakeRequest $request, CakeResponse $response) { $Exception = new UnauthorizedException(); - $Exception->responseHeader(array($this->loginHeaders())); + $Exception->responseHeader([$this->loginHeaders()]); throw $Exception; } diff --git a/lib/Cake/Controller/Component/Auth/CrudAuthorize.php b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php index 6eb06f3336..6df463dd5d 100644 --- a/lib/Cake/Controller/Component/Auth/CrudAuthorize.php +++ b/lib/Cake/Controller/Component/Auth/CrudAuthorize.php @@ -38,7 +38,7 @@ class CrudAuthorize extends BaseAuthorize { * @param ComponentCollection $collection The component collection from the controller. * @param string $settings An array of settings. This class does not use any settings. */ - public function __construct(ComponentCollection $collection, $settings = array()) { + public function __construct(ComponentCollection $collection, $settings = []) { parent::__construct($collection, $settings); $this->_setPrefixMappings(); } @@ -49,13 +49,13 @@ public function __construct(ComponentCollection $collection, $settings = array() * @return void */ protected function _setPrefixMappings() { - $crud = array('create', 'read', 'update', 'delete'); + $crud = ['create', 'read', 'update', 'delete']; $map = array_combine($crud, $crud); $prefixes = Router::prefixes(); if (!empty($prefixes)) { foreach ($prefixes as $prefix) { - $map = array_merge($map, array( + $map = array_merge($map, [ $prefix . '_index' => 'read', $prefix . '_add' => 'create', $prefix . '_edit' => 'update', @@ -65,7 +65,7 @@ protected function _setPrefixMappings() { $prefix . '_read' => 'read', $prefix . '_update' => 'update', $prefix . '_delete' => 'delete' - )); + ]); } } $this->mapActions($map); @@ -89,7 +89,7 @@ public function authorize($user, CakeRequest $request) { ); return false; } - $user = array($this->settings['userModel'] => $user); + $user = [$this->settings['userModel'] => $user]; $Acl = $this->_Collection->load('Acl'); return $Acl->check( $user, diff --git a/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php index 04637994fd..17e98c7ed2 100644 --- a/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/DigestAuthenticate.php @@ -73,14 +73,14 @@ class DigestAuthenticate extends BasicAuthenticate { * * @var array */ - public $settings = array( - 'fields' => array( + public $settings = [ + 'fields' => [ 'username' => 'username', 'password' => 'password' - ), + ], 'userModel' => 'User', 'userFields' => null, - 'scope' => array(), + 'scope' => [], 'recursive' => 0, 'contain' => null, 'realm' => '', @@ -88,7 +88,7 @@ class DigestAuthenticate extends BasicAuthenticate { 'nonce' => '', 'opaque' => '', 'passwordHasher' => 'Simple', - ); + ]; /** * Constructor, completes configuration for digest authentication. @@ -118,10 +118,10 @@ public function getUser(CakeRequest $request) { return false; } - list(, $model) = pluginSplit($this->settings['userModel']); - $user = $this->_findUser(array( + [, $model] = pluginSplit($this->settings['userModel']); + $user = $this->_findUser([ $model . '.' . $this->settings['fields']['username'] => $digest['username'] - )); + ]); if (empty($user)) { return false; } @@ -142,7 +142,7 @@ protected function _getDigest() { $digest = env('PHP_AUTH_DIGEST'); if (empty($digest) && function_exists('apache_request_headers')) { $headers = apache_request_headers(); - if (!empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) === 'Digest ') { + if (!empty($headers['Authorization']) && str_starts_with($headers['Authorization'], 'Digest ')) { $digest = substr($headers['Authorization'], 7); } } @@ -159,11 +159,11 @@ protected function _getDigest() { * @return array|null An array of digest authentication headers */ public function parseAuthData($digest) { - if (substr($digest, 0, 7) === 'Digest ') { + if (str_starts_with($digest, 'Digest ')) { $digest = substr($digest, 7); } - $keys = $match = array(); - $req = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1); + $keys = $match = []; + $req = ['nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1]; preg_match_all('/(\w+)=([\'"]?)([a-zA-Z0-9\:\#\%\?\&@=\.\/_-]+)\2/', $digest, $match, PREG_SET_ORDER); foreach ($match as $i) { @@ -210,13 +210,13 @@ public static function password($username, $password, $realm) { * @return string Headers for logging in. */ public function loginHeaders() { - $options = array( + $options = [ 'realm' => $this->settings['realm'], 'qop' => $this->settings['qop'], 'nonce' => $this->settings['nonce'], 'opaque' => $this->settings['opaque'] - ); - $opts = array(); + ]; + $opts = []; foreach ($options as $k => $v) { $opts[] = sprintf('%s="%s"', $k, $v); } diff --git a/lib/Cake/Controller/Component/Auth/FormAuthenticate.php b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php index 849673f7ea..bbf2974392 100644 --- a/lib/Cake/Controller/Component/Auth/FormAuthenticate.php +++ b/lib/Cake/Controller/Component/Auth/FormAuthenticate.php @@ -47,7 +47,7 @@ protected function _checkFields(CakeRequest $request, $model, $fields) { if (empty($request->data[$model])) { return false; } - foreach (array($fields['username'], $fields['password']) as $field) { + foreach ([$fields['username'], $fields['password']] as $field) { $value = $request->data($model . '.' . $field); if (empty($value) && $value !== '0' || !is_string($value)) { return false; @@ -67,7 +67,7 @@ protected function _checkFields(CakeRequest $request, $model, $fields) { */ public function authenticate(CakeRequest $request, CakeResponse $response) { $userModel = $this->settings['userModel']; - list(, $model) = pluginSplit($userModel); + [, $model] = pluginSplit($userModel); $fields = $this->settings['fields']; if (!$this->_checkFields($request, $model, $fields)) { diff --git a/lib/Cake/Controller/Component/Auth/SimplePasswordHasher.php b/lib/Cake/Controller/Component/Auth/SimplePasswordHasher.php index 53e381a5a7..58f9946db9 100644 --- a/lib/Cake/Controller/Component/Auth/SimplePasswordHasher.php +++ b/lib/Cake/Controller/Component/Auth/SimplePasswordHasher.php @@ -28,7 +28,7 @@ class SimplePasswordHasher extends AbstractPasswordHasher { * * @var array */ - protected $_config = array('hashType' => null); + protected $_config = ['hashType' => null]; /** * Generates password hash. diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index f21ac5cacd..9b25e0425b 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -50,7 +50,7 @@ class AuthComponent extends Component { * * @var array */ - public $components = array('Session', 'Flash', 'RequestHandler'); + public $components = ['Session', 'Flash', 'RequestHandler']; /** * An array of authentication objects to use for authenticating users. You can configure @@ -84,14 +84,14 @@ class AuthComponent extends Component { * @var array * @link https://book.cakephp.org/2.0/en/core-libraries/components/authentication.html */ - public $authenticate = array('Form'); + public $authenticate = ['Form']; /** * Objects that will be used for authentication checks. * * @var BaseAuthenticate[] */ - protected $_authenticateObjects = array(); + protected $_authenticateObjects = []; /** * An array of authorization objects to use for authorizing users. You can configure @@ -131,7 +131,7 @@ class AuthComponent extends Component { * * @var BaseAuthorize[] */ - protected $_authorizeObjects = array(); + protected $_authorizeObjects = []; /** * The name of an optional view element to render when an Ajax request is made @@ -151,11 +151,11 @@ class AuthComponent extends Component { * * @var array */ - public $flash = array( + public $flash = [ 'element' => 'default', 'key' => 'auth', - 'params' => array() - ); + 'params' => [] + ]; /** * The session key name where the record of the current user is stored. Default @@ -172,7 +172,7 @@ class AuthComponent extends Component { * * @var array */ - protected static $_user = array(); + protected static $_user = []; /** * A URL (defined as a string or array) to the controller action that handles @@ -180,11 +180,11 @@ class AuthComponent extends Component { * * @var mixed */ - public $loginAction = array( + public $loginAction = [ 'controller' => 'users', 'action' => 'login', 'plugin' => null - ); + ]; /** * Normally, if a user is redirected to the $loginAction page, the location they @@ -234,7 +234,7 @@ class AuthComponent extends Component { * @var array * @see AuthComponent::allow() */ - public $allowedActions = array(); + public $allowedActions = []; /** * Request object @@ -255,7 +255,7 @@ class AuthComponent extends Component { * * @var array */ - protected $_methods = array(); + protected $_methods = []; /** * Initializes AuthComponent for use in the controller. @@ -308,7 +308,7 @@ public function startup(Controller $controller) { if ($this->_isLoginAction($controller) || empty($this->authorize) || - $this->isAuthorized($this->user()) + $this->isAuthorized(static::user()) ) { return true; } @@ -430,10 +430,10 @@ protected function _unauthorized(Controller $controller) { * @return bool True */ protected function _setDefaults() { - $defaults = array( + $defaults = [ 'logoutRedirect' => $this->loginAction, 'authError' => __d('cake', 'You are not authorized to access that location.') - ); + ]; foreach ($defaults as $key => $value) { if (!isset($this->{$key}) || $this->{$key} === true) { $this->{$key} = $value; @@ -454,11 +454,11 @@ protected function _setDefaults() { * @return bool True if $user is authorized, otherwise false */ public function isAuthorized($user = null, ?CakeRequest $request = null) { - if (empty($user) && !$this->user()) { + if (empty($user) && !static::user()) { return false; } if (empty($user)) { - $user = $this->user(); + $user = static::user(); } if (empty($request)) { $request = $this->request; @@ -484,15 +484,15 @@ public function constructAuthorize() { if (empty($this->authorize)) { return null; } - $this->_authorizeObjects = array(); + $this->_authorizeObjects = []; $config = Hash::normalize((array)$this->authorize); - $global = array(); + $global = []; if (isset($config[AuthComponent::ALL])) { $global = $config[AuthComponent::ALL]; unset($config[AuthComponent::ALL]); } foreach ($config as $class => $settings) { - list($plugin, $class) = pluginSplit($class, true); + [$plugin, $class] = pluginSplit($class, true); $className = $class . 'Authorize'; App::uses($className, $plugin . 'Controller/Component/Auth'); if (!class_exists($className)) { @@ -550,7 +550,7 @@ public function allow($action = null) { public function deny($action = null) { $args = func_get_args(); if (empty($args) || $action === null) { - $this->allowedActions = array(); + $this->allowedActions = []; return; } if (isset($args[0]) && is_array($args[0])) { @@ -578,11 +578,11 @@ public function deny($action = null) { * @link https://book.cakephp.org/2.0/en/core-libraries/components/authentication.html#mapping-actions-when-using-crudauthorize * @deprecated 3.0.0 Map actions using `actionMap` config key on authorize objects instead */ - public function mapActions($map = array()) { + public function mapActions($map = []) { if (empty($this->_authorizeObjects)) { $this->constructAuthorize(); } - $mappedActions = array(); + $mappedActions = []; foreach ($this->_authorizeObjects as $auth) { $mappedActions = Hash::merge($mappedActions, $auth->mapActions($map)); } @@ -590,7 +590,7 @@ public function mapActions($map = array()) { return $mappedActions; } - return array(); + return []; } /** @@ -618,10 +618,10 @@ public function login($user = null) { } else { static::$_user = $user; } - $event = new CakeEvent('Auth.afterIdentify', $this, array('user' => $user)); + $event = new CakeEvent('Auth.afterIdentify', $this, ['user' => $user]); $this->_Collection->getController()->getEventManager()->dispatch($event); } - return (bool)$this->user(); + return (bool)static::user(); } /** @@ -642,11 +642,11 @@ public function logout() { if (empty($this->_authenticateObjects)) { $this->constructAuthenticate(); } - $user = $this->user(); + $user = static::user(); foreach ($this->_authenticateObjects as $auth) { $auth->logout($user); } - static::$_user = array(); + static::$_user = []; $this->Session->delete(static::$sessionKey); $this->Session->delete('Auth.redirect'); $this->Session->renew(); @@ -685,7 +685,7 @@ public static function user($key = null) { * @return bool True if a user can be found, false if one cannot. */ protected function _getUser() { - $user = $this->user(); + $user = static::user(); if ($user) { $this->Session->delete('Auth.redirect'); return true; @@ -751,7 +751,7 @@ public function redirectUrl($url = null) { $redir = '/'; } if (is_array($redir)) { - return Router::url($redir + array('base' => false)); + return Router::url($redir + ['base' => false]); } return $redir; } @@ -787,9 +787,9 @@ public function constructAuthenticate() { if (empty($this->authenticate)) { return null; } - $this->_authenticateObjects = array(); + $this->_authenticateObjects = []; $config = Hash::normalize((array)$this->authenticate); - $global = array(); + $global = []; if (isset($config[AuthComponent::ALL])) { $global = $config[AuthComponent::ALL]; unset($config[AuthComponent::ALL]); @@ -799,7 +799,7 @@ public function constructAuthenticate() { $class = $settings['className']; unset($settings['className']); } - list($plugin, $class) = pluginSplit($class, true); + [$plugin, $class] = pluginSplit($class, true); $className = $class . 'Authenticate'; App::uses($className, $plugin . 'Controller/Component/Auth'); if (!class_exists($className)) { @@ -837,7 +837,7 @@ public static function password($password) { * @deprecated 3.0.0 Since 2.5. Use AuthComponent::user() directly. */ public function loggedIn() { - return (bool)$this->user(); + return (bool)static::user(); } /** diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index 7d07d86951..0f06d3959e 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -123,7 +123,7 @@ class CookieComponent extends Component { * @see CookieComponent::read(); * @var string */ - protected $_values = array(); + protected $_values = []; /** * Type of encryption to use. @@ -166,7 +166,7 @@ class CookieComponent extends Component { * @param ComponentCollection $collection A ComponentCollection for this component * @param array $settings Array of settings. */ - public function __construct(ComponentCollection $collection, $settings = array()) { + public function __construct(ComponentCollection $collection, $settings = []) { $this->key = Configure::read('Security.salt'); parent::__construct($collection, $settings); if (isset($this->time)) { @@ -190,7 +190,7 @@ public function __construct(ComponentCollection $collection, $settings = array() public function startup(Controller $controller) { $this->_expire($this->time); - $this->_values[$this->name] = array(); + $this->_values[$this->name] = []; } /** @@ -225,13 +225,13 @@ public function write($key, $value = null, $encrypt = true, $expires = null) { $this->_expire($expires); if (!is_array($key)) { - $key = array($key => $value); + $key = [$key => $value]; } foreach ($key as $name => $value) { - if (strpos($name, '.') !== false) { + if (str_contains($name, '.')) { $this->_values[$this->name] = Hash::insert($this->_values[$this->name], $name, $value); - list($name) = explode('.', $name, 2); + [$name] = explode('.', $name, 2); $value = $this->_values[$this->name][$name]; } else { $this->_values[$this->name][$name] = $value; @@ -256,7 +256,7 @@ public function read($key = null) { $this->_values[$this->name] = $this->_decrypt($_COOKIE[$this->name]); } if (empty($this->_values[$this->name])) { - $this->_values[$this->name] = array(); + $this->_values[$this->name] = []; } if ($key === null) { return $this->_values[$this->name]; @@ -300,12 +300,12 @@ public function delete($key) { if (empty($this->_values[$this->name])) { $this->read(); } - if (strpos($key, '.') === false) { + if (!str_contains($key, '.')) { unset($this->_values[$this->name][$key]); $this->_delete('[' . $key . ']'); } else { $this->_values[$this->name] = Hash::remove((array)$this->_values[$this->name], $key); - list($key) = explode('.', $key, 2); + [$key] = explode('.', $key, 2); if (isset($this->_values[$this->name][$key])) { $value = $this->_values[$this->name][$key]; $this->_write('[' . $key . ']', $value); @@ -341,11 +341,11 @@ public function destroy() { * @return void */ public function type($type = 'cipher') { - $availableTypes = array( + $availableTypes = [ 'cipher', 'rijndael', 'aes' - ); + ]; if (!in_array($type, $availableTypes)) { trigger_error(__d('cake_dev', 'You must use cipher, rijndael or aes for cookie encryption type'), E_USER_WARNING); $type = 'cipher'; @@ -391,7 +391,7 @@ protected function _expire($expires = null) { * @return void */ protected function _write($name, $value) { - $this->_response->cookie(array( + $this->_response->cookie([ 'name' => $this->name . $name, 'value' => $this->_encrypt($value), 'expire' => $this->_expires, @@ -399,7 +399,7 @@ protected function _write($name, $value) { 'domain' => $this->domain, 'secure' => $this->secure, 'httpOnly' => $this->httpOnly - )); + ]); if (!empty($this->_reset)) { $this->_expires = $this->_reset; @@ -414,7 +414,7 @@ protected function _write($name, $value) { * @return void */ protected function _delete($name) { - $this->_response->cookie(array( + $this->_response->cookie([ 'name' => $this->name . $name, 'value' => '', 'expire' => time() - 42000, @@ -422,7 +422,7 @@ protected function _delete($name) { 'domain' => $this->domain, 'secure' => $this->secure, 'httpOnly' => $this->httpOnly - )); + ]); } /** @@ -458,7 +458,7 @@ protected function _encrypt($value) { * @return array decrypted string */ protected function _decrypt($values) { - $decrypted = array(); + $decrypted = []; $type = $this->_type; foreach ((array)$values as $name => $value) { @@ -519,9 +519,9 @@ protected function _explode($string) { $first = substr($string, 0, 1); if ($first === '{' || $first === '[') { $ret = json_decode($string, true); - return ($ret !== null) ? $ret : $string; + return $ret ?? $string; } - $array = array(); + $array = []; foreach (explode(',', $string) as $pair) { $key = explode('|', $pair); if (!isset($key[1])) { diff --git a/lib/Cake/Controller/Component/EmailComponent.php b/lib/Cake/Controller/Component/EmailComponent.php index 4fd96dfb7f..43f654fd38 100644 --- a/lib/Cake/Controller/Component/EmailComponent.php +++ b/lib/Cake/Controller/Component/EmailComponent.php @@ -79,7 +79,7 @@ class EmailComponent extends Component { * * @var array */ - public $cc = array(); + public $cc = []; /** * Blind Carbon Copy @@ -89,7 +89,7 @@ class EmailComponent extends Component { * * @var array */ - public $bcc = array(); + public $bcc = []; /** * The date to put in the Date: header. This should be a date @@ -113,7 +113,7 @@ class EmailComponent extends Component { * * @var array */ - public $headers = array(); + public $headers = []; /** * List of additional headers @@ -187,7 +187,7 @@ class EmailComponent extends Component { * * @var array */ - public $attachments = array(); + public $attachments = []; /** * What mailer should EmailComponent identify itself as @@ -201,7 +201,7 @@ class EmailComponent extends Component { * * @var array */ - public $filePaths = array(); + public $filePaths = []; /** * List of options to use for smtp mail method @@ -216,7 +216,7 @@ class EmailComponent extends Component { * * @var array */ - public $smtpOptions = array(); + public $smtpOptions = []; /** * Contains the rendered plain text message if one was sent. @@ -258,7 +258,7 @@ class EmailComponent extends Component { * @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components * @param array $settings Array of configuration settings. */ - public function __construct(ComponentCollection $collection, $settings = array()) { + public function __construct(ComponentCollection $collection, $settings = []) { $this->_controller = $collection->getController(); parent::__construct($collection, $settings); } @@ -313,7 +313,7 @@ public function send($content = null, $template = null, $layout = null) { $lib->messageID($this->messageId); $lib->helpers($this->_controller->helpers); - $headers = array('X-Mailer' => $this->xMailer); + $headers = ['X-Mailer' => $this->xMailer]; foreach ($this->headers as $key => $value) { $headers['X-' . $key] = $value; } @@ -336,11 +336,11 @@ public function send($content = null, $template = null, $layout = null) { $lib->transport(ucfirst($this->delivery)); if ($this->delivery === 'mail') { - $lib->config(array('eol' => $this->lineFeed, 'additionalParameters' => $this->additionalParams)); + $lib->config(['eol' => $this->lineFeed, 'additionalParameters' => $this->additionalParams]); } elseif ($this->delivery === 'smtp') { $lib->config($this->smtpOptions); } else { - $lib->config(array()); + $lib->config([]); } $sent = $lib->send($content); @@ -354,8 +354,8 @@ public function send($content = null, $template = null, $layout = null) { $this->textMessage = null; } - $this->_header = array(); - $this->_message = array(); + $this->_header = []; + $this->_message = []; return $sent; } @@ -367,16 +367,16 @@ public function send($content = null, $template = null, $layout = null) { */ public function reset() { $this->template = null; - $this->to = array(); + $this->to = []; $this->from = null; $this->replyTo = null; $this->return = null; - $this->cc = array(); - $this->bcc = array(); + $this->cc = []; + $this->bcc = []; $this->subject = null; $this->additionalParams = null; $this->date = null; - $this->attachments = array(); + $this->attachments = []; $this->htmlMessage = null; $this->textMessage = null; $this->messageId = true; @@ -389,7 +389,7 @@ public function reset() { * @return array */ protected function _formatAttachFiles() { - $files = array(); + $files = []; foreach ($this->attachments as $filename => $attachment) { $file = $this->_findFiles($attachment); if (!empty($file)) { @@ -428,7 +428,7 @@ protected function _findFiles($attachment) { * @return array */ protected function _formatAddresses($addresses) { - $formatted = array(); + $formatted = []; foreach ($addresses as $address) { if (preg_match('/((.*))?\s?<(.+)>/', $address, $matches) && !empty($matches[2])) { $formatted[$this->_strip($matches[3])] = $matches[2]; diff --git a/lib/Cake/Controller/Component/FlashComponent.php b/lib/Cake/Controller/Component/FlashComponent.php index 51e40ebfb9..404e375777 100644 --- a/lib/Cake/Controller/Component/FlashComponent.php +++ b/lib/Cake/Controller/Component/FlashComponent.php @@ -34,12 +34,12 @@ class FlashComponent extends Component { * * @var array */ - protected $_defaultConfig = array( + protected $_defaultConfig = [ 'key' => 'flash', 'element' => 'default', - 'params' => array(), + 'params' => [], 'clear' => false - ); + ]; /** * Constructor @@ -47,7 +47,7 @@ class FlashComponent extends Component { * @param ComponentCollection $collection The ComponentCollection object * @param array $settings Settings passed via controller */ - public function __construct(ComponentCollection $collection, $settings = array()) { + public function __construct(ComponentCollection $collection, $settings = []) { $this->_defaultConfig = Hash::merge($this->_defaultConfig, $settings); } @@ -69,31 +69,31 @@ public function __construct(ComponentCollection $collection, $settings = array() * @return void */ - public function set($message, $options = array()) { + public function set($message, $options = []) { $options += $this->_defaultConfig; if ($message instanceof Exception) { - $options['params'] += array('code' => $message->getCode()); + $options['params'] += ['code' => $message->getCode()]; $message = $message->getMessage(); } - list($plugin, $element) = pluginSplit($options['element'], true); + [$plugin, $element] = pluginSplit($options['element'], true); if (!empty($options['plugin'])) { $plugin = $options['plugin'] . '.'; } $options['element'] = $plugin . 'Flash/' . $element; - $messages = array(); + $messages = []; if ($options['clear'] === false) { $messages = (array)CakeSession::read('Message.' . $options['key']); } - $newMessage = array( + $newMessage = [ 'message' => $message, 'key' => $options['key'], 'element' => $options['element'], 'params' => $options['params'] - ); + ]; $messages[] = $newMessage; @@ -113,7 +113,7 @@ public function set($message, $options = array()) { * @throws InternalErrorException If missing the flash message. */ public function __call($name, $args) { - $options = array('element' => Inflector::underscore($name)); + $options = ['element' => Inflector::underscore($name)]; if (count($args) < 1) { throw new InternalErrorException('Flash message missing.'); diff --git a/lib/Cake/Controller/Component/PaginatorComponent.php b/lib/Cake/Controller/Component/PaginatorComponent.php index da5417082a..4877f1a018 100644 --- a/lib/Cake/Controller/Component/PaginatorComponent.php +++ b/lib/Cake/Controller/Component/PaginatorComponent.php @@ -98,13 +98,13 @@ class PaginatorComponent extends Component { * * @var array */ - public $settings = array( + public $settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null - ); + ]; /** * A list of parameters users are allowed to set using request parameters. Modifying @@ -113,9 +113,9 @@ class PaginatorComponent extends Component { * * @var array */ - public $whitelist = array( + public $whitelist = [ 'limit', 'sort', 'page', 'direction' - ); + ]; /** * Constructor @@ -123,7 +123,7 @@ class PaginatorComponent extends Component { * @param ComponentCollection $collection A ComponentCollection this component can use to lazy load its components * @param array $settings Array of configuration settings. */ - public function __construct(ComponentCollection $collection, $settings = array()) { + public function __construct(ComponentCollection $collection, $settings = []) { $settings = array_merge($this->settings, (array)$settings); $this->Controller = $collection->getController(); parent::__construct($collection, $settings); @@ -141,7 +141,7 @@ public function __construct(ComponentCollection $collection, $settings = array() * @throws MissingModelException * @throws NotFoundException */ - public function paginate($object = null, $scope = array(), $whitelist = array()) { + public function paginate($object = null, $scope = [], $whitelist = []) { if (is_array($object)) { $whitelist = $scope; $scope = $object; @@ -161,7 +161,7 @@ public function paginate($object = null, $scope = array(), $whitelist = array()) $conditions = $fields = $order = $limit = $page = $recursive = null; if (!isset($options['conditions'])) { - $options['conditions'] = array(); + $options['conditions'] = []; } $type = 'all'; @@ -176,7 +176,7 @@ public function paginate($object = null, $scope = array(), $whitelist = array()) if (is_array($scope) && !empty($scope)) { $conditions = array_merge($conditions, $scope); } elseif (is_string($scope)) { - $conditions = array($conditions, $scope); + $conditions = [$conditions, $scope]; } if ($recursive === null) { $recursive = $object->recursive; @@ -231,7 +231,7 @@ public function paginate($object = null, $scope = array(), $whitelist = array()) $requestedPage = $page; $page = max(min($page, $pageCount), 1); - $paging = array( + $paging = [ 'page' => $page, 'current' => count($results), 'count' => $count, @@ -243,14 +243,14 @@ public function paginate($object = null, $scope = array(), $whitelist = array()) 'options' => Hash::diff($options, $defaults), 'paramType' => $options['paramType'], 'queryScope' => $options['queryScope'], - ); + ]; if (!isset($this->Controller->request['paging'])) { - $this->Controller->request['paging'] = array(); + $this->Controller->request['paging'] = []; } $this->Controller->request['paging'] = array_merge( (array)$this->Controller->request['paging'], - array($object->alias => $paging) + [$object->alias => $paging] ); if ($requestedPage > $page) { @@ -274,8 +274,8 @@ public function paginate($object = null, $scope = array(), $whitelist = array()) protected function _getObject($object) { if (is_string($object)) { $assoc = null; - if (strpos($object, '.') !== false) { - list($object, $assoc) = pluginSplit($object); + if (str_contains($object, '.')) { + [$object, $assoc] = pluginSplit($object); } if ($assoc && isset($this->Controller->{$object}->{$assoc})) { return $this->Controller->{$object}->{$assoc}; @@ -297,8 +297,8 @@ protected function _getObject($object) { $className = null; $name = $this->Controller->uses[0]; - if (strpos($this->Controller->uses[0], '.') !== false) { - list($name, $className) = explode('.', $this->Controller->uses[0]); + if (str_contains($this->Controller->uses[0], '.')) { + [$name, $className] = explode('.', $this->Controller->uses[0]); } if ($className) { return $this->Controller->{$className}; @@ -335,7 +335,7 @@ public function mergeOptions($alias) { break; } if ($defaults['queryScope']) { - $request = Hash::get($request, $defaults['queryScope'], array()); + $request = Hash::get($request, $defaults['queryScope'], []); } $request = array_intersect_key($request, array_flip($this->whitelist)); return array_merge($defaults, $request); @@ -353,13 +353,13 @@ public function getDefaults($alias) { if (isset($this->settings[$alias])) { $defaults = $this->settings[$alias]; } - $defaults += array( + $defaults += [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null - ); + ]; return $defaults; } @@ -379,7 +379,7 @@ public function getDefaults($alias) { * @param array $whitelist The list of columns that can be used for sorting. If empty all keys are allowed. * @return array An array of options with sort + direction removed and replaced with order if possible. */ - public function validateSort(Model $object, array $options, array $whitelist = array()) { + public function validateSort(Model $object, array $options, array $whitelist = []) { if (empty($options['order']) && is_array($object->order)) { $options['order'] = $object->order; } @@ -389,10 +389,10 @@ public function validateSort(Model $object, array $options, array $whitelist = a if (isset($options['direction'])) { $direction = strtolower($options['direction']); } - if (!in_array($direction, array('asc', 'desc'))) { + if (!in_array($direction, ['asc', 'desc'])) { $direction = 'asc'; } - $options['order'] = array($options['sort'] => $direction); + $options['order'] = [$options['sort'] => $direction]; } if (!empty($whitelist) && isset($options['order']) && is_array($options['order'])) { @@ -404,7 +404,7 @@ public function validateSort(Model $object, array $options, array $whitelist = a return $options; } if (!empty($options['order']) && is_array($options['order'])) { - $order = array(); + $order = []; foreach ($options['order'] as $key => $value) { if (is_int($key)) { $field = explode(' ', $value); @@ -413,8 +413,8 @@ public function validateSort(Model $object, array $options, array $whitelist = a } $field = $key; $alias = $object->alias; - if (strpos($key, '.') !== false) { - list($alias, $field) = explode('.', $key); + if (str_contains($key, '.')) { + [$alias, $field] = explode('.', $key); } $correctAlias = ($object->alias === $alias); diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index 513af4029e..ce48c8f064 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -92,9 +92,9 @@ class RequestHandlerComponent extends Component { * * @var array */ - protected $_inputTypeMap = array( - 'json' => array('json_decode', true) - ); + protected $_inputTypeMap = [ + 'json' => ['json_decode', true] + ]; /** * A mapping between type and viewClass @@ -102,10 +102,10 @@ class RequestHandlerComponent extends Component { * * @var array */ - protected $_viewClassMap = array( + protected $_viewClassMap = [ 'json' => 'Json', 'xml' => 'Xml' - ); + ]; /** * Constructor. Parses the accepted content types accepted by the client using HTTP_ACCEPT @@ -113,9 +113,9 @@ class RequestHandlerComponent extends Component { * @param ComponentCollection $collection ComponentCollection object. * @param array $settings Array of settings. */ - public function __construct(ComponentCollection $collection, $settings = array()) { - parent::__construct($collection, $settings + array('checkHttpCache' => true)); - $this->addInputType('xml', array(array($this, 'convertXml'))); + public function __construct(ComponentCollection $collection, $settings = []) { + parent::__construct($collection, $settings + ['checkHttpCache' => true]); + $this->addInputType('xml', [[$this, 'convertXml']]); $Controller = $collection->getController(); $this->request = $Controller->request; @@ -167,7 +167,7 @@ protected function _setExtension() { $accepts = $this->response->mapType($accept); $preferedTypes = current($accepts); - if (array_intersect($preferedTypes, array('html', 'xhtml'))) { + if (array_intersect($preferedTypes, ['html', 'xhtml'])) { return; } @@ -206,7 +206,7 @@ protected function _setExtension() { public function startup(Controller $controller) { $controller->request->params['isAjax'] = $this->request->is('ajax'); $isRecognized = ( - !in_array($this->ext, array('html', 'htm')) && + !in_array($this->ext, ['html', 'htm']) && $this->response->getMimeType($this->ext) ); @@ -214,13 +214,13 @@ public function startup(Controller $controller) { $this->renderAs($controller, $this->ext); } elseif ($this->request->is('ajax')) { $this->renderAs($controller, 'ajax'); - } elseif (empty($this->ext) || in_array($this->ext, array('html', 'htm'))) { - $this->respondAs('html', array('charset' => Configure::read('App.encoding'))); + } elseif (empty($this->ext) || in_array($this->ext, ['html', 'htm'])) { + $this->respondAs('html', ['charset' => Configure::read('App.encoding')]); } foreach ($this->_inputTypeMap as $type => $handler) { if ($this->requestedWith($type)) { - $input = (array)call_user_func_array(array($controller->request, 'input'), $handler); + $input = (array)call_user_func_array([$controller->request, 'input'], $handler); $controller->request->data = $input; } } @@ -235,13 +235,13 @@ public function startup(Controller $controller) { */ public function convertXml($xml) { try { - $xml = Xml::build($xml, array('readFile' => false)); + $xml = Xml::build($xml, ['readFile' => false]); if (isset($xml->data)) { return Xml::toArray($xml->data); } return Xml::toArray($xml); - } catch (XmlException $e) { - return array(); + } catch (XmlException) { + return []; } } @@ -267,7 +267,7 @@ public function beforeRedirect(Controller $controller, $url, $status = null, $ex unset($_POST[$key]); } if (is_array($url)) { - $url = Router::url($url + array('base' => false)); + $url = Router::url($url + ['base' => false]); } if (!empty($status)) { $statusCode = $this->response->httpCodes($status); @@ -276,7 +276,7 @@ public function beforeRedirect(Controller $controller, $url, $status = null, $ex $this->response->statusCode($code); } } - $this->response->body($this->requestAction($url, array('return', 'bare' => false))); + $this->response->body($this->requestAction($url, ['return', 'bare' => false])); $this->response->send(); $this->_stop(); } @@ -420,7 +420,7 @@ public function isDelete() { */ public function getAjaxVersion() { $httpX = env('HTTP_X_PROTOTYPE_VERSION'); - return ($httpX === null) ? false : $httpX; + return $httpX ?? false; } /** @@ -436,7 +436,7 @@ public function getAjaxVersion() { * @deprecated 3.0.0 Use `$this->response->type()` instead. */ public function setContent($name, $type = null) { - $this->response->type(array($name => $type)); + $this->response->type([$name => $type]); } /** @@ -531,9 +531,9 @@ public function requestedWith($type = null) { return false; } - list($contentType) = explode(';', env('CONTENT_TYPE') ?? ''); + [$contentType] = explode(';', env('CONTENT_TYPE') ?? ''); if ($contentType === '') { - list($contentType) = explode(';', CakeRequest::header('CONTENT_TYPE')); + [$contentType] = explode(';', CakeRequest::header('CONTENT_TYPE')); } if (!$type) { return $this->mapType($contentType); @@ -611,8 +611,8 @@ public function prefers($type = null) { * @see RequestHandlerComponent::setContent() * @see RequestHandlerComponent::respondAs() */ - public function renderAs(Controller $controller, $type, $options = array()) { - $defaults = array('charset' => 'UTF-8'); + public function renderAs(Controller $controller, $type, $options = []) { + $defaults = ['charset' => 'UTF-8']; if (Configure::read('App.encoding') !== null) { $defaults['charset'] = Configure::read('App.encoding'); @@ -627,7 +627,7 @@ public function renderAs(Controller $controller, $type, $options = array()) { $pluginDot = null; $viewClassMap = $this->viewClassMap(); if (array_key_exists($type, $viewClassMap)) { - list($pluginDot, $viewClass) = pluginSplit($viewClassMap[$type], true); + [$pluginDot, $viewClass] = pluginSplit($viewClassMap[$type], true); } else { $viewClass = Inflector::classify($type); } @@ -677,12 +677,12 @@ public function renderAs(Controller $controller, $type, $options = array()) { * already been set by this method. * @see RequestHandlerComponent::setContent() */ - public function respondAs($type, $options = array()) { - $defaults = array('index' => null, 'charset' => null, 'attachment' => false); + public function respondAs($type, $options = []) { + $defaults = ['index' => null, 'charset' => null, 'attachment' => false]; $options = $options + $defaults; $cType = $type; - if (strpos($type, '/') === false) { + if (!str_contains($type, '/')) { $cType = $this->response->getMimeType($type); } if (is_array($cType)) { @@ -742,7 +742,7 @@ public function mapType($cType) { */ public function mapAlias($alias) { if (is_array($alias)) { - return array_map(array($this, 'mapAlias'), $alias); + return array_map([$this, 'mapAlias'], $alias); } $type = $this->response->getMimeType($alias); if ($type) { diff --git a/lib/Cake/Controller/Component/SecurityComponent.php b/lib/Cake/Controller/Component/SecurityComponent.php index e9d779e76a..2bb237f76c 100644 --- a/lib/Cake/Controller/Component/SecurityComponent.php +++ b/lib/Cake/Controller/Component/SecurityComponent.php @@ -55,7 +55,7 @@ class SecurityComponent extends Component { * @deprecated 3.0.0 Use CakeRequest::allowMethod() instead. * @see SecurityComponent::requirePost() */ - public $requirePost = array(); + public $requirePost = []; /** * List of controller actions for which a GET request is required @@ -64,7 +64,7 @@ class SecurityComponent extends Component { * @deprecated 3.0.0 Use CakeRequest::allowMethod() instead. * @see SecurityComponent::requireGet() */ - public $requireGet = array(); + public $requireGet = []; /** * List of controller actions for which a PUT request is required @@ -73,7 +73,7 @@ class SecurityComponent extends Component { * @deprecated 3.0.0 Use CakeRequest::allowMethod() instead. * @see SecurityComponent::requirePut() */ - public $requirePut = array(); + public $requirePut = []; /** * List of controller actions for which a DELETE request is required @@ -82,7 +82,7 @@ class SecurityComponent extends Component { * @deprecated 3.0.0 Use CakeRequest::allowMethod() instead. * @see SecurityComponent::requireDelete() */ - public $requireDelete = array(); + public $requireDelete = []; /** * List of actions that require an SSL-secured connection @@ -90,7 +90,7 @@ class SecurityComponent extends Component { * @var array * @see SecurityComponent::requireSecure() */ - public $requireSecure = array(); + public $requireSecure = []; /** * List of actions that require a valid authentication key @@ -99,7 +99,7 @@ class SecurityComponent extends Component { * @see SecurityComponent::requireAuth() * @deprecated 2.8.1 This feature is confusing and not useful. */ - public $requireAuth = array(); + public $requireAuth = []; /** * Controllers from which actions of the current controller are allowed to receive @@ -108,7 +108,7 @@ class SecurityComponent extends Component { * @var array * @see SecurityComponent::requireAuth() */ - public $allowedControllers = array(); + public $allowedControllers = []; /** * Actions from which actions of the current controller are allowed to receive @@ -117,7 +117,7 @@ class SecurityComponent extends Component { * @var array * @see SecurityComponent::requireAuth() */ - public $allowedActions = array(); + public $allowedActions = []; /** * Deprecated property, superseded by unlockedFields. @@ -126,7 +126,7 @@ class SecurityComponent extends Component { * @deprecated 3.0.0 Superseded by unlockedFields. * @see SecurityComponent::$unlockedFields */ - public $disabledFields = array(); + public $disabledFields = []; /** * Form fields to exclude from POST validation. Fields can be unlocked @@ -136,7 +136,7 @@ class SecurityComponent extends Component { * * @var array */ - public $unlockedFields = array(); + public $unlockedFields = []; /** * Actions to exclude from CSRF and POST validation checks. @@ -145,7 +145,7 @@ class SecurityComponent extends Component { * * @var array */ - public $unlockedActions = array(); + public $unlockedActions = []; /** * Whether to validate POST data. Set to false to disable for data coming from 3rd party @@ -201,7 +201,7 @@ class SecurityComponent extends Component { * * @var array */ - public $components = array('Session'); + public $components = ['Session']; /** * Holds the current action of the controller @@ -348,7 +348,7 @@ public function blackHole(Controller $controller, $error = '', ?SecurityExceptio if (!$this->blackHoleCallback) { $this->_throwException($exception); } - return $this->_callback($controller, $this->blackHoleCallback, array($error)); + return $this->_callback($controller, $this->blackHoleCallback, [$error]); } /** @@ -376,11 +376,11 @@ protected function _throwException($exception = null) { * @param array $actions Controller actions to set the required HTTP method to. * @return void */ - protected function _requireMethod($method, $actions = array()) { + protected function _requireMethod($method, $actions = []) { if (isset($actions[0]) && is_array($actions[0])) { $actions = $actions[0]; } - $this->{'require' . $method} = (empty($actions)) ? array('*') : $actions; + $this->{'require' . $method} = (empty($actions)) ? ['*'] : $actions; } /** @@ -391,11 +391,11 @@ protected function _requireMethod($method, $actions = array()) { * @return bool True if $method is required */ protected function _methodsRequired(Controller $controller) { - foreach (array('Post', 'Get', 'Put', 'Delete') as $method) { + foreach (['Post', 'Get', 'Put', 'Delete'] as $method) { $property = 'require' . $method; if (is_array($this->$property) && !empty($this->$property)) { $require = $this->$property; - if (in_array($this->_action, $require) || $this->$property === array('*')) { + if (in_array($this->_action, $require) || $this->$property === ['*']) { if (!$controller->request->is($method)) { throw new SecurityException( sprintf('The request method must be %s', strtoupper($method)) @@ -418,7 +418,7 @@ protected function _secureRequired(Controller $controller) { if (is_array($this->requireSecure) && !empty($this->requireSecure)) { $requireSecure = $this->requireSecure; - if (in_array($this->_action, $requireSecure) || $this->requireSecure === array('*')) { + if (in_array($this->_action, $requireSecure) || $this->requireSecure === ['*']) { if (!$controller->request->is('ssl')) { throw new SecurityException( 'Request is not SSL and the action is required to be secure' @@ -441,7 +441,7 @@ protected function _authRequired(Controller $controller) { if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($controller->request->data)) { $requireAuth = $this->requireAuth; - if (in_array($controller->request->params['action'], $requireAuth) || $this->requireAuth === array('*')) { + if (in_array($controller->request->params['action'], $requireAuth) || $this->requireAuth === ['*']) { if (!isset($controller->request->data['_Token'])) { throw new AuthSecurityException('\'_Token\' was not found in request data.'); } @@ -533,7 +533,7 @@ protected function _validToken(Controller $controller) { $token = urldecode($check['_Token']['fields']); if (strpos($token, ':')) { - list($token, ) = explode(':', $token, 2); + [$token, ] = explode(':', $token, 2); } return $token; @@ -549,12 +549,12 @@ protected function _hashParts(Controller $controller) { $fieldList = $this->_fieldsList($controller->request->data); $unlocked = $this->_sortedUnlocked($controller->request->data); - return array( + return [ $controller->request->here(), serialize($fieldList), $unlocked, Configure::read('Security.salt') - ); + ]; } /** @@ -569,7 +569,7 @@ protected function _fieldsList(array $check) { $unlocked = $this->_unlocked($check); if (strpos($token, ':')) { - list($token, $locked) = explode(':', $token, 2); + [$token, $locked] = explode(':', $token, 2); } unset($check['_Token'], $check['_csrfToken']); @@ -578,7 +578,7 @@ protected function _fieldsList(array $check) { $fields = Hash::flatten($check); $fieldList = array_keys($fields); - $multi = $lockedFields = array(); + $multi = $lockedFields = []; $isUnlocked = false; foreach ($fieldList as $i => $key) { @@ -657,7 +657,7 @@ protected function _sortedUnlocked($data) { * @return string Message explaining why the tokens are not matching */ protected function _debugPostTokenNotMatching(Controller $controller, $hashParts) { - $messages = array(); + $messages = []; $expectedParts = json_decode(urldecode($controller->request->data['_Token']['debug']), true); if (!is_array($expectedParts) || count($expectedParts) !== 3) { return 'Invalid security debug token.'; @@ -680,7 +680,7 @@ protected function _debugPostTokenNotMatching(Controller $controller, $hashParts 'Missing field \'%s\' in POST data' ); $expectedUnlockedFields = Hash::get($expectedParts, 2); - $dataUnlockedFields = Hash::get($hashParts, 2) ?: array(); + $dataUnlockedFields = Hash::get($hashParts, 2) ?: []; if ($dataUnlockedFields) { $dataUnlockedFields = explode('|', $dataUnlockedFields); } @@ -707,7 +707,7 @@ protected function _debugPostTokenNotMatching(Controller $controller, $hashParts * @param string $missingMessage Message string if missing field * @return array Messages */ - protected function _debugCheckFields($dataFields, $expectedFields = array(), $intKeyMessage = '', $stringKeyMessage = '', $missingMessage = '') { + protected function _debugCheckFields($dataFields, $expectedFields = [], $intKeyMessage = '', $stringKeyMessage = '', $missingMessage = '') { $messages = $this->_matchExistingFields($dataFields, $expectedFields, $intKeyMessage, $stringKeyMessage); $expectedFieldsMessage = $this->_debugExpectedFields($expectedFields, $missingMessage); if ($expectedFieldsMessage !== null) { @@ -731,15 +731,15 @@ public function generateToken(CakeRequest $request) { return false; } $authKey = hash('sha512', Security::randomBytes(16), false); - $token = array( + $token = [ 'key' => $authKey, 'allowedControllers' => $this->allowedControllers, 'allowedActions' => $this->allowedActions, 'unlockedFields' => array_merge($this->disabledFields, $this->unlockedFields), - 'csrfTokens' => array() - ); + 'csrfTokens' => [] + ]; - $tokenData = array(); + $tokenData = []; if ($this->Session->check('_Token')) { $tokenData = $this->Session->read('_Token'); if (!empty($tokenData['csrfTokens']) && is_array($tokenData['csrfTokens'])) { @@ -756,10 +756,10 @@ public function generateToken(CakeRequest $request) { $token['csrfTokens'][$authKey] = strtotime($this->csrfExpires); } $this->Session->write('_Token', $token); - $request->params['_Token'] = array( + $request->params['_Token'] = [ 'key' => $token['key'], 'unlockedFields' => $token['unlockedFields'] - ); + ]; return true; } @@ -824,11 +824,11 @@ protected function _expireTokens($tokens) { * @return mixed Controller callback method's response * @throws BadRequestException When the blackholeCallback is not callable. */ - protected function _callback(Controller $controller, $method, $params = array()) { - if (!is_callable(array($controller, $method))) { + protected function _callback(Controller $controller, $method, $params = []) { + if (!is_callable([$controller, $method])) { throw new BadRequestException(__d('cake_dev', 'The request has been black-holed')); } - return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params); + return call_user_func_array([&$controller, $method], empty($params) ? null : $params); } /** @@ -842,7 +842,7 @@ protected function _callback(Controller $controller, $method, $params = array()) * @return array Error messages */ protected function _matchExistingFields($dataFields, &$expectedFields, $intKeyMessage, $stringKeyMessage) { - $messages = array(); + $messages = []; foreach ((array)$dataFields as $key => $value) { if (is_int($key)) { $foundKey = array_search($value, (array)$expectedFields); @@ -869,12 +869,12 @@ protected function _matchExistingFields($dataFields, &$expectedFields, $intKeyMe * @param string $missingMessage Message template * @return string Error message about expected fields */ - protected function _debugExpectedFields($expectedFields = array(), $missingMessage = '') { + protected function _debugExpectedFields($expectedFields = [], $missingMessage = '') { if (count($expectedFields) === 0) { return null; } - $expectedFieldNames = array(); + $expectedFieldNames = []; foreach ((array)$expectedFields as $key => $expectedField) { if (is_int($key)) { $expectedFieldNames[] = $expectedField; diff --git a/lib/Cake/Controller/Component/SessionComponent.php b/lib/Cake/Controller/Component/SessionComponent.php index f09550957f..4a55040ade 100644 --- a/lib/Cake/Controller/Component/SessionComponent.php +++ b/lib/Cake/Controller/Component/SessionComponent.php @@ -135,13 +135,13 @@ public function error() { * @link https://book.cakephp.org/2.0/en/core-libraries/components/sessions.html#creating-notification-messages * @deprecated 3.0.0 Since 2.7, use the FlashComponent instead. */ - public function setFlash($message, $element = 'default', $params = array(), $key = 'flash') { + public function setFlash($message, $element = 'default', $params = [], $key = 'flash') { $messages = (array)CakeSession::read('Message.' . $key); - $messages[] = array( + $messages[] = [ 'message' => $message, 'element' => $element, 'params' => $params, - ); + ]; CakeSession::write('Message.' . $key, $messages); } diff --git a/lib/Cake/Controller/ComponentCollection.php b/lib/Cake/Controller/ComponentCollection.php index a9500dab2d..431c8d9bdc 100644 --- a/lib/Cake/Controller/ComponentCollection.php +++ b/lib/Cake/Controller/ComponentCollection.php @@ -93,12 +93,12 @@ public function getController() { * @return Component A component object, Either the existing loaded component or a new one. * @throws MissingComponentException when the component could not be found */ - public function load($component, $settings = array()) { + public function load($component, $settings = []) { if (isset($settings['className'])) { $alias = $component; $component = $settings['className']; } - list($plugin, $name) = pluginSplit($component, true); + [$plugin, $name] = pluginSplit($component, true); if (!isset($alias)) { $alias = $name; } @@ -108,13 +108,13 @@ public function load($component, $settings = array()) { $componentClass = $name . 'Component'; App::uses($componentClass, $plugin . 'Controller/Component'); if (!class_exists($componentClass)) { - throw new MissingComponentException(array( + throw new MissingComponentException([ 'class' => $componentClass, 'plugin' => substr($plugin, 0, -1) - )); + ]); } $this->_loaded[$alias] = new $componentClass($this, $settings); - $enable = isset($settings['enabled']) ? $settings['enabled'] : true; + $enable = $settings['enabled'] ?? true; if ($enable) { $this->enable($alias); } @@ -128,13 +128,13 @@ public function load($component, $settings = array()) { * @return array */ public function implementedEvents() { - return array( - 'Controller.initialize' => array('callable' => 'trigger'), - 'Controller.startup' => array('callable' => 'trigger'), - 'Controller.beforeRender' => array('callable' => 'trigger'), - 'Controller.beforeRedirect' => array('callable' => 'trigger'), - 'Controller.shutdown' => array('callable' => 'trigger'), - ); + return [ + 'Controller.initialize' => ['callable' => 'trigger'], + 'Controller.startup' => ['callable' => 'trigger'], + 'Controller.beforeRender' => ['callable' => 'trigger'], + 'Controller.beforeRedirect' => ['callable' => 'trigger'], + 'Controller.shutdown' => ['callable' => 'trigger'], + ]; } } diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index a0cc93b525..0dc105bb12 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -101,7 +101,7 @@ class Controller extends CakeObject implements CakeEventListener { * @var mixed * @link https://book.cakephp.org/2.0/en/controllers.html#components-helpers-and-uses */ - public $helpers = array(); + public $helpers = []; /** * An instance of a CakeRequest object that contains information about the current request. @@ -147,7 +147,7 @@ class Controller extends CakeObject implements CakeEventListener { * * @var array */ - public $viewVars = array(); + public $viewVars = []; /** * The name of the view file to render. The name specified @@ -197,7 +197,7 @@ class Controller extends CakeObject implements CakeEventListener { * @var array * @link https://book.cakephp.org/2.0/en/controllers/components.html */ - public $components = array('Session', 'Flash'); + public $components = ['Session', 'Flash']; /** * The name of the View class this controller sends output to. @@ -255,7 +255,7 @@ class Controller extends CakeObject implements CakeEventListener { * * @var mixed */ - public $passedArgs = array(); + public $passedArgs = []; /** * Triggers Scaffolding @@ -271,7 +271,7 @@ class Controller extends CakeObject implements CakeEventListener { * * @var array */ - public $methods = array(); + public $methods = []; /** * This controller's primary model class name, the Inflector::singularize()'ed version of @@ -326,7 +326,7 @@ class Controller extends CakeObject implements CakeEventListener { */ public function __construct($request = null, $response = null) { if ($this->name === null) { - $this->name = substr(get_class($this), 0, -10); + $this->name = substr(static::class, 0, -10); } if (!$this->viewPath) { @@ -371,7 +371,7 @@ public function __isset($name) { if (is_array($this->uses)) { foreach ($this->uses as $modelClass) { - list($plugin, $class) = pluginSplit($modelClass, true); + [$plugin, $class] = pluginSplit($modelClass, true); if ($name === $class) { return $this->loadModel($modelClass); } @@ -379,7 +379,7 @@ public function __isset($name) { } if ($name === $this->modelClass) { - list($plugin, $class) = pluginSplit($name, true); + [$plugin, $class] = pluginSplit($name, true); if (!$plugin) { $plugin = $this->plugin ? $this->plugin . '.' : null; } @@ -396,27 +396,16 @@ public function __isset($name) { * @param string $name The name of the requested value * @return mixed The requested value for valid variables/aliases else null */ - public function __get($name) { - switch ($name) { - case 'base': - case 'here': - case 'webroot': - case 'data': - return $this->request->{$name}; - case 'action': - return isset($this->request->params['action']) ? $this->request->params['action'] : ''; - case 'params': - return $this->request; - case 'paginate': - return $this->Components->load('Paginator')->settings; - } - - if (isset($this->{$name})) { - return $this->{$name}; - } - - return null; - } + public function __get($name) + { + return match ($name) { + 'base', 'here', 'webroot', 'data' => $this->request->{$name}, + 'action' => $this->request->params['action'] ?? '', + 'params' => $this->request, + 'paginate' => $this->Components->load('Paginator')->settings, + default => $this->{$name} ?? null, + }; + } /** * Provides backwards compatibility access for setting values to the request object. @@ -463,7 +452,7 @@ public function __set($name, $value) { public function setRequest(CakeRequest $request) { $this->request = $request; $this->plugin = isset($request->params['plugin']) ? Inflector::camelize($request->params['plugin']) : null; - $this->view = isset($request->params['action']) ? $request->params['action'] : null; + $this->view = $request->params['action'] ?? null; if (isset($request->params['pass']) && isset($request->params['named'])) { $this->passedArgs = array_merge($request->params['pass'], $request->params['named']); } @@ -491,10 +480,10 @@ public function invokeAction(CakeRequest $request) { $method = new ReflectionMethod($this, $request->params['action']); if ($this->_isPrivateAction($method, $request)) { - throw new PrivateActionException(array( + throw new PrivateActionException([ 'controller' => $this->name . "Controller", 'action' => $request->params['action'] - )); + ]); } return $method->invokeArgs( @@ -503,14 +492,14 @@ public function invokeAction(CakeRequest $request) { ? array_values($request->params['pass']) : [] ); - } catch (ReflectionException $e) { + } catch (ReflectionException) { if ($this->scaffold !== false) { return $this->_getScaffold($request); } - throw new MissingActionException(array( + throw new MissingActionException([ 'controller' => $this->name . "Controller", 'action' => $request->params['action'] - )); + ]); } } @@ -532,7 +521,7 @@ protected function _isPrivateAction(ReflectionMethod $method, CakeRequest $reque if (!$privateAction && !empty($prefixes)) { if (empty($request->params['prefix']) && strpos($request->params['action'], '_') > 0) { - list($prefix) = explode('_', $request->params['action']); + [$prefix] = explode('_', $request->params['action']); $privateAction = in_array(strtolower($prefix), $prefixes); } } @@ -558,8 +547,8 @@ protected function _getScaffold(CakeRequest $request) { protected function _mergeControllerVars() { $pluginController = $pluginDot = null; $mergeParent = is_subclass_of($this, $this->_mergeParent); - $pluginVars = array(); - $appVars = array(); + $pluginVars = []; + $appVars = []; if (!empty($this->plugin)) { $pluginController = $this->plugin . 'AppController'; @@ -570,13 +559,13 @@ protected function _mergeControllerVars() { } if ($pluginController) { - $merge = array('components', 'helpers'); + $merge = ['components', 'helpers']; $this->_mergeVars($merge, $pluginController); } if ($mergeParent || !empty($pluginController)) { $appVars = get_class_vars($this->_mergeParent); - $merge = array('components', 'helpers'); + $merge = ['components', 'helpers']; $this->_mergeVars($merge, $this->_mergeParent, true); } @@ -584,7 +573,7 @@ protected function _mergeControllerVars() { $this->uses = false; } if ($this->uses === true) { - $this->uses = array($pluginDot . $this->modelClass); + $this->uses = [$pluginDot . $this->modelClass]; } if (is_array($this->uses) && isset($appVars['uses']) && $appVars['uses'] === $this->uses) { array_unshift($this->uses, $pluginDot . $this->modelClass); @@ -596,7 +585,7 @@ protected function _mergeControllerVars() { $this->_mergeUses($pluginVars); $this->_mergeUses($appVars); } else { - $this->uses = array(); + $this->uses = []; $this->modelClass = ''; } } @@ -627,12 +616,12 @@ protected function _mergeUses($merge) { * @return array */ public function implementedEvents() { - return array( + return [ 'Controller.initialize' => 'beforeFilter', 'Controller.beforeRender' => 'beforeRender', - 'Controller.beforeRedirect' => array('callable' => 'beforeRedirect', 'passParams' => true), + 'Controller.beforeRedirect' => ['callable' => 'beforeRedirect', 'passParams' => true], 'Controller.shutdown' => 'afterFilter' - ); + ]; } /** @@ -649,7 +638,7 @@ public function constructClasses() { $this->_mergeControllerVars(); if ($this->uses) { $this->uses = (array)$this->uses; - list(, $this->modelClass) = pluginSplit(reset($this->uses)); + [, $this->modelClass] = pluginSplit(reset($this->uses)); } $this->Components->init($this); return true; @@ -740,16 +729,16 @@ public function loadModel($modelClass = null, $id = null) { $modelClass = $this->modelClass; } - $this->uses = ($this->uses) ? (array)$this->uses : array(); + $this->uses = ($this->uses) ? (array)$this->uses : []; if (!in_array($modelClass, $this->uses, true)) { $this->uses[] = $modelClass; } - list($plugin, $modelClass) = pluginSplit($modelClass, true); + [$plugin, $modelClass] = pluginSplit($modelClass, true); - $this->{$modelClass} = ClassRegistry::init(array( + $this->{$modelClass} = ClassRegistry::init([ 'class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id - )); + ]); if (!$this->{$modelClass}) { throw new MissingModelException($modelClass); } @@ -774,9 +763,9 @@ public function redirect($url, $status = null, $exit = true) { if (is_array($status)) { extract($status, EXTR_OVERWRITE); } - $event = new CakeEvent('Controller.beforeRedirect', $this, array($url, $status, $exit)); + $event = new CakeEvent('Controller.beforeRedirect', $this, [$url, $status, $exit]); - list($event->break, $event->breakOn, $event->collectReturn) = array(true, false, true); + [$event->break, $event->breakOn, $event->collectReturn] = [true, false, true]; $this->getEventManager()->dispatch($event); if ($event->isStopped()) { @@ -861,7 +850,7 @@ public function set($one, $two = null) { $data = $one; } } else { - $data = array($one => $two); + $data = [$one => $two]; } $this->viewVars = $data + $this->viewVars; } @@ -885,7 +874,7 @@ public function setAction($action) { $this->view = $action; $args = func_get_args(); unset($args[0]); - return call_user_func_array(array(&$this, $action), $args); + return call_user_func_array([&$this, $action], $args); } /** @@ -896,7 +885,7 @@ public function setAction($action) { */ public function validate() { $args = func_get_args(); - $errors = call_user_func_array(array(&$this, 'validateErrors'), $args); + $errors = call_user_func_array([&$this, 'validateErrors'], $args); if ($errors === false) { return 0; @@ -920,7 +909,7 @@ public function validateErrors() { return false; } - $errors = array(); + $errors = []; foreach ($objects as $object) { if (isset($this->{$object->alias})) { $object = $this->{$object->alias}; @@ -951,7 +940,7 @@ public function render($view = null, $layout = null) { if (!empty($this->uses) && is_array($this->uses)) { foreach ($this->uses as $model) { - list($plugin, $className) = pluginSplit($model); + [$plugin, $className] = pluginSplit($model); $this->request->params['models'][$className] = compact('plugin', 'className'); } } @@ -962,8 +951,8 @@ public function render($view = null, $layout = null) { foreach ($models as $currentModel) { $currentObject = ClassRegistry::getObject($currentModel); if ($currentObject instanceof Model) { - $className = get_class($currentObject); - list($plugin) = pluginSplit(App::location($className)); + $className = $currentObject::class; + [$plugin] = pluginSplit(App::location($className)); $this->request->params['models'][$currentObject->alias] = compact('plugin', 'className'); $this->View->validationErrors[$currentObject->alias] =& $currentObject->validationErrors; } @@ -1045,7 +1034,7 @@ public function flash($message, $url, $pause = 1, $layout = 'flash') { * @deprecated 3.0.0 Will be removed in 3.0. * @throws RuntimeException when unsafe operators are found. */ - public function postConditions($data = array(), $op = null, $bool = 'AND', $exclusive = false) { + public function postConditions($data = [], $op = null, $bool = 'AND', $exclusive = false) { if (!is_array($data) || empty($data)) { if (!empty($this->request->data)) { $data = $this->request->data; @@ -1053,7 +1042,7 @@ public function postConditions($data = array(), $op = null, $bool = 'AND', $excl return null; } } - $cond = array(); + $cond = []; if ($op === null) { $op = ''; @@ -1094,7 +1083,7 @@ public function postConditions($data = array(), $op = null, $bool = 'AND', $excl } } if ($bool && strtoupper($bool) !== 'AND') { - $cond = array($bool => $cond); + $cond = [$bool => $cond]; } return $cond; } @@ -1108,7 +1097,7 @@ public function postConditions($data = array(), $op = null, $bool = 'AND', $excl * @return array Model query results * @link https://book.cakephp.org/2.0/en/controllers.html#Controller::paginate */ - public function paginate($object = null, $scope = array(), $whitelist = array()) { + public function paginate($object = null, $scope = [], $whitelist = []) { return $this->Components->load('Paginator', $this->paginate)->paginate($object, $scope, $whitelist); } @@ -1265,7 +1254,7 @@ protected function _scaffoldError($method) { protected function _getViewObject() { $viewClass = $this->viewClass; if ($this->viewClass !== 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass, true); + [$plugin, $viewClass] = pluginSplit($viewClass, true); $viewClass = $viewClass . 'View'; App::uses($viewClass, $plugin . 'View'); } diff --git a/lib/Cake/Controller/Scaffold.php b/lib/Cake/Controller/Scaffold.php index 33999ecb7d..47fd8a5fe7 100644 --- a/lib/Cake/Controller/Scaffold.php +++ b/lib/Cake/Controller/Scaffold.php @@ -85,9 +85,9 @@ class Scaffold { * * @var array */ - protected $_passedVars = array( + protected $_passedVars = [ 'layout', 'name', 'viewPath', 'request' - ); + ]; /** * Title HTML element for current scaffolded view @@ -112,7 +112,7 @@ public function __construct(Controller $controller, CakeRequest $request) { $this->{$var} = $controller->{$var}; } - $this->redirect = array('action' => 'index'); + $this->redirect = ['action' => 'index']; $this->modelClass = $controller->modelClass; $this->modelKey = $controller->modelKey; @@ -360,11 +360,11 @@ protected function _scaffold(CakeRequest $request) { if (isset($db)) { if (empty($this->scaffoldActions)) { - $this->scaffoldActions = array( + $this->scaffoldActions = [ 'index', 'list', 'view', 'add', 'create', 'edit', 'update', 'delete' - ); + ]; } elseif (!empty($prefixes) && in_array($scaffoldPrefix, $prefixes)) { - $this->scaffoldActions = array( + $this->scaffoldActions = [ $scaffoldPrefix . '_index', $scaffoldPrefix . '_list', $scaffoldPrefix . '_view', @@ -373,7 +373,7 @@ protected function _scaffold(CakeRequest $request) { $scaffoldPrefix . '_edit', $scaffoldPrefix . '_update', $scaffoldPrefix . '_delete' - ); + ]; } if (in_array($request->params['action'], $this->scaffoldActions)) { @@ -401,13 +401,13 @@ protected function _scaffold(CakeRequest $request) { break; } } else { - throw new MissingActionException(array( - 'controller' => get_class($this->controller), + throw new MissingActionException([ + 'controller' => $this->controller::class, 'action' => $request->action - )); + ]); } } else { - throw new MissingDatabaseException(array('connection' => $this->ScaffoldModel->useDbConfig)); + throw new MissingDatabaseException(['connection' => $this->ScaffoldModel->useDbConfig]); } } @@ -417,8 +417,8 @@ protected function _scaffold(CakeRequest $request) { * @return array Associations for model */ protected function _associations() { - $keys = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); - $associations = array(); + $keys = ['belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany']; + $associations = []; foreach ($keys as $type) { foreach ($this->ScaffoldModel->{$type} as $assocKey => $assocData) { @@ -431,7 +431,7 @@ protected function _associations() { $associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey']; - list($plugin, $model) = pluginSplit($assocData['className']); + [$plugin, $model] = pluginSplit($assocData['className']); if ($plugin) { $plugin = Inflector::underscore($plugin); } diff --git a/lib/Cake/Core/App.php b/lib/Cake/Core/App.php index 5aeac30243..7cfd538065 100644 --- a/lib/Cake/Core/App.php +++ b/lib/Cake/Core/App.php @@ -97,27 +97,27 @@ class App { * * @var array */ - public static $types = array( - 'class' => array('extends' => null, 'core' => true), - 'file' => array('extends' => null, 'core' => true), - 'model' => array('extends' => 'AppModel', 'core' => false), - 'behavior' => array('suffix' => 'Behavior', 'extends' => 'Model/ModelBehavior', 'core' => true), - 'controller' => array('suffix' => 'Controller', 'extends' => 'AppController', 'core' => true), - 'component' => array('suffix' => 'Component', 'extends' => null, 'core' => true), - 'lib' => array('extends' => null, 'core' => true), - 'view' => array('suffix' => 'View', 'extends' => null, 'core' => true), - 'helper' => array('suffix' => 'Helper', 'extends' => 'AppHelper', 'core' => true), - 'vendor' => array('extends' => null, 'core' => true), - 'shell' => array('suffix' => 'Shell', 'extends' => 'AppShell', 'core' => true), - 'plugin' => array('extends' => null, 'core' => true) - ); + public static $types = [ + 'class' => ['extends' => null, 'core' => true], + 'file' => ['extends' => null, 'core' => true], + 'model' => ['extends' => 'AppModel', 'core' => false], + 'behavior' => ['suffix' => 'Behavior', 'extends' => 'Model/ModelBehavior', 'core' => true], + 'controller' => ['suffix' => 'Controller', 'extends' => 'AppController', 'core' => true], + 'component' => ['suffix' => 'Component', 'extends' => null, 'core' => true], + 'lib' => ['extends' => null, 'core' => true], + 'view' => ['suffix' => 'View', 'extends' => null, 'core' => true], + 'helper' => ['suffix' => 'Helper', 'extends' => 'AppHelper', 'core' => true], + 'vendor' => ['extends' => null, 'core' => true], + 'shell' => ['suffix' => 'Shell', 'extends' => 'AppShell', 'core' => true], + 'plugin' => ['extends' => null, 'core' => true] + ]; /** * Paths to search for files. * * @var array */ - public static $search = array(); + public static $search = []; /** * Whether or not to return the file that is loaded. @@ -131,42 +131,42 @@ class App { * * @var array */ - protected static $_map = array(); + protected static $_map = []; /** * Holds and key => value array of object types. * * @var array */ - protected static $_objects = array(); + protected static $_objects = []; /** * Holds the location of each class * * @var array */ - protected static $_classMap = array(); + protected static $_classMap = []; /** * Holds the possible paths for each package name * * @var array */ - protected static $_packages = array(); + protected static $_packages = []; /** * Holds the templates for each customizable package path in the application * * @var array */ - protected static $_packageFormat = array(); + protected static $_packageFormat = []; /** * Maps an old style CakePHP class type to the corresponding package * * @var array */ - public static $legacy = array( + public static $legacy = [ 'models' => 'Model', 'behaviors' => 'Model/Behavior', 'datasources' => 'Model/Datasource', @@ -179,7 +179,7 @@ class App { 'vendors' => 'Vendor', 'plugins' => 'Plugin', 'locales' => 'Locale' - ); + ]; /** * Indicates whether the class cache should be stored again because of an addition to it @@ -223,7 +223,7 @@ public static function path($type, $plugin = null) { } if (!empty($plugin)) { - $path = array(); + $path = []; $pluginPath = CakePlugin::path($plugin); $packageFormat = static::_packageFormat(); if (!empty($packageFormat[$type])) { @@ -235,7 +235,7 @@ public static function path($type, $plugin = null) { } if (!isset(static::$_packages[$type])) { - return array(); + return []; } return static::$_packages[$type]; } @@ -275,9 +275,9 @@ public static function paths() { * @return void * @link https://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::build */ - public static function build($paths = array(), $mode = App::PREPEND) { + public static function build($paths = [], $mode = App::PREPEND) { //Provides Backwards compatibility for old-style package names - $legacyPaths = array(); + $legacyPaths = []; foreach ($paths as $type => $path) { if (!empty(static::$legacy[$type])) { $type = static::$legacy[$type]; @@ -312,7 +312,7 @@ public static function build($paths = array(), $mode = App::PREPEND) { static::$_packageFormat = $packageFormat; } - $defaults = array(); + $defaults = []; foreach ($packageFormat as $package => $format) { foreach ($format as $f) { $defaults[$package][] = sprintf($f, APP); @@ -325,7 +325,7 @@ public static function build($paths = array(), $mode = App::PREPEND) { } if ($mode === App::REGISTER) { - $paths = array(); + $paths = []; } foreach ($defaults as $type => $default) { @@ -400,7 +400,7 @@ public static function themePath($theme) { * @link https://book.cakephp.org/2.0/en/core-utility-libraries/app.html#App::core */ public static function core($type) { - return array(CAKE . str_replace('/', DS, $type) . DS); + return [CAKE . str_replace('/', DS, $type) . DS]; } /** @@ -444,7 +444,7 @@ public static function objects($type, $path = null, $cache = true) { $includeDirectories = true; } - list($plugin, $type) = pluginSplit($type); + [$plugin, $type] = pluginSplit($type); if (isset(static::$legacy[$type . 's'])) { $type = static::$legacy[$type . 's']; @@ -460,7 +460,7 @@ public static function objects($type, $path = null, $cache = true) { $cacheLocation = empty($plugin) ? 'app' : $plugin; if ($cache !== true || !isset(static::$_objects[$cacheLocation][$name])) { - $objects = array(); + $objects = []; if (empty($path)) { $path = static::path($type, $plugin); @@ -535,12 +535,12 @@ public static function load($className) { if (!isset(static::$_classMap[$className])) { return false; } - if (strpos($className, '..') !== false) { + if (str_contains($className, '..')) { return false; } $parts = explode('.', static::$_classMap[$className], 2); - list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts)); + [$plugin, $package] = count($parts) > 1 ? $parts : [null, current($parts)]; $file = static::_mapped($className, $plugin); if ($file) { @@ -603,7 +603,7 @@ public static function location($className) { * @return bool true if Class is already in memory or if file is found and loaded, false if not * @link https://book.cakephp.org/2.0/en/core-utility-libraries/app.html#including-files-with-app-import */ - public static function import($type = null, $name = null, $parent = true, $search = array(), $file = null, $return = false) { + public static function import($type = null, $name = null, $parent = true, $search = [], $file = null, $return = false) { $ext = null; if (is_array($type)) { @@ -620,7 +620,7 @@ public static function import($type = null, $name = null, $parent = true, $searc if (is_array($name)) { foreach ($name as $class) { - if (!App::import(compact('type', 'parent', 'search', 'file', 'return') + array('name' => $class))) { + if (!App::import(compact('type', 'parent', 'search', 'file', 'return') + ['name' => $class])) { return false; } } @@ -628,11 +628,11 @@ public static function import($type = null, $name = null, $parent = true, $searc } $originalType = strtolower($type); - $specialPackage = in_array($originalType, array('file', 'vendor')); + $specialPackage = in_array($originalType, ['file', 'vendor']); if (!$specialPackage && isset(static::$legacy[$originalType . 's'])) { $type = static::$legacy[$originalType . 's']; } - list($plugin, $name) = pluginSplit($name); + [$plugin, $name] = pluginSplit($name); if (!empty($plugin)) { if (!CakePlugin::loaded($plugin)) { return false; @@ -675,13 +675,13 @@ protected static function _loadClass($name, $plugin, $type, $originalType, $pare if ($parent && isset(static::$types[$originalType]['extends'])) { $extends = static::$types[$originalType]['extends']; $extendType = $type; - if (strpos($extends, '/') !== false) { + if (str_contains($extends, '/')) { $parts = explode('/', $extends); $extends = array_pop($parts); $extendType = implode('/', $parts); } App::uses($extends, $extendType); - if ($plugin && in_array($originalType, array('controller', 'model'))) { + if ($plugin && in_array($originalType, ['controller', 'model'])) { App::uses($plugin . $extends, $plugin . '.' . $type); } } @@ -744,7 +744,7 @@ protected static function _loadVendor($name, $plugin, $file, $ext) { if ($mapped = static::_mapped($name, $plugin)) { return (bool)include_once $mapped; } - $fileTries = array(); + $fileTries = []; $paths = ($plugin) ? App::path('vendors', $plugin) : App::path('vendors'); if (empty($ext)) { $ext = 'php'; @@ -774,7 +774,7 @@ protected static function _loadVendor($name, $plugin, $file, $ext) { */ public static function init() { static::$_map += (array)Cache::read('file_map', '_cake_core_'); - register_shutdown_function(array('App', 'shutdown')); + register_shutdown_function(['App', 'shutdown']); } /** @@ -813,7 +813,7 @@ protected static function _mapped($name, $plugin = null) { if ($plugin) { $key = 'plugin.' . $name; } - return isset(static::$_map[$key]) ? static::$_map[$key] : false; + return static::$_map[$key] ?? false; } /** @@ -823,66 +823,66 @@ protected static function _mapped($name, $plugin = null) { */ protected static function _packageFormat() { if (empty(static::$_packageFormat)) { - static::$_packageFormat = array( - 'Model' => array( + static::$_packageFormat = [ + 'Model' => [ '%s' . 'Model' . DS - ), - 'Model/Behavior' => array( + ], + 'Model/Behavior' => [ '%s' . 'Model' . DS . 'Behavior' . DS - ), - 'Model/Datasource' => array( + ], + 'Model/Datasource' => [ '%s' . 'Model' . DS . 'Datasource' . DS - ), - 'Model/Datasource/Database' => array( + ], + 'Model/Datasource/Database' => [ '%s' . 'Model' . DS . 'Datasource' . DS . 'Database' . DS - ), - 'Model/Datasource/Session' => array( + ], + 'Model/Datasource/Session' => [ '%s' . 'Model' . DS . 'Datasource' . DS . 'Session' . DS - ), - 'Controller' => array( + ], + 'Controller' => [ '%s' . 'Controller' . DS - ), - 'Controller/Component' => array( + ], + 'Controller/Component' => [ '%s' . 'Controller' . DS . 'Component' . DS - ), - 'Controller/Component/Auth' => array( + ], + 'Controller/Component/Auth' => [ '%s' . 'Controller' . DS . 'Component' . DS . 'Auth' . DS - ), - 'Controller/Component/Acl' => array( + ], + 'Controller/Component/Acl' => [ '%s' . 'Controller' . DS . 'Component' . DS . 'Acl' . DS - ), - 'View' => array( + ], + 'View' => [ '%s' . 'View' . DS - ), - 'View/Helper' => array( + ], + 'View/Helper' => [ '%s' . 'View' . DS . 'Helper' . DS - ), - 'Console' => array( + ], + 'Console' => [ '%s' . 'Console' . DS - ), - 'Console/Command' => array( + ], + 'Console/Command' => [ '%s' . 'Console' . DS . 'Command' . DS - ), - 'Console/Command/Task' => array( + ], + 'Console/Command/Task' => [ '%s' . 'Console' . DS . 'Command' . DS . 'Task' . DS - ), - 'Lib' => array( + ], + 'Lib' => [ '%s' . 'Lib' . DS - ), - 'Locale' => array( + ], + 'Locale' => [ '%s' . 'Locale' . DS - ), - 'Vendor' => array( + ], + 'Vendor' => [ '%s' . 'Vendor' . DS, ROOT . DS . 'vendors' . DS, - dirname(dirname(CAKE)) . DS . 'vendors' . DS - ), - 'Plugin' => array( + dirname(CAKE, 2) . DS . 'vendors' . DS + ], + 'Plugin' => [ APP . 'Plugin' . DS, ROOT . DS . 'plugins' . DS, - dirname(dirname(CAKE)) . DS . 'plugins' . DS - ) - ); + dirname(CAKE, 2) . DS . 'plugins' . DS + ] + ]; } return static::$_packageFormat; @@ -954,7 +954,7 @@ protected static function _checkFatalError() { return; } - list(, $log) = ErrorHandler::mapErrorCode($lastError['type']); + [, $log] = ErrorHandler::mapErrorCode($lastError['type']); if ($log !== LOG_ERR) { return; } @@ -967,7 +967,7 @@ protected static function _checkFatalError() { if (!is_callable($errorHandler)) { return; } - call_user_func($errorHandler, $lastError['type'], $lastError['message'], $lastError['file'], $lastError['line'], array()); + call_user_func($errorHandler, $lastError['type'], $lastError['message'], $lastError['file'], $lastError['line'], []); } } diff --git a/lib/Cake/Core/CakeObject.php b/lib/Cake/Core/CakeObject.php index 776982248b..5560b05140 100644 --- a/lib/Cake/Core/CakeObject.php +++ b/lib/Cake/Core/CakeObject.php @@ -43,7 +43,7 @@ public function __construct() { * @return string The name of this class */ public function toString() { - $class = get_class($this); + $class = static::class; return $class; } @@ -67,7 +67,7 @@ public function toString() { * @return mixed Boolean true or false on success/failure, or contents * of rendered action if 'return' is set in $extra. */ - public function requestAction($url, $extra = array()) { + public function requestAction($url, $extra = []) { if (empty($url)) { return false; } @@ -78,22 +78,22 @@ public function requestAction($url, $extra = array()) { } $arrayUrl = is_array($url); if ($arrayUrl && !isset($extra['url'])) { - $extra['url'] = array(); + $extra['url'] = []; } if ($arrayUrl && !isset($extra['data'])) { - $extra['data'] = array(); + $extra['data'] = []; } - $extra += array('autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1); - $data = isset($extra['data']) ? $extra['data'] : null; + $extra += ['autoRender' => 0, 'return' => 1, 'bare' => 1, 'requested' => 1]; + $data = $extra['data'] ?? null; unset($extra['data']); - if (is_string($url) && strpos($url, Router::fullBaseUrl()) === 0) { + if (is_string($url) && str_starts_with($url, Router::fullBaseUrl())) { $url = Router::normalize(str_replace(Router::fullBaseUrl(), '', $url)); } if (is_string($url)) { $request = new CakeRequest($url); } elseif (is_array($url)) { - $params = $url + array('pass' => array(), 'named' => array(), 'base' => false); + $params = $url + ['pass' => [], 'named' => [], 'base' => false]; $params = $extra + $params; $request = new CakeRequest(Router::reverse($params)); } @@ -115,23 +115,16 @@ public function requestAction($url, $extra = array()) { * @param array $params Parameter list to use when calling $method * @return mixed Returns the result of the method call */ - public function dispatchMethod($method, $params = array()) { - switch (count($params)) { - case 0: - return $this->{$method}(); - case 1: - return $this->{$method}($params[0]); - case 2: - return $this->{$method}($params[0], $params[1]); - case 3: - return $this->{$method}($params[0], $params[1], $params[2]); - case 4: - return $this->{$method}($params[0], $params[1], $params[2], $params[3]); - case 5: - return $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]); - default: - return call_user_func_array(array(&$this, $method), $params); - } + public function dispatchMethod($method, $params = []) { + return match (count($params)) { + 0 => $this->{$method}(), + 1 => $this->{$method}($params[0]), + 2 => $this->{$method}($params[0], $params[1]), + 3 => $this->{$method}($params[0], $params[1], $params[2]), + 4 => $this->{$method}($params[0], $params[1], $params[2], $params[3]), + 5 => $this->{$method}($params[0], $params[1], $params[2], $params[3], $params[4]), + default => call_user_func_array([&$this, $method], $params), + }; } /** @@ -170,7 +163,7 @@ public function log($msg, $type = LOG_ERR, $scope = null) { * @param array $properties An associative array containing properties and corresponding values. * @return void */ - protected function _set($properties = array()) { + protected function _set($properties = []) { if (is_array($properties) && !empty($properties)) { $vars = get_object_vars($this); foreach ($properties as $key => $val) { diff --git a/lib/Cake/Core/CakePlugin.php b/lib/Cake/Core/CakePlugin.php index ff2897efa5..d68af67ba9 100644 --- a/lib/Cake/Core/CakePlugin.php +++ b/lib/Cake/Core/CakePlugin.php @@ -31,7 +31,7 @@ class CakePlugin { * * @var array */ - protected static $_plugins = array(); + protected static $_plugins = []; /** * Loads a plugin and optionally loads bootstrapping, routing files or loads an initialization function @@ -90,26 +90,26 @@ class CakePlugin { * @throws MissingPluginException if the folder for the plugin to be loaded is not found * @return void */ - public static function load($plugin, $config = array()) { + public static function load($plugin, $config = []) { if (is_array($plugin)) { foreach ($plugin as $name => $conf) { - list($name, $conf) = (is_numeric($name)) ? array($conf, $config) : array($name, $conf); + [$name, $conf] = (is_numeric($name)) ? [$conf, $config] : [$name, $conf]; static::load($name, $conf); } return; } - $config += array('bootstrap' => false, 'routes' => false, 'ignoreMissing' => false); + $config += ['bootstrap' => false, 'routes' => false, 'ignoreMissing' => false]; if (empty($config['path'])) { foreach (App::path('plugins') as $path) { if (is_dir($path . $plugin)) { - static::$_plugins[$plugin] = $config + array('path' => $path . $plugin . DS); + static::$_plugins[$plugin] = $config + ['path' => $path . $plugin . DS]; break; } //Backwards compatibility to make easier to migrate to 2.0 $underscored = Inflector::underscore($plugin); if (is_dir($path . $underscored)) { - static::$_plugins[$plugin] = $config + array('path' => $path . $underscored . DS); + static::$_plugins[$plugin] = $config + ['path' => $path . $underscored . DS]; break; } } @@ -118,7 +118,7 @@ public static function load($plugin, $config = array()) { } if (empty(static::$_plugins[$plugin]['path'])) { - throw new MissingPluginException(array('plugin' => $plugin)); + throw new MissingPluginException(['plugin' => $plugin]); } if (!empty(static::$_plugins[$plugin]['bootstrap'])) { static::bootstrap($plugin); @@ -157,10 +157,10 @@ public static function load($plugin, $config = array()) { * @param array $options Options list. See CakePlugin::load() for valid options. * @return void */ - public static function loadAll($options = array()) { + public static function loadAll($options = []) { $plugins = App::objects('plugins'); foreach ($plugins as $plugin) { - $pluginOptions = isset($options[$plugin]) ? (array)$options[$plugin] : array(); + $pluginOptions = isset($options[$plugin]) ? (array)$options[$plugin] : []; if (isset($options[0])) { $pluginOptions += $options[0]; } @@ -177,7 +177,7 @@ public static function loadAll($options = array()) { */ public static function path($plugin) { if (empty(static::$_plugins[$plugin])) { - throw new MissingPluginException(array('plugin' => $plugin)); + throw new MissingPluginException(['plugin' => $plugin]); } return static::$_plugins[$plugin]['path']; } @@ -195,7 +195,7 @@ public static function bootstrap($plugin) { return false; } if (is_callable($config['bootstrap'])) { - return call_user_func_array($config['bootstrap'], array($plugin, $config)); + return call_user_func_array($config['bootstrap'], [$plugin, $config]); } $path = static::path($plugin); @@ -266,7 +266,7 @@ public static function loaded($plugin = null) { */ public static function unload($plugin = null) { if ($plugin === null) { - static::$_plugins = array(); + static::$_plugins = []; } else { unset(static::$_plugins[$plugin]); } diff --git a/lib/Cake/Core/Configure.php b/lib/Cake/Core/Configure.php index 901606cd23..d3bdc05eb8 100644 --- a/lib/Cake/Core/Configure.php +++ b/lib/Cake/Core/Configure.php @@ -39,9 +39,9 @@ class Configure { * * @var array */ - protected static $_values = array( + protected static $_values = [ 'debug' => 0 - ); + ]; /** * Configured reader classes, used to load config files from resources @@ -49,7 +49,7 @@ class Configure { * @var array * @see Configure::load() */ - protected static $_readers = array(); + protected static $_readers = []; /** * Initializes configure and runs the bootstrap process. @@ -80,18 +80,18 @@ public static function bootstrap($boot = true) { App::$bootstrapping = false; App::build(); - $exception = array( + $exception = [ 'handler' => 'ErrorHandler::handleException', - ); - $error = array( + ]; + $error = [ 'handler' => 'ErrorHandler::handleError', 'level' => E_ALL & ~E_DEPRECATED, - ); + ]; if (PHP_SAPI === 'cli') { App::uses('ConsoleErrorHandler', 'Console'); $console = new ConsoleErrorHandler(); - $exception['handler'] = array($console, 'handleException'); - $error['handler'] = array($console, 'handleError'); + $exception['handler'] = [$console, 'handleException']; + $error['handler'] = [$console, 'handleError']; } static::_setErrorHandlers($error, $exception); @@ -126,13 +126,13 @@ class_exists('CakeText'); * @return void */ protected static function _appDefaults() { - static::write('App', (array)static::read('App') + array( + static::write('App', (array)static::read('App') + [ 'base' => false, 'baseUrl' => false, 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'www_root' => WWW_ROOT - )); + ]); } /** @@ -161,7 +161,7 @@ protected static function _appDefaults() { */ public static function write($config, $value = null) { if (!is_array($config)) { - $config = array($config => $value); + $config = [$config => $value]; } foreach ($config as $name => $value) { @@ -209,7 +209,7 @@ public static function read($var = null) { * @return array|null */ public static function consume($var) { - $simple = strpos($var, '.') === false; + $simple = !str_contains($var, '.'); if ($simple && !isset(static::$_values[$var])) { return null; } @@ -368,7 +368,7 @@ public static function load($key, $config = 'default', $merge = true) { * @return bool success * @throws ConfigureException if the adapter does not implement a `dump` method. */ - public static function dump($key, $config = 'default', $keys = array()) { + public static function dump($key, $config = 'default', $keys = []) { $reader = static::_getReader($config); if (!$reader) { throw new ConfigureException(__d('cake_dev', 'There is no "%s" adapter.', $config)); @@ -455,7 +455,7 @@ public static function restore($name, $cacheConfig = 'default') { * @return bool Success. */ public static function clear() { - static::$_values = array(); + static::$_values = []; return true; } diff --git a/lib/Cake/Error/ErrorHandler.php b/lib/Cake/Error/ErrorHandler.php index de892f6be0..408b387f7e 100644 --- a/lib/Cake/Error/ErrorHandler.php +++ b/lib/Cake/Error/ErrorHandler.php @@ -117,9 +117,9 @@ public static function handleException($exception) { $config = Configure::read('Exception'); static::_log($exception, $config); - $renderer = isset($config['renderer']) ? $config['renderer'] : 'ExceptionRenderer'; + $renderer = $config['renderer'] ?? 'ExceptionRenderer'; if ($renderer !== 'ExceptionRenderer') { - list($plugin, $renderer) = pluginSplit($renderer, true); + [$plugin, $renderer] = pluginSplit($renderer, true); App::uses($renderer, $plugin . 'Error'); } try { @@ -129,7 +129,7 @@ public static function handleException($exception) { set_error_handler(Configure::read('Error.handler')); // Should be using configured ErrorHandler Configure::write('Error.trace', false); // trace is useless here since it's internal $message = sprintf("[%s] %s\n%s", // Keeping same message format - get_class($e), + $e::class, $e->getMessage(), $e->getTraceAsString() ); @@ -147,7 +147,7 @@ public static function handleException($exception) { */ protected static function _getMessage($exception) { $message = sprintf("[%s] %s", - get_class($exception), + $exception::class, $exception->getMessage() ); if (method_exists($exception, 'getAttributes')) { @@ -209,14 +209,14 @@ public static function handleError($code, $description, $file = null, $line = nu if (!(error_reporting() & $code)) { return false; } - list($error, $log) = static::mapErrorCode($code); + [$error, $log] = static::mapErrorCode($code); if ($log === LOG_ERR) { return static::handleFatalError($code, $description, $file, $line); } $debug = Configure::read('debug'); if ($debug) { - $data = array( + $data = [ 'level' => $log, 'code' => $code, 'error' => $error, @@ -226,7 +226,7 @@ public static function handleError($code, $description, $file = null, $line = nu 'context' => $context, 'start' => 2, 'path' => Debugger::trimPath($file) - ); + ]; return Debugger::getInstance()->outputError($data); } $message = static::_getErrorMessage($error, $code, $description, $file, $line); @@ -312,7 +312,7 @@ public static function mapErrorCode($code) { $log = LOG_NOTICE; break; } - return array($error, $log); + return [$error, $log]; } /** @@ -339,7 +339,7 @@ protected static function _getErrorMessage($error, $code, $description, $file, $ App::load('CakeText'); } } - $trace = Debugger::trace(array('start' => 1, 'format' => 'log')); + $trace = Debugger::trace(['start' => 1, 'format' => 'log']); $message .= "\nTrace:\n" . $trace . "\n"; } return $message; diff --git a/lib/Cake/Error/ExceptionRenderer.php b/lib/Cake/Error/ExceptionRenderer.php index 64e85b21b2..a31e62bf82 100644 --- a/lib/Cake/Error/ExceptionRenderer.php +++ b/lib/Cake/Error/ExceptionRenderer.php @@ -98,7 +98,7 @@ public function __construct($exception) { $this->controller->appError($exception); return; } - $method = $template = Inflector::variable(str_replace('Exception', '', get_class($exception))); + $method = $template = Inflector::variable(str_replace('Exception', '', $exception::class)); $code = $exception->getCode(); $methodExists = method_exists($this, $method); @@ -157,7 +157,7 @@ protected function _getController($exception) { $controller = new CakeErrorController($request, $response); $controller->startupProcess(); $startup = true; - } catch (Exception $e) { + } catch (Exception) { $startup = false; } // Retry RequestHandler, as another aspect of startupProcess() @@ -169,7 +169,7 @@ protected function _getController($exception) { ) { try { $controller->RequestHandler->startup($controller); - } catch (Exception $e) { + } catch (Exception) { } } } @@ -187,7 +187,7 @@ protected function _getController($exception) { */ public function render() { if ($this->method) { - call_user_func_array(array($this, $this->method), array($this->error)); + call_user_func_array([$this, $this->method], [$this->error]); } } @@ -201,14 +201,14 @@ protected function _cakeError(CakeException $error) { $url = $this->controller->request->here(); $code = ($error->getCode() >= 400 && $error->getCode() < 506) ? $error->getCode() : 500; $this->controller->response->statusCode($code); - $this->controller->set(array( + $this->controller->set([ 'code' => $code, 'name' => h($error->getMessage()), 'message' => h($error->getMessage()), 'url' => h($url), 'error' => $error, - '_serialize' => array('code', 'name', 'message', 'url') - )); + '_serialize' => ['code', 'name', 'message', 'url'] + ]); $this->controller->set($error->getAttributes()); $this->_outputMessage($this->template); } @@ -226,13 +226,13 @@ public function error400($error) { } $url = $this->controller->request->here(); $this->controller->response->statusCode($error->getCode()); - $this->controller->set(array( + $this->controller->set([ 'name' => h($message), 'message' => h($message), 'url' => h($url), 'error' => $error, - '_serialize' => array('name', 'message', 'url') - )); + '_serialize' => ['name', 'message', 'url'] + ]); $this->_outputMessage('error400'); } @@ -250,13 +250,13 @@ public function error500($error) { $url = $this->controller->request->here(); $code = ($error->getCode() > 500 && $error->getCode() < 506) ? $error->getCode() : 500; $this->controller->response->statusCode($code); - $this->controller->set(array( + $this->controller->set([ 'name' => h($message), 'message' => h($message), 'url' => h($url), 'error' => $error, - '_serialize' => array('name', 'message', 'url') - )); + '_serialize' => ['name', 'message', 'url'] + ]); $this->_outputMessage('error500'); } @@ -270,14 +270,14 @@ public function pdoError(PDOException $error) { $url = $this->controller->request->here(); $code = 500; $this->controller->response->statusCode($code); - $this->controller->set(array( + $this->controller->set([ 'code' => $code, 'name' => h($error->getMessage()), 'message' => h($error->getMessage()), 'url' => h($url), 'error' => $error, - '_serialize' => array('code', 'name', 'message', 'url', 'error') - )); + '_serialize' => ['code', 'name', 'message', 'url', 'error'] + ]); $this->_outputMessage($this->template); } @@ -294,7 +294,7 @@ protected function _outputMessage($template) { $this->controller->response->send(); } catch (MissingViewException $e) { $attributes = $e->getAttributes(); - if (isset($attributes['file']) && strpos($attributes['file'], 'error500') !== false) { + if (isset($attributes['file']) && str_contains($attributes['file'], 'error500')) { $this->_outputMessageSafe('error500'); } else { $this->_outputMessage('error500'); @@ -305,7 +305,7 @@ protected function _outputMessage($template) { $this->controller->plugin = null; } $this->_outputMessageSafe('error500'); - } catch (Exception $e) { + } catch (Exception) { $this->_outputMessageSafe('error500'); } } @@ -322,7 +322,7 @@ protected function _outputMessageSafe($template) { $this->controller->subDir = null; $this->controller->viewPath = 'Errors'; $this->controller->layout = 'error'; - $this->controller->helpers = array('Form', 'Html', 'Session'); + $this->controller->helpers = ['Form', 'Html', 'Session']; $view = new View($this->controller); $this->controller->response->body($view->render($template, 'error')); @@ -342,10 +342,10 @@ protected function _shutdown() { $this->controller->getEventManager()->dispatch($afterFilterEvent); $Dispatcher = new Dispatcher(); - $afterDispatchEvent = new CakeEvent('Dispatcher.afterDispatch', $Dispatcher, array( + $afterDispatchEvent = new CakeEvent('Dispatcher.afterDispatch', $Dispatcher, [ 'request' => $this->controller->request, 'response' => $this->controller->response - )); + ]); $Dispatcher->getEventManager()->dispatch($afterDispatchEvent); } diff --git a/lib/Cake/Error/exceptions.php b/lib/Cake/Error/exceptions.php index 373d01a1bd..2e934a01a2 100644 --- a/lib/Cake/Error/exceptions.php +++ b/lib/Cake/Error/exceptions.php @@ -46,7 +46,7 @@ public function responseHeader($header = null, $value = null) { if (is_array($header)) { return $this->_responseHeaders = $header; } - $this->_responseHeaders = array($header => $value); + $this->_responseHeaders = [$header => $value]; } return $this->_responseHeaders; } @@ -212,7 +212,7 @@ class CakeException extends CakeBaseException { * * @var array */ - protected $_attributes = array(); + protected $_attributes = []; /** * Template string that has attributes sprintf()'ed into it. @@ -387,7 +387,7 @@ class MissingConnectionException extends CakeException { */ public function __construct($message, $code = 500) { if (is_array($message)) { - $message += array('enabled' => true); + $message += ['enabled' => true]; } parent::__construct($message, $code); } diff --git a/lib/Cake/Event/CakeEvent.php b/lib/Cake/Event/CakeEvent.php index d05f4d351f..04d367b78f 100644 --- a/lib/Cake/Event/CakeEvent.php +++ b/lib/Cake/Event/CakeEvent.php @@ -53,27 +53,6 @@ class CakeEvent { */ public mixed $collectReturn; -/** - * Name of the event - * - * @var string - */ - protected $_name = null; - -/** - * The object this event applies to (usually the same object that generates the event) - * - * @var object - */ - protected $_subject; - -/** - * Custom data for the method that receives the event - * - * @var mixed - */ - public $data = null; - /** * Property used to retain the result value of the event listeners * @@ -89,24 +68,35 @@ class CakeEvent { protected $_stopped = false; /** - * Constructor - * - * @param string $name Name of the event - * @param object $subject the object that this event applies to (usually the object that is generating the event) - * @param mixed $data any value you wish to be transported with this event to it can be read by listeners - * - * ## Examples of usage: - * - * ``` - * $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData)); - * $event = new CakeEvent('User.afterRegister', $UserModel); - * ``` - */ - public function __construct($name, $subject = null, $data = null) { - $this->_name = $name; - $this->data = $data; - $this->_subject = $subject; - } + * Constructor + * + * @param string $_name Name of the event + * @param object $_subject the object that this event applies to (usually the object that is generating the event) + * @param mixed $data any value you wish to be transported with this event to it can be read by listeners + * + * ## Examples of usage: + * + * ``` + * $event = new CakeEvent('Order.afterBuy', $this, array('buyer' => $userData)); + * $event = new CakeEvent('User.afterRegister', $UserModel); + * ``` + */ + public function __construct( + /** + * Name of the event + */ + protected $_name, + /** + * The object this event applies to (usually the same object that generates the event) + */ + protected $_subject = null, + /** + * Custom data for the method that receives the event + */ + public $data = null + ) + { + } /** * Dynamically returns the name and subject if accessed directly diff --git a/lib/Cake/Event/CakeEventManager.php b/lib/Cake/Event/CakeEventManager.php index 216c03131b..155a009d31 100644 --- a/lib/Cake/Event/CakeEventManager.php +++ b/lib/Cake/Event/CakeEventManager.php @@ -46,7 +46,7 @@ class CakeEventManager { * * @var object */ - protected $_listeners = array(); + protected $_listeners = []; /** * Internal flag to distinguish a common manager from the singleton @@ -98,7 +98,7 @@ public static function instance($manager = null) { * @throws InvalidArgumentException When event key is missing or callable is not an * instance of CakeEventListener. */ - public function attach($callable, $eventKey = null, $options = array()) { + public function attach($callable, $eventKey = null, $options = []) { if (!$eventKey && !($callable instanceof CakeEventListener)) { throw new InvalidArgumentException(__d('cake_dev', 'The eventKey variable is required')); } @@ -106,11 +106,11 @@ public function attach($callable, $eventKey = null, $options = array()) { $this->_attachSubscriber($callable); return; } - $options = $options + array('priority' => static::$defaultPriority, 'passParams' => false); - $this->_listeners[$eventKey][$options['priority']][] = array( + $options = $options + ['priority' => static::$defaultPriority, 'passParams' => false]; + $this->_listeners[$eventKey][$options['priority']][] = [ 'callable' => $callable, 'passParams' => $options['passParams'], - ); + ]; } /** @@ -122,19 +122,19 @@ public function attach($callable, $eventKey = null, $options = array()) { */ protected function _attachSubscriber(CakeEventListener $subscriber) { foreach ((array)$subscriber->implementedEvents() as $eventKey => $function) { - $options = array(); + $options = []; $method = $function; if (is_array($function) && isset($function['callable'])) { - list($method, $options) = $this->_extractCallable($function, $subscriber); + [$method, $options] = $this->_extractCallable($function, $subscriber); } elseif (is_array($function) && is_numeric(key($function))) { foreach ($function as $f) { - list($method, $options) = $this->_extractCallable($f, $subscriber); + [$method, $options] = $this->_extractCallable($f, $subscriber); $this->attach($method, $eventKey, $options); } continue; } if (is_string($method)) { - $method = array($subscriber, $function); + $method = [$subscriber, $function]; } $this->attach($method, $eventKey, $options); } @@ -153,9 +153,9 @@ protected function _extractCallable($function, $object) { $options = $function; unset($options['callable']); if (is_string($method)) { - $method = array($object, $method); + $method = [$object, $method]; } - return array($method, $options); + return [$method, $options]; } /** @@ -200,20 +200,20 @@ protected function _detachSubscriber(CakeEventListener $subscriber, $eventKey = if (!empty($eventKey) && empty($events[$eventKey])) { return; } elseif (!empty($eventKey)) { - $events = array($eventKey => $events[$eventKey]); + $events = [$eventKey => $events[$eventKey]]; } foreach ($events as $key => $function) { if (is_array($function)) { if (is_numeric(key($function))) { foreach ($function as $handler) { - $handler = isset($handler['callable']) ? $handler['callable'] : $handler; - $this->detach(array($subscriber, $handler), $key); + $handler = $handler['callable'] ?? $handler; + $this->detach([$subscriber, $handler], $key); } continue; } $function = $function['callable']; } - $this->detach(array($subscriber, $function), $key); + $this->detach([$subscriber, $function], $key); } } @@ -260,20 +260,20 @@ public function dispatch($event) { * @return array */ public function listeners($eventKey) { - $localListeners = array(); - $priorities = array(); + $localListeners = []; + $priorities = []; if (!$this->_isGlobal) { $localListeners = $this->prioritisedListeners($eventKey); - $localListeners = empty($localListeners) ? array() : $localListeners; + $localListeners = empty($localListeners) ? [] : $localListeners; } $globalListeners = static::instance()->prioritisedListeners($eventKey); - $globalListeners = empty($globalListeners) ? array() : $globalListeners; + $globalListeners = empty($globalListeners) ? [] : $globalListeners; $priorities = array_merge(array_keys($globalListeners), array_keys($localListeners)); $priorities = array_unique($priorities); asort($priorities); - $result = array(); + $result = []; foreach ($priorities as $priority) { if (isset($globalListeners[$priority])) { $result = array_merge($result, $globalListeners[$priority]); @@ -293,7 +293,7 @@ public function listeners($eventKey) { */ public function prioritisedListeners($eventKey) { if (empty($this->_listeners[$eventKey])) { - return array(); + return []; } return $this->_listeners[$eventKey]; } diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 56a92f52bd..1265c02e07 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -68,7 +68,7 @@ class I18n { * * @var array */ - protected $_domains = array(); + protected $_domains = []; /** * Set to true when I18N::_bindTextDomain() is called for the first time. @@ -83,9 +83,9 @@ class I18n { * * @var array */ - protected $_categories = array( + protected $_categories = [ 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'LC_MESSAGES' - ); + ]; /** * Constants for the translation categories. @@ -169,7 +169,7 @@ public function __construct() { * @return I18n */ public static function getInstance() { - static $instance = array(); + static $instance = []; if (!$instance) { $instance[0] = new I18n(); } @@ -197,10 +197,10 @@ public static function translate($singular, $plural = null, $domain = null, $cat ) { $_this = I18n::getInstance(); - if (strpos($singular, "\r\n") !== false) { + if (str_contains($singular, "\r\n")) { $singular = str_replace("\r\n", "\n", $singular); } - if ($plural !== null && strpos($plural, "\r\n") !== false) { + if ($plural !== null && str_contains($plural, "\r\n")) { $plural = str_replace("\r\n", "\n", $plural); } @@ -297,7 +297,7 @@ public static function translate($singular, $plural = null, $domain = null, $cat */ public static function clear() { $self = I18n::getInstance(); - $self->_domains = array(); + $self->_domains = []; } /** @@ -378,7 +378,7 @@ protected function _pluralGuess($header, $n) { protected function _bindTextDomain($domain) { $this->_noLocale = true; $core = true; - $merge = array(); + $merge = []; $searchPaths = App::path('locales'); $plugins = CakePlugin::loaded(); @@ -498,7 +498,7 @@ public static function loadMo($filename) { // @codingStandardsIgnoreStart // Binary files extracted makes non-standard local variables if ($data = file_get_contents($filename)) { - $translations = array(); + $translations = []; $header = substr($data, 0, 20); $header = unpack('L1magic/L1version/L1count/L1o_msg/L1o_trn', $header); extract($header); @@ -510,11 +510,11 @@ public static function loadMo($filename) { unset($msgid_plural); $context = null; - if (strpos($msgid, "\x04") !== false) { - list($context, $msgid) = explode("\x04", $msgid); + if (str_contains($msgid, "\x04")) { + [$context, $msgid] = explode("\x04", $msgid); } if (strpos($msgid, "\000")) { - list($msgid, $msgid_plural) = explode("\000", $msgid); + [$msgid, $msgid_plural] = explode("\000", $msgid); } $r = unpack("L1len/L1offs", substr($data, $o_trn + $n * 8, 8)); $msgstr = substr($data, $r["offs"], $r["len"]); @@ -552,7 +552,7 @@ public static function loadPo($filename) { } $type = 0; - $translations = array(); + $translations = []; $translationKey = ''; $translationContext = null; $plural = 0; @@ -631,7 +631,7 @@ public static function loadLocaleDefinition($filename) { return false; } - $definitions = array(); + $definitions = []; $comment = '#'; $escape = '\\'; $currentToken = false; @@ -667,14 +667,14 @@ public static function loadLocaleDefinition($filename) { continue; } - $mustEscape = array($escape . ',', $escape . ';', $escape . '<', $escape . '>', $escape . $escape); + $mustEscape = [$escape . ',', $escape . ';', $escape . '<', $escape . '>', $escape . $escape]; $replacements = array_map('crc32', $mustEscape); $value = str_replace($mustEscape, $replacements, $value); $value = explode(';', $value); $_this->_escape = $escape; foreach ($value as $i => $val) { $val = trim($val, '"'); - $val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/', array(&$_this, '_parseLiteralValue'), $val); + $val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/', [&$_this, '_parseLiteralValue'], $val); $val = str_replace($replacements, $mustEscape, $val); $value[$i] = $val; } @@ -729,12 +729,12 @@ protected function _parseLiteralValue($string) { $delimiter = $this->_escape; return implode('', array_map('chr', array_filter(explode($delimiter, $string)))); } - if (substr($string, 0, 3) === 'U00') { + if (str_starts_with($string, 'U00')) { $delimiter = 'U00'; return implode('', array_map('chr', array_map('hexdec', array_filter(explode($delimiter, $string))))); } if (preg_match('/U([0-9a-fA-F]{4})/', $string, $match)) { - return Multibyte::ascii(array(hexdec($match[1]))); + return Multibyte::ascii([hexdec($match[1])]); } return $string; } diff --git a/lib/Cake/I18n/L10n.php b/lib/Cake/I18n/L10n.php index b82c08d24c..7322f8663b 100644 --- a/lib/Cake/I18n/L10n.php +++ b/lib/Cake/I18n/L10n.php @@ -37,7 +37,7 @@ class L10n { * * @var array */ - public $languagePath = array('en_us', 'eng'); + public $languagePath = ['en_us', 'eng']; /** * ISO 639-3 for current locale @@ -86,7 +86,7 @@ class L10n { * * @var array */ - protected $_l10nMap = array( + protected $_l10nMap = [ /* Afrikaans */ 'afr' => 'af', /* Albanian */ 'sqi' => 'sq', /* Albanian - bibliographic */ 'alb' => 'sq', @@ -173,7 +173,7 @@ class L10n { /* Xhosa */ 'xho' => 'xh', /* Yiddish */ 'yid' => 'yi', /* Zulu */ 'zul' => 'zu' - ); + ]; /** * HTTP_ACCEPT_LANGUAGE catalog @@ -182,165 +182,165 @@ class L10n { * * @var array */ - protected $_l10nCatalog = array( - 'af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-dz' => array('language' => 'Arabic (Algeria)', 'locale' => 'ar_dz', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-eg' => array('language' => 'Arabic (Egypt)', 'locale' => 'ar_eg', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-iq' => array('language' => 'Arabic (Iraq)', 'locale' => 'ar_iq', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-jo' => array('language' => 'Arabic (Jordan)', 'locale' => 'ar_jo', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-kw' => array('language' => 'Arabic (Kuwait)', 'locale' => 'ar_kw', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-ly' => array('language' => 'Arabic (Libya)', 'locale' => 'ar_ly', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-ma' => array('language' => 'Arabic (Morocco)', 'locale' => 'ar_ma', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-om' => array('language' => 'Arabic (Oman)', 'locale' => 'ar_om', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-qa' => array('language' => 'Arabic (Qatar)', 'locale' => 'ar_qa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-sa' => array('language' => 'Arabic (Saudi Arabia)', 'locale' => 'ar_sa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-sy' => array('language' => 'Arabic (Syria)', 'locale' => 'ar_sy', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-tn' => array('language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'bo' => array('language' => 'Tibetan', 'locale' => 'bod', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'bo-cn' => array('language' => 'Tibetan (China)', 'locale' => 'bo_cn', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'bo-in' => array('language' => 'Tibetan (India)', 'locale' => 'bo_in', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'cs' => array('language' => 'Czech', 'locale' => 'ces', 'localeFallback' => 'ces', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'da' => array('language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'da-dk' => array('language' => 'Danish (Denmark)', 'locale' => 'da_dk', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-at' => array('language' => 'German (Austria)', 'locale' => 'de_at', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-ch' => array('language' => 'German (Swiss)', 'locale' => 'de_ch', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-de' => array('language' => 'German (Germany)', 'locale' => 'de_de', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-li' => array('language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-lu' => array('language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'el' => array('language' => 'Greek', 'locale' => 'ell', 'localeFallback' => 'ell', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-au' => array('language' => 'English (Australian)', 'locale' => 'en_au', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-bz' => array('language' => 'English (Belize)', 'locale' => 'en_bz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-ca' => array('language' => 'English (Canadian)', 'locale' => 'en_ca', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-gb' => array('language' => 'English (British)', 'locale' => 'en_gb', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-ie' => array('language' => 'English (Ireland)', 'locale' => 'en_ie', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-jm' => array('language' => 'English (Jamaica)', 'locale' => 'en_jm', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-tt' => array('language' => 'English (Trinidad)', 'locale' => 'en_tt', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-us' => array('language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-za' => array('language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es' => array('language' => 'Spanish (Spain - Traditional)', 'locale' => 'spa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-ar' => array('language' => 'Spanish (Argentina)', 'locale' => 'es_ar', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-bo' => array('language' => 'Spanish (Bolivia)', 'locale' => 'es_bo', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-cl' => array('language' => 'Spanish (Chile)', 'locale' => 'es_cl', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-co' => array('language' => 'Spanish (Colombia)', 'locale' => 'es_co', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-cr' => array('language' => 'Spanish (Costa Rica)', 'locale' => 'es_cr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-ec' => array('language' => 'Spanish (Ecuador)', 'locale' => 'es_ec', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-es' => array('language' => 'Spanish (Spain)', 'locale' => 'es_es', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-gt' => array('language' => 'Spanish (Guatemala)', 'locale' => 'es_gt', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-hn' => array('language' => 'Spanish (Honduras)', 'locale' => 'es_hn', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-mx' => array('language' => 'Spanish (Mexican)', 'locale' => 'es_mx', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-ni' => array('language' => 'Spanish (Nicaragua)', 'locale' => 'es_ni', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-pa' => array('language' => 'Spanish (Panama)', 'locale' => 'es_pa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-pe' => array('language' => 'Spanish (Peru)', 'locale' => 'es_pe', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-pr' => array('language' => 'Spanish (Puerto Rico)', 'locale' => 'es_pr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-py' => array('language' => 'Spanish (Paraguay)', 'locale' => 'es_py', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-sv' => array('language' => 'Spanish (El Salvador)', 'locale' => 'es_sv', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-uy' => array('language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-ve' => array('language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'et' => array('language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'et-ee' => array('language' => 'Estonian (Estonia)', 'locale' => 'et_ee', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'eu' => array('language' => 'Basque', 'locale' => 'eus', 'localeFallback' => 'eus', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fa' => array('language' => 'Farsi', 'locale' => 'fas', 'localeFallback' => 'fas', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fi-fi' => array('language' => 'Finnish (Finland)', 'locale' => 'fi_fi', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fo-fo' => array('language' => 'Faeroese (Faroe Island)', 'locale' => 'fo_fo', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr' => array('language' => 'French (Standard)', 'locale' => 'fra', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-be' => array('language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-ca' => array('language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-ch' => array('language' => 'French (Swiss)', 'locale' => 'fr_ch', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-fr' => array('language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-lu' => array('language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ga' => array('language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'gd' => array('language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'gd-ie' => array('language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'gl' => array('language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'hi' => array('language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'hr' => array('language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'hu' => array('language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'hu-hu' => array('language' => 'Hungarian (Hungary)', 'locale' => 'hu_hu', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'is' => array('language' => 'Icelandic', 'locale' => 'isl', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'is-is' => array('language' => 'Icelandic (Iceland)', 'locale' => 'is_is', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'kk' => array('language' => 'Kazakh', 'locale' => 'kaz', 'localeFallback' => 'kaz', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'kl' => array('language' => 'Kalaallisut (Greenlandic)', 'locale' => 'kal', 'localeFallback' => 'kal', 'charset' => 'kl', 'direction' => 'ltr'), - 'kl-gl' => array('language' => 'Kalaallisut (Greenland)', 'locale' => 'kl_gl', 'localeFallback' => 'kal', 'charset' => 'kl', 'direction' => 'ltr'), - 'ko' => array('language' => 'Korean', 'locale' => 'kor', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), - 'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), - 'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), - 'koi8-r' => array('language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r', 'direction' => 'ltr'), - 'lb' => array('language' => 'Luxembourgish', 'locale' => 'ltz', 'localeFallback' => 'ltz', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'li' => array('language' => 'Limburgish', 'locale' => 'lim', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'lv-lv' => array('language' => 'Latvian (Latvia)', 'locale' => 'lv_lv', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'mk' => array('language' => 'FYRO Macedonian', 'locale' => 'mkd', 'localeFallback' => 'mkd', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'mk-mk' => array('language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mkd', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ms' => array('language' => 'Malaysian', 'locale' => 'msa', 'localeFallback' => 'msa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'mt' => array('language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'nb-no' => array('language' => 'Norwegian Bokmål (Norway)', 'locale' => 'nb_no', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'nl' => array('language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'nl-be' => array('language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'nl-nl' => array('language' => 'Dutch (Netherlands)', 'locale' => 'nl_nl', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'nn' => array('language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'nn-no' => array('language' => 'Norwegian Nynorsk (Norway)', 'locale' => 'nn_no', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'no' => array('language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'pl' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'pl-pl' => array('language' => 'Polish (Poland)', 'locale' => 'pl_pl', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'pt' => array('language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'rm' => array('language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ro' => array('language' => 'Romanian', 'locale' => 'ron', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ro-ro' => array('language' => 'Romanian (Romania)', 'locale' => 'ro_ro', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ru' => array('language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ru-ru' => array('language' => 'Russian (Russia)', 'locale' => 'ru_ru', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sk' => array('language' => 'Slovak', 'locale' => 'slk', 'localeFallback' => 'slk', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sq' => array('language' => 'Albanian', 'locale' => 'sqi', 'localeFallback' => 'sqi', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sr' => array('language' => 'Serbian', 'locale' => 'srp', 'localeFallback' => 'srp', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sv' => array('language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sv-se' => array('language' => 'Swedish (Sweden)', 'locale' => 'sv_se', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sv-fi' => array('language' => 'Swedish (Finland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'se' => array('language' => 'Sami', 'locale' => 'sme', 'localeFallback' => 'sme', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'th' => array('language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'tn' => array('language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'tr' => array('language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ts' => array('language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'uk' => array('language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl'), - 've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'cy' => array('language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zh' => array('language' => 'Chinese', 'locale' => 'zho', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zh-cn' => array('language' => 'Chinese (PRC)', 'locale' => 'zh_cn', 'localeFallback' => 'zho', 'charset' => 'GB2312', 'direction' => 'ltr'), - 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + protected $_l10nCatalog = [ + 'af' => ['language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ar' => ['language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-ae' => ['language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-bh' => ['language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-dz' => ['language' => 'Arabic (Algeria)', 'locale' => 'ar_dz', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-eg' => ['language' => 'Arabic (Egypt)', 'locale' => 'ar_eg', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-iq' => ['language' => 'Arabic (Iraq)', 'locale' => 'ar_iq', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-jo' => ['language' => 'Arabic (Jordan)', 'locale' => 'ar_jo', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-kw' => ['language' => 'Arabic (Kuwait)', 'locale' => 'ar_kw', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-lb' => ['language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-ly' => ['language' => 'Arabic (Libya)', 'locale' => 'ar_ly', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-ma' => ['language' => 'Arabic (Morocco)', 'locale' => 'ar_ma', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-om' => ['language' => 'Arabic (Oman)', 'locale' => 'ar_om', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-qa' => ['language' => 'Arabic (Qatar)', 'locale' => 'ar_qa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-sa' => ['language' => 'Arabic (Saudi Arabia)', 'locale' => 'ar_sa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-sy' => ['language' => 'Arabic (Syria)', 'locale' => 'ar_sy', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-tn' => ['language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-ye' => ['language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'be' => ['language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'bg' => ['language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'bo' => ['language' => 'Tibetan', 'locale' => 'bod', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'bo-cn' => ['language' => 'Tibetan (China)', 'locale' => 'bo_cn', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'bo-in' => ['language' => 'Tibetan (India)', 'locale' => 'bo_in', 'localeFallback' => 'bod', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'bs' => ['language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ca' => ['language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'cs' => ['language' => 'Czech', 'locale' => 'ces', 'localeFallback' => 'ces', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'da' => ['language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'da-dk' => ['language' => 'Danish (Denmark)', 'locale' => 'da_dk', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de' => ['language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-at' => ['language' => 'German (Austria)', 'locale' => 'de_at', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-ch' => ['language' => 'German (Swiss)', 'locale' => 'de_ch', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-de' => ['language' => 'German (Germany)', 'locale' => 'de_de', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-li' => ['language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-lu' => ['language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'el' => ['language' => 'Greek', 'locale' => 'ell', 'localeFallback' => 'ell', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en' => ['language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-au' => ['language' => 'English (Australian)', 'locale' => 'en_au', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-bz' => ['language' => 'English (Belize)', 'locale' => 'en_bz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-ca' => ['language' => 'English (Canadian)', 'locale' => 'en_ca', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-gb' => ['language' => 'English (British)', 'locale' => 'en_gb', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-ie' => ['language' => 'English (Ireland)', 'locale' => 'en_ie', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-jm' => ['language' => 'English (Jamaica)', 'locale' => 'en_jm', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-nz' => ['language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-tt' => ['language' => 'English (Trinidad)', 'locale' => 'en_tt', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-us' => ['language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-za' => ['language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es' => ['language' => 'Spanish (Spain - Traditional)', 'locale' => 'spa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-ar' => ['language' => 'Spanish (Argentina)', 'locale' => 'es_ar', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-bo' => ['language' => 'Spanish (Bolivia)', 'locale' => 'es_bo', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-cl' => ['language' => 'Spanish (Chile)', 'locale' => 'es_cl', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-co' => ['language' => 'Spanish (Colombia)', 'locale' => 'es_co', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-cr' => ['language' => 'Spanish (Costa Rica)', 'locale' => 'es_cr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-do' => ['language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-ec' => ['language' => 'Spanish (Ecuador)', 'locale' => 'es_ec', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-es' => ['language' => 'Spanish (Spain)', 'locale' => 'es_es', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-gt' => ['language' => 'Spanish (Guatemala)', 'locale' => 'es_gt', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-hn' => ['language' => 'Spanish (Honduras)', 'locale' => 'es_hn', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-mx' => ['language' => 'Spanish (Mexican)', 'locale' => 'es_mx', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-ni' => ['language' => 'Spanish (Nicaragua)', 'locale' => 'es_ni', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-pa' => ['language' => 'Spanish (Panama)', 'locale' => 'es_pa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-pe' => ['language' => 'Spanish (Peru)', 'locale' => 'es_pe', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-pr' => ['language' => 'Spanish (Puerto Rico)', 'locale' => 'es_pr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-py' => ['language' => 'Spanish (Paraguay)', 'locale' => 'es_py', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-sv' => ['language' => 'Spanish (El Salvador)', 'locale' => 'es_sv', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-uy' => ['language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-ve' => ['language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'et' => ['language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'et-ee' => ['language' => 'Estonian (Estonia)', 'locale' => 'et_ee', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'eu' => ['language' => 'Basque', 'locale' => 'eus', 'localeFallback' => 'eus', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fa' => ['language' => 'Farsi', 'locale' => 'fas', 'localeFallback' => 'fas', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'fi' => ['language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fi-fi' => ['language' => 'Finnish (Finland)', 'locale' => 'fi_fi', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fo' => ['language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fo-fo' => ['language' => 'Faeroese (Faroe Island)', 'locale' => 'fo_fo', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr' => ['language' => 'French (Standard)', 'locale' => 'fra', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-be' => ['language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-ca' => ['language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-ch' => ['language' => 'French (Swiss)', 'locale' => 'fr_ch', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-fr' => ['language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-lu' => ['language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ga' => ['language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'gd' => ['language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'gd-ie' => ['language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'gl' => ['language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'he' => ['language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'hi' => ['language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'hr' => ['language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'hu' => ['language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'hu-hu' => ['language' => 'Hungarian (Hungary)', 'locale' => 'hu_hu', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'hy' => ['language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'id' => ['language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'is' => ['language' => 'Icelandic', 'locale' => 'isl', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'is-is' => ['language' => 'Icelandic (Iceland)', 'locale' => 'is_is', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'it' => ['language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'it-ch' => ['language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ja' => ['language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'kk' => ['language' => 'Kazakh', 'locale' => 'kaz', 'localeFallback' => 'kaz', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'kl' => ['language' => 'Kalaallisut (Greenlandic)', 'locale' => 'kal', 'localeFallback' => 'kal', 'charset' => 'kl', 'direction' => 'ltr'], + 'kl-gl' => ['language' => 'Kalaallisut (Greenland)', 'locale' => 'kl_gl', 'localeFallback' => 'kal', 'charset' => 'kl', 'direction' => 'ltr'], + 'ko' => ['language' => 'Korean', 'locale' => 'kor', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'], + 'ko-kp' => ['language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'], + 'ko-kr' => ['language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'], + 'koi8-r' => ['language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r', 'direction' => 'ltr'], + 'lb' => ['language' => 'Luxembourgish', 'locale' => 'ltz', 'localeFallback' => 'ltz', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'li' => ['language' => 'Limburgish', 'locale' => 'lim', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'lt' => ['language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'lv' => ['language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'lv-lv' => ['language' => 'Latvian (Latvia)', 'locale' => 'lv_lv', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'mk' => ['language' => 'FYRO Macedonian', 'locale' => 'mkd', 'localeFallback' => 'mkd', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'mk-mk' => ['language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mkd', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ms' => ['language' => 'Malaysian', 'locale' => 'msa', 'localeFallback' => 'msa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'mt' => ['language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'nb' => ['language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'nb-no' => ['language' => 'Norwegian Bokmål (Norway)', 'locale' => 'nb_no', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'nl' => ['language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'nl-be' => ['language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'nl-nl' => ['language' => 'Dutch (Netherlands)', 'locale' => 'nl_nl', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'nn' => ['language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'nn-no' => ['language' => 'Norwegian Nynorsk (Norway)', 'locale' => 'nn_no', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'no' => ['language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'pl' => ['language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'pl-pl' => ['language' => 'Polish (Poland)', 'locale' => 'pl_pl', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'pt' => ['language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'pt-br' => ['language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'rm' => ['language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ro' => ['language' => 'Romanian', 'locale' => 'ron', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ro-mo' => ['language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ro-ro' => ['language' => 'Romanian (Romania)', 'locale' => 'ro_ro', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ru' => ['language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ru-mo' => ['language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ru-ru' => ['language' => 'Russian (Russia)', 'locale' => 'ru_ru', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sb' => ['language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sk' => ['language' => 'Slovak', 'locale' => 'slk', 'localeFallback' => 'slk', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sl' => ['language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sq' => ['language' => 'Albanian', 'locale' => 'sqi', 'localeFallback' => 'sqi', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sr' => ['language' => 'Serbian', 'locale' => 'srp', 'localeFallback' => 'srp', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sv' => ['language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sv-se' => ['language' => 'Swedish (Sweden)', 'locale' => 'sv_se', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sv-fi' => ['language' => 'Swedish (Finland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'se' => ['language' => 'Sami', 'locale' => 'sme', 'localeFallback' => 'sme', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'th' => ['language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'tn' => ['language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'tr' => ['language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ts' => ['language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'uk' => ['language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ur' => ['language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl'], + 've' => ['language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'vi' => ['language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'cy' => ['language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'xh' => ['language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'yi' => ['language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zh' => ['language' => 'Chinese', 'locale' => 'zho', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zh-cn' => ['language' => 'Chinese (PRC)', 'locale' => 'zh_cn', 'localeFallback' => 'zho', 'charset' => 'GB2312', 'direction' => 'ltr'], + 'zh-hk' => ['language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zh-sg' => ['language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zh-tw' => ['language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zu' => ['language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; /** * Class constructor @@ -394,17 +394,17 @@ protected function _setLanguage($language = null) { if ($catalog) { $this->language = $catalog['language']; - $this->languagePath = array_unique(array( + $this->languagePath = array_unique([ $catalog['locale'], $catalog['localeFallback'] - )); + ]); $this->lang = $language; $this->locale = $catalog['locale']; $this->charset = $catalog['charset']; $this->direction = $catalog['direction']; } elseif ($language) { $this->lang = $language; - $this->languagePath = array($language); + $this->languagePath = [$language]; } if ($this->default && $language !== $this->default) { @@ -436,7 +436,7 @@ protected function _autoLanguage() { $this->_setLanguage($langKey); return true; } - if (strpos($langKey, '-') !== false) { + if (str_contains($langKey, '-')) { $langKey = substr($langKey, 0, 2); if (isset($this->_l10nCatalog[$langKey])) { $this->_setLanguage($langKey); @@ -456,7 +456,7 @@ protected function _autoLanguage() { */ public function map($mixed = null) { if (is_array($mixed)) { - $result = array(); + $result = []; foreach ($mixed as $_mixed) { if ($_result = $this->map($_mixed)) { $result[$_mixed] = $_result; @@ -468,10 +468,7 @@ public function map($mixed = null) { if (strlen($mixed) === 2 && in_array($mixed, $this->_l10nMap)) { return array_search($mixed, $this->_l10nMap); } - if (isset($this->_l10nMap[$mixed])) { - return $this->_l10nMap[$mixed]; - } - return false; + return $this->_l10nMap[$mixed] ?? false; } return $this->_l10nMap; } @@ -485,7 +482,7 @@ public function map($mixed = null) { */ public function catalog($language = null) { if (is_array($language)) { - $result = array(); + $result = []; foreach ($language as $_language) { if ($_result = $this->catalog($_language)) { $result[$_language] = $_result; diff --git a/lib/Cake/I18n/Multibyte.php b/lib/Cake/I18n/Multibyte.php index c11082ac0b..c72e9689af 100644 --- a/lib/Cake/I18n/Multibyte.php +++ b/lib/Cake/I18n/Multibyte.php @@ -28,14 +28,14 @@ class Multibyte { * * @var array */ - protected static $_caseFold = array(); + protected static $_caseFold = []; /** * Holds an array of Unicode code point ranges * * @var array */ - protected static $_codeRange = array(); + protected static $_codeRange = []; /** * Holds the current code point range @@ -52,9 +52,9 @@ class Multibyte { * @return array */ public static function utf8($string) { - $map = array(); + $map = []; - $values = array(); + $values = []; $find = 1; $length = strlen($string); @@ -75,7 +75,7 @@ public static function utf8($string) { } else { $map[] = (($values[0] % 32) * 64) + ($values[1] % 64); } - $values = array(); + $values = []; $find = 1; } } @@ -152,7 +152,7 @@ public static function stristr($haystack, $needle, $part = false) { $needle = Multibyte::utf8($needle); $needleCount = count($needle); - $parts = array(); + $parts = []; $position = 0; while (($found === false) && ($position < $haystackCount)) { @@ -267,7 +267,7 @@ public static function strrchr($haystack, $needle, $part = false) { $needle = Multibyte::utf8($needle); $needleCount = count($needle); - $parts = array(); + $parts = []; $position = 0; while (($found === false) && ($position < $haystackCount)) { @@ -278,7 +278,7 @@ public static function strrchr($haystack, $needle, $part = false) { $found = true; } unset($parts[$position - 1]); - $haystack = array_merge(array($haystack[$position]), $haystack); + $haystack = array_merge([$haystack[$position]], $haystack); break; } } @@ -329,7 +329,7 @@ public static function strrichr($haystack, $needle, $part = false) { $needle = Multibyte::utf8($needle); $needleCount = count($needle); - $parts = array(); + $parts = []; $position = 0; while (($found === false) && ($position < $haystackCount)) { @@ -340,7 +340,7 @@ public static function strrichr($haystack, $needle, $part = false) { $found = true; } unset($parts[$position - 1]); - $haystack = array_merge(array($haystack[$position]), $haystack); + $haystack = array_merge([$haystack[$position]], $haystack); break; } } @@ -490,7 +490,7 @@ public static function strstr($haystack, $needle, $part = false) { $needle = Multibyte::utf8($needle); $needleCount = count($needle); - $parts = array(); + $parts = []; $position = 0; while (($found === false) && ($position < $haystackCount)) { @@ -535,7 +535,7 @@ public static function strtolower($string) { $utf8Map = Multibyte::utf8($string); $length = count($utf8Map); - $lowerCase = array(); + $lowerCase = []; for ($i = 0; $i < $length; $i++) { $char = $utf8Map[$i]; @@ -579,8 +579,8 @@ public static function strtoupper($string) { $utf8Map = Multibyte::utf8($string); $length = count($utf8Map); - $replaced = array(); - $upperCase = array(); + $replaced = []; + $upperCase = []; for ($i = 0; $i < $length; $i++) { $char = $utf8Map[$i]; @@ -716,7 +716,7 @@ public static function substr($string, $start, $length = null) { } $string = array_values($string); - $value = array(); + $value = []; for ($i = 0; $i < $length; $i++) { $value[] = $string[$i]; } @@ -748,7 +748,7 @@ public static function mimeEncode($string, $charset = null, $newline = "\r\n") { $length = 75 - strlen($start) - strlen($end); $length = $length - ($length % 4); if ($charset === 'UTF-8') { - $parts = array(); + $parts = []; $maxchars = floor(($length * 3) / 4); $stringLength = strlen($string); while ($stringLength > $maxchars) { @@ -827,11 +827,11 @@ protected static function _codepoint($decimal) { * @return array */ protected static function _find($char, $type = 'lower') { - $found = array(); + $found = []; if (!isset(static::$_codeRange[$char])) { $range = static::_codepoint($char); if ($range === false) { - return array(); + return []; } if (!Configure::configured('_cake_core_')) { App::uses('PhpReader', 'Configure'); @@ -843,7 +843,7 @@ protected static function _find($char, $type = 'lower') { } if (!static::$_codeRange[$char]) { - return array(); + return []; } static::$_table = static::$_codeRange[$char]; $count = count(static::$_caseFold[static::$_table]); diff --git a/lib/Cake/Log/CakeLog.php b/lib/Cake/Log/CakeLog.php index 3b2cfb6cd7..f4c552afd0 100644 --- a/lib/Cake/Log/CakeLog.php +++ b/lib/Cake/Log/CakeLog.php @@ -90,7 +90,7 @@ class CakeLog { * * @var array */ - protected static $_defaultLevels = array( + protected static $_defaultLevels = [ 'emergency' => LOG_EMERG, 'alert' => LOG_ALERT, 'critical' => LOG_CRIT, @@ -99,7 +99,7 @@ class CakeLog { 'notice' => LOG_NOTICE, 'info' => LOG_INFO, 'debug' => LOG_DEBUG, - ); + ]; /** * Active log levels for this instance. @@ -261,7 +261,7 @@ public static function configured() { * @param bool $append true to append, false to replace * @return array Active log levels */ - public static function levels($levels = array(), $append = true) { + public static function levels($levels = [], $append = true) { if (empty(static::$_Collection)) { static::_init(); } @@ -405,7 +405,7 @@ public static function stream($streamName) { * @return bool Success * @link https://book.cakephp.org/2.0/en/core-libraries/logging.html#writing-to-logs */ - public static function write($type, $message, $scope = array()) { + public static function write($type, $message, $scope = []) { if (empty(static::$_Collection)) { static::_init(); } @@ -419,7 +419,7 @@ public static function write($type, $message, $scope = array()) { $logged = false; foreach (static::$_Collection->enabled() as $streamName) { $logger = static::$_Collection->{$streamName}; - $types = $scopes = $config = array(); + $types = $scopes = $config = []; if (method_exists($logger, 'config')) { $config = $logger->config(); } @@ -457,7 +457,7 @@ public static function write($type, $message, $scope = array()) { * See CakeLog::config() for more information on logging scopes. * @return bool Success */ - public static function emergency($message, $scope = array()) { + public static function emergency($message, $scope = []) { return static::write(static::$_levelMap['emergency'], $message, $scope); } @@ -469,7 +469,7 @@ public static function emergency($message, $scope = array()) { * See CakeLog::config() for more information on logging scopes. * @return bool Success */ - public static function alert($message, $scope = array()) { + public static function alert($message, $scope = []) { return static::write(static::$_levelMap['alert'], $message, $scope); } @@ -481,7 +481,7 @@ public static function alert($message, $scope = array()) { * See CakeLog::config() for more information on logging scopes. * @return bool Success */ - public static function critical($message, $scope = array()) { + public static function critical($message, $scope = []) { return static::write(static::$_levelMap['critical'], $message, $scope); } @@ -493,7 +493,7 @@ public static function critical($message, $scope = array()) { * See CakeLog::config() for more information on logging scopes. * @return bool Success */ - public static function error($message, $scope = array()) { + public static function error($message, $scope = []) { return static::write(static::$_levelMap['error'], $message, $scope); } @@ -505,7 +505,7 @@ public static function error($message, $scope = array()) { * See CakeLog::config() for more information on logging scopes. * @return bool Success */ - public static function warning($message, $scope = array()) { + public static function warning($message, $scope = []) { return static::write(static::$_levelMap['warning'], $message, $scope); } @@ -517,7 +517,7 @@ public static function warning($message, $scope = array()) { * See CakeLog::config() for more information on logging scopes. * @return bool Success */ - public static function notice($message, $scope = array()) { + public static function notice($message, $scope = []) { return static::write(static::$_levelMap['notice'], $message, $scope); } @@ -529,7 +529,7 @@ public static function notice($message, $scope = array()) { * See CakeLog::config() for more information on logging scopes. * @return bool Success */ - public static function debug($message, $scope = array()) { + public static function debug($message, $scope = []) { return static::write(static::$_levelMap['debug'], $message, $scope); } @@ -541,7 +541,7 @@ public static function debug($message, $scope = array()) { * See CakeLog::config() for more information on logging scopes. * @return bool Success */ - public static function info($message, $scope = array()) { + public static function info($message, $scope = []) { return static::write(static::$_levelMap['info'], $message, $scope); } diff --git a/lib/Cake/Log/Engine/BaseLog.php b/lib/Cake/Log/Engine/BaseLog.php index f2ad6e142f..18942eb433 100644 --- a/lib/Cake/Log/Engine/BaseLog.php +++ b/lib/Cake/Log/Engine/BaseLog.php @@ -30,14 +30,14 @@ abstract class BaseLog implements CakeLogInterface { * * @var string */ - protected $_config = array(); + protected $_config = []; /** * Constructor * * @param array $config Configuration array */ - public function __construct($config = array()) { + public function __construct($config = []) { $this->config($config); } @@ -52,11 +52,11 @@ public function __construct($config = array()) { * @param array $config engine configuration * @return array */ - public function config($config = array()) { + public function config($config = []) { if (!empty($config)) { - foreach (array('types', 'scopes') as $option) { + foreach (['types', 'scopes'] as $option) { if (isset($config[$option]) && is_string($config[$option])) { - $config[$option] = array($config[$option]); + $config[$option] = [$config[$option]]; } } $this->_config = $config; diff --git a/lib/Cake/Log/Engine/ConsoleLog.php b/lib/Cake/Log/Engine/ConsoleLog.php index ced97e6398..f7c2876d9b 100644 --- a/lib/Cake/Log/Engine/ConsoleLog.php +++ b/lib/Cake/Log/Engine/ConsoleLog.php @@ -46,7 +46,7 @@ class ConsoleLog extends BaseLog { * @param array $config Options for the FileLog, see above. * @throws CakeLogException */ - public function __construct($config = array()) { + public function __construct($config = []) { parent::__construct($config); if ((DS === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') || (function_exists('posix_isatty') && !posix_isatty($this->_output)) @@ -55,12 +55,12 @@ public function __construct($config = array()) { } else { $outputAs = ConsoleOutput::COLOR; } - $config = Hash::merge(array( + $config = Hash::merge([ 'stream' => 'php://stderr', 'types' => null, - 'scopes' => array(), + 'scopes' => [], 'outputAs' => $outputAs, - ), $this->_config); + ], $this->_config); $config = $this->config($config); if ($config['stream'] instanceof ConsoleOutput) { $this->_output = $config['stream']; diff --git a/lib/Cake/Log/Engine/FileLog.php b/lib/Cake/Log/Engine/FileLog.php index c2d5bf734d..3ee671a442 100644 --- a/lib/Cake/Log/Engine/FileLog.php +++ b/lib/Cake/Log/Engine/FileLog.php @@ -34,15 +34,15 @@ class FileLog extends BaseLog { * @var array * @see FileLog::__construct() */ - protected $_defaults = array( + protected $_defaults = [ 'path' => LOGS, 'file' => null, 'types' => null, - 'scopes' => array(), + 'scopes' => [], 'rotate' => 10, 'size' => 10485760, // 10MB 'mask' => null, - ); + ]; /** * Path to save log files on. @@ -85,7 +85,7 @@ class FileLog extends BaseLog { * * @param array $config Options for the FileLog, see above. */ - public function __construct($config = array()) { + public function __construct($config = []) { $config = Hash::merge($this->_defaults, $config); parent::__construct($config); } @@ -96,7 +96,7 @@ public function __construct($config = array()) { * @param array $config Engine configuration * @return array */ - public function config($config = array()) { + public function config($config = []) { parent::config($config); if (!empty($config['path'])) { @@ -108,7 +108,7 @@ public function config($config = array()) { if (!empty($config['file'])) { $this->_file = $config['file']; - if (substr($this->_file, -4) !== '.log') { + if (!str_ends_with($this->_file, '.log')) { $this->_file .= '.log'; } } @@ -149,7 +149,7 @@ public function write($type, $message) { $selfError = true; trigger_error(__d( 'cake_dev', 'Could not apply permission mask "%s" on log file "%s"', - array($this->_config['mask'], $pathname)), E_USER_WARNING); + [$this->_config['mask'], $pathname]), E_USER_WARNING); $selfError = false; } return $result; @@ -162,7 +162,7 @@ public function write($type, $message) { * @return string File name */ protected function _getFilename($type) { - $debugTypes = array('notice', 'info', 'debug'); + $debugTypes = ['notice', 'info', 'debug']; if (!empty($this->_file)) { $filename = $this->_file; diff --git a/lib/Cake/Log/Engine/SyslogLog.php b/lib/Cake/Log/Engine/SyslogLog.php index d20841e255..9849d7a27b 100644 --- a/lib/Cake/Log/Engine/SyslogLog.php +++ b/lib/Cake/Log/Engine/SyslogLog.php @@ -51,19 +51,19 @@ class SyslogLog extends BaseLog { * * @var array */ - protected $_defaults = array( + protected $_defaults = [ 'format' => '%s: %s', 'flag' => LOG_ODELAY, 'prefix' => '', 'facility' => LOG_USER - ); + ]; /** * Used to map the string names back to their LOG_* constants * * @var array */ - protected $_priorityMap = array( + protected $_priorityMap = [ 'emergency' => LOG_EMERG, 'alert' => LOG_ALERT, 'critical' => LOG_CRIT, @@ -72,7 +72,7 @@ class SyslogLog extends BaseLog { 'notice' => LOG_NOTICE, 'info' => LOG_INFO, 'debug' => LOG_DEBUG - ); + ]; /** * Whether the logger connection is open or not @@ -87,7 +87,7 @@ class SyslogLog extends BaseLog { * * @param array $config Options list. */ - public function __construct($config = array()) { + public function __construct($config = []) { $config += $this->_defaults; parent::__construct($config); } diff --git a/lib/Cake/Log/LogEngineCollection.php b/lib/Cake/Log/LogEngineCollection.php index f68a332084..e6dca5d3ec 100644 --- a/lib/Cake/Log/LogEngineCollection.php +++ b/lib/Cake/Log/LogEngineCollection.php @@ -33,11 +33,11 @@ class LogEngineCollection extends ObjectCollection { * @return BaseLog BaseLog engine instance * @throws CakeLogException when logger class does not implement a write method */ - public function load($name, $options = array()) { - $enable = isset($options['enabled']) ? $options['enabled'] : true; + public function load($name, $options = []) { + $enable = $options['enabled'] ?? true; $loggerName = $options['engine']; unset($options['engine']); - $className = $this->_getLogger($loggerName); + $className = static::_getLogger($loggerName); $logger = new $className($options); if (!$logger instanceof CakeLogInterface) { throw new CakeLogException( @@ -60,8 +60,8 @@ public function load($name, $options = array()) { * @throws CakeLogException */ protected static function _getLogger($loggerName) { - list($plugin, $loggerName) = pluginSplit($loggerName, true); - if (substr($loggerName, -3) !== 'Log') { + [$plugin, $loggerName] = pluginSplit($loggerName, true); + if (!str_ends_with($loggerName, 'Log')) { $loggerName .= 'Log'; } App::uses($loggerName, $plugin . 'Log/Engine'); diff --git a/lib/Cake/Model/AclNode.php b/lib/Cake/Model/AclNode.php index 11c9a51016..210e37fd0a 100644 --- a/lib/Cake/Model/AclNode.php +++ b/lib/Cake/Model/AclNode.php @@ -35,7 +35,7 @@ class AclNode extends Model { * * @var array */ - public $actsAs = array('Tree' => array('type' => 'nested')); + public $actsAs = ['Tree' => ['type' => 'nested']]; /** * Constructor @@ -78,43 +78,43 @@ public function node($ref = null) { $start = $path[0]; unset($path[0]); - $queryData = array( - 'conditions' => array( + $queryData = [ + 'conditions' => [ $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft"), - $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght")), - 'fields' => array('id', 'parent_id', 'model', 'foreign_key', 'alias'), - 'joins' => array(array( + $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght")], + 'fields' => ['id', 'parent_id', 'model', 'foreign_key', 'alias'], + 'joins' => [[ 'table' => $table, 'alias' => "{$type}0", 'type' => 'INNER', - 'conditions' => array("{$type}0.alias" => $start) - )), + 'conditions' => ["{$type}0.alias" => $start] + ]], 'order' => $db->name("{$type}.lft") . ' DESC' - ); + ]; - $conditionsAfterJoin = array(); + $conditionsAfterJoin = []; foreach ($path as $i => $alias) { $j = $i - 1; - $queryData['joins'][] = array( + $queryData['joins'][] = [ 'table' => $table, 'alias' => "{$type}{$i}", 'type' => 'INNER', - 'conditions' => array( + 'conditions' => [ "{$type}{$i}.alias" => $alias - ) - ); + ] + ]; // it will be better if this conditions will performs after join operation $conditionsAfterJoin[] = $db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id"); $conditionsAfterJoin[] = $db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght"); $conditionsAfterJoin[] = $db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft"); - $queryData['conditions'] = array('or' => array( + $queryData['conditions'] = ['or' => [ $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght"), - $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}{$i}.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}{$i}.rght")) - ); + $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}{$i}.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}{$i}.rght")] + ]; } $queryData['conditions'] = array_merge($queryData['conditions'], $conditionsAfterJoin); $result = $db->read($this, $queryData, -1); @@ -127,12 +127,12 @@ public function node($ref = null) { return false; } } elseif (is_object($ref) && $ref instanceof Model) { - $ref = array('model' => $ref->name, 'foreign_key' => $ref->id); + $ref = ['model' => $ref->name, 'foreign_key' => $ref->id]; } elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) { $name = key($ref); - list(, $alias) = pluginSplit($name); + [, $alias] = pluginSplit($name); - $model = ClassRegistry::init(array('class' => $name, 'alias' => $alias)); + $model = ClassRegistry::init(['class' => $name, 'alias' => $alias]); if (empty($model)) { throw new CakeException('cake_dev', "Model class '%s' not found in AclNode::node() when trying to bind %s object", $type, $this->alias); @@ -143,7 +143,7 @@ public function node($ref = null) { $tmpRef = $model->bindNode($ref); } if (empty($tmpRef)) { - $ref = array('model' => $alias, 'foreign_key' => $ref[$name][$model->primaryKey]); + $ref = ['model' => $alias, 'foreign_key' => $ref[$name][$model->primaryKey]]; } else { if (is_string($tmpRef)) { return $this->node($tmpRef); @@ -157,25 +157,25 @@ public function node($ref = null) { $ref = current($ref); } foreach ($ref as $key => $val) { - if (strpos($key, $type) !== 0 && strpos($key, '.') === false) { + if (!str_starts_with($key, $type) && !str_contains($key, '.')) { unset($ref[$key]); $ref["{$type}0.{$key}"] = $val; } } - $queryData = array( + $queryData = [ 'conditions' => $ref, - 'fields' => array('id', 'parent_id', 'model', 'foreign_key', 'alias'), - 'joins' => array(array( + 'fields' => ['id', 'parent_id', 'model', 'foreign_key', 'alias'], + 'joins' => [[ 'table' => $table, 'alias' => "{$type}0", 'type' => 'INNER', - 'conditions' => array( + 'conditions' => [ $db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft"), $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght") - ) - )), + ] + ]], 'order' => $db->name("{$type}.lft") . ' DESC' - ); + ]; $result = $db->read($this, $queryData, -1); if (!$result) { diff --git a/lib/Cake/Model/Aco.php b/lib/Cake/Model/Aco.php index 2a20d8e599..41495df7d9 100644 --- a/lib/Cake/Model/Aco.php +++ b/lib/Cake/Model/Aco.php @@ -35,5 +35,5 @@ class Aco extends AclNode { * * @var array */ - public $hasAndBelongsToMany = array('Aro' => array('with' => 'Permission')); + public $hasAndBelongsToMany = ['Aro' => ['with' => 'Permission']]; } diff --git a/lib/Cake/Model/AcoAction.php b/lib/Cake/Model/AcoAction.php index 20cfe27934..fa911de799 100644 --- a/lib/Cake/Model/AcoAction.php +++ b/lib/Cake/Model/AcoAction.php @@ -35,5 +35,5 @@ class AcoAction extends AppModel { * * @var array */ - public $belongsTo = array('Aco'); + public $belongsTo = ['Aco']; } diff --git a/lib/Cake/Model/Aro.php b/lib/Cake/Model/Aro.php index de8e9fbf67..accdde41ee 100644 --- a/lib/Cake/Model/Aro.php +++ b/lib/Cake/Model/Aro.php @@ -35,5 +35,5 @@ class Aro extends AclNode { * * @var array */ - public $hasAndBelongsToMany = array('Aco' => array('with' => 'Permission')); + public $hasAndBelongsToMany = ['Aco' => ['with' => 'Permission']]; } diff --git a/lib/Cake/Model/Behavior/AclBehavior.php b/lib/Cake/Model/Behavior/AclBehavior.php index 45a3260994..6808f37c0e 100644 --- a/lib/Cake/Model/Behavior/AclBehavior.php +++ b/lib/Cake/Model/Behavior/AclBehavior.php @@ -37,7 +37,7 @@ class AclBehavior extends ModelBehavior { * * @var array */ - protected $_typeMaps = array('requester' => 'Aro', 'controlled' => 'Aco', 'both' => array('Aro', 'Aco')); + protected $_typeMaps = ['requester' => 'Aro', 'controlled' => 'Aco', 'both' => ['Aro', 'Aco']]; /** * Sets up the configuration for the model, and loads ACL models if they haven't been already @@ -46,18 +46,18 @@ class AclBehavior extends ModelBehavior { * @param array $config Configuration options. * @return void */ - public function setup(Model $model, $config = array()) { + public function setup(Model $model, $config = []) { if (isset($config[0])) { $config['type'] = $config[0]; unset($config[0]); } - $this->settings[$model->name] = array_merge(array('type' => 'controlled'), $config); + $this->settings[$model->name] = array_merge(['type' => 'controlled'], $config); $this->settings[$model->name]['type'] = strtolower($this->settings[$model->name]['type']); $types = $this->_typeMaps[$this->settings[$model->name]['type']]; if (!is_array($types)) { - $types = array($types); + $types = [$types]; } foreach ($types as $type) { $model->{$type} = ClassRegistry::init($type); @@ -81,11 +81,11 @@ public function node(Model $model, $ref = null, $type = null) { $type = $this->_typeMaps[$this->settings[$model->name]['type']]; if (is_array($type)) { trigger_error(__d('cake_dev', 'AclBehavior is setup with more then one type, please specify type parameter for node()'), E_USER_WARNING); - return array(); + return []; } } if (empty($ref)) { - $ref = array('model' => $model->name, 'foreign_key' => $model->id); + $ref = ['model' => $model->name, 'foreign_key' => $model->id]; } return $model->{$type}->node($ref); } @@ -98,24 +98,24 @@ public function node(Model $model, $ref = null, $type = null) { * @param array $options Options passed from Model::save(). * @return void */ - public function afterSave(Model $model, $created, $options = array()) { + public function afterSave(Model $model, $created, $options = []) { $types = $this->_typeMaps[$this->settings[$model->name]['type']]; if (!is_array($types)) { - $types = array($types); + $types = [$types]; } foreach ($types as $type) { $parent = $model->parentNode($type); if (!empty($parent)) { $parent = $this->node($model, $parent, $type); } - $data = array( - 'parent_id' => isset($parent[0][$type]['id']) ? $parent[0][$type]['id'] : null, + $data = [ + 'parent_id' => $parent[0][$type]['id'] ?? null, 'model' => $model->name, 'foreign_key' => $model->id - ); + ]; if (!$created) { $node = $this->node($model, null, $type); - $data['id'] = isset($node[0][$type]['id']) ? $node[0][$type]['id'] : null; + $data['id'] = $node[0][$type]['id'] ?? null; } $model->{$type}->create(); $model->{$type}->save($data); @@ -131,7 +131,7 @@ public function afterSave(Model $model, $created, $options = array()) { public function afterDelete(Model $model) { $types = $this->_typeMaps[$this->settings[$model->name]['type']]; if (!is_array($types)) { - $types = array($types); + $types = [$types]; } foreach ($types as $type) { $node = Hash::extract($this->node($model, null, $type), "0.{$type}.id"); diff --git a/lib/Cake/Model/Behavior/ContainableBehavior.php b/lib/Cake/Model/Behavior/ContainableBehavior.php index 5eaf179b52..b70e286583 100644 --- a/lib/Cake/Model/Behavior/ContainableBehavior.php +++ b/lib/Cake/Model/Behavior/ContainableBehavior.php @@ -35,14 +35,14 @@ class ContainableBehavior extends ModelBehavior { * * @var array */ - public $types = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); + public $types = ['belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany']; /** * Runtime configuration for this behavior * * @var array */ - public $runtime = array(); + public $runtime = []; /** * Initiate behavior for the model using specified settings. @@ -62,9 +62,9 @@ class ContainableBehavior extends ModelBehavior { * @param array $settings Settings to override for model. * @return void */ - public function setup(Model $Model, $settings = array()) { + public function setup(Model $Model, $settings = []) { if (!isset($this->settings[$Model->alias])) { - $this->settings[$Model->alias] = array('recursive' => true, 'notices' => true, 'autoFields' => true); + $this->settings[$Model->alias] = ['recursive' => true, 'notices' => true, 'autoFields' => true]; } $this->settings[$Model->alias] = array_merge($this->settings[$Model->alias], $settings); } @@ -91,9 +91,9 @@ public function setup(Model $Model, $settings = array()) { * @return array */ public function beforeFind(Model $Model, $query) { - $reset = (isset($query['reset']) ? $query['reset'] : true); + $reset = ($query['reset'] ?? true); $noContain = false; - $contain = array(); + $contain = []; if (isset($this->runtime[$Model->alias]['contain'])) { $noContain = empty($this->runtime[$Model->alias]['contain']); @@ -123,7 +123,7 @@ public function beforeFind(Model $Model, $query) { $containments = $this->containments($Model, $contain); $map = $this->containmentsMap($containments); - $mandatory = array(); + $mandatory = []; foreach ($containments['models'] as $model) { $instance = $model['instance']; $needed = $this->fieldDependencies($instance, $map, false); @@ -131,7 +131,7 @@ public function beforeFind(Model $Model, $query) { $mandatory = array_merge($mandatory, $needed); } if ($contain) { - $backupBindings = array(); + $backupBindings = []; foreach ($this->types as $relation) { if (!empty($instance->__backAssociation[$relation])) { $backupBindings[$relation] = $instance->__backAssociation[$relation]; @@ -140,7 +140,7 @@ public function beforeFind(Model $Model, $query) { } } foreach ($this->types as $type) { - $unbind = array(); + $unbind = []; foreach ($instance->{$type} as $assoc => $options) { if (!isset($model['keep'][$assoc])) { $unbind[] = $assoc; @@ -150,7 +150,7 @@ public function beforeFind(Model $Model, $query) { if (!$reset && empty($instance->__backOriginalAssociation)) { $instance->__backOriginalAssociation = $backupBindings; } - $instance->unbindModel(array($type => $unbind), $reset); + $instance->unbindModel([$type => $unbind], $reset); } foreach ($instance->{$type} as $assoc => $options) { if (isset($model['keep'][$assoc]) && !empty($model['keep'][$assoc])) { @@ -177,7 +177,7 @@ public function beforeFind(Model $Model, $query) { } $autoFields = ($this->settings[$Model->alias]['autoFields'] - && !in_array($Model->findQueryType, array('list', 'count')) + && !in_array($Model->findQueryType, ['list', 'count']) && !empty($query['fields'])); if (!$autoFields) { @@ -185,12 +185,12 @@ public function beforeFind(Model $Model, $query) { } $query['fields'] = (array)$query['fields']; - foreach (array('hasOne', 'belongsTo') as $type) { + foreach (['hasOne', 'belongsTo'] as $type) { if (!empty($Model->{$type})) { foreach ($Model->{$type} as $assoc => $data) { if ($Model->useDbConfig === $Model->{$assoc}->useDbConfig && !empty($data['fields'])) { foreach ((array)$data['fields'] as $field) { - $query['fields'][] = (strpos($field, '.') === false ? $assoc . '.' : '') . $field; + $query['fields'][] = (!str_contains($field, '.') ? $assoc . '.' : '') . $field; } } } @@ -202,7 +202,7 @@ public function beforeFind(Model $Model, $query) { if ($field === '--primaryKey--') { $field = $Model->primaryKey; } elseif (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) { - list($modelName, $field) = explode('.', $field); + [$modelName, $field] = explode('.', $field); if ($Model->useDbConfig === $Model->{$modelName}->useDbConfig) { $field = $modelName . '.' . ( ($field === '--primaryKey--') ? $Model->$modelName->primaryKey : $field @@ -250,7 +250,7 @@ public function resetBindings(Model $Model) { $Model->resetAssociations(); if (!empty($Model->__backInnerAssociation)) { $assocs = $Model->__backInnerAssociation; - $Model->__backInnerAssociation = array(); + $Model->__backInnerAssociation = []; foreach ($assocs as $currentModel) { $this->resetBindings($Model->$currentModel); } @@ -266,24 +266,24 @@ public function resetBindings(Model $Model) { * @param bool $throwErrors Whether non-existent bindings show throw errors * @return array Containments */ - public function containments(Model $Model, $contain, $containments = array(), $throwErrors = null) { - $options = array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery'); - $keep = array(); + public function containments(Model $Model, $contain, $containments = [], $throwErrors = null) { + $options = ['className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery']; + $keep = []; if ($throwErrors === null) { $throwErrors = (empty($this->settings[$Model->alias]) ? true : $this->settings[$Model->alias]['notices']); } foreach ((array)$contain as $name => $children) { if (is_numeric($name)) { $name = $children; - $children = array(); + $children = []; } if (preg_match('/(? $children); + $children = [implode('.', $chain) => $children]; } $children = (array)$children; @@ -305,7 +305,7 @@ public function containments(Model $Model, $contain, $containments = array(), $t $optionKey = in_array($key, $options, true); if (!$optionKey && is_string($key) && preg_match('/^[a-z(]/', $key) && (!isset($Model->{$key}) || !is_object($Model->{$key}))) { $option = 'fields'; - $val = array($key); + $val = [$key]; if ($key[0] === '(') { $val = preg_split('/\s*,\s*/', substr($key, 1, -1)); } elseif (preg_match('/ASC|DESC$/', $key)) { @@ -315,7 +315,7 @@ public function containments(Model $Model, $contain, $containments = array(), $t $option = 'conditions'; $val = $Model->{$name}->alias . '.' . $key; } - $children[$option] = is_array($val) ? $val : array($val); + $children[$option] = is_array($val) ? $val : [$val]; $newChildren = null; if (!empty($name) && !empty($children[$key])) { $newChildren = $children[$key]; @@ -329,7 +329,7 @@ public function containments(Model $Model, $contain, $containments = array(), $t } if ($optionKey && isset($children[$key])) { if (!empty($keep[$name][$key]) && is_array($keep[$name][$key])) { - $keep[$name][$key] = array_merge((isset($keep[$name][$key]) ? $keep[$name][$key] : array()), (array)$children[$key]); + $keep[$name][$key] = array_merge(($keep[$name][$key] ?? []), (array)$children[$key]); } else { $keep[$name][$key] = $children[$key]; } @@ -347,12 +347,12 @@ public function containments(Model $Model, $contain, $containments = array(), $t $containments = $this->containments($Model->{$name}, $children, $containments); $depths[] = $containments['depth'] + 1; if (!isset($keep[$name])) { - $keep[$name] = array(); + $keep[$name] = []; } } if (!isset($containments['models'][$Model->alias])) { - $containments['models'][$Model->alias] = array('keep' => array(), 'instance' => &$Model); + $containments['models'][$Model->alias] = ['keep' => [], 'instance' => &$Model]; } $containments['models'][$Model->alias]['keep'] = array_merge($containments['models'][$Model->alias]['keep'], $keep); @@ -368,7 +368,7 @@ public function containments(Model $Model, $contain, $containments = array(), $t * @param array|bool $fields If array, fields to initially load, if false use $Model as primary model * @return array Fields */ - public function fieldDependencies(Model $Model, $map, $fields = array()) { + public function fieldDependencies(Model $Model, $map, $fields = []) { if ($fields === false) { $fields = []; foreach ($map as $parent => $children) { @@ -389,7 +389,7 @@ public function fieldDependencies(Model $Model, $map, $fields = array()) { } foreach ($map[$Model->alias] as $type => $bindings) { foreach ($bindings as $dependency) { - $innerFields = array(); + $innerFields = []; switch ($type) { case 'belongsTo': $fields[] = $Model->{$type}[$dependency]['foreignKey']; @@ -415,7 +415,7 @@ public function fieldDependencies(Model $Model, $map, $fields = array()) { * @return array Built containments */ public function containmentsMap($containments) { - $map = array(); + $map = []; foreach ($containments['models'] as $name => $model) { $instance = $model['instance']; foreach ($this->types as $type) { diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index e4bb53734b..424d347868 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -31,7 +31,7 @@ class TranslateBehavior extends ModelBehavior { * * @var array */ - public $runtime = array(); + public $runtime = []; /** * Stores the joinTable object for generating joins. @@ -83,7 +83,7 @@ class TranslateBehavior extends ModelBehavior { * @param array $config Array of configuration information. * @return mixed */ - public function setup(Model $Model, $config = array()) { + public function setup(Model $Model, $config = []) { $db = ConnectionManager::getDataSource($Model->useDbConfig); if (!$db->connected) { trigger_error( @@ -93,11 +93,11 @@ public function setup(Model $Model, $config = array()) { return false; } - $this->settings[$Model->alias] = array(); - $this->runtime[$Model->alias] = array( - 'fields' => array(), + $this->settings[$Model->alias] = []; + $this->runtime[$Model->alias] = [ + 'fields' => [], 'joinType' => 'INNER', - ); + ]; if (isset($config['joinType'])) { $this->runtime[$Model->alias]['joinType'] = $config['joinType']; unset($config['joinType']); @@ -150,16 +150,16 @@ public function beforeFind(Model $Model, $query) { if (is_string($query['fields'])) { if ($query['fields'] === "COUNT(*) AS {$db->name('count')}") { $query['fields'] = "COUNT(DISTINCT({$db->name($Model->escapeField())})) {$db->alias}count"; - $query['joins'][] = array( + $query['joins'][] = [ 'type' => $this->runtime[$Model->alias]['joinType'], 'alias' => $RuntimeModel->alias, 'table' => $joinTable, - 'conditions' => array( + 'conditions' => [ $Model->escapeField() => $db->identifier($RuntimeModel->escapeField('foreign_key')), $RuntimeModel->escapeField('model') => $Model->name, $RuntimeModel->escapeField('locale') => $locale - ) - ); + ] + ]; $conditionFields = $this->_checkConditions($Model, $query); foreach ($conditionFields as $field) { $query = $this->_addJoin($Model, $query, $field, $field, $locale); @@ -190,7 +190,7 @@ protected function _getFields(Model $Model, $query) { $this->settings[$Model->alias], $this->runtime[$Model->alias]['fields'] ); - $addFields = array(); + $addFields = []; if (empty($query['fields'])) { $addFields = $fields; } elseif (is_array($query['fields'])) { @@ -224,7 +224,7 @@ protected function _addAllJoins(Model $Model, $query, $addFields) { if ($addFields) { foreach ($addFields as $_f => $field) { $aliasField = is_numeric($_f) ? $field : $_f; - foreach (array($aliasField, $Model->alias . '.' . $aliasField) as $_field) { + foreach ([$aliasField, $Model->alias . '.' . $aliasField] as $_field) { $key = array_search($_field, (array)$query['fields']); if ($key !== false) { unset($query['fields'][$key]); @@ -246,7 +246,7 @@ protected function _addAllJoins(Model $Model, $query, $addFields) { */ protected function _checkConditions(Model $Model, $query) { if (empty($query['conditions']) || (!empty($query['conditions']) && !is_array($query['conditions']))) { - return array(); + return []; } return $this->_getConditionFields($Model, $query['conditions']); } @@ -259,7 +259,7 @@ protected function _checkConditions(Model $Model, $query) { * @return array The list of condition fields. */ protected function _getConditionFields(Model $Model, $conditions) { - $conditionFields = array(); + $conditionFields = []; foreach ($conditions as $col => $val) { if (is_array($val)) { $subConditionFields = $this->_getConditionFields($Model, $val); @@ -269,7 +269,7 @@ protected function _getConditionFields(Model $Model, $conditions) { if (is_numeric($field)) { $field = $assoc; } - if (strpos($col, $field) !== false) { + if (str_contains($col, $field)) { $conditionFields[] = $field; } } @@ -301,34 +301,34 @@ protected function _addJoin(Model $Model, $query, $field, $aliasField, $locale) if (!empty($query['fields']) && is_array($query['fields'])) { $query['fields'][] = $aliasVirtualLocale; } - $query['joins'][] = array( + $query['joins'][] = [ 'type' => 'LEFT', 'alias' => $aliasLocale, 'table' => $joinTable, - 'conditions' => array( + 'conditions' => [ $Model->escapeField() => $db->identifier("{$aliasLocale}.foreign_key"), "{$aliasLocale}.model" => $Model->name, "{$aliasLocale}.{$RuntimeModel->displayField}" => $aliasField, "{$aliasLocale}.locale" => $_locale - ) - ); + ] + ]; } } else { $Model->virtualFields[$aliasVirtual] = "{$alias}.content"; if (!empty($query['fields']) && is_array($query['fields'])) { $query['fields'][] = $aliasVirtual; } - $query['joins'][] = array( + $query['joins'][] = [ 'type' => $this->runtime[$Model->alias]['joinType'], 'alias' => $alias, 'table' => $joinTable, - 'conditions' => array( + 'conditions' => [ "{$Model->alias}.{$Model->primaryKey}" => $db->identifier("{$alias}.foreign_key"), "{$alias}.model" => $Model->name, "{$alias}.{$RuntimeModel->displayField}" => $aliasField, "{$alias}.locale" => $locale - ) - ); + ] + ]; } return $query; } @@ -344,7 +344,7 @@ protected function _addJoin(Model $Model, $query, $field, $aliasField, $locale) public function afterFind(Model $Model, $results, $primary = false) { $Model->virtualFields = $this->runtime[$Model->alias]['virtualFields']; - $this->runtime[$Model->alias]['virtualFields'] = array(); + $this->runtime[$Model->alias]['virtualFields'] = []; if (!empty($this->runtime[$Model->alias]['restoreFields'])) { $this->runtime[$Model->alias]['fields'] = $this->runtime[$Model->alias]['restoreFields']; unset($this->runtime[$Model->alias]['restoreFields']); @@ -396,7 +396,7 @@ public function afterFind(Model $Model, $results, $primary = false) { * @return bool * @see Model::save() */ - public function beforeValidate(Model $Model, $options = array()) { + public function beforeValidate(Model $Model, $options = []) { unset($this->runtime[$Model->alias]['beforeSave']); $this->_setRuntimeData($Model); return true; @@ -413,7 +413,7 @@ public function beforeValidate(Model $Model, $options = array()) { * @return bool true. * @see Model::save() */ - public function beforeSave(Model $Model, $options = array()) { + public function beforeSave(Model $Model, $options = []) { if (isset($options['validate']) && !$options['validate']) { unset($this->runtime[$Model->alias]['beforeSave']); } @@ -440,7 +440,7 @@ protected function _setRuntimeData(Model $Model) { return true; } $fields = array_merge($this->settings[$Model->alias], $this->runtime[$Model->alias]['fields']); - $tempData = array(); + $tempData = []; foreach ($fields as $key => $value) { $field = (is_numeric($key)) ? $value : $key; @@ -483,7 +483,7 @@ public function afterValidate(Model $Model) { * @param array $options Options passed from Model::save(). * @return bool true. */ - public function afterSave(Model $Model, $created, $options = array()) { + public function afterSave(Model $Model, $created, $options = []) { if (!isset($this->runtime[$Model->alias]['beforeValidate']) && !isset($this->runtime[$Model->alias]['beforeSave'])) { return true; } @@ -494,16 +494,16 @@ public function afterSave(Model $Model, $created, $options = array()) { } unset($this->runtime[$Model->alias]['beforeValidate'], $this->runtime[$Model->alias]['beforeSave']); - $conditions = array('model' => $Model->name, 'foreign_key' => $Model->id); + $conditions = ['model' => $Model->name, 'foreign_key' => $Model->id]; $RuntimeModel = $this->translateModel($Model); if ($created) { $tempData = $this->_prepareTranslations($Model, $tempData); } $locale = $this->_getLocale($Model); - $atomic = array(); + $atomic = []; if (isset($options['atomic'])) { - $atomic = array('atomic' => $options['atomic']); + $atomic = ['atomic' => $options['atomic']]; } foreach ($tempData as $field => $value) { @@ -514,31 +514,31 @@ public function afterSave(Model $Model, $created, $options = array()) { } else { $conditions['locale'] = $locale; if (is_array($locale)) { - $value = array($locale[0] => $value); + $value = [$locale[0] => $value]; } else { - $value = array($locale => $value); + $value = [$locale => $value]; } } - $translations = $RuntimeModel->find('list', array( + $translations = $RuntimeModel->find('list', [ 'conditions' => $conditions, - 'fields' => array( + 'fields' => [ $RuntimeModel->alias . '.locale', $RuntimeModel->alias . '.id' - ) - )); + ] + ]); foreach ($value as $_locale => $_value) { $RuntimeModel->create(); $conditions['locale'] = $_locale; $conditions['content'] = $_value; if (array_key_exists($_locale, $translations)) { - $RuntimeModel->save(array( + $RuntimeModel->save([ $RuntimeModel->alias => array_merge( - $conditions, array('id' => $translations[$_locale]) + $conditions, ['id' => $translations[$_locale]] ), $atomic - )); + ]); } else { - $RuntimeModel->save(array($RuntimeModel->alias => $conditions), $atomic); + $RuntimeModel->save([$RuntimeModel->alias => $conditions], $atomic); } } } @@ -554,7 +554,7 @@ public function afterSave(Model $Model, $created, $options = array()) { */ protected function _prepareTranslations(Model $Model, $data) { $fields = array_merge($this->settings[$Model->alias], $this->runtime[$Model->alias]['fields']); - $locales = array(); + $locales = []; foreach ($data as $key => $value) { if (is_array($value)) { $locales = array_merge($locales, array_keys($value)); @@ -584,7 +584,7 @@ protected function _prepareTranslations(Model $Model, $data) { */ public function afterDelete(Model $Model) { $RuntimeModel = $this->translateModel($Model); - $conditions = array('model' => $Model->name, 'foreign_key' => $Model->id); + $conditions = ['model' => $Model->name, 'foreign_key' => $Model->id]; $RuntimeModel->deleteAll($conditions); } @@ -648,15 +648,15 @@ public function translateModel(Model $Model) { */ public function bindTranslation(Model $Model, $fields, $reset = true) { if (is_string($fields)) { - $fields = array($fields); + $fields = [$fields]; } - $associations = array(); + $associations = []; $RuntimeModel = $this->translateModel($Model); - $default = array( + $default = [ 'className' => $RuntimeModel->alias, 'foreignKey' => 'foreign_key', 'order' => 'id' - ); + ]; foreach ($fields as $key => $value) { if (is_numeric($key)) { @@ -687,7 +687,7 @@ public function bindTranslation(Model $Model, $fields, $reset = true) { $this->settings[$Model->alias][$field] = $association; } - foreach (array('hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany') as $type) { + foreach (['hasOne', 'hasMany', 'belongsTo', 'hasAndBelongsToMany'] as $type) { if (isset($Model->{$type}[$association]) || isset($Model->__backAssociation[$type][$association])) { trigger_error( __d('cake_dev', 'Association %s is already bound to model %s', $association, $Model->alias), @@ -696,15 +696,15 @@ public function bindTranslation(Model $Model, $fields, $reset = true) { return false; } } - $associations[$association] = array_merge($default, array('conditions' => array( + $associations[$association] = array_merge($default, ['conditions' => [ 'model' => $Model->name, $RuntimeModel->displayField => $field - ))); + ]]); } } if (!empty($associations)) { - $Model->bindModel(array('hasMany' => $associations), $reset); + $Model->bindModel(['hasMany' => $associations], $reset); } return true; } @@ -720,13 +720,13 @@ protected function _removeField(Model $Model, $field) { if (array_key_exists($field, $this->settings[$Model->alias])) { unset($this->settings[$Model->alias][$field]); } elseif (in_array($field, $this->settings[$Model->alias])) { - $this->settings[$Model->alias] = array_merge(array_diff($this->settings[$Model->alias], array($field))); + $this->settings[$Model->alias] = array_merge(array_diff($this->settings[$Model->alias], [$field])); } if (array_key_exists($field, $this->runtime[$Model->alias]['fields'])) { unset($this->runtime[$Model->alias]['fields'][$field]); } elseif (in_array($field, $this->runtime[$Model->alias]['fields'])) { - $this->runtime[$Model->alias]['fields'] = array_merge(array_diff($this->runtime[$Model->alias]['fields'], array($field))); + $this->runtime[$Model->alias]['fields'] = array_merge(array_diff($this->runtime[$Model->alias]['fields'], [$field])); } } @@ -748,9 +748,9 @@ public function unbindTranslation(Model $Model, $fields = null) { } if (is_string($fields)) { - $fields = array($fields); + $fields = [$fields]; } - $associations = array(); + $associations = []; foreach ($fields as $key => $value) { if (is_numeric($key)) { @@ -769,7 +769,7 @@ public function unbindTranslation(Model $Model, $fields = null) { } if (!empty($associations)) { - $Model->unbindModel(array('hasMany' => $associations), false); + $Model->unbindModel(['hasMany' => $associations], false); } return true; } diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index d944007be4..53f960ea44 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -36,24 +36,24 @@ class TreeBehavior extends ModelBehavior { * * @var array */ - public $errors = array(); + public $errors = []; /** * Defaults * * @var array */ - protected $_defaults = array( + protected $_defaults = [ 'parent' => 'parent_id', 'left' => 'lft', 'right' => 'rght', 'level' => null, 'scope' => '1 = 1', 'type' => 'nested', '__parentChange' => false, 'recursive' => -1 - ); + ]; /** * Used to preserve state between delete callbacks. * * @var array */ - protected $_deletedRow = array(); + protected $_deletedRow = []; /** * Initiate Tree behavior @@ -62,7 +62,7 @@ class TreeBehavior extends ModelBehavior { * @param array $config array of configuration settings. * @return void */ - public function setup(Model $Model, $config = array()) { + public function setup(Model $Model, $config = []) { if (isset($config[0])) { $config['type'] = $config[0]; unset($config[0]); @@ -89,7 +89,7 @@ public function setup(Model $Model, $config = array()) { * @param array $options Options passed from Model::save(). * @return bool true on success, false on failure */ - public function afterSave(Model $Model, $created, $options = array()) { + public function afterSave(Model $Model, $created, $options = []) { extract($this->settings[$Model->alias]); if ($created) { if ((isset($Model->data[$Model->alias][$parent])) && $Model->data[$Model->alias][$parent]) { @@ -114,13 +114,13 @@ public function afterSave(Model $Model, $created, $options = array()) { protected function _setChildrenLevel(Model $Model, $id) { $settings = $this->settings[$Model->alias]; $primaryKey = $Model->primaryKey; - $depths = array($id => (int)$Model->data[$Model->alias][$settings['level']]); + $depths = [$id => (int)$Model->data[$Model->alias][$settings['level']]]; $children = $this->children( $Model, $id, false, - array($primaryKey, $settings['parent'], $settings['level']), + [$primaryKey, $settings['parent'], $settings['level']], $settings['left'], null, 1, @@ -133,8 +133,8 @@ protected function _setChildrenLevel(Model $Model, $id) { $depths[$node[$Model->alias][$primaryKey]] = $depth; $Model->updateAll( - array($Model->escapeField($settings['level']) => $depth), - array($Model->escapeField($primaryKey) => $node[$Model->alias][$primaryKey]) + [$Model->escapeField($settings['level']) => $depth], + [$Model->escapeField($primaryKey) => $node[$Model->alias][$primaryKey]] ); } } @@ -164,11 +164,11 @@ public function beforeFind(Model $Model, $query) { */ public function beforeDelete(Model $Model, $cascade = true) { extract($this->settings[$Model->alias]); - $data = $Model->find('first', array( - 'conditions' => array($Model->escapeField($Model->primaryKey) => $Model->id), - 'fields' => array($Model->escapeField($left), $Model->escapeField($right)), + $data = $Model->find('first', [ + 'conditions' => [$Model->escapeField($Model->primaryKey) => $Model->id], + 'fields' => [$Model->escapeField($left), $Model->escapeField($right)], 'order' => false, - 'recursive' => -1)); + 'recursive' => -1]); if ($data) { $this->_deletedRow[$Model->alias] = current($data); } @@ -195,9 +195,9 @@ public function afterDelete(Model $Model) { if ($diff > 2) { if (is_string($scope)) { - $scope = array($scope); + $scope = [$scope]; } - $scope[][$Model->escapeField($left) . " BETWEEN ? AND ?"] = array($data[$left] + 1, $data[$right] - 1); + $scope[][$Model->escapeField($left) . " BETWEEN ? AND ?"] = [$data[$left] + 1, $data[$right] - 1]; $Model->deleteAll($scope); } $this->_sync($Model, $diff, '-', '> ' . $data[$right]); @@ -216,10 +216,10 @@ public function afterDelete(Model $Model) { * @return bool true to continue, false to abort the save * @see Model::save() */ - public function beforeSave(Model $Model, $options = array()) { + public function beforeSave(Model $Model, $options = []) { extract($this->settings[$Model->alias]); - $this->_addToWhitelist($Model, array($left, $right)); + $this->_addToWhitelist($Model, [$left, $right]); if ($level) { $this->_addToWhitelist($Model, $level); } @@ -266,13 +266,13 @@ public function beforeSave(Model $Model, $options = array()) { if (empty($values)) { return false; } - list($node) = array_values($values); + [$node] = array_values($values); $parentNode = $this->_getNode($Model, $Model->data[$Model->alias][$parent]); if (!$parentNode) { return false; } - list($parentNode) = array_values($parentNode); + [$parentNode] = array_values($parentNode); if (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) { return false; @@ -297,17 +297,17 @@ public function beforeSave(Model $Model, $options = array()) { */ protected function _getNode(Model $Model, $id) { $settings = $this->settings[$Model->alias]; - $fields = array($Model->primaryKey, $settings['parent'], $settings['left'], $settings['right']); + $fields = [$Model->primaryKey, $settings['parent'], $settings['left'], $settings['right']]; if ($settings['level']) { $fields[] = $settings['level']; } - return $Model->find('first', array( - 'conditions' => array($Model->escapeField() => $id), + return $Model->find('first', [ + 'conditions' => [$Model->escapeField() => $id], 'fields' => $fields, 'recursive' => $settings['recursive'], 'order' => false, - )); + ]); } /** @@ -324,7 +324,7 @@ protected function _getNode(Model $Model, $id) { */ public function childCount(Model $Model, $id = null, $direct = false) { if (is_array($id)) { - extract(array_merge(array('id' => null), $id)); + extract(array_merge(['id' => null], $id)); } if ($id === null && $Model->id) { $id = $Model->id; @@ -334,11 +334,11 @@ public function childCount(Model $Model, $id = null, $direct = false) { extract($this->settings[$Model->alias]); if ($direct) { - return $Model->find('count', array('conditions' => array($scope, $Model->escapeField($parent) => $id))); + return $Model->find('count', ['conditions' => [$scope, $Model->escapeField($parent) => $id]]); } if ($id === null) { - return $Model->find('count', array('conditions' => $scope)); + return $Model->find('count', ['conditions' => $scope]); } elseif ($Model->id === $id && isset($Model->data[$Model->alias][$left]) && isset($Model->data[$Model->alias][$right])) { $data = $Model->data[$Model->alias]; } else { @@ -369,10 +369,10 @@ public function childCount(Model $Model, $id = null, $direct = false) { * @link https://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::children */ public function children(Model $Model, $id = null, $direct = false, $fields = null, $order = null, $limit = null, $page = 1, $recursive = null) { - $options = array(); + $options = []; if (is_array($id)) { $options = $this->_getOptions($id); - extract(array_merge(array('id' => null), $id)); + extract(array_merge(['id' => null], $id)); } $overrideRecursive = $recursive; @@ -391,27 +391,27 @@ public function children(Model $Model, $id = null, $direct = false, $fields = nu $order = $Model->escapeField($left) . " asc"; } if ($direct) { - $conditions = array($scope, $Model->escapeField($parent) => $id); + $conditions = [$scope, $Model->escapeField($parent) => $id]; return $Model->find('all', compact('conditions', 'fields', 'order', 'limit', 'page', 'recursive')); } if (!$id) { $conditions = $scope; } else { - $result = array_values((array)$Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField() => $id), - 'fields' => array($left, $right), + $result = array_values((array)$Model->find('first', [ + 'conditions' => [$scope, $Model->escapeField() => $id], + 'fields' => [$left, $right], 'recursive' => $recursive, 'order' => false, - ))); + ])); if (empty($result) || !isset($result[0])) { - return array(); + return []; } - $conditions = array($scope, + $conditions = [$scope, $Model->escapeField($right) . ' <' => $result[0][$right], $Model->escapeField($left) . ' >' => $result[0][$left] - ); + ]; } $options = array_merge(compact( 'conditions', 'fields', 'order', 'limit', 'page', 'recursive' @@ -440,7 +440,7 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu $fields = null; if (!$keyPath && !$valuePath && $Model->hasField($Model->displayField)) { - $fields = array($Model->primaryKey, $Model->displayField, $left, $right); + $fields = [$Model->primaryKey, $Model->displayField, $left, $right]; } $conditions = (array)$conditions; @@ -471,15 +471,15 @@ public function generateTreeList(Model $Model, $conditions = null, $keyPath = nu * @param array $options Options * @return array An associative array of records, where the id is the key, and the display field is the value */ - public function formatTreeList(Model $Model, array $results, array $options = array()) { + public function formatTreeList(Model $Model, array $results, array $options = []) { if (empty($results)) { - return array(); + return []; } - $defaults = array( + $defaults = [ 'keyPath' => null, 'valuePath' => null, 'spacer' => '_' - ); + ]; $options += $defaults; extract($this->settings[$Model->alias]); @@ -489,16 +489,16 @@ public function formatTreeList(Model $Model, array $results, array $options = ar } if (!$options['valuePath']) { - $options['valuePath'] = array('%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField); + $options['valuePath'] = ['%s%s', '{n}.tree_prefix', '{n}.' . $Model->alias . '.' . $Model->displayField]; } elseif (is_string($options['valuePath'])) { - $options['valuePath'] = array('%s%s', '{n}.tree_prefix', $options['valuePath']); + $options['valuePath'] = ['%s%s', '{n}.tree_prefix', $options['valuePath']]; } else { array_unshift($options['valuePath'], '%s' . $options['valuePath'][0], '{n}.tree_prefix'); } - $stack = array(); + $stack = []; foreach ($results as $i => $result) { $count = count($stack); @@ -526,10 +526,10 @@ public function formatTreeList(Model $Model, array $results, array $options = ar * @link https://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getParentNode */ public function getParentNode(Model $Model, $id = null, $fields = null, $recursive = null) { - $options = array(); + $options = []; if (is_array($id)) { $options = $this->_getOptions($id); - extract(array_merge(array('id' => null), $id)); + extract(array_merge(['id' => null], $id)); } $overrideRecursive = $recursive; if (empty($id)) { @@ -539,21 +539,21 @@ public function getParentNode(Model $Model, $id = null, $fields = null, $recursi if ($overrideRecursive !== null) { $recursive = $overrideRecursive; } - $parentId = $Model->find('first', array( - 'conditions' => array($Model->primaryKey => $id), - 'fields' => array($parent), + $parentId = $Model->find('first', [ + 'conditions' => [$Model->primaryKey => $id], + 'fields' => [$parent], 'order' => false, 'recursive' => -1 - )); + ]); if ($parentId) { $parentId = $parentId[$Model->alias][$parent]; - $options = array_merge(array( - 'conditions' => array($Model->escapeField() => $parentId), + $options = array_merge([ + 'conditions' => [$Model->escapeField() => $parentId], 'fields' => $fields, 'order' => false, 'recursive' => $recursive - ), $options); + ], $options); $parent = $Model->find('first', $options); return $parent; @@ -571,7 +571,7 @@ public function getParentNode(Model $Model, $id = null, $fields = null, $recursi protected function _getOptions($arg) { return count(array_filter(array_keys($arg), 'is_string')) > 0 ? $arg : - array(); + []; } /** @@ -585,10 +585,10 @@ protected function _getOptions($arg) { * @link https://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::getPath */ public function getPath(Model $Model, $id = null, $fields = null, $recursive = null) { - $options = array(); + $options = []; if (is_array($id)) { $options = $this->_getOptions($id); - extract(array_merge(array('id' => null), $id)); + extract(array_merge(['id' => null], $id)); } if (!empty($options)) { @@ -608,28 +608,28 @@ public function getPath(Model $Model, $id = null, $fields = null, $recursive = n if ($overrideRecursive !== null) { $recursive = $overrideRecursive; } - $result = $Model->find('first', array( - 'conditions' => array($Model->escapeField() => $id), - 'fields' => array($left, $right), + $result = $Model->find('first', [ + 'conditions' => [$Model->escapeField() => $id], + 'fields' => [$left, $right], 'order' => false, 'recursive' => $recursive - )); + ]); if ($result) { $result = array_values($result); } else { - return array(); + return []; } $item = $result[0]; - $options = array_merge(array( - 'conditions' => array( + $options = array_merge([ + 'conditions' => [ $scope, $Model->escapeField($left) . ' <=' => $item[$left], $Model->escapeField($right) . ' >=' => $item[$right], - ), + ], 'fields' => $fields, - 'order' => array($Model->escapeField($left) => 'asc'), + 'order' => [$Model->escapeField($left) => 'asc'], 'recursive' => $recursive - ), $options); + ], $options); $results = $Model->find('all', $options); return $results; } @@ -647,7 +647,7 @@ public function getPath(Model $Model, $id = null, $fields = null, $recursive = n */ public function moveDown(Model $Model, $id = null, $number = 1) { if (is_array($id)) { - extract(array_merge(array('id' => null), $id)); + extract(array_merge(['id' => null], $id)); } if (!$number) { return false; @@ -656,21 +656,21 @@ public function moveDown(Model $Model, $id = null, $number = 1) { $id = $Model->id; } extract($this->settings[$Model->alias]); - list($node) = array_values($this->_getNode($Model, $id)); + [$node] = array_values($this->_getNode($Model, $id)); if ($node[$parent]) { - list($parentNode) = array_values($this->_getNode($Model, $node[$parent])); + [$parentNode] = array_values($this->_getNode($Model, $node[$parent])); if (($node[$right] + 1) == $parentNode[$right]) { return false; } } - $nextNode = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField($left) => ($node[$right] + 1)), - 'fields' => array($Model->primaryKey, $left, $right), + $nextNode = $Model->find('first', [ + 'conditions' => [$scope, $Model->escapeField($left) => ($node[$right] + 1)], + 'fields' => [$Model->primaryKey, $left, $right], 'order' => false, - 'recursive' => $recursive) + 'recursive' => $recursive] ); if ($nextNode) { - list($nextNode) = array_values($nextNode); + [$nextNode] = array_values($nextNode); } else { return false; } @@ -701,7 +701,7 @@ public function moveDown(Model $Model, $id = null, $number = 1) { */ public function moveUp(Model $Model, $id = null, $number = 1) { if (is_array($id)) { - extract(array_merge(array('id' => null), $id)); + extract(array_merge(['id' => null], $id)); } if (!$number) { return false; @@ -710,22 +710,22 @@ public function moveUp(Model $Model, $id = null, $number = 1) { $id = $Model->id; } extract($this->settings[$Model->alias]); - list($node) = array_values($this->_getNode($Model, $id)); + [$node] = array_values($this->_getNode($Model, $id)); if ($node[$parent]) { - list($parentNode) = array_values($this->_getNode($Model, $node[$parent])); + [$parentNode] = array_values($this->_getNode($Model, $node[$parent])); if (($node[$left] - 1) == $parentNode[$left]) { return false; } } - $previousNode = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField($right) => ($node[$left] - 1)), - 'fields' => array($Model->primaryKey, $left, $right), + $previousNode = $Model->find('first', [ + 'conditions' => [$scope, $Model->escapeField($right) => ($node[$left] - 1)], + 'fields' => [$Model->primaryKey, $left, $right], 'order' => false, 'recursive' => $recursive - )); + ]); if ($previousNode) { - list($previousNode) = array_values($previousNode); + [$previousNode] = array_values($previousNode); } else { return false; } @@ -759,24 +759,24 @@ public function moveUp(Model $Model, $id = null, $number = 1) { */ public function recover(Model $Model, $mode = 'parent', $missingParentAction = null) { if (is_array($mode)) { - extract(array_merge(array('mode' => 'parent'), $mode)); + extract(array_merge(['mode' => 'parent'], $mode)); } extract($this->settings[$Model->alias]); $Model->recursive = $recursive; if ($mode === 'parent') { - $Model->bindModel(array('belongsTo' => array('VerifyParent' => array( + $Model->bindModel(['belongsTo' => ['VerifyParent' => [ 'className' => $Model->name, 'foreignKey' => $parent, - 'fields' => array($Model->primaryKey, $left, $right, $parent), - )))); - $missingParents = $Model->find('list', array( + 'fields' => [$Model->primaryKey, $left, $right, $parent], + ]]]); + $missingParents = $Model->find('list', [ 'recursive' => 0, - 'conditions' => array($scope, array( - 'NOT' => array($Model->escapeField($parent) => null), $Model->VerifyParent->escapeField() => null - )), + 'conditions' => [$scope, [ + 'NOT' => [$Model->escapeField($parent) => null], $Model->VerifyParent->escapeField() => null + ]], 'order' => false, - )); - $Model->unbindModel(array('belongsTo' => array('VerifyParent'))); + ]); + $Model->unbindModel(['belongsTo' => ['VerifyParent']]); if ($missingParents) { if ($missingParentAction === 'return') { foreach ($missingParents as $id => $display) { @@ -784,22 +784,22 @@ public function recover(Model $Model, $mode = 'parent', $missingParentAction = n } return false; } elseif ($missingParentAction === 'delete') { - $Model->deleteAll(array($Model->escapeField($Model->primaryKey) => array_flip($missingParents)), false); + $Model->deleteAll([$Model->escapeField($Model->primaryKey) => array_flip($missingParents)], false); } else { - $Model->updateAll(array($Model->escapeField($parent) => $missingParentAction), array($Model->escapeField($Model->primaryKey) => array_flip($missingParents))); + $Model->updateAll([$Model->escapeField($parent) => $missingParentAction], [$Model->escapeField($Model->primaryKey) => array_flip($missingParents)]); } } $this->_recoverByParentId($Model); } else { $db = ConnectionManager::getDataSource($Model->useDbConfig); - foreach ($Model->find('all', array('conditions' => $scope, 'fields' => array($Model->primaryKey, $parent), 'order' => $left)) as $array) { + foreach ($Model->find('all', ['conditions' => $scope, 'fields' => [$Model->primaryKey, $parent], 'order' => $left]) as $array) { $path = $this->getPath($Model, $array[$Model->alias][$Model->primaryKey]); $parentId = null; if (count($path) > 1) { $parentId = $path[count($path) - 2][$Model->alias][$Model->primaryKey]; } - $Model->updateAll(array($parent => $db->value($parentId, $parent)), array($Model->escapeField() => $array[$Model->alias][$Model->primaryKey])); + $Model->updateAll([$parent => $db->value($parentId, $parent)], [$Model->escapeField() => $array[$Model->alias][$Model->primaryKey]]); } } return true; @@ -816,15 +816,15 @@ public function recover(Model $Model, $mode = 'parent', $missingParentAction = n * @return int counter */ protected function _recoverByParentId(Model $Model, $counter = 1, $parentId = null) { - $params = array( - 'conditions' => array( + $params = [ + 'conditions' => [ $this->settings[$Model->alias]['parent'] => $parentId - ), - 'fields' => array($Model->primaryKey), + ], + 'fields' => [$Model->primaryKey], 'page' => 1, 'limit' => 100, - 'order' => array($Model->primaryKey) - ); + 'order' => [$Model->primaryKey] + ]; $scope = $this->settings[$Model->alias]['scope']; if ($scope && ($scope !== '1 = 1' && $scope !== true)) { @@ -837,17 +837,17 @@ protected function _recoverByParentId(Model $Model, $counter = 1, $parentId = nu if ($parentId !== null) { if ($hasChildren) { $Model->updateAll( - array($this->settings[$Model->alias]['left'] => $counter), - array($Model->escapeField() => $parentId) + [$this->settings[$Model->alias]['left'] => $counter], + [$Model->escapeField() => $parentId] ); $counter++; } else { $Model->updateAll( - array( + [ $this->settings[$Model->alias]['left'] => $counter, $this->settings[$Model->alias]['right'] => $counter + 1 - ), - array($Model->escapeField() => $parentId) + ], + [$Model->escapeField() => $parentId] ); $counter += 2; } @@ -867,8 +867,8 @@ protected function _recoverByParentId(Model $Model, $counter = 1, $parentId = nu if ($parentId !== null && $hasChildren) { $Model->updateAll( - array($this->settings[$Model->alias]['right'] => $counter), - array($Model->escapeField() => $parentId) + [$this->settings[$Model->alias]['right'] => $counter], + [$Model->escapeField() => $parentId] ); $counter++; } @@ -896,15 +896,15 @@ protected function _recoverByParentId(Model $Model, $counter = 1, $parentId = nu * @return bool true on success, false on failure * @link https://book.cakephp.org/2.0/en/core-libraries/behaviors/tree.html#TreeBehavior::reorder */ - public function reorder(Model $Model, $options = array()) { - $options += array('id' => null, 'field' => $Model->displayField, 'order' => 'ASC', 'verify' => true); + public function reorder(Model $Model, $options = []) { + $options += ['id' => null, 'field' => $Model->displayField, 'order' => 'ASC', 'verify' => true]; extract($options); if ($verify && !$this->verify($Model)) { return false; } $verify = false; extract($this->settings[$Model->alias]); - $fields = array($Model->primaryKey, $field, $left, $right); + $fields = [$Model->primaryKey, $field, $left, $right]; $sort = $field . ' ' . $order; $nodes = $this->children($Model, $id, true, $fields, $sort, null, null, $recursive); @@ -937,11 +937,11 @@ public function reorder(Model $Model, $options = array()) { */ public function removeFromTree(Model $Model, $id = null, $delete = false) { if (is_array($id)) { - extract(array_merge(array('id' => null), $id)); + extract(array_merge(['id' => null], $id)); } extract($this->settings[$Model->alias]); - list($node) = array_values($this->_getNode($Model, $id)); + [$node] = array_values($this->_getNode($Model, $id)); if ($node[$right] == $node[$left] + 1) { if ($delete) { @@ -950,15 +950,15 @@ public function removeFromTree(Model $Model, $id = null, $delete = false) { $Model->id = $id; return $Model->saveField($parent, null); } elseif ($node[$parent]) { - list($parentNode) = array_values($this->_getNode($Model, $node[$parent])); + [$parentNode] = array_values($this->_getNode($Model, $node[$parent])); } else { $parentNode[$right] = $node[$right] + 1; } $db = ConnectionManager::getDataSource($Model->useDbConfig); $Model->updateAll( - array($parent => $db->value($node[$parent], $parent)), - array($Model->escapeField($parent) => $node[$Model->primaryKey]) + [$parent => $db->value($node[$parent], $parent)], + [$Model->escapeField($parent) => $node[$Model->primaryKey]] ); $this->_sync($Model, 1, '-', 'BETWEEN ' . ($node[$left] + 1) . ' AND ' . ($node[$right] - 1)); $this->_sync($Model, 2, '-', '> ' . ($node[$right])); @@ -966,12 +966,12 @@ public function removeFromTree(Model $Model, $id = null, $delete = false) { if ($delete) { $Model->updateAll( - array( + [ $Model->escapeField($left) => 0, $Model->escapeField($right) => 0, $Model->escapeField($parent) => null - ), - array($Model->escapeField() => $id) + ], + [$Model->escapeField() => $id] ); return $Model->delete($id); } @@ -981,8 +981,8 @@ public function removeFromTree(Model $Model, $id = null, $delete = false) { } $Model->id = $id; return $Model->save( - array($left => $edge + 1, $right => $edge + 2, $parent => null), - array('callbacks' => false, 'validate' => false) + [$left => $edge + 1, $right => $edge + 2, $parent => null], + ['callbacks' => false, 'validate' => false] ); } @@ -998,61 +998,61 @@ public function removeFromTree(Model $Model, $id = null, $delete = false) { */ public function verify(Model $Model) { extract($this->settings[$Model->alias]); - if (!$Model->find('count', array('conditions' => $scope))) { + if (!$Model->find('count', ['conditions' => $scope])) { return true; } $min = $this->_getMin($Model, $scope, $left, $recursive); $edge = $this->_getMax($Model, $scope, $right, $recursive); - $errors = array(); + $errors = []; for ($i = $min; $i <= $edge; $i++) { - $count = $Model->find('count', array('conditions' => array( - $scope, 'OR' => array($Model->escapeField($left) => $i, $Model->escapeField($right) => $i) - ))); + $count = $Model->find('count', ['conditions' => [ + $scope, 'OR' => [$Model->escapeField($left) => $i, $Model->escapeField($right) => $i] + ]]); if ($count != 1) { if (!$count) { - $errors[] = array('index', $i, 'missing'); + $errors[] = ['index', $i, 'missing']; } else { - $errors[] = array('index', $i, 'duplicate'); + $errors[] = ['index', $i, 'duplicate']; } } } - $node = $Model->find('first', array( - 'conditions' => array($scope, $Model->escapeField($right) . '< ' . $Model->escapeField($left)), + $node = $Model->find('first', [ + 'conditions' => [$scope, $Model->escapeField($right) . '< ' . $Model->escapeField($left)], 'order' => false, 'recursive' => 0 - )); + ]); if ($node) { - $errors[] = array('node', $node[$Model->alias][$Model->primaryKey], 'left greater than right.'); + $errors[] = ['node', $node[$Model->alias][$Model->primaryKey], 'left greater than right.']; } - $Model->bindModel(array('belongsTo' => array('VerifyParent' => array( + $Model->bindModel(['belongsTo' => ['VerifyParent' => [ 'className' => $Model->name, 'foreignKey' => $parent, - 'fields' => array($Model->primaryKey, $left, $right, $parent) - )))); + 'fields' => [$Model->primaryKey, $left, $right, $parent] + ]]]); - $rows = $Model->find('all', array('conditions' => $scope, 'recursive' => 0)); + $rows = $Model->find('all', ['conditions' => $scope, 'recursive' => 0]); foreach ($rows as $instance) { if ($instance[$Model->alias][$left] === null || $instance[$Model->alias][$right] === null) { - $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], - 'has invalid left or right values'); + $errors[] = ['node', $instance[$Model->alias][$Model->primaryKey], + 'has invalid left or right values']; } elseif ($instance[$Model->alias][$left] == $instance[$Model->alias][$right]) { - $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], - 'left and right values identical'); + $errors[] = ['node', $instance[$Model->alias][$Model->primaryKey], + 'left and right values identical']; } elseif ($instance[$Model->alias][$parent]) { if (!$instance['VerifyParent'][$Model->primaryKey]) { - $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], - 'The parent node ' . $instance[$Model->alias][$parent] . ' doesn\'t exist'); + $errors[] = ['node', $instance[$Model->alias][$Model->primaryKey], + 'The parent node ' . $instance[$Model->alias][$parent] . ' doesn\'t exist']; } elseif ($instance[$Model->alias][$left] < $instance['VerifyParent'][$left]) { - $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], - 'left less than parent (node ' . $instance['VerifyParent'][$Model->primaryKey] . ').'); + $errors[] = ['node', $instance[$Model->alias][$Model->primaryKey], + 'left less than parent (node ' . $instance['VerifyParent'][$Model->primaryKey] . ').']; } elseif ($instance[$Model->alias][$right] > $instance['VerifyParent'][$right]) { - $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], - 'right greater than parent (node ' . $instance['VerifyParent'][$Model->primaryKey] . ').'); + $errors[] = ['node', $instance[$Model->alias][$Model->primaryKey], + 'right greater than parent (node ' . $instance['VerifyParent'][$Model->primaryKey] . ').']; } - } elseif ($Model->find('count', array('conditions' => array($scope, $Model->escapeField($left) . ' <' => $instance[$Model->alias][$left], $Model->escapeField($right) . ' >' => $instance[$Model->alias][$right]), 'recursive' => 0))) { - $errors[] = array('node', $instance[$Model->alias][$Model->primaryKey], 'The parent field is blank, but has a parent'); + } elseif ($Model->find('count', ['conditions' => [$scope, $Model->escapeField($left) . ' <' => $instance[$Model->alias][$left], $Model->escapeField($right) . ' >' => $instance[$Model->alias][$right]], 'recursive' => 0])) { + $errors[] = ['node', $instance[$Model->alias][$Model->primaryKey], 'The parent field is blank, but has a parent']; } } if ($errors) { @@ -1073,11 +1073,11 @@ public function getLevel(Model $Model, $id = null) { $id = $Model->id; } - $node = $Model->find('first', array( - 'conditions' => array($Model->escapeField() => $id), + $node = $Model->find('first', [ + 'conditions' => [$Model->escapeField() => $id], 'order' => false, 'recursive' => -1 - )); + ]); if (empty($node)) { return false; @@ -1085,15 +1085,15 @@ public function getLevel(Model $Model, $id = null) { extract($this->settings[$Model->alias]); - return $Model->find('count', array( - 'conditions' => array( + return $Model->find('count', [ + 'conditions' => [ $scope, $left . ' <' => $node[$Model->alias][$left], $right . ' >' => $node[$Model->alias][$right] - ), + ], 'order' => false, 'recursive' => -1 - )); + ]); } /** @@ -1110,7 +1110,7 @@ public function getLevel(Model $Model, $id = null) { */ protected function _setParent(Model $Model, $parentId = null, $created = false) { extract($this->settings[$Model->alias]); - list($node) = array_values($this->_getNode($Model, $Model->id)); + [$node] = array_values($this->_getNode($Model, $Model->id)); $edge = $this->_getMax($Model, $scope, $right, $recursive, $created); if (empty($parentId)) { @@ -1137,8 +1137,8 @@ protected function _setParent(Model $Model, $parentId = null, $created = false) if (empty($node[$left]) && empty($node[$right])) { $this->_sync($Model, 2, '+', '>= ' . $parentNode[$right], $created); $result = $Model->save( - array($left => $parentNode[$right], $right => $parentNode[$right] + 1, $parent => $parentId), - array('validate' => false, 'callbacks' => false) + [$left => $parentNode[$right], $right => $parentNode[$right] + 1, $parent => $parentId], + ['validate' => false, 'callbacks' => false] ); $Model->data = $result; } else { @@ -1183,13 +1183,13 @@ protected function _getMax(Model $Model, $scope, $right, $recursive = -1, $creat } } $name = $Model->escapeField($right); - list($edge) = array_values($Model->find('first', array( + [$edge] = array_values($Model->find('first', [ 'conditions' => $scope, - 'fields' => $db->calculate($Model, 'max', array($name, $right)), + 'fields' => $db->calculate($Model, 'max', [$name, $right]), 'recursive' => $recursive, 'order' => false, 'callbacks' => false - ))); + ])); return (empty($edge[$right])) ? 0 : $edge[$right]; } @@ -1205,13 +1205,13 @@ protected function _getMax(Model $Model, $scope, $right, $recursive = -1, $creat protected function _getMin(Model $Model, $scope, $left, $recursive = -1) { $db = ConnectionManager::getDataSource($Model->useDbConfig); $name = $Model->escapeField($left); - list($edge) = array_values($Model->find('first', array( + [$edge] = array_values($Model->find('first', [ 'conditions' => $scope, - 'fields' => $db->calculate($Model, 'min', array($name, $left)), + 'fields' => $db->calculate($Model, 'min', [$name, $left]), 'recursive' => $recursive, 'order' => false, 'callbacks' => false - ))); + ])); return (empty($edge[$left])) ? 0 : $edge[$left]; } @@ -1228,7 +1228,7 @@ protected function _getMin(Model $Model, $scope, $left, $recursive = -1) { * @param string $field Field type. * @return void */ - protected function _sync(Model $Model, $shift, $dir = '+', $conditions = array(), $created = false, $field = 'both') { + protected function _sync(Model $Model, $shift, $dir = '+', $conditions = [], $created = false, $field = 'both') { $ModelRecursive = $Model->recursive; extract($this->settings[$Model->alias]); $Model->recursive = $recursive; @@ -1238,7 +1238,7 @@ protected function _sync(Model $Model, $shift, $dir = '+', $conditions = array() $field = $right; } if (is_string($conditions)) { - $conditions = array($Model->escapeField($field) . " {$conditions}"); + $conditions = [$Model->escapeField($field) . " {$conditions}"]; } if (($scope !== '1 = 1' && $scope !== true) && $scope) { $conditions[] = $scope; @@ -1246,7 +1246,7 @@ protected function _sync(Model $Model, $shift, $dir = '+', $conditions = array() if ($created) { $conditions['NOT'][$Model->escapeField()] = $Model->id; } - $Model->updateAll(array($Model->escapeField($field) => $Model->escapeField($field) . ' ' . $dir . ' ' . $shift), $conditions); + $Model->updateAll([$Model->escapeField($field) => $Model->escapeField($field) . ' ' . $dir . ' ' . $shift], $conditions); $Model->recursive = $ModelRecursive; } diff --git a/lib/Cake/Model/BehaviorCollection.php b/lib/Cake/Model/BehaviorCollection.php index faae57064f..b7652174be 100644 --- a/lib/Cake/Model/BehaviorCollection.php +++ b/lib/Cake/Model/BehaviorCollection.php @@ -42,14 +42,14 @@ class BehaviorCollection extends ObjectCollection implements CakeEventListener { * * @var array */ - protected $_methods = array(); + protected $_methods = []; /** * Keeps a list of all methods which have been mapped with regular expressions * * @var array */ - protected $_mappedMethods = array(); + protected $_mappedMethods = []; /** * Attaches a model object and loads a list of behaviors @@ -58,7 +58,7 @@ class BehaviorCollection extends ObjectCollection implements CakeEventListener { * @param array $behaviors Behaviors list. * @return void */ - public function init($modelName, $behaviors = array()) { + public function init($modelName, $behaviors = []) { $this->modelName = $modelName; if (!empty($behaviors)) { @@ -76,7 +76,7 @@ public function init($modelName, $behaviors = array()) { * @return bool true. * @deprecated 3.0.0 Will be removed in 3.0. Replaced with load(). */ - public function attach($behavior, $config = array()) { + public function attach($behavior, $config = []) { return $this->load($behavior, $config); } @@ -100,16 +100,16 @@ public function attach($behavior, $config = array()) { * @return bool True on success. * @throws MissingBehaviorException when a behavior could not be found. */ - public function load($behavior, $config = array()) { + public function load($behavior, $config = []) { if (isset($config['className'])) { $alias = $behavior; $behavior = $config['className']; } $configDisabled = isset($config['enabled']) && $config['enabled'] === false; - $priority = isset($config['priority']) ? $config['priority'] : $this->defaultPriority; + $priority = $config['priority'] ?? $this->defaultPriority; unset($config['enabled'], $config['className'], $config['priority']); - list($plugin, $name) = pluginSplit($behavior, true); + [$plugin, $name] = pluginSplit($behavior, true); if (!isset($alias)) { $alias = $name; } @@ -118,10 +118,10 @@ public function load($behavior, $config = array()) { App::uses($class, $plugin . 'Model/Behavior'); if (!class_exists($class)) { - throw new MissingBehaviorException(array( + throw new MissingBehaviorException([ 'class' => $class, 'plugin' => substr($plugin, 0, -1) - )); + ]); } if (!isset($this->{$alias})) { @@ -135,24 +135,24 @@ public function load($behavior, $config = array()) { if ($config !== null && $config !== false) { $config = array_merge($this->_loaded[$alias]->settings[$this->modelName], $config); } else { - $config = array(); + $config = []; } } if (empty($config)) { - $config = array(); + $config = []; } $this->_loaded[$alias]->settings['priority'] = $priority; $this->_loaded[$alias]->setup(ClassRegistry::getObject($this->modelName), $config); foreach ($this->_loaded[$alias]->mapMethods as $method => $methodAlias) { - $this->_mappedMethods[$method] = array($alias, $methodAlias); + $this->_mappedMethods[$method] = [$alias, $methodAlias]; } $methods = get_class_methods($this->_loaded[$alias]); $parentMethods = array_flip(get_class_methods('ModelBehavior')); - $callbacks = array( + $callbacks = [ 'setup', 'cleanup', 'beforeFind', 'afterFind', 'beforeSave', 'afterSave', 'beforeDelete', 'afterDelete', 'onError' - ); + ]; foreach ($methods as $m) { if (!isset($parentMethods[$m])) { @@ -161,7 +161,7 @@ public function load($behavior, $config = array()) { !in_array($m, $callbacks) ); if ($methodAllowed) { - $this->_methods[$m] = array($alias, $m); + $this->_methods[$m] = [$alias, $m]; } } } @@ -184,7 +184,7 @@ public function load($behavior, $config = array()) { * @return void */ public function unload($name) { - list(, $name) = pluginSplit($name); + [, $name] = pluginSplit($name); if (isset($this->_loaded[$name])) { $this->_loaded[$name]->cleanup(ClassRegistry::getObject($this->modelName)); parent::unload($name); @@ -219,7 +219,7 @@ public function detach($name) { * @param bool $strict If methods are not found, trigger an error. * @return array All methods for all behaviors attached to this object */ - public function dispatchMethod($model, $method, $params = array(), $strict = false) { + public function dispatchMethod($model, $method, $params = [], $strict = false) { $method = $this->hasMethod($method, true); if ($strict && empty($method)) { @@ -227,15 +227,15 @@ public function dispatchMethod($model, $method, $params = array(), $strict = fal return null; } if (empty($method)) { - return array('unhandled'); + return ['unhandled']; } if (count($method) === 3) { array_unshift($params, $method[2]); unset($method[2]); } return call_user_func_array( - array($this->_loaded[$method[0]], $method[1]), - array_merge(array(&$model), $params) + [$this->_loaded[$method[0]], $method[1]], + array_merge([&$model], $params) ); } @@ -281,7 +281,7 @@ public function hasMethod($method, $callback = false) { * @return array */ public function implementedEvents() { - return array( + return [ 'Model.beforeFind' => 'trigger', 'Model.afterFind' => 'trigger', 'Model.beforeValidate' => 'trigger', @@ -290,7 +290,7 @@ public function implementedEvents() { 'Model.afterSave' => 'trigger', 'Model.beforeDelete' => 'trigger', 'Model.afterDelete' => 'trigger' - ); + ]; } } diff --git a/lib/Cake/Model/CakeSchema.php b/lib/Cake/Model/CakeSchema.php index f2cb4e73d2..6ca5c26ccb 100644 --- a/lib/Cake/Model/CakeSchema.php +++ b/lib/Cake/Model/CakeSchema.php @@ -68,18 +68,18 @@ class CakeSchema extends CakeObject { * * @var array */ - public $tables = array(); + public $tables = []; /** * Constructor * * @param array $options Optional load object properties. */ - public function __construct($options = array()) { + public function __construct($options = []) { parent::__construct(); if (empty($options['name'])) { - $this->name = preg_replace('/schema$/i', '', get_class($this)); + $this->name = preg_replace('/schema$/i', '', static::class); } if (!empty($options['plugin'])) { $this->plugin = $options['plugin']; @@ -107,7 +107,7 @@ public function build($data) { $file = null; foreach ($data as $key => $val) { if (!empty($val)) { - if (!in_array($key, array('plugin', 'name', 'path', 'file', 'connection', 'tables', '_log'))) { + if (!in_array($key, ['plugin', 'name', 'path', 'file', 'connection', 'tables', '_log'])) { if ($key[0] === '_') { continue; } @@ -134,7 +134,7 @@ public function build($data) { * @param array $event Schema object properties. * @return bool Should process continue. */ - public function before($event = array()) { + public function before($event = []) { return true; } @@ -144,7 +144,7 @@ public function before($event = array()) { * @param array $event Schema object properties. * @return void */ - public function after($event = array()) { + public function after($event = []) { } /** @@ -153,9 +153,9 @@ public function after($event = array()) { * @param array $options Schema object properties. * @return array|bool Set of name and tables. */ - public function load($options = array()) { + public function load($options = []) { if (is_string($options)) { - $options = array('path' => $options); + $options = ['path' => $options]; } $this->build($options); @@ -187,13 +187,13 @@ public function load($options = array()) { * @param array $options Schema object properties. * @return array Array indexed by name and tables. */ - public function read($options = array()) { + public function read($options = []) { $options = array_merge( - array( + [ 'connection' => $this->connection, 'name' => $this->name, 'models' => true, - ), + ], $options ); $db = ConnectionManager::getDataSource($options['connection']); @@ -202,7 +202,7 @@ public function read($options = array()) { App::uses($this->plugin . 'AppModel', $this->plugin . '.Model'); } - $tables = array(); + $tables = []; $currentTables = (array)$db->listSources(); $prefix = null; @@ -245,8 +245,8 @@ public function read($options = array()) { } try { - $Object = ClassRegistry::init(array('class' => $model, 'ds' => $options['connection'])); - } catch (CakeException $e) { + $Object = ClassRegistry::init(['class' => $model, 'ds' => $options['connection']]); + } catch (CakeException) { continue; } @@ -256,7 +256,7 @@ public function read($options = array()) { $db = $Object->getDataSource(); $fulltable = $table = $db->fullTableName($Object, false, false); - if ($prefix && strpos($table, $prefix) !== 0) { + if ($prefix && !str_starts_with($table, $prefix)) { continue; } if (!in_array($fulltable, $currentTables)) { @@ -283,7 +283,7 @@ public function read($options = array()) { continue; } $withTable = $db->fullTableName($Object->$class, false, false); - if ($prefix && strpos($withTable, $prefix) !== 0) { + if ($prefix && !str_starts_with($withTable, $prefix)) { continue; } if (in_array($withTable, $currentTables)) { @@ -302,18 +302,18 @@ public function read($options = array()) { if (!empty($currentTables)) { foreach ($currentTables as $table) { if ($prefix) { - if (strpos($table, $prefix) !== 0) { + if (!str_starts_with($table, $prefix)) { continue; } $table = $this->_noPrefixTable($prefix, $table); } - $Object = new AppModel(array( + $Object = new AppModel([ 'name' => Inflector::classify($table), 'table' => $table, 'ds' => $options['connection'] - )); + ]); - $systemTables = array( + $systemTables = [ 'aros', 'acos', 'aros_acos', Configure::read('Session.table'), 'i18n' - ); + ]; $fulltable = $db->fullTableName($Object, false, false); @@ -334,7 +334,7 @@ public function read($options = array()) { } ksort($tables); - return array('name' => $options['name'], 'tables' => $tables); + return ['name' => $options['name'], 'tables' => $tables]; } /** @@ -344,7 +344,7 @@ public function read($options = array()) { * @param array $options Schema object properties to override object. * @return mixed False or string written to file. */ - public function write($object, $options = array()) { + public function write($object, $options = []) { if (is_object($object)) { $object = get_object_vars($object); $this->build($object); @@ -413,12 +413,12 @@ public function generateTable($table, $fields) { $out = "\tpublic \${$table} = array(\n"; if (is_array($fields)) { - $cols = array(); + $cols = []; foreach ($fields as $field => $value) { if ($field !== 'indexes' && $field !== 'tableParameters') { if (is_string($value)) { $type = $value; - $value = array('type' => $type); + $value = ['type' => $type]; } $value['type'] = addslashes($value['type']); $col = "\t\t'{$field}' => array('type' => '" . $value['type'] . "', "; @@ -426,7 +426,7 @@ public function generateTable($table, $fields) { $col .= implode(', ', $this->_values($value)); } elseif ($field === 'indexes') { $col = "\t\t'indexes' => array(\n\t\t\t"; - $props = array(); + $props = []; foreach ((array)$value as $key => $index) { $props[] = "'{$key}' => array(" . implode(', ', $this->_values($index)) . ")"; } @@ -471,7 +471,7 @@ public function compare($old, $new = null) { } else { $old = $old->tables; } - $tables = array(); + $tables = []; foreach ($new as $table => $fields) { if ($table === 'missing') { continue; @@ -514,7 +514,7 @@ public function compare($old, $new = null) { $diff = $this->_compareIndexes($new[$table]['indexes'], $old[$table]['indexes']); if ($diff) { if (!isset($tables[$table])) { - $tables[$table] = array(); + $tables[$table] = []; } if (isset($diff['drop'])) { $tables[$table]['drop']['indexes'] = $diff['drop']; @@ -548,7 +548,7 @@ public function compare($old, $new = null) { * where match was not found. */ protected function _arrayDiffAssoc($array1, $array2) { - $difference = array(); + $difference = []; foreach ($array1 as $key => $value) { if (!array_key_exists($key, $array2)) { $difference[$key] = $value; @@ -581,7 +581,7 @@ protected function _arrayDiffAssoc($array1, $array2) { * @return array Formatted values. */ protected function _values($values) { - $vals = array(); + $vals = []; if (is_array($values)) { foreach ($values as $key => $val) { if (is_array($val)) { @@ -620,12 +620,12 @@ protected function _columns(&$Obj) { } } - $columns = array(); + $columns = []; foreach ($fields as $name => $value) { if ($Obj->primaryKey === $name && !$hasPrimaryAlready && !isset($value['key'])) { $value['key'] = 'primary'; } - if (substr($value['type'], 0, 4) !== 'enum') { + if (!str_starts_with($value['type'], 'enum')) { if (!isset($db->columns[$value['type']])) { trigger_error(__d('cake_dev', 'Schema generation error: invalid column type %s for %s.%s does not exist in DBO', $value['type'], $Obj->name, $name), E_USER_NOTICE); continue; @@ -682,7 +682,7 @@ protected function _compareIndexes($new, $old) { return false; } - $add = $drop = array(); + $add = $drop = []; $diff = $this->_arrayDiffAssoc($new, $old); if (!empty($diff)) { @@ -696,8 +696,8 @@ protected function _compareIndexes($new, $old) { foreach ($new as $name => $value) { if (isset($old[$name])) { - $newUnique = isset($value['unique']) ? $value['unique'] : 0; - $oldUnique = isset($old[$name]['unique']) ? $old[$name]['unique'] : 0; + $newUnique = $value['unique'] ?? 0; + $oldUnique = $old[$name]['unique'] ?? 0; $newColumn = $value['column']; $oldColumn = $old[$name]['column']; diff --git a/lib/Cake/Model/ConnectionManager.php b/lib/Cake/Model/ConnectionManager.php index 2a93624cbb..3716b357e2 100644 --- a/lib/Cake/Model/ConnectionManager.php +++ b/lib/Cake/Model/ConnectionManager.php @@ -42,14 +42,14 @@ class ConnectionManager { * * @var array */ - protected static $_dataSources = array(); + protected static $_dataSources = []; /** * Contains a list of all file and class names used in Connection settings * * @var array */ - protected static $_connectionsEnum = array(); + protected static $_connectionsEnum = []; /** * Indicates if the init code for this class has already been executed @@ -95,12 +95,12 @@ public static function getDataSource($name) { $conn = static::$_connectionsEnum[$name]; $class = $conn['classname']; - if (strpos(App::location($class), 'Datasource') === false) { - throw new MissingDatasourceException(array( + if (!str_contains(App::location($class), 'Datasource')) { + throw new MissingDatasourceException([ 'class' => $class, 'plugin' => null, 'message' => 'Datasource is not found in Model/Datasource package.' - )); + ]); } static::$_dataSources[$name] = new $class(static::$config->{$name}); static::$_dataSources[$name]->configKeyName = $name; @@ -175,10 +175,10 @@ public static function loadDataSource($connName) { App::uses($conn['classname'], $plugin . 'Model/Datasource' . $package); if (!class_exists($conn['classname'])) { - throw new MissingDatasourceException(array( + throw new MissingDatasourceException([ 'class' => $conn['classname'], 'plugin' => substr($plugin, 0, -1) - )); + ]); } return true; } @@ -203,7 +203,7 @@ public static function enumConnectionObjects() { * @param array $config The DataSource configuration settings * @return DataSource|null A reference to the DataSource object, or null if creation failed */ - public static function create($name = '', $config = array()) { + public static function create($name = '', $config = []) { if (empty(static::$_init)) { static::_init(); } @@ -246,7 +246,7 @@ protected static function _getConnectionObject($name) { if (!empty(static::$config->{$name})) { static::$_connectionsEnum[$name] = static::_connectionData(static::$config->{$name}); } else { - throw new MissingDatasourceConfigException(array('config' => $name)); + throw new MissingDatasourceConfigException(['config' => $name]); } } @@ -259,8 +259,8 @@ protected static function _getConnectionObject($name) { protected static function _connectionData($config) { $package = $classname = $plugin = null; - list($plugin, $classname) = pluginSplit($config['datasource']); - if (strpos($classname, '/') !== false) { + [$plugin, $classname] = pluginSplit($config['datasource']); + if (str_contains($classname, '/')) { $package = dirname($classname); $classname = basename($classname); } diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index e67731429b..6626c6614d 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -183,10 +183,10 @@ protected static function _setPath($base = null) { static::$path = '/'; return; } - if (strpos($base, 'index.php') !== false) { + if (str_contains($base, 'index.php')) { $base = str_replace('index.php', '', $base); } - if (strpos($base, '?') !== false) { + if (str_contains($base, '?')) { $base = str_replace('?', '', $base); } static::$path = $base; @@ -200,7 +200,7 @@ protected static function _setPath($base = null) { */ protected static function _setHost($host) { static::$host = $host; - if (strpos(static::$host, ':') !== false) { + if (str_contains(static::$host, ':')) { static::$host = substr(static::$host, 0, strpos(static::$host, ':')); } } @@ -408,11 +408,7 @@ public static function read($name = null) { return static::_returnSessionVars(); } $result = Hash::get($_SESSION, $name); - - if (isset($result)) { - return $result; - } - return null; + return $result ?? null; } /** @@ -442,7 +438,7 @@ public static function write($name, $value = null) { $write = $name; if (!is_array($name)) { - $write = array($name => $value); + $write = [$name => $value]; } foreach ($write as $key => $val) { static::_overwrite($_SESSION, Hash::insert($_SESSION, $key, $val)); @@ -505,7 +501,7 @@ public static function destroy() { */ public static function clear($renew = true) { if (!$renew) { - $_SESSION = array(); + $_SESSION = []; return; } @@ -591,12 +587,12 @@ protected static function _configureSession() { $handler = static::_getHandler($sessionConfig['handler']['engine']); if (!function_exists('session_status') || session_status() !== PHP_SESSION_ACTIVE) { session_set_save_handler( - array($handler, 'open'), - array($handler, 'close'), - array($handler, 'read'), - array($handler, 'write'), - array($handler, 'destroy'), - array($handler, 'gc') + [$handler, 'open'], + [$handler, 'close'], + [$handler, 'read'], + [$handler, 'write'], + [$handler, 'destroy'], + [$handler, 'gc'] ); } } @@ -644,7 +640,7 @@ protected static function _hasSession() { * @throws CakeSessionException */ protected static function _getHandler($handler) { - list($plugin, $class) = pluginSplit($handler, true); + [$plugin, $class] = pluginSplit($handler, true); App::uses($class, $plugin . 'Model/Datasource/Session'); if (!class_exists($class)) { throw new CakeSessionException(__d('cake_dev', 'Could not load %s to handle the session.', $class)); @@ -663,19 +659,19 @@ protected static function _getHandler($handler) { * @return bool|array */ protected static function _defaultConfig($name) { - $defaults = array( - 'php' => array( + $defaults = [ + 'php' => [ 'cookie' => 'CAKEPHP', 'timeout' => 240, - 'ini' => array( + 'ini' => [ 'session.use_trans_sid' => 0, 'session.cookie_path' => static::$path - ) - ), - 'cake' => array( + ] + ], + 'cake' => [ 'cookie' => 'CAKEPHP', 'timeout' => 240, - 'ini' => array( + 'ini' => [ 'session.use_trans_sid' => 0, 'url_rewriter.tags' => '', 'session.serialize_handler' => 'php', @@ -683,44 +679,41 @@ protected static function _defaultConfig($name) { 'session.cookie_path' => static::$path, 'session.save_path' => TMP . 'sessions', 'session.save_handler' => 'files' - ) - ), - 'cache' => array( + ] + ], + 'cache' => [ 'cookie' => 'CAKEPHP', 'timeout' => 240, - 'ini' => array( + 'ini' => [ 'session.use_trans_sid' => 0, 'url_rewriter.tags' => '', 'session.use_cookies' => 1, 'session.cookie_path' => static::$path, 'session.save_handler' => 'user', - ), - 'handler' => array( + ], + 'handler' => [ 'engine' => 'CacheSession', 'config' => 'default' - ) - ), - 'database' => array( + ] + ], + 'database' => [ 'cookie' => 'CAKEPHP', 'timeout' => 240, - 'ini' => array( + 'ini' => [ 'session.use_trans_sid' => 0, 'url_rewriter.tags' => '', 'session.use_cookies' => 1, 'session.cookie_path' => static::$path, 'session.save_handler' => 'user', 'session.serialize_handler' => 'php', - ), - 'handler' => array( + ], + 'handler' => [ 'engine' => 'DatabaseSession', 'model' => 'Session' - ) - ) - ); - if (isset($defaults[$name])) { - return $defaults[$name]; - } - return false; + ] + ] + ]; + return $defaults[$name] ?? false; } /** @@ -735,7 +728,7 @@ protected static function _startSession() { if (headers_sent()) { if (empty($_SESSION)) { - $_SESSION = array(); + $_SESSION = []; } } else { $limit = Configure::read('Session.cacheLimiter'); @@ -770,7 +763,7 @@ protected static function _checkValid() { } } } else { - $_SESSION = array(); + $_SESSION = []; static::destroy(); static::_setError(1, 'Session Highjacking Attempted !!!'); static::_startSession(); @@ -802,7 +795,7 @@ public static function renew() { return; } if (isset($_COOKIE[static::_cookieName()])) { - setcookie(Configure::read('Session.cookie'), '', time() - 42000, static::$path); + setcookie(Configure::read('Session.cookie'), '', ['expires' => time() - 42000, 'path' => static::$path]); } if (!headers_sent()) { session_write_close(); @@ -820,7 +813,7 @@ public static function renew() { */ protected static function _setError($errorNumber, $errorMessage) { if (static::$error === false) { - static::$error = array(); + static::$error = []; } static::$error[$errorNumber] = $errorMessage; static::$lastError = $errorNumber; diff --git a/lib/Cake/Model/Datasource/DataSource.php b/lib/Cake/Model/Datasource/DataSource.php index 6d0710b9c3..5659d0f63d 100644 --- a/lib/Cake/Model/Datasource/DataSource.php +++ b/lib/Cake/Model/Datasource/DataSource.php @@ -38,14 +38,14 @@ class DataSource extends CakeObject { * * @var array */ - protected $_baseConfig = array(); + protected $_baseConfig = []; /** * Holds references to descriptions loaded by the DataSource * * @var array */ - protected $_descriptions = array(); + protected $_descriptions = []; /** * Holds a list of sources (tables) contained in the DataSource @@ -59,7 +59,7 @@ class DataSource extends CakeObject { * * @var array */ - public $config = array(); + public $config = []; /** * Whether or not this DataSource is in the middle of a transaction @@ -81,7 +81,7 @@ class DataSource extends CakeObject { * * @param array $config Array of configuration information for the datasource. */ - public function __construct($config = array()) { + public function __construct($config = []) { parent::__construct(); $this->setConfig($config); } @@ -202,7 +202,7 @@ public function create(Model $Model, $fields = null, $values = null) { * @param int $recursive Number of levels of association * @return mixed */ - public function read(Model $Model, $queryData = array(), $recursive = null) { + public function read(Model $Model, $queryData = [], $recursive = null) { return false; } @@ -282,7 +282,7 @@ public function enabled() { * @param array $config The configuration array * @return void */ - public function setConfig($config = array()) { + public function setConfig($config = []) { $this->config = array_merge($this->_baseConfig, $this->config, $config); } @@ -324,12 +324,12 @@ protected function _cacheDescription($object, $data = null) { * @return mixed String of query data with placeholders replaced, or false on failure. */ public function insertQueryData($query, $data, $association, Model $Model, $stack) { - $keys = array('{$__cakeID__$}', '{$__cakeForeignKey__$}'); + $keys = ['{$__cakeID__$}', '{$__cakeForeignKey__$}']; $modelAlias = $Model->alias; foreach ($keys as $key) { - if (strpos($query, $key) === false) { + if (!str_contains($query, $key)) { continue; } diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 000a19ea95..31bf1a218d 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -39,15 +39,15 @@ class Mysql extends DboSource { * * @var array */ - protected $_baseConfig = array( + protected $_baseConfig = [ 'persistent' => true, 'host' => 'localhost', 'login' => 'root', 'password' => '', 'database' => 'cake', 'port' => '3306', - 'flags' => array() - ); + 'flags' => [] + ]; /** * Reference to the PDO object connection @@ -82,33 +82,33 @@ class Mysql extends DboSource { * * @var array */ - public $fieldParameters = array( - 'charset' => array('value' => 'CHARACTER SET', 'quote' => false, 'join' => ' ', 'column' => false, 'position' => 'beforeDefault'), - 'collate' => array('value' => 'COLLATE', 'quote' => false, 'join' => ' ', 'column' => 'Collation', 'position' => 'beforeDefault'), - 'comment' => array('value' => 'COMMENT', 'quote' => true, 'join' => ' ', 'column' => 'Comment', 'position' => 'afterDefault'), - 'unsigned' => array( + public $fieldParameters = [ + 'charset' => ['value' => 'CHARACTER SET', 'quote' => false, 'join' => ' ', 'column' => false, 'position' => 'beforeDefault'], + 'collate' => ['value' => 'COLLATE', 'quote' => false, 'join' => ' ', 'column' => 'Collation', 'position' => 'beforeDefault'], + 'comment' => ['value' => 'COMMENT', 'quote' => true, 'join' => ' ', 'column' => 'Comment', 'position' => 'afterDefault'], + 'unsigned' => [ 'value' => 'UNSIGNED', 'quote' => false, 'join' => ' ', 'column' => false, 'position' => 'beforeDefault', 'noVal' => true, - 'options' => array(true), - 'types' => array('integer', 'smallinteger', 'tinyinteger', 'float', 'decimal', 'biginteger') - ) - ); + 'options' => [true], + 'types' => ['integer', 'smallinteger', 'tinyinteger', 'float', 'decimal', 'biginteger'] + ] + ]; /** * List of table engine specific parameters used on table creating * * @var array */ - public $tableParameters = array( - 'charset' => array('value' => 'DEFAULT CHARSET', 'quote' => false, 'join' => '=', 'column' => 'charset'), - 'collate' => array('value' => 'COLLATE', 'quote' => false, 'join' => '=', 'column' => 'Collation'), - 'engine' => array('value' => 'ENGINE', 'quote' => false, 'join' => '=', 'column' => 'Engine'), - 'comment' => array('value' => 'COMMENT', 'quote' => true, 'join' => '=', 'column' => 'Comment'), - ); + public $tableParameters = [ + 'charset' => ['value' => 'DEFAULT CHARSET', 'quote' => false, 'join' => '=', 'column' => 'charset'], + 'collate' => ['value' => 'COLLATE', 'quote' => false, 'join' => '=', 'column' => 'Collation'], + 'engine' => ['value' => 'ENGINE', 'quote' => false, 'join' => '=', 'column' => 'Engine'], + 'comment' => ['value' => 'COMMENT', 'quote' => true, 'join' => '=', 'column' => 'Comment'], + ]; /** * MySQL column definition @@ -116,31 +116,31 @@ class Mysql extends DboSource { * @var array * @link https://dev.mysql.com/doc/refman/5.7/en/data-types.html MySQL Data Types */ - public $columns = array( - 'primary_key' => array('name' => 'NOT NULL AUTO_INCREMENT'), - 'string' => array('name' => 'varchar', 'limit' => '255'), - 'text' => array('name' => 'text'), - 'enum' => array('name' => 'enum'), - 'biginteger' => array('name' => 'bigint', 'limit' => '20'), - 'integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), - 'smallinteger' => array('name' => 'smallint', 'limit' => '6', 'formatter' => 'intval'), - 'tinyinteger' => array('name' => 'tinyint', 'limit' => '4', 'formatter' => 'intval'), - 'float' => array('name' => 'float', 'formatter' => 'floatval'), - 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'), - 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'), - 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'), - 'binary' => array('name' => 'blob'), - 'boolean' => array('name' => 'tinyint', 'limit' => '1') - ); + public $columns = [ + 'primary_key' => ['name' => 'NOT NULL AUTO_INCREMENT'], + 'string' => ['name' => 'varchar', 'limit' => '255'], + 'text' => ['name' => 'text'], + 'enum' => ['name' => 'enum'], + 'biginteger' => ['name' => 'bigint', 'limit' => '20'], + 'integer' => ['name' => 'int', 'limit' => '11', 'formatter' => 'intval'], + 'smallinteger' => ['name' => 'smallint', 'limit' => '6', 'formatter' => 'intval'], + 'tinyinteger' => ['name' => 'tinyint', 'limit' => '4', 'formatter' => 'intval'], + 'float' => ['name' => 'float', 'formatter' => 'floatval'], + 'decimal' => ['name' => 'decimal', 'formatter' => 'floatval'], + 'datetime' => ['name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'], + 'timestamp' => ['name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'], + 'time' => ['name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'], + 'date' => ['name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'], + 'binary' => ['name' => 'blob'], + 'boolean' => ['name' => 'tinyint', 'limit' => '1'] + ]; /** * Mapping of collation names to character set names * * @var array */ - protected $_charsets = array(); + protected $_charsets = []; /** * Connects to the database using options in the given configuration array. @@ -161,11 +161,11 @@ public function connect() { $config = $this->config; $this->connected = false; - $flags = $config['flags'] + array( + $flags = $config['flags'] + [ PDO::ATTR_PERSISTENT => $config['persistent'], PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION - ); + ]; if (!empty($config['encoding'])) { $flags[PDO::MYSQL_ATTR_INIT_COMMAND] = 'SET NAMES ' . $config['encoding']; @@ -197,13 +197,13 @@ public function connect() { } } } catch (PDOException $e) { - throw new MissingConnectionException(array( - 'class' => get_class($this), + throw new MissingConnectionException([ + 'class' => static::class, 'message' => $e->getMessage() - )); + ]); } - $this->_charsets = array(); + $this->_charsets = []; $this->_useAlias = (bool)version_compare($this->getVersion(), "4.1", ">="); return $this->connected; @@ -233,9 +233,9 @@ public function listSources($data = null) { if (!$result) { $result->closeCursor(); - return array(); + return []; } - $tables = array(); + $tables = []; while ($line = $result->fetch(PDO::FETCH_NUM)) { $tables[] = $line[0]; @@ -253,7 +253,7 @@ public function listSources($data = null) { * @return void */ public function resultSet($results) { - $this->map = array(); + $this->map = []; $numFields = $results->columnCount(); $index = 0; @@ -264,10 +264,10 @@ public function resultSet($results) { } else { $type = empty($column['native_type']) ? 'string' : $column['native_type']; } - if (!empty($column['table']) && strpos($column['name'], $this->virtualFieldSeparator) === false) { - $this->map[$index++] = array($column['table'], $column['name'], $type); + if (!empty($column['table']) && !str_contains($column['name'], $this->virtualFieldSeparator)) { + $this->map[$index++] = [$column['table'], $column['name'], $type]; } else { - $this->map[$index++] = array(0, $column['name'], $type); + $this->map[$index++] = [0, $column['name'], $type]; } } } @@ -279,9 +279,9 @@ public function resultSet($results) { */ public function fetchResult() { if ($row = $this->_result->fetch(PDO::FETCH_NUM)) { - $resultRow = array(); + $resultRow = []; foreach ($this->map as $col => $meta) { - list($table, $column, $type) = $meta; + [$table, $column, $type] = $meta; $resultRow[$table][$column] = $row[$col]; if ($type === 'boolean' && $row[$col] !== null) { $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]); @@ -299,7 +299,7 @@ public function fetchResult() { * @return string The database encoding */ public function getEncoding() { - return $this->_execute('SHOW VARIABLES LIKE ?', array('character_set_client'))->fetchObject()->Value; + return $this->_execute('SHOW VARIABLES LIKE ?', ['character_set_client'])->fetchObject()->Value; } /** @@ -317,7 +317,7 @@ public function getCharsetName($name) { } $r = $this->_execute( 'SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?', - array($name) + [$name] ); $cols = $r->fetch(PDO::FETCH_ASSOC); @@ -344,25 +344,25 @@ public function describe($model) { } $table = $this->fullTableName($model); - $fields = array(); + $fields = []; $cols = $this->_execute('SHOW FULL COLUMNS FROM ' . $table); if (!$cols) { throw new CakeException(__d('cake_dev', 'Could not describe table for %s', $table)); } while ($column = $cols->fetch(PDO::FETCH_OBJ)) { - $fields[$column->Field] = array( + $fields[$column->Field] = [ 'type' => $this->column($column->Type), 'null' => ($column->Null === 'YES' ? true : false), 'default' => $column->Default, 'length' => $this->length($column->Type) - ); + ]; if (in_array($fields[$column->Field]['type'], $this->fieldParameters['unsigned']['types'], true)) { $fields[$column->Field]['unsigned'] = $this->_unsigned($column->Type); } - if (in_array($fields[$column->Field]['type'], array('timestamp', 'datetime')) && + if (in_array($fields[$column->Field]['type'], ['timestamp', 'datetime']) && //Falling back to default empty string due to PHP8.1 deprecation notice. - in_array(strtoupper($column->Default ?? ""), array('CURRENT_TIMESTAMP', 'CURRENT_TIMESTAMP()')) + in_array(strtoupper($column->Default ?? ""), ['CURRENT_TIMESTAMP', 'CURRENT_TIMESTAMP()']) ) { $fields[$column->Field]['default'] = null; } @@ -401,7 +401,7 @@ public function describe($model) { * @param mixed $conditions The conditions to use. * @return bool */ - public function update(Model $model, $fields = array(), $values = null, $conditions = null) { + public function update(Model $model, $fields = [], $values = null, $conditions = null) { if (!$this->_useAlias) { return parent::update($model, $fields, $values, $conditions); } @@ -484,7 +484,7 @@ protected function _deleteNeedsComplexConditions(Model $model, $conditions) { if ($this->_deleteNeedsComplexConditions($model, $value)) { return true; } - } elseif (strpos($key, $model->alias) === false && !in_array($key, $fields, true)) { + } elseif (!str_contains($key, $model->alias) && !in_array($key, $fields, true)) { return true; } } @@ -508,7 +508,7 @@ public function setEncoding($enc) { * @return array Fields in table. Keys are column and unique */ public function index($model) { - $index = array(); + $index = []; $table = $this->fullTableName($model); $old = version_compare($this->getVersion(), '4.1', '<='); if ($table) { @@ -520,7 +520,7 @@ public function index($model) { $idx = (object)current((array)$idx); } if (!isset($index[$idx->Key_name]['column'])) { - $col = array(); + $col = []; $index[$idx->Key_name]['column'] = $idx->Column_name; if ($idx->Index_type === 'FULLTEXT') { @@ -537,7 +537,7 @@ public function index($model) { } if (!empty($idx->Sub_part)) { if (!isset($index[$idx->Key_name]['length'])) { - $index[$idx->Key_name]['length'] = array(); + $index[$idx->Key_name]['length'] = []; } $index[$idx->Key_name]['length'][$idx->Column_name] = $idx->Sub_part; } @@ -560,9 +560,9 @@ public function alterSchema($compare, $table = null) { return false; } $out = ''; - $colList = array(); + $colList = []; foreach ($compare as $curTable => $types) { - $indexes = $tableParameters = $colList = array(); + $indexes = $tableParameters = $colList = []; if (!$table || $table === $curTable) { $out .= 'ALTER TABLE ' . $this->fullTableName($curTable) . " \n"; foreach ($types as $type => $column) { @@ -634,7 +634,7 @@ protected function _alterTableParameters($table, $parameters) { if (isset($parameters['change'])) { return $this->buildTableParameters($parameters['change']); } - return array(); + return []; } /** @@ -646,7 +646,7 @@ protected function _alterTableParameters($table, $parameters) { * @see DboSource::buildIndex() */ public function buildIndex($indexes, $table = null) { - $join = array(); + $join = []; foreach ($indexes as $name => $value) { $out = ''; if ($name === 'PRIMARY') { @@ -665,7 +665,7 @@ public function buildIndex($indexes, $table = null) { if (is_array($value['column'])) { if (isset($value['length'])) { - $vals = array(); + $vals = []; foreach ($value['column'] as $column) { $name = $this->name($column); if (isset($value['length'])) { @@ -675,7 +675,7 @@ public function buildIndex($indexes, $table = null) { } $out .= implode(', ', $vals); } else { - $out .= implode(', ', array_map(array(&$this, 'name'), $value['column'])); + $out .= implode(', ', array_map([&$this, 'name'], $value['column'])); } } else { $out .= $this->name($value['column']); @@ -697,7 +697,7 @@ public function buildIndex($indexes, $table = null) { * @return array Index alteration statements */ protected function _alterIndexes($table, $indexes) { - $alter = array(); + $alter = []; if (isset($indexes['drop'])) { foreach ($indexes['drop'] as $name => $value) { $out = 'DROP '; @@ -750,9 +750,9 @@ public function listDetailedSources($name = null) { if (!$result) { $result->closeCursor(); - return array(); + return []; } - $tables = array(); + $tables = []; foreach ($result as $row) { $tables[$row['Name']] = (array)$row; unset($tables[$row['Name']]['queryString']); @@ -787,47 +787,47 @@ public function column($real) { $col = str_replace(')', '', $real); $limit = $this->length($real); - if (strpos($col, '(') !== false) { - list($col, $vals) = explode('(', $col); + if (str_contains($col, '(')) { + [$col, $vals] = explode('(', $col); } - if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) { + if (in_array($col, ['date', 'time', 'datetime', 'timestamp'])) { return $col; } if (($col === 'tinyint' && $limit === 1) || $col === 'boolean') { return 'boolean'; } - if (strpos($col, 'bigint') !== false || $col === 'bigint') { + if (str_contains($col, 'bigint') || $col === 'bigint') { return 'biginteger'; } - if (strpos($col, 'tinyint') !== false) { + if (str_contains($col, 'tinyint')) { return 'tinyinteger'; } - if (strpos($col, 'smallint') !== false) { + if (str_contains($col, 'smallint')) { return 'smallinteger'; } - if (strpos($col, 'int') !== false) { + if (str_contains($col, 'int')) { return 'integer'; } - if (strpos($col, 'char') !== false || $col === 'tinytext') { + if (str_contains($col, 'char') || $col === 'tinytext') { return 'string'; } - if (strpos($col, 'text') !== false) { + if (str_contains($col, 'text')) { return 'text'; } - if (strpos($col, 'blob') !== false || $col === 'binary') { + if (str_contains($col, 'blob') || $col === 'binary') { return 'binary'; } - if (strpos($col, 'float') !== false || strpos($col, 'double') !== false) { + if (str_contains($col, 'float') || str_contains($col, 'double')) { return 'float'; } - if (strpos($col, 'decimal') !== false || strpos($col, 'numeric') !== false) { + if (str_contains($col, 'decimal') || str_contains($col, 'numeric')) { return 'decimal'; } - if (strpos($col, 'enum') !== false) { + if (str_contains($col, 'enum')) { return "enum($vals)"; } - if (strpos($col, 'set') !== false) { + if (str_contains($col, 'set')) { return "set($vals)"; } return 'text'; @@ -869,7 +869,7 @@ public function nestedTransactionSupported() { * @return bool True if column is unsigned, false otherwise */ protected function _unsigned($real) { - return strpos(strtolower($real), 'unsigned') !== false; + return str_contains(strtolower($real), 'unsigned'); } /** @@ -886,15 +886,15 @@ protected function _unsigned($real) { public function insertMulti($table, $fields, $values) { $table = $this->fullTableName($table); $holder = implode(', ', array_fill(0, count($fields), '?')); - $fields = implode(', ', array_map(array($this, 'name'), $fields)); - $pdoMap = array( + $fields = implode(', ', array_map([$this, 'name'], $fields)); + $pdoMap = [ 'integer' => PDO::PARAM_INT, 'float' => PDO::PARAM_STR, 'boolean' => PDO::PARAM_BOOL, 'string' => PDO::PARAM_STR, 'text' => PDO::PARAM_STR - ); - $columnMap = array(); + ]; + $columnMap = []; $rowHolder = "({$holder})"; $sql = "INSERT INTO {$table} ({$fields}) VALUES "; $countRows = count($values); @@ -909,7 +909,7 @@ public function insertMulti($table, $fields, $values) { $type = $this->introspectType($val); $columnMap[$key] = $pdoMap[$type]; } - $valuesList = array(); + $valuesList = []; $i = 1; foreach ($values as $value) { foreach ($value as $col => $val) { diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index f81bee5b3b..94d077b633 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -35,7 +35,7 @@ class Postgres extends DboSource { * * @var array */ - protected $_baseConfig = array( + protected $_baseConfig = [ 'persistent' => true, 'host' => 'localhost', 'login' => 'root', @@ -45,8 +45,8 @@ class Postgres extends DboSource { 'port' => 5432, 'encoding' => '', 'sslmode' => 'allow', - 'flags' => array() - ); + 'flags' => [] + ]; /** * Columns @@ -54,26 +54,26 @@ class Postgres extends DboSource { * @var array * @link https://www.postgresql.org/docs/9.6/static/datatype.html PostgreSQL Data Types */ - public $columns = array( - 'primary_key' => array('name' => 'serial NOT NULL'), - 'string' => array('name' => 'varchar', 'limit' => '255'), - 'text' => array('name' => 'text'), - 'integer' => array('name' => 'integer', 'formatter' => 'intval'), - 'smallinteger' => array('name' => 'smallint', 'formatter' => 'intval'), - 'tinyinteger' => array('name' => 'smallint', 'formatter' => 'intval'), - 'biginteger' => array('name' => 'bigint', 'limit' => '20'), - 'float' => array('name' => 'float', 'formatter' => 'floatval'), - 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'), - 'datetime' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'), - 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'), - 'binary' => array('name' => 'bytea'), - 'boolean' => array('name' => 'boolean'), - 'number' => array('name' => 'numeric'), - 'inet' => array('name' => 'inet'), - 'uuid' => array('name' => 'uuid') - ); + public $columns = [ + 'primary_key' => ['name' => 'serial NOT NULL'], + 'string' => ['name' => 'varchar', 'limit' => '255'], + 'text' => ['name' => 'text'], + 'integer' => ['name' => 'integer', 'formatter' => 'intval'], + 'smallinteger' => ['name' => 'smallint', 'formatter' => 'intval'], + 'tinyinteger' => ['name' => 'smallint', 'formatter' => 'intval'], + 'biginteger' => ['name' => 'bigint', 'limit' => '20'], + 'float' => ['name' => 'float', 'formatter' => 'floatval'], + 'decimal' => ['name' => 'decimal', 'formatter' => 'floatval'], + 'datetime' => ['name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'], + 'timestamp' => ['name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'], + 'time' => ['name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'], + 'date' => ['name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'], + 'binary' => ['name' => 'bytea'], + 'boolean' => ['name' => 'boolean'], + 'number' => ['name' => 'numeric'], + 'inet' => ['name' => 'inet'], + 'uuid' => ['name' => 'uuid'] + ]; /** * Starting Quote @@ -95,14 +95,14 @@ class Postgres extends DboSource { * * @var array */ - protected $_sequenceMap = array(); + protected $_sequenceMap = []; /** * The set of valid SQL operations usable in a WHERE statement * * @var array */ - protected $_sqlOps = array('like', 'ilike', 'or', 'not', 'in', 'between', '~', '~\*', '\!~', '\!~\*', 'similar to'); + protected $_sqlOps = ['like', 'ilike', 'or', 'not', 'in', 'between', '~', '~\*', '\!~', '\!~\*', 'similar to']; /** * Connects to the database using options in the given configuration array. @@ -114,10 +114,10 @@ public function connect() { $config = $this->config; $this->connected = false; - $flags = $config['flags'] + array( + $flags = $config['flags'] + [ PDO::ATTR_PERSISTENT => $config['persistent'], PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION - ); + ]; try { $this->_connection = new PDO( @@ -140,10 +140,10 @@ public function connect() { } } } catch (PDOException $e) { - throw new MissingConnectionException(array( - 'class' => get_class($this), + throw new MissingConnectionException([ + 'class' => static::class, 'message' => $e->getMessage() - )); + ]); } return $this->connected; @@ -173,13 +173,13 @@ public function listSources($data = null) { $schema = $this->config['schema']; $sql = "SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE table_schema = ?"; - $result = $this->_execute($sql, array($schema)); + $result = $this->_execute($sql, [$schema]); if (!$result) { - return array(); + return []; } - $tables = array(); + $tables = []; foreach ($result as $item) { $tables[] = $item->name; @@ -199,7 +199,7 @@ public function listSources($data = null) { public function describe($model) { $table = $this->fullTableName($model, false, false); $fields = parent::describe($table); - $this->_sequenceMap[$table] = array(); + $this->_sequenceMap[$table] = []; $cols = null; $hasPrimary = false; @@ -220,7 +220,7 @@ public function describe($model) { LEFT JOIN pg_catalog.pg_attribute attr ON (cl.oid = attr.attrelid AND column_name = attr.attname) WHERE table_name = ? AND table_schema = ? AND table_catalog = ? ORDER BY ordinal_position', - array($table, $this->config['schema'], $this->config['database']) + [$table, $this->config['schema'], $this->config['database']] ); // @codingStandardsIgnoreStart @@ -245,7 +245,7 @@ public function describe($model) { if (empty($length)) { $length = null; } - $fields[$c->name] = array( + $fields[$c->name] = [ 'type' => $this->column($type), 'null' => ($c->null === 'NO' ? false : true), 'default' => preg_replace( @@ -254,7 +254,7 @@ public function describe($model) { preg_replace('/::[\w\s]+/', '', $c->default) ), 'length' => $length, - ); + ]; // Serial columns are primary integer keys if ($c->has_serial) { @@ -281,7 +281,7 @@ public function describe($model) { ) { $fields[$c->name]['default'] = null; if (!empty($seq) && isset($seq[1])) { - if (strpos($seq[1], '.') === false) { + if (!str_contains($seq[1], '.')) { $sequenceName = $c->schema . '.' . $seq[1]; } else { $sequenceName = $seq[1]; @@ -336,10 +336,7 @@ public function getSequence($table, $field = 'id') { if (!isset($this->_sequenceMap[$table])) { $this->describe($table); } - if (isset($this->_sequenceMap[$table][$field])) { - return $this->_sequenceMap[$table][$field]; - } - return "{$table}_{$field}_seq"; + return $this->_sequenceMap[$table][$field] ?? "{$table}_{$field}_seq"; } /** @@ -411,7 +408,7 @@ public function name($data) { * @param bool $quote Whether or not to quote identifiers. * @return array */ - public function fields(Model $model, $alias = null, $fields = array(), $quote = true) { + public function fields(Model $model, $alias = null, $fields = [], $quote = true) { if (empty($alias)) { $alias = $model->alias; } @@ -423,11 +420,11 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = $count = count($fields); if ($count >= 1 && !preg_match('/^\s*COUNT\(\*/', $fields[0])) { - $result = array(); + $result = []; for ($i = 0; $i < $count; $i++) { if (!preg_match('/^.+\\(.*\\)/', $fields[$i]) && !preg_match('/\s+AS\s+/', $fields[$i])) { - if (substr($fields[$i], -1) === '*') { - if (strpos($fields[$i], '.') !== false && $fields[$i] != $alias . '.*') { + if (str_ends_with($fields[$i], '*')) { + if (str_contains($fields[$i], '.') && $fields[$i] != $alias . '.*') { $build = explode('.', $fields[$i]); $AssociatedModel = $model->{$build[0]}; } else { @@ -440,7 +437,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = } $prepend = ''; - if (strpos($fields[$i], 'DISTINCT') !== false) { + if (str_contains($fields[$i], 'DISTINCT')) { $prepend = 'DISTINCT '; $fields[$i] = trim(str_replace('DISTINCT', '', $fields[$i])); } @@ -452,7 +449,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = $fields[$i] = $prepend . $this->name($build[0]) . '.' . $this->name($build[1]) . ' AS ' . $this->name($build[0] . '__' . $build[1]); } } else { - $fields[$i] = preg_replace_callback('/\(([\s\.\w]+)\)/', array(&$this, '_quoteFunctionField'), $fields[$i]); + $fields[$i] = preg_replace_callback('/\(([\s\.\w]+)\)/', [&$this, '_quoteFunctionField'], $fields[$i]); } $result[] = $fields[$i]; } @@ -470,13 +467,13 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = */ protected function _quoteFunctionField($match) { $prepend = ''; - if (strpos($match[1], 'DISTINCT') !== false) { + if (str_contains($match[1], 'DISTINCT')) { $prepend = 'DISTINCT '; $match[1] = trim(str_replace('DISTINCT', '', $match[1])); } $constant = preg_match('/^\d+|NULL|FALSE|TRUE$/i', $match[1]); - if (!$constant && strpos($match[1], '.') === false) { + if (!$constant && !str_contains($match[1], '.')) { $match[1] = $this->name($match[1]); } elseif (!$constant) { $parts = explode('.', $match[1]); @@ -494,7 +491,7 @@ protected function _quoteFunctionField($match) { * @return array Fields in table. Keys are column and unique */ public function index($model) { - $index = array(); + $index = []; $table = $this->fullTableName($model, false, false); if ($table) { $indexes = $this->query("SELECT c2.relname, i.indisprimary, i.indisunique, i.indisclustered, i.indisvalid, pg_catalog.pg_get_indexdef(i.indexrelid, 0, true) as statement, c2.reltablespace @@ -515,7 +512,7 @@ public function index($model) { } preg_match('/\(([^\)]+)\)/', $key['statement'], $indexColumns); $parsedColumn = $indexColumns[1]; - if (strpos($indexColumns[1], ',') !== false) { + if (str_contains($indexColumns[1], ',')) { $parsedColumn = explode(', ', $indexColumns[1]); } $index[$key['relname']]['unique'] = $key['indisunique']; @@ -537,9 +534,9 @@ public function alterSchema($compare, $table = null) { return false; } $out = ''; - $colList = array(); + $colList = []; foreach ($compare as $curTable => $types) { - $indexes = $colList = array(); + $indexes = $colList = []; if (!$table || $table === $curTable) { $out .= 'ALTER TABLE ' . $this->fullTableName($curTable) . " \n"; foreach ($types as $type => $column) { @@ -569,8 +566,8 @@ public function alterSchema($compare, $table = null) { $original = $schema[$field]; $fieldName = $this->name($field); - $default = isset($col['default']) ? $col['default'] : null; - $nullable = isset($col['null']) ? $col['null'] : null; + $default = $col['default'] ?? null; + $nullable = $col['null'] ?? null; $boolToInt = $original['type'] === 'boolean' && $col['type'] === 'integer'; unset($col['default'], $col['null']); if ($field !== $col['name']) { @@ -582,12 +579,12 @@ public function alterSchema($compare, $table = null) { if ($boolToInt) { $colList[] = 'ALTER COLUMN ' . $fieldName . ' SET DEFAULT NULL'; - $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . ' USING CASE WHEN TRUE THEN 1 ELSE 0 END'; + $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace([$fieldName, 'NOT NULL'], '', $this->buildColumn($col)) . ' USING CASE WHEN TRUE THEN 1 ELSE 0 END'; } else { if ($original['type'] === 'text' && $col['type'] === 'integer') { - $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)) . " USING cast({$fieldName} as INTEGER)"; + $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace([$fieldName, 'NOT NULL'], '', $this->buildColumn($col)) . " USING cast({$fieldName} as INTEGER)"; } else { - $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace(array($fieldName, 'NOT NULL'), '', $this->buildColumn($col)); + $colList[] = 'ALTER COLUMN ' . $fieldName . ' TYPE ' . str_replace([$fieldName, 'NOT NULL'], '', $this->buildColumn($col)); } } @@ -638,7 +635,7 @@ public function alterSchema($compare, $table = null) { * @return array Index alteration statements */ protected function _alterIndexes($table, $indexes) { - $alter = array(); + $alter = []; if (isset($indexes['drop'])) { foreach ($indexes['drop'] as $name => $value) { $out = 'DROP '; @@ -662,7 +659,7 @@ protected function _alterIndexes($table, $indexes) { $out .= 'INDEX '; } if (is_array($value['column'])) { - $out .= $name . ' ON ' . $table . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; + $out .= $name . ' ON ' . $table . ' (' . implode(', ', array_map([&$this, 'name'], $value['column'])) . ')'; } else { $out .= $name . ' ON ' . $table . ' (' . $this->name($value['column']) . ')'; } @@ -707,42 +704,29 @@ public function column($real) { $col = str_replace(')', '', $real); - if (strpos($col, '(') !== false) { - list($col, $limit) = explode('(', $col); + if (str_contains($col, '(')) { + [$col, $limit] = explode('(', $col); } - $floats = array( + $floats = [ 'float', 'float4', 'float8', 'double', 'double precision', 'real' - ); - - switch (true) { - case (in_array($col, array('date', 'time', 'inet', 'boolean'))): - return $col; - case (strpos($col, 'timestamp') !== false): - return 'datetime'; - case (strpos($col, 'time') === 0): - return 'time'; - case ($col === 'bigint'): - return 'biginteger'; - case ($col === 'smallint'): - return 'smallinteger'; - case (strpos($col, 'int') !== false && $col !== 'interval'): - return 'integer'; - case (strpos($col, 'char') !== false): - return 'string'; - case (strpos($col, 'uuid') !== false): - return 'uuid'; - case (strpos($col, 'text') !== false): - return 'text'; - case (strpos($col, 'bytea') !== false): - return 'binary'; - case ($col === 'decimal' || $col === 'numeric'): - return 'decimal'; - case (in_array($col, $floats)): - return 'float'; - default: - return 'text'; - } + ]; + + return match (true) { + in_array($col, ['date', 'time', 'inet', 'boolean']) => $col, + str_contains($col, 'timestamp') => 'datetime', + str_starts_with($col, 'time') => 'time', + $col === 'bigint' => 'biginteger', + $col === 'smallint' => 'smallinteger', + str_contains($col, 'int') && $col !== 'interval' => 'integer', + str_contains($col, 'char') => 'string', + str_contains($col, 'uuid') => 'uuid', + str_contains($col, 'text') => 'text', + str_contains($col, 'bytea') => 'binary', + $col === 'decimal' || $col === 'numeric' => 'decimal', + in_array($col, $floats) => 'float', + default => 'text', + }; } /** @@ -753,8 +737,8 @@ public function column($real) { */ public function length($real) { $col = $real; - if (strpos($real, '(') !== false) { - list($col, $limit) = explode('(', $real); + if (str_contains($real, '(')) { + [$col, $limit] = explode('(', $real); } if ($col === 'uuid') { return 36; @@ -769,7 +753,7 @@ public function length($real) { * @return void */ public function resultSet($results) { - $this->map = array(); + $this->map = []; $numFields = $results->columnCount(); $index = 0; $j = 0; @@ -777,10 +761,10 @@ public function resultSet($results) { while ($j < $numFields) { $column = $results->getColumnMeta($j); if (strpos($column['name'], '__')) { - list($table, $name) = explode('__', $column['name']); - $this->map[$index++] = array($table, $name, $column['native_type']); + [$table, $name] = explode('__', $column['name']); + $this->map[$index++] = [$table, $name, $column['native_type']]; } else { - $this->map[$index++] = array(0, $column['name'], $column['native_type']); + $this->map[$index++] = [0, $column['name'], $column['native_type']]; } $j++; } @@ -793,22 +777,16 @@ public function resultSet($results) { */ public function fetchResult() { if ($row = $this->_result->fetch(PDO::FETCH_NUM)) { - $resultRow = array(); + $resultRow = []; foreach ($this->map as $index => $meta) { - list($table, $column, $type) = $meta; + [$table, $column, $type] = $meta; - switch ($type) { - case 'bool': - $resultRow[$table][$column] = $row[$index] === null ? null : $this->boolean($row[$index]); - break; - case 'binary': - case 'bytea': - $resultRow[$table][$column] = $row[$index] === null ? null : stream_get_contents($row[$index]); - break; - default: - $resultRow[$table][$column] = $row[$index]; - } + $resultRow[$table][$column] = match ($type) { + 'bool' => $row[$index] === null ? null : $this->boolean($row[$index]), + 'binary', 'bytea' => $row[$index] === null ? null : stream_get_contents($row[$index]), + default => $row[$index], + }; } return $resultRow; } @@ -824,22 +802,13 @@ public function fetchResult() { * @return bool Converted boolean value */ public function boolean($data, $quote = false) { - switch (true) { - case ($data === true || $data === false): - $result = $data; - break; - case ($data === 't' || $data === 'f'): - $result = ($data === 't'); - break; - case ($data === 'true' || $data === 'false'): - $result = ($data === 'true'); - break; - case ($data === 'TRUE' || $data === 'FALSE'): - $result = ($data === 'TRUE'); - break; - default: - $result = (bool)$data; - } + $result = match (true) { + $data === true || $data === false => $data, + $data === 't' || $data === 'f' => $data === 't', + $data === 'true' || $data === 'false' => $data === 'true', + $data === 'TRUE' || $data === 'FALSE' => $data === 'TRUE', + default => (bool)$data, + }; if ($quote) { return ($result) ? 'TRUE' : 'FALSE'; @@ -867,7 +836,7 @@ public function getEncoding() { if ($result === false) { return false; } - return (isset($result['client_encoding'])) ? $result['client_encoding'] : false; + return $result['client_encoding'] ?? false; } /** @@ -908,7 +877,7 @@ public function buildColumn($column) { if (strpos($out, 'DEFAULT DEFAULT')) { if (isset($column['null']) && $column['null']) { $out = str_replace('DEFAULT DEFAULT', 'DEFAULT NULL', $out); - } elseif (in_array($column['type'], array('integer', 'float'))) { + } elseif (in_array($column['type'], ['integer', 'float'])) { $out = str_replace('DEFAULT DEFAULT', 'DEFAULT 0', $out); } elseif ($column['type'] === 'boolean') { $out = str_replace('DEFAULT DEFAULT', 'DEFAULT FALSE', $out); @@ -925,9 +894,9 @@ public function buildColumn($column) { * @return string */ public function buildIndex($indexes, $table = null) { - $join = array(); + $join = []; if (!is_array($indexes)) { - return array(); + return []; } foreach ($indexes as $name => $value) { if ($name === 'PRIMARY') { @@ -938,7 +907,7 @@ public function buildIndex($indexes, $table = null) { $out .= 'UNIQUE '; } if (is_array($value['column'])) { - $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column'])); + $value['column'] = implode(', ', array_map([&$this, 'name'], $value['column'])); } else { $value['column'] = $this->name($value['column']); } @@ -979,9 +948,9 @@ public function renderStatement($type, $data) { break; } } - $join = array('columns' => ",\n\t", 'indexes' => "\n"); + $join = ['columns' => ",\n\t", 'indexes' => "\n"]; - foreach (array('columns', 'indexes') as $var) { + foreach (['columns', 'indexes'] as $var) { if (is_array(${$var})) { ${$var} = implode($join[$var], array_filter(${$var})); } diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 487868be4a..f9b5e71d5e 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -54,11 +54,11 @@ class Sqlite extends DboSource { * * @var array */ - protected $_baseConfig = array( + protected $_baseConfig = [ 'persistent' => false, 'database' => null, - 'flags' => array() - ); + 'flags' => [] + ]; /** * SQLite3 column definition @@ -66,41 +66,41 @@ class Sqlite extends DboSource { * @var array * @link https://www.sqlite.org/datatype3.html Datatypes In SQLite Version 3 */ - public $columns = array( - 'primary_key' => array('name' => 'integer primary key autoincrement'), - 'string' => array('name' => 'varchar', 'limit' => '255'), - 'text' => array('name' => 'text'), - 'integer' => array('name' => 'integer', 'limit' => null, 'formatter' => 'intval'), - 'smallinteger' => array('name' => 'smallint', 'limit' => null, 'formatter' => 'intval'), - 'tinyinteger' => array('name' => 'tinyint', 'limit' => null, 'formatter' => 'intval'), - 'biginteger' => array('name' => 'bigint', 'limit' => 20), - 'float' => array('name' => 'float', 'formatter' => 'floatval'), - 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'), - 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'time' => array('name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'), - 'date' => array('name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'), - 'binary' => array('name' => 'blob'), - 'boolean' => array('name' => 'boolean') - ); + public $columns = [ + 'primary_key' => ['name' => 'integer primary key autoincrement'], + 'string' => ['name' => 'varchar', 'limit' => '255'], + 'text' => ['name' => 'text'], + 'integer' => ['name' => 'integer', 'limit' => null, 'formatter' => 'intval'], + 'smallinteger' => ['name' => 'smallint', 'limit' => null, 'formatter' => 'intval'], + 'tinyinteger' => ['name' => 'tinyint', 'limit' => null, 'formatter' => 'intval'], + 'biginteger' => ['name' => 'bigint', 'limit' => 20], + 'float' => ['name' => 'float', 'formatter' => 'floatval'], + 'decimal' => ['name' => 'decimal', 'formatter' => 'floatval'], + 'datetime' => ['name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'], + 'timestamp' => ['name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'], + 'time' => ['name' => 'time', 'format' => 'H:i:s', 'formatter' => 'date'], + 'date' => ['name' => 'date', 'format' => 'Y-m-d', 'formatter' => 'date'], + 'binary' => ['name' => 'blob'], + 'boolean' => ['name' => 'boolean'] + ]; /** * List of engine specific additional field parameters used on table creating * * @var array */ - public $fieldParameters = array( - 'collate' => array( + public $fieldParameters = [ + 'collate' => [ 'value' => 'COLLATE', 'quote' => false, 'join' => ' ', 'column' => 'Collate', 'position' => 'afterDefault', - 'options' => array( + 'options' => [ 'BINARY', 'NOCASE', 'RTRIM' - ) - ), - ); + ] + ], + ]; /** * Connects to the database using config['database'] as a filename. @@ -110,18 +110,18 @@ class Sqlite extends DboSource { */ public function connect() { $config = $this->config; - $flags = $config['flags'] + array( + $flags = $config['flags'] + [ PDO::ATTR_PERSISTENT => $config['persistent'], PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION - ); + ]; try { $this->_connection = new PDO('sqlite:' . $config['database'], null, null, $flags); $this->connected = true; } catch(PDOException $e) { - throw new MissingConnectionException(array( - 'class' => get_class($this), + throw new MissingConnectionException([ + 'class' => static::class, 'message' => $e->getMessage() - )); + ]); } return $this->connected; } @@ -150,10 +150,10 @@ public function listSources($data = null) { $result = $this->fetchAll("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;", false); if (!$result || empty($result)) { - return array(); + return []; } - $tables = array(); + $tables = []; foreach ($result as $table) { $tables[] = $table[0]['name']; } @@ -173,7 +173,7 @@ public function describe($model) { if ($cache) { return $cache; } - $fields = array(); + $fields = []; $result = $this->_execute( 'PRAGMA table_info(' . $this->value($table, 'string') . ')' ); @@ -181,13 +181,13 @@ public function describe($model) { foreach ($result as $column) { $default = ($column['dflt_value'] === 'NULL') ? null : trim($column['dflt_value'], "'"); - $fields[$column['name']] = array( + $fields[$column['name']] = [ 'type' => $this->column($column['type']), 'null' => !$column['notnull'], 'default' => $default, 'length' => $this->length($column['type']) - ); - if (in_array($fields[$column['name']]['type'], array('timestamp', 'datetime')) && strtoupper($fields[$column['name']]['default']) === 'CURRENT_TIMESTAMP') { + ]; + if (in_array($fields[$column['name']]['type'], ['timestamp', 'datetime']) && strtoupper($fields[$column['name']]['default']) === 'CURRENT_TIMESTAMP') { $fields[$column['name']]['default'] = null; } if ($column['pk'] == 1) { @@ -213,10 +213,10 @@ public function describe($model) { * @param mixed $conditions array of conditions to use. * @return bool */ - public function update(Model $model, $fields = array(), $values = null, $conditions = null) { + public function update(Model $model, $fields = [], $values = null, $conditions = null) { if (empty($values) && !empty($fields)) { foreach ($fields as $field => $value) { - if (strpos($field, $model->alias . '.') !== false) { + if (str_contains($field, $model->alias . '.')) { unset($fields[$field]); $field = str_replace($model->alias . '.', "", $field); $field = str_replace($model->alias . '.', "", $field); @@ -257,11 +257,11 @@ public function column($real) { } $col = strtolower(str_replace(')', '', $real)); - if (strpos($col, '(') !== false) { - list($col) = explode('(', $col); + if (str_contains($col, '(')) { + [$col] = explode('(', $col); } - $standard = array( + $standard = [ 'text', 'integer', 'float', @@ -270,7 +270,7 @@ public function column($real) { 'date', 'datetime', 'time' - ); + ]; if (in_array($col, $standard)) { return $col; } @@ -283,13 +283,13 @@ public function column($real) { if ($col === 'bigint') { return 'biginteger'; } - if (strpos($col, 'char') !== false) { + if (str_contains($col, 'char')) { return 'string'; } - if (in_array($col, array('blob', 'clob'))) { + if (in_array($col, ['blob', 'clob'])) { return 'binary'; } - if (strpos($col, 'numeric') !== false || strpos($col, 'decimal') !== false) { + if (str_contains($col, 'numeric') || str_contains($col, 'decimal')) { return 'decimal'; } return 'text'; @@ -303,7 +303,7 @@ public function column($real) { */ public function resultSet($results) { $this->results = $results; - $this->map = array(); + $this->map = []; $numFields = $results->columnCount(); $index = 0; $j = 0; @@ -313,7 +313,7 @@ public function resultSet($results) { $querystring = $results->queryString; if (stripos($querystring, 'SELECT') === 0 && stripos($querystring, 'FROM') > 0) { $selectpart = substr($querystring, 7); - $selects = array(); + $selects = []; foreach (CakeText::tokenize($selectpart, ',', '(', ')') as $part) { $fromPos = stripos($part, ' FROM '); if ($fromPos !== false) { @@ -322,12 +322,12 @@ public function resultSet($results) { } $selects[] = $part; } - } elseif (strpos($querystring, 'PRAGMA table_info') === 0) { - $selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk'); - } elseif (strpos($querystring, 'PRAGMA index_list') === 0) { - $selects = array('seq', 'name', 'unique'); - } elseif (strpos($querystring, 'PRAGMA index_info') === 0) { - $selects = array('seqno', 'cid', 'name'); + } elseif (str_starts_with($querystring, 'PRAGMA table_info')) { + $selects = ['cid', 'name', 'type', 'notnull', 'dflt_value', 'pk']; + } elseif (str_starts_with($querystring, 'PRAGMA index_list')) { + $selects = ['seq', 'name', 'unique']; + } elseif (str_starts_with($querystring, 'PRAGMA index_info')) { + $selects = ['seqno', 'cid', 'name']; } while ($j < $numFields) { if (!isset($selects[$j])) { @@ -340,7 +340,7 @@ public function resultSet($results) { $columnName = trim(str_replace('"', '', $selects[$j])); } - if (strpos($selects[$j], 'DISTINCT') === 0) { + if (str_starts_with($selects[$j], 'DISTINCT')) { $columnName = str_ireplace('DISTINCT', '', $columnName); } @@ -350,14 +350,14 @@ public function resultSet($results) { if (!empty($metaData['sqlite:decl_type'])) { $metaType = trim($metaData['sqlite:decl_type']); } - } catch (Exception $e) { + } catch (Exception) { } if (strpos($columnName, '.')) { $parts = explode('.', $columnName); - $this->map[$index++] = array(trim($parts[0]), trim($parts[1]), $metaType); + $this->map[$index++] = [trim($parts[0]), trim($parts[1]), $metaType]; } else { - $this->map[$index++] = array(0, $columnName, $metaType); + $this->map[$index++] = [0, $columnName, $metaType]; } $j++; } @@ -370,9 +370,9 @@ public function resultSet($results) { */ public function fetchResult() { if ($row = $this->_result->fetch(PDO::FETCH_NUM)) { - $resultRow = array(); + $resultRow = []; foreach ($this->map as $col => $meta) { - list($table, $column, $type) = $meta; + [$table, $column, $type] = $meta; $resultRow[$table][$column] = $row[$col]; if ($type === 'boolean' && $row[$col] !== null) { $resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]); @@ -411,7 +411,7 @@ public function limit($limit, $offset = null) { */ public function buildColumn($column) { $name = $type = null; - $column += array('null' => true); + $column += ['null' => true]; extract($column); if (empty($name) || empty($type)) { @@ -446,7 +446,7 @@ public function buildColumn($column) { * @return bool */ public function setEncoding($enc) { - if (!in_array($enc, array("UTF-8", "UTF-16", "UTF-16le", "UTF-16be"))) { + if (!in_array($enc, ["UTF-8", "UTF-16", "UTF-16le", "UTF-16be"])) { return false; } return $this->_execute("PRAGMA encoding = \"{$enc}\"") !== false; @@ -469,10 +469,10 @@ public function getEncoding() { * @return string The completed index. */ public function buildIndex($indexes, $table = null) { - $join = array(); + $join = []; $table = str_replace('"', '', $table); - list($dbname, $table) = explode('.', $table); + [$dbname, $table] = explode('.', $table); $dbname = $this->name($dbname); foreach ($indexes as $name => $value) { @@ -486,7 +486,7 @@ public function buildIndex($indexes, $table = null) { $out .= 'UNIQUE '; } if (is_array($value['column'])) { - $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column'])); + $value['column'] = implode(', ', array_map([&$this, 'name'], $value['column'])); } else { $value['column'] = $this->name($value['column']); } @@ -507,20 +507,20 @@ public function buildIndex($indexes, $table = null) { * @return array Fields in table. Keys are column and unique */ public function index($model) { - $index = array(); + $index = []; $table = $this->fullTableName($model, false, false); if ($table) { $indexes = $this->query('PRAGMA index_list(' . $table . ')'); if (is_bool($indexes)) { - return array(); + return []; } foreach ($indexes as $info) { $key = array_pop($info); $keyInfo = $this->query('PRAGMA index_info("' . $key['name'] . '")'); foreach ($keyInfo as $keyCol) { if (!isset($index[$key['name']])) { - $col = array(); + $col = []; if (preg_match('/autoindex/', $key['name'])) { $key['name'] = 'PRIMARY'; } diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index c25934409b..59f114a24b 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -57,7 +57,7 @@ class Sqlserver extends DboSource { * * @var array */ - protected $_fieldMappings = array(); + protected $_fieldMappings = []; /** * Storing the last affected value @@ -71,14 +71,14 @@ class Sqlserver extends DboSource { * * @var array */ - protected $_baseConfig = array( + protected $_baseConfig = [ 'host' => 'localhost\SQLEXPRESS', 'login' => '', 'password' => '', 'database' => 'cake', 'schema' => '', - 'flags' => array() - ); + 'flags' => [] + ]; /** * MS SQL column definition @@ -86,25 +86,25 @@ class Sqlserver extends DboSource { * @var array * @link https://msdn.microsoft.com/en-us/library/ms187752.aspx SQL Server Data Types */ - public $columns = array( - 'primary_key' => array('name' => 'IDENTITY (1, 1) NOT NULL'), - 'string' => array('name' => 'nvarchar', 'limit' => '255'), - 'text' => array('name' => 'nvarchar', 'limit' => 'MAX'), - 'integer' => array('name' => 'int', 'formatter' => 'intval'), - 'smallinteger' => array('name' => 'smallint', 'formatter' => 'intval'), - 'tinyinteger' => array('name' => 'tinyint', 'formatter' => 'intval'), - 'biginteger' => array('name' => 'bigint'), - 'numeric' => array('name' => 'decimal', 'formatter' => 'floatval'), - 'decimal' => array('name' => 'decimal', 'formatter' => 'floatval'), - 'float' => array('name' => 'float', 'formatter' => 'floatval'), - 'real' => array('name' => 'float', 'formatter' => 'floatval'), - 'datetime' => array('name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'timestamp' => array('name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'), - 'time' => array('name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'), - 'date' => array('name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'), - 'binary' => array('name' => 'varbinary'), - 'boolean' => array('name' => 'bit') - ); + public $columns = [ + 'primary_key' => ['name' => 'IDENTITY (1, 1) NOT NULL'], + 'string' => ['name' => 'nvarchar', 'limit' => '255'], + 'text' => ['name' => 'nvarchar', 'limit' => 'MAX'], + 'integer' => ['name' => 'int', 'formatter' => 'intval'], + 'smallinteger' => ['name' => 'smallint', 'formatter' => 'intval'], + 'tinyinteger' => ['name' => 'tinyint', 'formatter' => 'intval'], + 'biginteger' => ['name' => 'bigint'], + 'numeric' => ['name' => 'decimal', 'formatter' => 'floatval'], + 'decimal' => ['name' => 'decimal', 'formatter' => 'floatval'], + 'float' => ['name' => 'float', 'formatter' => 'floatval'], + 'real' => ['name' => 'float', 'formatter' => 'floatval'], + 'datetime' => ['name' => 'datetime', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'], + 'timestamp' => ['name' => 'timestamp', 'format' => 'Y-m-d H:i:s', 'formatter' => 'date'], + 'time' => ['name' => 'datetime', 'format' => 'H:i:s', 'formatter' => 'date'], + 'date' => ['name' => 'datetime', 'format' => 'Y-m-d', 'formatter' => 'date'], + 'binary' => ['name' => 'varbinary'], + 'boolean' => ['name' => 'bit'] + ]; /** * Magic column name used to provide pagination support for SQLServer 2008 @@ -134,9 +134,9 @@ public function connect() { throw new InvalidArgumentException('Config setting "persistent" cannot be set to true, as the Sqlserver PDO driver does not support PDO::ATTR_PERSISTENT'); } - $flags = $config['flags'] + array( + $flags = $config['flags'] + [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION - ); + ]; if (!empty($config['encoding'])) { $flags[PDO::SQLSRV_ATTR_ENCODING] = $config['encoding']; @@ -156,10 +156,10 @@ public function connect() { } } } catch (PDOException $e) { - throw new MissingConnectionException(array( - 'class' => get_class($this), + throw new MissingConnectionException([ + 'class' => static::class, 'message' => $e->getMessage() - )); + ]); } return $this->connected; @@ -189,9 +189,9 @@ public function listSources($data = null) { if (!$result) { $result->closeCursor(); - return array(); + return []; } - $tables = array(); + $tables = []; while ($line = $result->fetch(PDO::FETCH_NUM)) { $tables[] = $line[0]; @@ -218,7 +218,7 @@ public function describe($model) { return $cache; } - $fields = array(); + $fields = []; $schema = is_object($model) ? $model->schemaName : false; $cols = $this->_execute( @@ -240,13 +240,13 @@ public function describe($model) { while ($column = $cols->fetch(PDO::FETCH_OBJ)) { $field = $column->Field; - $fields[$field] = array( + $fields[$field] = [ 'type' => $this->column($column), 'null' => ($column->Null === 'YES' ? true : false), 'default' => $column->Default, 'length' => $this->length($column), 'key' => ($column->Key == '1') ? 'primary' : false - ); + ]; if ($fields[$field]['default'] === 'null') { $fields[$field]['default'] = null; @@ -265,7 +265,7 @@ public function describe($model) { } elseif ($fields[$field]['key'] === false) { unset($fields[$field]['key']); } - if (in_array($fields[$field]['type'], array('date', 'time', 'datetime', 'timestamp'))) { + if (in_array($fields[$field]['type'], ['date', 'time', 'datetime', 'timestamp'])) { $fields[$field]['length'] = null; } if ($fields[$field]['type'] === 'float' && !empty($column->Size)) { @@ -286,30 +286,30 @@ public function describe($model) { * @param bool $quote Whether or not to quote identfiers. * @return array */ - public function fields(Model $model, $alias = null, $fields = array(), $quote = true) { + public function fields(Model $model, $alias = null, $fields = [], $quote = true) { if (empty($alias)) { $alias = $model->alias; } $fields = parent::fields($model, $alias, $fields, false); $count = count($fields); - if ($count >= 1 && strpos($fields[0], 'COUNT(*)') === false) { - $result = array(); + if ($count >= 1 && !str_contains($fields[0], 'COUNT(*)')) { + $result = []; for ($i = 0; $i < $count; $i++) { $prepend = ''; - if (strpos($fields[$i], 'DISTINCT') !== false && strpos($fields[$i], 'COUNT') === false) { + if (str_contains($fields[$i], 'DISTINCT') && !str_contains($fields[$i], 'COUNT')) { $prepend = 'DISTINCT '; $fields[$i] = trim(str_replace('DISTINCT', '', $fields[$i])); } - if (strpos($fields[$i], 'COUNT(DISTINCT') !== false) { + if (str_contains($fields[$i], 'COUNT(DISTINCT')) { $prepend = 'COUNT(DISTINCT '; $fields[$i] = trim(str_replace('COUNT(DISTINCT', '', $this->_quoteFields($fields[$i]))); } if (!preg_match('/\s+AS\s+/i', $fields[$i])) { - if (substr($fields[$i], -1) === '*') { - if (strpos($fields[$i], '.') !== false && $fields[$i] != $alias . '.*') { + if (str_ends_with($fields[$i], '*')) { + if (str_contains($fields[$i], '.') && $fields[$i] != $alias . '.*') { $build = explode('.', $fields[$i]); $AssociatedModel = $model->{$build[0]}; } else { @@ -321,7 +321,7 @@ public function fields(Model $model, $alias = null, $fields = array(), $quote = continue; } - if (strpos($fields[$i], '.') === false) { + if (!str_contains($fields[$i], '.')) { $this->_fieldMappings[$alias . '__' . $fields[$i]] = $alias . '.' . $fields[$i]; $fieldName = $this->name($alias . '.' . $fields[$i]); $fieldAlias = $this->name($alias . '__' . $fields[$i]); @@ -388,7 +388,7 @@ public function create(Model $model, $fields = null, $values = null) { * @param mixed $conditions The conditions to use. * @return array */ - public function update(Model $model, $fields = array(), $values = null, $conditions = null) { + public function update(Model $model, $fields = [], $values = null, $conditions = null) { if (!empty($values)) { $fields = array_combine($fields, $values); } @@ -411,7 +411,7 @@ public function update(Model $model, $fields = array(), $values = null, $conditi public function limit($limit, $offset = null) { if ($limit) { $rt = ''; - if (!strpos(strtolower($limit), 'top') || strpos(strtolower($limit), 'top') === 0) { + if (!strpos(strtolower($limit), 'top') || str_starts_with(strtolower($limit), 'top')) { $rt = ' TOP'; } $rt .= sprintf(' %u', $limit); @@ -441,40 +441,40 @@ public function column($real) { if ($col === 'datetime2') { return 'datetime'; } - if (in_array($col, array('date', 'time', 'datetime', 'timestamp'))) { + if (in_array($col, ['date', 'time', 'datetime', 'timestamp'])) { return $col; } if ($col === 'bit') { return 'boolean'; } - if (strpos($col, 'bigint') !== false) { + if (str_contains($col, 'bigint')) { return 'biginteger'; } - if (strpos($col, 'smallint') !== false) { + if (str_contains($col, 'smallint')) { return 'smallinteger'; } - if (strpos($col, 'tinyint') !== false) { + if (str_contains($col, 'tinyint')) { return 'tinyinteger'; } - if (strpos($col, 'int') !== false) { + if (str_contains($col, 'int')) { return 'integer'; } - if (strpos($col, 'char') !== false && $limit == -1) { + if (str_contains($col, 'char') && $limit == -1) { return 'text'; } - if (strpos($col, 'char') !== false) { + if (str_contains($col, 'char')) { return 'string'; } - if (strpos($col, 'text') !== false) { + if (str_contains($col, 'text')) { return 'text'; } - if (strpos($col, 'binary') !== false || $col === 'image') { + if (str_contains($col, 'binary') || $col === 'image') { return 'binary'; } - if (in_array($col, array('float', 'real'))) { + if (in_array($col, ['float', 'real'])) { return 'float'; } - if (in_array($col, array('decimal', 'numeric'))) { + if (in_array($col, ['decimal', 'numeric'])) { return 'decimal'; } return 'text'; @@ -489,10 +489,10 @@ public function column($real) { */ public function length($length) { if (is_object($length) && isset($length->Length)) { - if ($length->Length == -1 && strpos($length->Type, 'char') !== false) { + if ($length->Length == -1 && str_contains($length->Type, 'char')) { return null; } - if (in_array($length->Type, array('nchar', 'nvarchar'))) { + if (in_array($length->Type, ['nchar', 'nvarchar'])) { return floor($length->Length / 2); } if ($length->Type === 'text') { @@ -510,7 +510,7 @@ public function length($length) { * @return void */ public function resultSet($results) { - $this->map = array(); + $this->map = []; $numFields = $results->columnCount(); $index = 0; @@ -522,12 +522,12 @@ public function resultSet($results) { if (isset($this->_fieldMappings[$name]) && strpos($this->_fieldMappings[$name], '.')) { $map = explode('.', $this->_fieldMappings[$name]); } elseif (isset($this->_fieldMappings[$name])) { - $map = array(0, $this->_fieldMappings[$name]); + $map = [0, $this->_fieldMappings[$name]]; } else { - $map = array(0, $name); + $map = [0, $name]; } } else { - $map = array(0, $name); + $map = [0, $name]; } $map[] = ($column['sqlsrv:decl_type'] === 'bit') ? 'boolean' : $column['native_type']; $this->map[$index++] = $map; @@ -550,7 +550,7 @@ public function renderStatement($type, $data) { $having = !empty($having) ? " $having" : ''; $lock = !empty($lock) ? " $lock" : ''; - if (strpos($limit, 'TOP') !== false && strpos($fields, 'DISTINCT ') === 0) { + if (str_contains($limit, 'TOP') && str_starts_with($fields, 'DISTINCT ')) { $limit = 'DISTINCT ' . trim($limit); $fields = substr($fields, 9); } @@ -578,7 +578,7 @@ public function renderStatement($type, $data) { "; return trim($sql); } - if (strpos($limit, 'FETCH') !== false) { + if (str_contains($limit, 'FETCH')) { return trim("SELECT {$fields} FROM {$table} {$alias}{$lock} {$joins} {$conditions} {$group}{$having} {$order} {$limit}"); } return trim("SELECT {$limit} {$fields} FROM {$table} {$alias}{$lock} {$joins} {$conditions} {$group}{$having} {$order}"); @@ -592,7 +592,7 @@ public function renderStatement($type, $data) { } } - foreach (array('columns', 'indexes') as $var) { + foreach (['columns', 'indexes'] as $var) { if (is_array(${$var})) { ${$var} = "\t" . implode(",\n\t", array_filter(${$var})); } @@ -615,7 +615,7 @@ public function value($data, $column = null, $null = true) { if ($data === null || is_array($data) || is_object($data)) { return parent::value($data, $column, $null); } - if (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) { + if (in_array($data, ['{$__cakeID__$}', '{$__cakeForeignKey__$}'], true)) { return $data; } @@ -623,13 +623,10 @@ public function value($data, $column = null, $null = true) { $column = $this->introspectType($data); } - switch ($column) { - case 'string': - case 'text': - return 'N' . $this->_connection->quote($data, PDO::PARAM_STR); - default: - return parent::value($data, $column, $null); - } + return match ($column) { + 'string', 'text' => 'N' . $this->_connection->quote($data, PDO::PARAM_STR), + default => parent::value($data, $column, $null), + }; } /** @@ -641,9 +638,9 @@ public function value($data, $column = null, $null = true) { * @param int $recursive How many layers to go. * @return array|false Array of resultset rows, or false if no rows matched */ - public function read(Model $model, $queryData = array(), $recursive = null) { + public function read(Model $model, $queryData = [], $recursive = null) { $results = parent::read($model, $queryData, $recursive); - $this->_fieldMappings = array(); + $this->_fieldMappings = []; return $results; } @@ -655,9 +652,9 @@ public function read(Model $model, $queryData = array(), $recursive = null) { */ public function fetchResult() { if ($row = $this->_result->fetch(PDO::FETCH_NUM)) { - $resultRow = array(); + $resultRow = []; foreach ($this->map as $col => $meta) { - list($table, $column, $type) = $meta; + [$table, $column, $type] = $meta; if ($table === 0 && $column === static::ROW_COUNTER) { continue; } @@ -684,7 +681,7 @@ public function insertMulti($table, $fields, $values) { $primaryKey = $this->_getPrimaryKey($table); $hasPrimaryKey = $primaryKey && ( (is_array($fields) && in_array($primaryKey, $fields) - || (is_string($fields) && strpos($fields, $this->startQuote . $primaryKey . $this->endQuote) !== false)) + || (is_string($fields) && str_contains($fields, $this->startQuote . $primaryKey . $this->endQuote))) ); if ($hasPrimaryKey) { @@ -710,13 +707,13 @@ public function buildColumn($column) { $result = parent::buildColumn($column); $result = preg_replace('/(bigint|int|integer)\([0-9]+\)/i', '$1', $result); $result = preg_replace('/(bit)\([0-9]+\)/i', '$1', $result); - if (strpos($result, 'DEFAULT NULL') !== false) { + if (str_contains($result, 'DEFAULT NULL')) { if (isset($column['default']) && $column['default'] === '') { $result = str_replace('DEFAULT NULL', "DEFAULT ''", $result); } else { $result = str_replace('DEFAULT NULL', 'NULL', $result); } - } elseif (array_keys($column) === array('type', 'name')) { + } elseif (array_keys($column) === ['type', 'name']) { $result .= ' NULL'; } elseif (strpos($result, "DEFAULT N'")) { $result = str_replace("DEFAULT N'", "DEFAULT '", $result); @@ -732,7 +729,7 @@ public function buildColumn($column) { * @return string */ public function buildIndex($indexes, $table = null) { - $join = array(); + $join = []; foreach ($indexes as $name => $value) { if ($name === 'PRIMARY') { @@ -741,7 +738,7 @@ public function buildIndex($indexes, $table = null) { $out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE"; if (is_array($value['column'])) { - $value['column'] = implode(', ', array_map(array(&$this, 'name'), $value['column'])); + $value['column'] = implode(', ', array_map([&$this, 'name'], $value['column'])); } else { $value['column'] = $this->name($value['column']); } @@ -793,11 +790,11 @@ public function lastAffected($source = null) { * query returning no rows, such as a CREATE statement, false otherwise * @throws PDOException */ - protected function _execute($sql, $params = array(), $prepareOptions = array()) { + protected function _execute($sql, $params = [], $prepareOptions = []) { $this->_lastAffected = false; $sql = trim($sql); if (strncasecmp($sql, 'SELECT', 6) === 0 || preg_match('/^EXEC(?:UTE)?\s/mi', $sql) > 0) { - $prepareOptions += array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL); + $prepareOptions += [PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL]; return parent::_execute($sql, $params, $prepareOptions); } try { diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index d356492df2..2fe90a84e5 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -42,7 +42,7 @@ class DboSource extends DataSource { * * @var array */ - public $index = array('PRI' => 'primary', 'MUL' => 'index', 'UNI' => 'unique'); + public $index = ['PRI' => 'primary', 'MUL' => 'index', 'UNI' => 'unique']; /** * Database keyword used to assign aliases to identifiers. @@ -60,7 +60,7 @@ class DboSource extends DataSource { * * @var array */ - public static $methodCache = array(); + public static $methodCache = []; /** * Whether or not to cache the results of DboSource::name() and DboSource::fields() into the memory cache. @@ -133,7 +133,7 @@ class DboSource extends DataSource { * * @var array */ - protected $_queriesLog = array(); + protected $_queriesLog = []; /** * Maximum number of items in query log @@ -149,7 +149,7 @@ class DboSource extends DataSource { * * @var array */ - protected $_queryCache = array(); + protected $_queryCache = []; /** * A reference to the physical connection of this DataSource @@ -184,14 +184,14 @@ class DboSource extends DataSource { * * @var array */ - protected $_sqlOps = array('like', 'ilike', 'rlike', 'or', 'not', 'in', 'between', 'regexp', 'similar to'); + protected $_sqlOps = ['like', 'ilike', 'rlike', 'or', 'not', 'in', 'between', 'regexp', 'similar to']; /** * The set of valid SQL boolean operations usable in a WHERE statement * * @var array */ - protected $_sqlBoolOps = array('and', 'or', 'not', 'and not', 'or not', 'xor', '||', '&&'); + protected $_sqlBoolOps = ['and', 'or', 'not', 'and not', 'or not', 'xor', '||', '&&']; /** * Indicates the level of nested transactions @@ -205,19 +205,19 @@ class DboSource extends DataSource { * * @var array */ - protected $_queryDefaults = array( - 'conditions' => array(), + protected $_queryDefaults = [ + 'conditions' => [], 'fields' => null, 'table' => null, 'alias' => null, 'order' => null, 'limit' => null, - 'joins' => array(), + 'joins' => [], 'group' => null, 'offset' => null, 'having' => null, 'lock' => null, - ); + ]; /** * Separator string for virtualField composition @@ -231,14 +231,14 @@ class DboSource extends DataSource { * * @var array */ - public $tableParameters = array(); + public $tableParameters = []; /** * List of engine specific additional field parameters used on table creating * * @var array */ - public $fieldParameters = array(); + public $fieldParameters = []; /** * Indicates whether there was a change on the cached results on the methods of this class @@ -253,7 +253,7 @@ class DboSource extends DataSource { * * @var array */ - public $map = array(); + public $map = []; /** * Constructor @@ -269,11 +269,11 @@ public function __construct($config = null, $autoConnect = true) { parent::__construct($config); $this->fullDebug = Configure::read('debug') > 1; if (!$this->enabled()) { - throw new MissingConnectionException(array( - 'class' => get_class($this), + throw new MissingConnectionException([ + 'class' => static::class, 'message' => __d('cake_dev', 'Selected driver is not enabled'), 'enabled' => false - )); + ]); } if ($autoConnect) { $this->connect(); @@ -296,7 +296,7 @@ public function connect() { * @param array $config An array defining the new configuration settings * @return bool True on success, false on failure */ - public function reconnect($config = array()) { + public function reconnect($config = []) { $this->disconnect(); $this->setConfig($config); $this->_sources = null; @@ -347,7 +347,7 @@ public function getVersion() { public function value($data, $column = null, $null = true) { if (is_array($data) && !empty($data)) { return array_map( - array(&$this, 'value'), + [&$this, 'value'], $data, array_fill(0, count($data), $column) ); } elseif (is_object($data) && isset($data->type, $data->value)) { @@ -356,7 +356,7 @@ public function value($data, $column = null, $null = true) { } elseif ($data->type === 'expression') { return $data->value; } - } elseif (in_array($data, array('{$__cakeID__$}', '{$__cakeForeignKey__$}'), true)) { + } elseif (in_array($data, ['{$__cakeID__$}', '{$__cakeForeignKey__$}'], true)) { return $data; } @@ -369,7 +369,7 @@ public function value($data, $column = null, $null = true) { } $isStringEnum = false; - if (strpos($column, "enum") === 0) { + if (str_starts_with($column, "enum")) { $firstValue = null; if (preg_match("/(enum\()(.*)(\))/i", $column, $acceptingValues)) { $values = explode(",", $acceptingValues[2]); @@ -397,9 +397,9 @@ public function value($data, $column = null, $null = true) { } if (((is_int($data) || $data === '0') || ( is_numeric($data) && - strpos($data, ',') === false && + !str_contains($data, ',') && $data[0] != '0' && - strpos($data, 'e') === false) + !str_contains($data, 'e')) ) && !$isStringEnum ) { return $data; @@ -443,9 +443,9 @@ public function expression($expression) { * @param array $params Additional options for the query. * @return mixed Resource or object representing the result set, or false on failure */ - public function rawQuery($sql, $params = array()) { + public function rawQuery($sql, $params = []) { $this->took = $this->numRows = false; - return $this->execute($sql, array(), $params); + return $this->execute($sql, [], $params); } /** @@ -462,8 +462,8 @@ public function rawQuery($sql, $params = array()) { * @param array $params values to be bound to the query. * @return mixed Resource or object representing the result set, or false on failure */ - public function execute($sql, $options = array(), $params = array()) { - $options += array('log' => $this->fullDebug); + public function execute($sql, $options = [], $params = []) { + $options += ['log' => $this->fullDebug]; $t = microtime(true); $this->_result = $this->_execute($sql, $params); @@ -487,12 +487,12 @@ public function execute($sql, $options = array(), $params = array()) { * query returning no rows, such as a CREATE statement, false otherwise * @throws PDOException */ - protected function _execute($sql, $params = array(), $prepareOptions = array()) { + protected function _execute($sql, $params = [], $prepareOptions = []) { $sql = trim($sql); if (preg_match('/^(?:CREATE|ALTER|DROP)\s+(?:UNIQUE\s+)?(?:TABLE|INDEX)/i', $sql)) { $statements = array_filter(explode(';', $sql)); if (count($statements) > 1) { - $result = array_map(array($this, '_execute'), $statements); + $result = array_map([$this, '_execute'], $statements); return array_search(false, $result) === false; } } @@ -587,7 +587,7 @@ public function query() { $findType = lcfirst($matches[1]); $field = Inflector::underscore($matches[2]); - $or = (strpos($field, '_or_') !== false); + $or = (str_contains($field, '_or_')); if ($or) { $field = explode('_or_', $field); } else { @@ -608,14 +608,14 @@ public function query() { } $c = 0; - $conditions = array(); + $conditions = []; foreach ($field as $f) { $conditions[$args[2]->alias . '.' . $f] = $params[$c++]; } if ($or) { - $conditions = array('OR' => $conditions); + $conditions = ['OR' => $conditions]; } if ($findType !== 'first' && $findType !== '') { @@ -647,7 +647,7 @@ public function query() { } else { $cache = true; } - return $this->fetchAll($args[0], $args[1], array('cache' => $cache)); + return $this->fetchAll($args[0], $args[1], ['cache' => $cache]); } } @@ -701,22 +701,22 @@ public function fetchRow($sql = null) { * @param array $options additional options for the query. * @return bool|array Array of resultset rows, or false if no rows matched */ - public function fetchAll($sql, $params = array(), $options = array()) { + public function fetchAll($sql, $params = [], $options = []) { if (is_string($options)) { - $options = array('modelName' => $options); + $options = ['modelName' => $options]; } if (is_bool($params)) { $options['cache'] = $params; - $params = array(); + $params = []; } - $options += array('cache' => true); + $options += ['cache' => true]; $cache = $options['cache']; if ($cache && ($cached = $this->getQueryCache($sql, $params)) !== false) { return $cached; } - $result = $this->execute($sql, array(), $params); + $result = $this->execute($sql, [], $params); if ($result) { - $out = array(); + $out = []; if ($this->hasResult()) { $first = $this->fetchRow(); @@ -761,11 +761,11 @@ public function fetchResult() { public function fetchVirtualField(&$result) { if (isset($result[0]) && is_array($result[0])) { foreach ($result[0] as $field => $value) { - if (strpos($field, $this->virtualFieldSeparator) === false) { + if (!str_contains($field, $this->virtualFieldSeparator)) { continue; } - list($alias, $virtual) = explode($this->virtualFieldSeparator, $field); + [$alias, $virtual] = explode($this->virtualFieldSeparator, $field); if (!ClassRegistry::isKeySet($alias)) { return; @@ -807,7 +807,7 @@ public function field($name, $sql) { */ public function flushMethodCache() { $this->_methodCacheChange = true; - static::$methodCache = array(); + static::$methodCache = []; } /** @@ -830,7 +830,7 @@ public function cacheMethod($method, $key, $value = null) { static::$methodCache = (array)Cache::read('method_cache', '_cake_core_'); } if ($value === null) { - return (isset(static::$methodCache[$method][$key])) ? static::$methodCache[$method][$key] : null; + return static::$methodCache[$method][$key] ?? null; } if (!$this->cacheMethodFilter($method, $key, $value)) { return $value; @@ -929,7 +929,7 @@ public function name($data) { } $data = trim($data); if (preg_match('/^[\w-]+(?:\.[^ \*]*)*$/', $data)) { // string, string.string - if (strpos($data, '.') === false) { // string + if (!str_contains($data, '.')) { // string return $this->cacheMethod(__FUNCTION__, $cacheKey, $this->startQuote . $data . $this->endQuote); } $items = explode('.', $data); @@ -972,7 +972,7 @@ public function isConnected() { } else { try { $connected = $this->_connection->query('SELECT 1'); - } catch (Exception $e) { + } catch (Exception) { $connected = false; } } @@ -1003,9 +1003,9 @@ public function getLog($sorted = false, $clear = true) { $log = $this->_queriesLog; } if ($clear) { - $this->_queriesLog = array(); + $this->_queriesLog = []; } - return array('log' => $log, 'count' => $this->_queriesCnt, 'time' => $this->_queriesTime); + return ['log' => $log, 'count' => $this->_queriesCnt, 'time' => $this->_queriesTime]; } /** @@ -1023,8 +1023,8 @@ public function showLog($sorted = false) { if (PHP_SAPI !== 'cli') { $controller = null; $View = new View($controller, false); - $View->set('sqlLogs', array($this->configKeyName => $log)); - echo $View->element('sql_dump', array('_forced_from_dbo_' => true)); + $View->set('sqlLogs', [$this->configKeyName => $log]); + echo $View->element('sql_dump', ['_forced_from_dbo_' => true]); } else { foreach ($log['log'] as $k => $i) { print (($k + 1) . ". {$i['query']}\n"); @@ -1039,16 +1039,16 @@ public function showLog($sorted = false) { * @param array $params Values binded to the query (prepared statements) * @return void */ - public function logQuery($sql, $params = array()) { + public function logQuery($sql, $params = []) { $this->_queriesCnt++; $this->_queriesTime += $this->took; - $this->_queriesLog[] = array( + $this->_queriesLog[] = [ 'query' => $sql, 'params' => $params, 'affected' => $this->affected, 'numRows' => $this->numRows, 'took' => $this->took - ); + ]; if (count($this->_queriesLog) > $this->_queriesLogMax) { array_shift($this->_queriesLog); } @@ -1066,7 +1066,7 @@ public function fullTableName($model, $quote = true, $schema = true) { if (is_object($model)) { $schemaName = $model->schemaName; $table = $model->tablePrefix . $model->table; - } elseif (!empty($this->config['prefix']) && strpos($model, $this->config['prefix']) !== 0) { + } elseif (!empty($this->config['prefix']) && !str_starts_with($model, $this->config['prefix'])) { $table = $this->config['prefix'] . strval($model); } else { $table = strval($model); @@ -1078,7 +1078,7 @@ public function fullTableName($model, $quote = true, $schema = true) { if ($quote) { if ($schema && !empty($schemaName)) { - if (strstr($table, '.') === false) { + if (!str_contains($table, '.')) { return $this->name($schemaName) . '.' . $this->name($table); } } @@ -1086,7 +1086,7 @@ public function fullTableName($model, $quote = true, $schema = true) { } if ($schema && !empty($schemaName)) { - if (strstr($table, '.') === false) { + if (!str_contains($table, '.')) { return $schemaName . '.' . $table; } } @@ -1118,22 +1118,22 @@ public function create(Model $Model, $fields = null, $values = null) { for ($i = 0; $i < $count; $i++) { $schema = $Model->schema(); - $valueInsert[] = $this->value($values[$i], $Model->getColumnType($fields[$i]), isset($schema[$fields[$i]]['null']) ? $schema[$fields[$i]]['null'] : true); + $valueInsert[] = $this->value($values[$i], $Model->getColumnType($fields[$i]), $schema[$fields[$i]]['null'] ?? true); $fieldInsert[] = $this->name($fields[$i]); if ($fields[$i] === $Model->primaryKey) { $id = $values[$i]; } } - $query = array( + $query = [ 'table' => $this->fullTableName($Model), 'fields' => implode(', ', $fieldInsert), 'values' => implode(', ', $valueInsert) - ); + ]; if ($this->execute($this->renderStatement('create', $query))) { if (empty($id)) { - $id = $this->lastInsertId($this->fullTableName($Model, false, false), $Model->primaryKey); + $id = $this->lastInsertId($this->fullTableName($Model, false, false)); } $Model->setInsertID($id); $Model->id = $id; @@ -1154,10 +1154,10 @@ public function create(Model $Model, $fields = null, $values = null) { * @param int $recursive Number of levels of association * @return mixed boolean false on error/failure. An array of results on success. */ - public function read(Model $Model, $queryData = array(), $recursive = null) { + public function read(Model $Model, $queryData = [], $recursive = null) { $queryData = $this->_scrubQueryData($queryData); - $array = array('callbacks' => $queryData['callbacks']); + $array = ['callbacks' => $queryData['callbacks']]; if ($recursive === null && isset($queryData['recursive'])) { $recursive = $queryData['recursive']; @@ -1178,7 +1178,7 @@ public function read(Model $Model, $queryData = array(), $recursive = null) { if ($Model->recursive === -1) { // Primary model data only, no joins. - $associations = array(); + $associations = []; } else { $associations = $Model->associations(); @@ -1190,10 +1190,10 @@ public function read(Model $Model, $queryData = array(), $recursive = null) { } $originalJoins = $queryData['joins']; - $queryData['joins'] = array(); + $queryData['joins'] = []; // Generate hasOne and belongsTo associations inside $queryData - $linkedModels = array(); + $linkedModels = []; foreach ($associations as $type) { if ($type !== 'hasOne' && $type !== 'belongsTo') { continue; @@ -1233,11 +1233,11 @@ public function read(Model $Model, $queryData = array(), $recursive = null) { return false; } - $filtered = array(); + $filtered = []; // Deep associations if ($Model->recursive > -1) { - $joined = array(); + $joined = []; if (isset($queryData['joins'][0]['alias'])) { $joined[$Model->alias] = (array)Hash::extract($queryData['joins'], '{n}.alias'); } @@ -1253,7 +1253,7 @@ public function read(Model $Model, $queryData = array(), $recursive = null) { } if (isset($db) && method_exists($db, 'queryAssociation')) { - $stack = array($assoc); + $stack = [$assoc]; $stack['_joined'] = $joined; $db->queryAssociation($Model, $LinkModel, $type, $assoc, $assocData, $array, true, $resultSet, $Model->recursive - 1, $stack); @@ -1288,18 +1288,18 @@ public function read(Model $Model, $queryData = array(), $recursive = null) { * @param array $filtered List of classes already filtered, to be skipped. * @return array Array of results that have been filtered through $Model->afterFind. */ - protected function _filterResults(&$resultSet, Model $Model, $filtered = array()) { + protected function _filterResults(&$resultSet, Model $Model, $filtered = []) { if (!is_array($resultSet)) { - return array(); + return []; } $current = reset($resultSet); if (!is_array($current)) { - return array(); + return []; } - $keys = array_diff(array_keys($current), $filtered, array($Model->alias)); - $filtering = array(); + $keys = array_diff(array_keys($current), $filtered, [$Model->alias]); + $filtering = []; foreach ($keys as $className) { if (!isset($Model->{$className}) || !is_object($Model->{$className})) { @@ -1310,7 +1310,7 @@ protected function _filterResults(&$resultSet, Model $Model, $filtered = array() $filtering[] = $className; foreach ($resultSet as $key => &$result) { - $data = $LinkedModel->afterFind(array(array($className => $result[$className])), false); + $data = $LinkedModel->afterFind([[$className => $result[$className]]], false); if (isset($data[0][$className])) { $result[$className] = $data[0][$className]; } else { @@ -1333,8 +1333,8 @@ protected function _filterResults(&$resultSet, Model $Model, $filtered = array() * @param array $toBeFiltered List of classes to be filtered. * @return array Array of results that have been filtered through $Model->afterFind. */ - protected function _filterResultsInclusive(&$resultSet, Model $Model, $toBeFiltered = array()) { - $exclude = array(); + protected function _filterResultsInclusive(&$resultSet, Model $Model, $toBeFiltered = []) { + $exclude = []; if (is_array($resultSet)) { $current = reset($resultSet); @@ -1382,20 +1382,20 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa } if (!is_array($resultSet)) { - throw new CakeException(__d('cake_dev', 'Error in Model %s', get_class($Model))); + throw new CakeException(__d('cake_dev', 'Error in Model %s', $Model::class)); } if ($type === 'hasMany' && empty($assocData['limit']) && !empty($assocData['foreignKey'])) { // 'hasMany' associations with no limit set. - $assocIds = array(); + $assocIds = []; foreach ($resultSet as $result) { $assocIds[] = $this->insertQueryData('{$__cakeID__$}', $result, $association, $Model, $stack); } $assocIds = array_filter($assocIds); // Fetch - $assocResultSet = array(); + $assocResultSet = []; if (!empty($assocIds)) { $assocResultSet = $this->_fetchHasMany($Model, $queryTemplate, $assocIds); } @@ -1417,7 +1417,7 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa // Filter if ($queryData['callbacks'] === true || $queryData['callbacks'] === 'after') { - $this->_filterResultsInclusive($assocResultSet, $Model, array($association)); + $this->_filterResultsInclusive($assocResultSet, $Model, [$association]); } // Merge @@ -1426,27 +1426,27 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa } elseif ($type === 'hasAndBelongsToMany') { // 'hasAndBelongsToMany' associations. - $assocIds = array(); + $assocIds = []; foreach ($resultSet as $result) { $assocIds[] = $this->insertQueryData('{$__cakeID__$}', $result, $association, $Model, $stack); } $assocIds = array_filter($assocIds); // Fetch - $assocResultSet = array(); + $assocResultSet = []; if (!empty($assocIds)) { $assocResultSet = $this->_fetchHasAndBelongsToMany($Model, $queryTemplate, $assocIds, $association); } $habtmAssocData = $Model->hasAndBelongsToMany[$association]; $foreignKey = $habtmAssocData['foreignKey']; - $joinKeys = array($foreignKey, $habtmAssocData['associationForeignKey']); - list($with, $habtmFields) = $Model->joinModel($habtmAssocData['with'], $joinKeys); + $joinKeys = [$foreignKey, $habtmAssocData['associationForeignKey']]; + [$with, $habtmFields] = $Model->joinModel($habtmAssocData['with'], $joinKeys); $habtmFieldsCount = count($habtmFields); // Filter if ($queryData['callbacks'] === true || $queryData['callbacks'] === 'after') { - $this->_filterResultsInclusive($assocResultSet, $Model, array($association, $with)); + $this->_filterResultsInclusive($assocResultSet, $Model, [$association, $with]); } } @@ -1456,7 +1456,7 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa foreach ($resultSet as &$row) { if ($type === 'hasOne' || $type === 'belongsTo' || $type === 'hasMany') { - $assocResultSet = array(); + $assocResultSet = []; $prefetched = false; if (($type === 'hasOne' || $type === 'belongsTo') && @@ -1465,7 +1465,7 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa ) { $joinedData = Hash::filter($row[$LinkModel->alias]); if (!empty($joinedData)) { - $assocResultSet[0] = array($LinkModel->alias => $row[$LinkModel->alias]); + $assocResultSet[0] = [$LinkModel->alias => $row[$LinkModel->alias]]; } $prefetched = true; } else { @@ -1498,7 +1498,7 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa } if ($type === 'hasAndBelongsToMany') { - $merge = array(); + $merge = []; foreach ($assocResultSet as $data) { if (isset($data[$with]) && $data[$with][$foreignKey] === $row[$modelAlias][$primaryKey]) { if ($habtmFieldsCount <= 2) { @@ -1516,7 +1516,7 @@ public function queryAssociation(Model $Model, Model $LinkModel, $type, $associa } else { if (!$prefetched && $LinkModel->useConsistentAfterFind) { if ($queryData['callbacks'] === true || $queryData['callbacks'] === 'after') { - $this->_filterResultsInclusive($assocResultSet, $Model, array($association)); + $this->_filterResultsInclusive($assocResultSet, $Model, [$association]); } } $this->_mergeAssociation($row, $assocResultSet, $association, $type, $selfJoin); @@ -1607,12 +1607,12 @@ protected function _mergeHasMany(&$resultSet, $assocResultSet, $association, Mod // Make one pass through children and collect by parent key // Make second pass through parents and associate children - $mergedByFK = array(); + $mergedByFK = []; if (is_array($assocResultSet)) { foreach ($assocResultSet as $data) { $fk = $data[$association][$foreignKey]; if (! array_key_exists($fk, $mergedByFK)) { - $mergedByFK[$fk] = array(); + $mergedByFK[$fk] = []; } if (count($data) > 1) { $data = array_merge($data[$association], $data); @@ -1634,12 +1634,12 @@ protected function _mergeHasMany(&$resultSet, $assocResultSet, $association, Mod if (!isset($result[$modelAlias])) { continue; } - $merged = array(); + $merged = []; $pk = $result[$modelAlias][$primaryKey]; if (isset($mergedByFK[$pk])) { $merged = $mergedByFK[$pk]; } - $result = Hash::mergeDiff($result, array($association => $merged)); + $result = Hash::mergeDiff($result, [$association => $merged]); } } @@ -1672,13 +1672,13 @@ protected function _mergeAssociation(&$data, &$merge, $association, $type, $self } } if (!isset($dataAssociation)) { - $dataAssociation = array(); + $dataAssociation = []; if ($merge[0][$association]) { $dataAssociation = $merge[0][$association]; } } else { if (is_array($merge[0][$association])) { - $mergeAssocTmp = array(); + $mergeAssocTmp = []; foreach ($dataAssociation as $k => $v) { if (!is_array($v)) { $dataAssocTmp[$k] = $v; @@ -1700,18 +1700,18 @@ protected function _mergeAssociation(&$data, &$merge, $association, $type, $self $dataAssociation = array_merge($merge[0][$association], $diff); } } elseif ($selfJoin && array_key_exists($association, $merge[0])) { - $dataAssociation = array_merge($dataAssociation, array($association => array())); + $dataAssociation = array_merge($dataAssociation, [$association => []]); } } } } else { if (isset($merge[0][$association]) && $merge[0][$association] === false) { if (!isset($dataAssociation)) { - $dataAssociation = array(); + $dataAssociation = []; } } else { foreach ($merge as $row) { - $insert = array(); + $insert = []; if (count($row) === 1) { $insert = $row[$association]; } elseif (isset($row[$association])) { @@ -1746,7 +1746,7 @@ public function prepareFields(Model $Model, $queryData) { $passedFields = $queryData['fields']; if (count($passedFields) > 1 || - (strpos($passedFields[0], $assocFields[0]) === false && !preg_match('/^[a-z]+\(/i', $passedFields[0])) + (!str_contains($passedFields[0], $assocFields[0]) && !preg_match('/^[a-z]+\(/i', $passedFields[0])) ) { $queryData['fields'] = array_merge($passedFields, $assocFields); } @@ -1769,7 +1769,7 @@ public function buildAssociationQuery(Model $Model, $queryData) { $queryData = $this->_scrubQueryData($queryData); return $this->buildStatement( - array( + [ 'fields' => $this->prepareFields($Model, $queryData), 'table' => $this->fullTableName($Model), 'alias' => $Model->alias, @@ -1781,7 +1781,7 @@ public function buildAssociationQuery(Model $Model, $queryData) { 'group' => $queryData['group'], 'having' => $queryData['having'], 'lock' => $queryData['lock'], - ), + ], $Model ); } @@ -1808,7 +1808,7 @@ public function generateAssociationQuery(Model $Model, $LinkModel, $type, $assoc if ($LinkModel === null) { return $this->buildStatement( - array( + [ 'fields' => array_unique($queryData['fields']), 'table' => $this->fullTableName($Model), 'alias' => $Model->alias, @@ -1818,7 +1818,7 @@ public function generateAssociationQuery(Model $Model, $LinkModel, $type, $assoc 'conditions' => $queryData['conditions'], 'order' => $queryData['order'], 'group' => $queryData['group'] - ), + ], $Model ); } @@ -1846,28 +1846,28 @@ public function generateAssociationQuery(Model $Model, $LinkModel, $type, $assoc if ($Model->name !== $LinkModel->name) { $modelAlias = $Model->alias; foreach ($conditions as $key => $condition) { - if (is_numeric($key) && strpos($condition, $modelAlias . '.') !== false) { + if (is_numeric($key) && str_contains($condition, $modelAlias . '.')) { unset($conditions[$key]); } } } - $query = array_merge($assocData, array( + $query = array_merge($assocData, [ 'conditions' => $conditions, 'table' => $this->fullTableName($LinkModel), 'fields' => $this->fields($LinkModel, $association, $assocData['fields']), 'alias' => $association, 'group' => null - )); + ]); } else { - $join = array( + $join = [ 'table' => $LinkModel, 'alias' => $association, - 'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT', + 'type' => $assocData['type'] ?? 'LEFT', 'conditions' => trim($this->conditions($conditions, true, false, $Model)) - ); + ]; - $fields = array(); + $fields = []; if ($assocData['fields'] !== false) { $fields = $this->fields($LinkModel, $association, $assocData['fields']); } @@ -1887,10 +1887,10 @@ public function generateAssociationQuery(Model $Model, $LinkModel, $type, $assoc case 'hasMany': $assocData['fields'] = $this->fields($LinkModel, $association, $assocData['fields']); if (!empty($assocData['foreignKey'])) { - $assocData['fields'] = array_merge($assocData['fields'], $this->fields($LinkModel, $association, array("{$association}.{$assocData['foreignKey']}"))); + $assocData['fields'] = array_merge($assocData['fields'], $this->fields($LinkModel, $association, ["{$association}.{$assocData['foreignKey']}"])); } - $query = array( + $query = [ 'conditions' => $this->_mergeConditions($this->getConstraint('hasMany', $Model, $LinkModel, $association, $assocData), $assocData['conditions']), 'fields' => array_unique($assocData['fields']), 'table' => $this->fullTableName($LinkModel), @@ -1899,15 +1899,15 @@ public function generateAssociationQuery(Model $Model, $LinkModel, $type, $assoc 'limit' => $assocData['limit'], 'offset' => $assocData['offset'], 'group' => null - ); + ]; break; case 'hasAndBelongsToMany': - $joinFields = array(); + $joinFields = []; $joinAssoc = null; if (isset($assocData['with']) && !empty($assocData['with'])) { - $joinKeys = array($assocData['foreignKey'], $assocData['associationForeignKey']); - list($with, $joinFields) = $Model->joinModel($assocData['with'], $joinKeys); + $joinKeys = [$assocData['foreignKey'], $assocData['associationForeignKey']]; + [$with, $joinFields] = $Model->joinModel($assocData['with'], $joinKeys); $joinTbl = $Model->{$with}; $joinAlias = $joinTbl; @@ -1916,14 +1916,14 @@ public function generateAssociationQuery(Model $Model, $LinkModel, $type, $assoc $joinAssoc = $joinAlias = $joinTbl->alias; $joinFields = $this->fields($joinTbl, $joinAlias, $joinFields); } else { - $joinFields = array(); + $joinFields = []; } } else { $joinTbl = $assocData['joinTable']; $joinAlias = $this->fullTableName($assocData['joinTable']); } - $query = array( + $query = [ 'conditions' => $assocData['conditions'], 'limit' => $assocData['limit'], 'offset' => $assocData['offset'], @@ -1932,12 +1932,12 @@ public function generateAssociationQuery(Model $Model, $LinkModel, $type, $assoc 'fields' => array_merge($this->fields($LinkModel, $association, $assocData['fields']), $joinFields), 'order' => $assocData['order'], 'group' => null, - 'joins' => array(array( + 'joins' => [[ 'table' => $joinTbl, 'alias' => $joinAssoc, 'conditions' => $this->getConstraint('hasAndBelongsToMany', $Model, $LinkModel, $joinAlias, $assocData, $association) - )) - ); + ]] + ]; break; } @@ -1960,47 +1960,47 @@ public function generateAssociationQuery(Model $Model, $LinkModel, $type, $assoc * @return array Conditions array defining the constraint between $Model and $LinkModel. */ public function getConstraint($type, Model $Model, Model $LinkModel, $association, $assocData, $association2 = null) { - $assocData += array('external' => false); + $assocData += ['external' => false]; if (empty($assocData['foreignKey'])) { - return array(); + return []; } switch ($type) { case 'hasOne': if ($assocData['external']) { - return array( + return [ "{$association}.{$assocData['foreignKey']}" => '{$__cakeID__$}' - ); + ]; } else { - return array( + return [ "{$association}.{$assocData['foreignKey']}" => $this->identifier("{$Model->alias}.{$Model->primaryKey}") - ); + ]; } case 'belongsTo': if ($assocData['external']) { - return array( + return [ "{$association}.{$LinkModel->primaryKey}" => '{$__cakeForeignKey__$}' - ); + ]; } else { - return array( + return [ "{$Model->alias}.{$assocData['foreignKey']}" => $this->identifier("{$association}.{$LinkModel->primaryKey}") - ); + ]; } case 'hasMany': - return array("{$association}.{$assocData['foreignKey']}" => array('{$__cakeID__$}')); + return ["{$association}.{$assocData['foreignKey']}" => ['{$__cakeID__$}']]; case 'hasAndBelongsToMany': - return array( - array( + return [ + [ "{$association}.{$assocData['foreignKey']}" => '{$__cakeID__$}' - ), - array( + ], + [ "{$association}.{$assocData['associationForeignKey']}" => $this->identifier("{$association2}.{$LinkModel->primaryKey}") - ) - ); + ] + ]; } - return array(); + return []; } /** @@ -2012,12 +2012,12 @@ public function getConstraint($type, Model $Model, Model $LinkModel, $associatio * @see DboSource::buildStatement() */ public function buildJoinStatement($join) { - $data = array_merge(array( + $data = array_merge([ 'type' => null, 'alias' => null, 'table' => 'join_table', 'conditions' => '', - ), $join); + ], $join); if (!empty($data['alias'])) { $data['alias'] = $this->alias . $this->name($data['alias']); @@ -2025,7 +2025,7 @@ public function buildJoinStatement($join) { if (!empty($data['conditions'])) { $data['conditions'] = trim($this->conditions($data['conditions'], true, false)); } - if (!empty($data['table']) && (!is_string($data['table']) || strpos($data['table'], '(') !== 0)) { + if (!empty($data['table']) && (!is_string($data['table']) || !str_starts_with($data['table'], '('))) { $data['table'] = $this->fullTableName($data['table']); } return $this->renderJoinStatement($data); @@ -2051,7 +2051,7 @@ public function buildStatement($query, Model $Model) { } } - return $this->renderStatement('select', array( + return $this->renderStatement('select', [ 'conditions' => $this->conditions($query['conditions'], true, true, $Model), 'fields' => implode(', ', $query['fields']), 'table' => $query['table'], @@ -2062,7 +2062,7 @@ public function buildStatement($query, Model $Model) { 'group' => $this->group($query['group'], $Model), 'having' => $this->having($query['having'], true, $Model), 'lock' => $this->getLockingHint($query['lock']), - )); + ]); } /** @@ -2108,7 +2108,7 @@ public function renderStatement($type, $data) { } return trim("DELETE {$alias} FROM {$table} {$aliases}{$conditions}"); case 'schema': - foreach (array('columns', 'indexes', 'tableParameters') as $var) { + foreach (['columns', 'indexes', 'tableParameters'] as $var) { if (is_array(${$var})) { ${$var} = "\t" . implode(",\n\t", array_filter(${$var})); } else { @@ -2141,7 +2141,7 @@ protected function _mergeConditions($query, $assoc) { } if (!empty($query)) { - $query = array($query); + $query = [$query]; if (is_array($assoc)) { $query = array_merge($query, $assoc); } else { @@ -2163,7 +2163,7 @@ protected function _mergeConditions($query, $assoc) { * @param mixed $conditions The conditions for the update. When non-empty $values will not be quoted. * @return bool Success */ - public function update(Model $Model, $fields = array(), $values = null, $conditions = null) { + public function update(Model $Model, $fields = [], $values = null, $conditions = null) { if (!$values) { $combined = $fields; } else { @@ -2201,11 +2201,11 @@ protected function _prepareUpdateFields(Model $Model, $fields, $quoteValues = tr $quotedAlias = $this->startQuote . $Model->alias . $this->endQuote; $schema = $Model->schema(); - $updates = array(); + $updates = []; foreach ($fields as $field => $value) { - if ($alias && strpos($field, '.') === false) { + if ($alias && !str_contains($field, '.')) { $quoted = $Model->escapeField($field); - } elseif (!$alias && strpos($field, '.') !== false) { + } elseif (!$alias && str_contains($field, '.')) { $quoted = $this->name(str_replace($quotedAlias . '.', '', str_replace( $Model->alias . '.', '', $field ))); @@ -2220,7 +2220,7 @@ protected function _prepareUpdateFields(Model $Model, $fields, $quoteValues = tr $update = $quoted . ' = '; if ($quoteValues) { - $update .= $this->value($value, $Model->getColumnType($field), isset($schema[$field]['null']) ? $schema[$field]['null'] : true); + $update .= $this->value($value, $Model->getColumnType($field), $schema[$field]['null'] ?? true); } elseif ($Model->getColumnType($field) === 'boolean' && (is_int($value) || is_bool($value))) { $update .= $this->boolean($value, true); } elseif (!$alias) { @@ -2276,8 +2276,8 @@ protected function _matchRecords(Model $Model, $conditions = null) { $noJoin = true; foreach ($conditions as $field => $value) { $originalField = $field; - if (strpos($field, '.') !== false) { - list(, $field) = explode('.', $field); + if (str_contains($field, '.')) { + [, $field] = explode('.', $field); $field = ltrim($field, $this->startQuote); $field = rtrim($field, $this->endQuote); } @@ -2293,18 +2293,18 @@ protected function _matchRecords(Model $Model, $conditions = null) { if ($noJoin === true) { return $this->conditions($conditions); } - $idList = $Model->find('all', array( + $idList = $Model->find('all', [ 'fields' => "{$Model->alias}.{$Model->primaryKey}", 'conditions' => $conditions - )); + ]); if (empty($idList)) { return false; } - $conditions = $this->conditions(array( + $conditions = $this->conditions([ $Model->primaryKey => Hash::extract($idList, "{n}.{$Model->alias}.{$Model->primaryKey}") - )); + ]); } return $conditions; @@ -2317,7 +2317,7 @@ protected function _matchRecords(Model $Model, $conditions = null) { * @return array */ protected function _getJoins(Model $Model) { - $join = array(); + $join = []; $joins = array_merge($Model->getAssociated('hasOne'), $Model->getAssociated('belongsTo')); foreach ($joins as $assoc) { @@ -2333,17 +2333,17 @@ protected function _getJoins(Model $Model) { $assocData = $Model->getAssociated($assoc); - $join[] = $this->buildJoinStatement(array( + $join[] = $this->buildJoinStatement([ 'table' => $LinkModel, 'alias' => $assoc, - 'type' => isset($assocData['type']) ? $assocData['type'] : 'LEFT', + 'type' => $assocData['type'] ?? 'LEFT', 'conditions' => trim($this->conditions( $this->_mergeConditions($assocData['conditions'], $this->getConstraint($assocData['association'], $Model, $LinkModel, $assoc, $assocData)), true, false, $Model )) - )); + ]); } return $join; @@ -2357,7 +2357,7 @@ protected function _getJoins(Model $Model) { * @param array $params Function parameters (any values must be quoted manually) * @return string An SQL calculation function */ - public function calculate(Model $Model, $func, $params = array()) { + public function calculate(Model $Model, $func, $params = []) { $params = (array)$params; switch (strtolower($func)) { @@ -2574,7 +2574,7 @@ public function defaultConditions(Model $Model, $conditions, $useAlias = true) { if (!$useAlias) { $alias = $this->fullTableName($Model, false); } - return array("{$alias}.{$Model->primaryKey}" => $Model->getID()); + return ["{$alias}.{$Model->primaryKey}" => $Model->getID()]; } /** @@ -2586,7 +2586,7 @@ public function defaultConditions(Model $Model, $conditions, $useAlias = true) { * @return string */ public function resolveKey(Model $Model, $key, $assoc = null) { - if (strpos('.', $key) !== false) { + if (str_contains('.', $key)) { return $this->name($Model->alias) . '.' . $this->name($key); } return $key; @@ -2601,7 +2601,7 @@ public function resolveKey(Model $Model, $key, $assoc = null) { protected function _scrubQueryData($data) { static $base = null; if ($base === null) { - $base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array()); + $base = array_fill_keys(['conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'], []); $base['having'] = null; $base['lock'] = null; $base['callbacks'] = null; @@ -2618,7 +2618,7 @@ protected function _scrubQueryData($data) { * @return array */ protected function _constructVirtualFields(Model $Model, $alias, $fields) { - $virtual = array(); + $virtual = []; foreach ($fields as $field) { $virtualField = $this->name($alias . $this->virtualFieldSeparator . $field); $virtualFieldExpression = $Model->getVirtualField($field); @@ -2641,14 +2641,14 @@ protected function _constructVirtualFields(Model $Model, $alias, $fields) { * @param bool $quote If false, returns fields array unquoted * @return array */ - public function fields(Model $Model, $alias = null, $fields = array(), $quote = true) { + public function fields(Model $Model, $alias = null, $fields = [], $quote = true) { if (empty($alias)) { $alias = $Model->alias; } $virtualFields = $Model->getVirtualField(); - $cacheKey = array( + $cacheKey = [ $alias, - get_class($Model), + $Model::class, $Model->alias, $virtualFields, $fields, @@ -2656,7 +2656,7 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote = ConnectionManager::getSourceName($this), $Model->schemaName, $Model->table - ); + ]; $cacheKey = $this->cacheMethodHasher(serialize($cacheKey)); if ($return = $this->cacheMethod(__FUNCTION__, $cacheKey)) { return $return; @@ -2670,7 +2670,7 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote = $fields = array_values(array_filter($fields)); $allFields = $allFields || in_array('*', $fields) || in_array($Model->alias . '.*', $fields); - $virtual = array(); + $virtual = []; if (!empty($virtualFields)) { $virtualKeys = array_keys($virtualFields); foreach ($virtualKeys as $field) { @@ -2678,10 +2678,10 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote = } $virtual = ($allFields) ? $virtualKeys : array_intersect($virtualKeys, $fields); foreach ($virtual as $i => $field) { - if (strpos($field, '.') !== false) { + if (str_contains($field, '.')) { $virtual[$i] = str_replace($Model->alias . '.', '', $field); } - $fields = array_diff($fields, array($field)); + $fields = array_diff($fields, [$field]); } $fields = array_values($fields); } @@ -2693,7 +2693,7 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote = } $count = count($fields); - if ($count >= 1 && !in_array($fields[0], array('*', 'COUNT(*)'))) { + if ($count >= 1 && !in_array($fields[0], ['*', 'COUNT(*)'])) { for ($i = 0; $i < $count; $i++) { if (is_string($fields[$i]) && in_array($fields[$i], $virtual)) { unset($fields[$i]); @@ -2706,7 +2706,7 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote = } elseif (!preg_match('/^.+\\(.*\\)/', $fields[$i])) { $prepend = ''; - if (strpos($fields[$i], 'DISTINCT') !== false) { + if (str_contains($fields[$i], 'DISTINCT')) { $prepend = 'DISTINCT '; $fields[$i] = trim(str_replace('DISTINCT', '', $fields[$i])); } @@ -2714,12 +2714,12 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote = if ($dot === false) { $prefix = !( - strpos($fields[$i], ' ') !== false || - strpos($fields[$i], '(') !== false + str_contains($fields[$i], ' ') || + str_contains($fields[$i], '(') ); $fields[$i] = $this->name(($prefix ? $alias . '.' : '') . $fields[$i]); } else { - if (strpos($fields[$i], ',') === false) { + if (!str_contains($fields[$i], ',')) { $build = explode('.', $fields[$i]); if (!Hash::numeric($build)) { $fields[$i] = $this->name(implode('.', $build)); @@ -2729,12 +2729,12 @@ public function fields(Model $Model, $alias = null, $fields = array(), $quote = $fields[$i] = $prepend . $fields[$i]; } elseif (preg_match('/\(([\.\w]+)\)/', $fields[$i], $field)) { if (isset($field[1])) { - if (strpos($field[1], '.') === false) { + if (!str_contains($field[1], '.')) { $field[1] = $this->name($alias . '.' . $field[1]); } else { $field[0] = explode('.', $field[1]); if (!Hash::numeric($field[0])) { - $field[0] = implode('.', array_map(array(&$this, 'name'), $field[0])); + $field[0] = implode('.', array_map([&$this, 'name'], $field[0])); $fields[$i] = preg_replace('/\(' . $field[1] . '\)/', '(' . $field[0] . ')', $fields[$i], 1); } } @@ -2807,7 +2807,7 @@ public function conditions($conditions, $quoteValues = true, $where = true, ?Mod * @return string SQL fragment */ public function conditionKeysToString($conditions, $quoteValues = true, ?Model $Model = null) { - $out = array(); + $out = []; $data = $columnType = null; foreach ($conditions as $key => $value) { @@ -2833,7 +2833,7 @@ public function conditionKeysToString($conditions, $quoteValues = true, ?Model $ } $value = $this->conditionKeysToString($value, $quoteValues, $Model); - if (strpos($join, 'NOT') !== false) { + if (str_contains($join, 'NOT')) { if (strtoupper(trim($key)) === 'NOT') { $key = 'AND ' . trim($key); } @@ -2914,15 +2914,15 @@ public function conditionKeysToString($conditions, $quoteValues = true, ?Model $ protected function _parseKey($key, $value, ?Model $Model = null) { $operatorMatch = '/^(((' . implode(')|(', $this->_sqlOps); $operatorMatch .= ')\\x20?)|<[>=]?(?![^>]+>)\\x20?|[>=!]{1,3}(?!<)\\x20?)/is'; - $bound = (strpos($key, '?') !== false || (is_array($value) && strpos($key, ':') !== false)); + $bound = (str_contains($key, '?') || (is_array($value) && str_contains($key, ':'))); $key = trim($key); - if (strpos($key, ' ') === false) { + if (!str_contains($key, ' ')) { $operator = '='; } else { - list($key, $operator) = explode(' ', $key, 2); + [$key, $operator] = explode(' ', $key, 2); - if (!preg_match($operatorMatch, trim($operator)) && strpos($operator, ' ') !== false) { + if (!preg_match($operatorMatch, trim($operator)) && str_contains($operator, ' ')) { $key = $key . ' ' . $operator; $split = strrpos($key, ' '); $operator = substr($key, $split); @@ -2951,7 +2951,7 @@ protected function _parseKey($key, $value, ?Model $Model = null) { if (strtolower($operator) === 'not') { $data = $this->conditionKeysToString( - array($operator => array($key => $value)), true, $Model + [$operator => [$key => $value]], true, $Model ); return $data[0]; } @@ -2960,10 +2960,10 @@ protected function _parseKey($key, $value, ?Model $Model = null) { if (!$virtual && $key !== '?') { $isKey = ( - strpos($key, '(') !== false || - strpos($key, ')') !== false || - strpos($key, '|') !== false || - strpos($key, '->') !== false + str_contains($key, '(') || + str_contains($key, ')') || + str_contains($key, '|') || + str_contains($key, '->') ); $key = $isKey ? $this->_quoteFields($key) : $this->name($key); } @@ -3025,10 +3025,10 @@ protected function _quoteFields($conditions) { } // Remove quotes and requote all the Model.field names. - $conditions = str_replace(array($start, $end), '', $conditions); + $conditions = str_replace([$start, $end], '', $conditions); $conditions = preg_replace_callback( '/(?:[\'\"][^\'\"\\\]*(?:\\\.[^\'\"\\\]*)*[\'\"])|([a-z0-9_][a-z0-9\\-_]*\\.[a-z0-9_][a-z0-9_\\-]*[a-z0-9_])|([a-z0-9_][a-z0-9_\\-]*)(?=->)/i', - array(&$this, '_quoteMatchedField'), + [&$this, '_quoteMatchedField'], $conditions ); // Quote `table_name AS Alias` @@ -3087,11 +3087,11 @@ public function limit($limit, $offset = null) { */ public function order($keys, $direction = 'ASC', ?Model $Model = null) { if (!is_array($keys)) { - $keys = array($keys); + $keys = [$keys]; } $keys = array_filter($keys); - $result = array(); + $result = []; while (!empty($keys)) { $key = key($keys); $dir = current($keys); @@ -3102,7 +3102,7 @@ public function order($keys, $direction = 'ASC', ?Model $Model = null) { $dir = $direction; } - if (is_string($key) && strpos($key, ',') !== false && !preg_match('/\(.+\,.+\)/', $key)) { + if (is_string($key) && str_contains($key, ',') && !preg_match('/\(.+\,.+\)/', $key)) { $key = array_map('trim', explode(',', $key)); } @@ -3113,7 +3113,7 @@ public function order($keys, $direction = 'ASC', ?Model $Model = null) { if (is_numeric($k)) { array_unshift($keys, $v); } else { - $keys = array($k => $v) + $keys; + $keys = [$k => $v] + $keys; } } continue; @@ -3134,7 +3134,7 @@ public function order($keys, $direction = 'ASC', ?Model $Model = null) { $key = '(' . $this->_quoteFields($Model->getVirtualField($key)) . ')'; } - list($alias) = pluginSplit($key); + [$alias] = pluginSplit($key); if ($alias !== $Model->alias && is_object($Model->{$alias}) && $Model->{$alias}->isVirtualField($key)) { $key = '(' . $this->_quoteFields($Model->{$alias}->getVirtualField($key)) . ')'; @@ -3142,10 +3142,10 @@ public function order($keys, $direction = 'ASC', ?Model $Model = null) { } if (strpos($key, '.')) { - $key = preg_replace_callback('/([a-zA-Z0-9_-]{1,})\\.([a-zA-Z0-9_-]{1,})/', array(&$this, '_quoteMatchedField'), $key); + $key = preg_replace_callback('/([a-zA-Z0-9_-]{1,})\\.([a-zA-Z0-9_-]{1,})/', [&$this, '_quoteMatchedField'], $key); } - if (!preg_match('/\s/', $key) && strpos($key, '.') === false) { + if (!preg_match('/\s/', $key) && !str_contains($key, '.')) { $key = $this->name($key); } @@ -3174,7 +3174,7 @@ public function group($fields, ?Model $Model = null) { } if (!is_array($fields)) { - $fields = array($fields); + $fields = [$fields]; } if ($Model !== null) { @@ -3259,9 +3259,9 @@ public function hasAny(Model $Model, $sql) { */ public function length($real) { preg_match('/([\w\s]+)(?:\((.+?)\))?(\sunsigned)?/i', $real, $result); - $types = array( + $types = [ 'int' => 1, 'tinyint' => 1, 'smallint' => 1, 'mediumint' => 1, 'integer' => 1, 'bigint' => 1 - ); + ]; $type = $length = null; if (isset($result[1])) { @@ -3277,15 +3277,15 @@ public function length($real) { return null; } - $isFloat = in_array($type, array('dec', 'decimal', 'float', 'numeric', 'double')); - if ($isFloat && strpos($length, ',') !== false) { + $isFloat = in_array($type, ['dec', 'decimal', 'float', 'numeric', 'double']); + if ($isFloat && str_contains($length, ',')) { return $length; } if (isset($types[$type])) { return (int)$length; } - if (in_array($type, array('enum', 'set'))) { + if (in_array($type, ['enum', 'set'])) { return null; } return (int)$length; @@ -3318,16 +3318,16 @@ public function boolean($data, $quote = false) { public function insertMulti($table, $fields, $values) { $table = $this->fullTableName($table); $holder = implode(',', array_fill(0, count($fields), '?')); - $fields = implode(', ', array_map(array(&$this, 'name'), $fields)); + $fields = implode(', ', array_map([&$this, 'name'], $fields)); - $pdoMap = array( + $pdoMap = [ 'integer' => PDO::PARAM_INT, 'float' => PDO::PARAM_STR, 'boolean' => PDO::PARAM_BOOL, 'string' => PDO::PARAM_STR, 'text' => PDO::PARAM_STR - ); - $columnMap = array(); + ]; + $columnMap = []; $sql = "INSERT INTO {$table} ({$fields}) VALUES ({$holder})"; $statement = $this->_connection->prepare($sql); @@ -3377,7 +3377,7 @@ public function resetSequence($table, $column) { * @return array Fields in table. Keys are column and unique */ public function index($model) { - return array(); + return []; } /** @@ -3397,7 +3397,7 @@ public function createSchema($schema, $tableName = null) { foreach ($schema->tables as $curTable => $columns) { if (!$tableName || $tableName === $curTable) { - $cols = $indexes = $tableParameters = array(); + $cols = $indexes = $tableParameters = []; $primary = null; $table = $this->fullTableName($curTable); @@ -3410,7 +3410,7 @@ public function createSchema($schema, $tableName = null) { foreach ($columns as $name => $col) { if (is_string($col)) { - $col = array('type' => $col); + $col = ['type' => $col]; } $isPrimary = isset($col['key']) && $col['key'] === 'primary'; // Multi-column primary keys are not supported. @@ -3434,7 +3434,7 @@ public function createSchema($schema, $tableName = null) { } } if (!isset($columns['indexes']['PRIMARY']) && !empty($primary)) { - $col = array('PRIMARY' => array('column' => $primary, 'unique' => 1)); + $col = ['PRIMARY' => ['column' => $primary, 'unique' => 1]]; $indexes = array_merge($indexes, $this->buildIndex($col, $table)); } $columns = $cols; @@ -3497,19 +3497,19 @@ protected function _dropTable($table) { */ public function buildColumn($column) { $name = $type = null; - extract(array_merge(array('null' => true), $column)); + extract(array_merge(['null' => true], $column)); if (empty($name) || empty($type)) { trigger_error(__d('cake_dev', 'Column name or type not defined in schema'), E_USER_WARNING); return null; } - if (!isset($this->columns[$type]) && substr($type, 0, 4) !== 'enum') { + if (!isset($this->columns[$type]) && !str_starts_with($type, 'enum')) { trigger_error(__d('cake_dev', 'Column type %s does not exist', $type), E_USER_WARNING); return null; } - if (substr($type, 0, 4) === 'enum') { + if (str_starts_with($type, 'enum')) { $out = $this->name($name) . ' ' . $type; } else { $real = $this->columns[$type]; @@ -3548,8 +3548,8 @@ public function buildColumn($column) { } elseif (isset($column['null']) && $column['null'] === false) { $out .= ' NOT NULL'; } - if (in_array($type, array('timestamp', 'datetime')) && isset($column['default']) && strtolower($column['default']) === 'current_timestamp') { - $out = str_replace(array("'CURRENT_TIMESTAMP'", "'current_timestamp'"), 'CURRENT_TIMESTAMP', $out); + if (in_array($type, ['timestamp', 'datetime']) && isset($column['default']) && strtolower($column['default']) === 'current_timestamp') { + $out = str_replace(["'CURRENT_TIMESTAMP'", "'current_timestamp'"], 'CURRENT_TIMESTAMP', $out); } return $this->_buildFieldParameters($out, $column, 'afterDefault'); } @@ -3589,7 +3589,7 @@ protected function _buildFieldParameters($columnString, $columnData, $position) * @return array */ public function buildIndex($indexes, $table = null) { - $join = array(); + $join = []; foreach ($indexes as $name => $value) { $out = ''; if ($name === 'PRIMARY') { @@ -3602,7 +3602,7 @@ public function buildIndex($indexes, $table = null) { $name = $this->startQuote . $name . $this->endQuote; } if (is_array($value['column'])) { - $out .= 'KEY ' . $name . ' (' . implode(', ', array_map(array(&$this, 'name'), $value['column'])) . ')'; + $out .= 'KEY ' . $name . ' (' . implode(', ', array_map([&$this, 'name'], $value['column'])) . ')'; } else { $out .= 'KEY ' . $name . ' (' . $this->name($value['column']) . ')'; } @@ -3618,7 +3618,7 @@ public function buildIndex($indexes, $table = null) { * @return array */ public function readTableParameters($name) { - $parameters = array(); + $parameters = []; if (method_exists($this, 'listDetailedSources')) { $currentTableDetails = $this->listDetailedSources($name); foreach ($this->tableParameters as $paramName => $parameter) { @@ -3638,7 +3638,7 @@ public function readTableParameters($name) { * @return array */ public function buildTableParameters($parameters, $table = null) { - $result = array(); + $result = []; foreach ($parameters as $name => $value) { if (isset($this->tableParameters[$name])) { if ($this->tableParameters[$name]['quote']) { @@ -3710,7 +3710,7 @@ public function introspectType($value) { * @return void */ public function flushQueryCache() { - $this->_queryCache = array(); + $this->_queryCache = []; } /** @@ -3721,7 +3721,7 @@ public function flushQueryCache() { * @param array $params query params bound as values * @return void */ - protected function _writeQueryCache($sql, $data, $params = array()) { + protected function _writeQueryCache($sql, $data, $params = []) { if (preg_match('/^\s*select/i', $sql)) { $this->_queryCache[$sql][serialize($params)] = $data; } @@ -3734,7 +3734,7 @@ protected function _writeQueryCache($sql, $data, $params = array()) { * @param array $params query params bound as values * @return mixed results for query if it is cached, false otherwise */ - public function getQueryCache($sql, $params = array()) { + public function getQueryCache($sql, $params = []) { if (isset($this->_queryCache[$sql]) && preg_match('/^\s*select/i', $sql)) { $serialized = serialize($params); if (isset($this->_queryCache[$sql][$serialized])) { diff --git a/lib/Cake/Model/Datasource/Session/DatabaseSession.php b/lib/Cake/Model/Datasource/Session/DatabaseSession.php index c77f3de198..0b8472e110 100644 --- a/lib/Cake/Model/Datasource/Session/DatabaseSession.php +++ b/lib/Cake/Model/Datasource/Session/DatabaseSession.php @@ -48,16 +48,16 @@ public function __construct() { $modelName = Configure::read('Session.handler.model'); if (empty($modelName)) { - $settings = array( + $settings = [ 'class' => 'Session', 'alias' => 'Session', 'table' => 'cake_sessions', - ); + ]; } else { - $settings = array( + $settings = [ 'class' => $modelName, 'alias' => 'Session', - ); + ]; } $this->_model = ClassRegistry::init($settings); $this->_timeout = Configure::read('Session.timeout') * 60; @@ -88,9 +88,9 @@ public function close() { * @return mixed The value of the key or false if it does not exist */ public function read($id) { - $row = $this->_model->find('first', array( - 'conditions' => array($this->_model->alias . '.' . $this->_model->primaryKey => $id) - )); + $row = $this->_model->find('first', [ + 'conditions' => [$this->_model->alias . '.' . $this->_model->primaryKey => $id] + ]); if (empty($row[$this->_model->alias])) { return ''; @@ -121,14 +121,14 @@ public function write($id, $data) { $record = compact('id', 'data', 'expires'); $record[$this->_model->primaryKey] = $id; - $options = array( + $options = [ 'validate' => false, 'callbacks' => false, 'counterCache' => false - ); + ]; try { return (bool)$this->_model->save($record, $options); - } catch (PDOException $e) { + } catch (PDOException) { return (bool)$this->_model->save($record, $options); } } @@ -155,7 +155,7 @@ public function gc($expires = null) { } else { $expires = time() - $expires; } - $this->_model->deleteAll(array($this->_model->alias . ".expires <" => $expires), false, false); + $this->_model->deleteAll([$this->_model->alias . ".expires <" => $expires], false, false); return true; } diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index 3ac6f6d6f5..35498149a1 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -88,7 +88,7 @@ class Model extends CakeObject implements CakeEventListener { * @var array|false * @link https://book.cakephp.org/2.0/en/models/model-attributes.html#data */ - public $data = array(); + public $data = []; /** * Holds physical schema/database name for this model. Automatically set during Model creation. @@ -210,14 +210,14 @@ class Model extends CakeObject implements CakeEventListener { * @link https://book.cakephp.org/2.0/en/models/model-attributes.html#validate * @link https://book.cakephp.org/2.0/en/models/data-validation.html */ - public $validate = array(); + public $validate = []; /** * List of validation errors. * * @var array */ - public $validationErrors = array(); + public $validationErrors = []; /** * Name of the validation string domain to use when translating validation errors. @@ -261,7 +261,7 @@ class Model extends CakeObject implements CakeEventListener { * * @var array */ - public $tableToModel = array(); + public $tableToModel = []; /** * Whether or not to cache queries for this model. This enables in-memory @@ -317,7 +317,7 @@ class Model extends CakeObject implements CakeEventListener { * @var array * @link https://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#belongsto */ - public $belongsTo = array(); + public $belongsTo = []; /** * Detailed list of hasOne associations. @@ -360,7 +360,7 @@ class Model extends CakeObject implements CakeEventListener { * @var array * @link https://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasone */ - public $hasOne = array(); + public $hasOne = []; /** * Detailed list of hasMany associations. @@ -409,7 +409,7 @@ class Model extends CakeObject implements CakeEventListener { * @var array * @link https://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasmany */ - public $hasMany = array(); + public $hasMany = []; /** * Detailed list of hasAndBelongsToMany associations. @@ -470,7 +470,7 @@ class Model extends CakeObject implements CakeEventListener { * @var array * @link https://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#hasandbelongstomany-habtm */ - public $hasAndBelongsToMany = array(); + public $hasAndBelongsToMany = []; /** * List of behaviors to load when the model object is initialized. Settings can be @@ -502,7 +502,7 @@ class Model extends CakeObject implements CakeEventListener { * * @var array */ - public $whitelist = array(); + public $whitelist = []; /** * Whether or not to cache sources for this model. @@ -550,26 +550,26 @@ class Model extends CakeObject implements CakeEventListener { * @var array * @link https://book.cakephp.org/2.0/en/models/model-attributes.html#virtualfields */ - public $virtualFields = array(); + public $virtualFields = []; /** * Default list of association keys. * * @var array */ - protected $_associationKeys = array( - 'belongsTo' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'), - 'hasOne' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'dependent'), - 'hasMany' => array('className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'), - 'hasAndBelongsToMany' => array('className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery') - ); + protected $_associationKeys = [ + 'belongsTo' => ['className', 'foreignKey', 'conditions', 'fields', 'order', 'counterCache'], + 'hasOne' => ['className', 'foreignKey', 'conditions', 'fields', 'order', 'dependent'], + 'hasMany' => ['className', 'foreignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'dependent', 'exclusive', 'finderQuery', 'counterQuery'], + 'hasAndBelongsToMany' => ['className', 'joinTable', 'with', 'foreignKey', 'associationForeignKey', 'conditions', 'fields', 'order', 'limit', 'offset', 'unique', 'finderQuery'] + ]; /** * Holds provided/generated association key names and other data for all associations. * * @var array */ - protected $_associations = array('belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany'); + protected $_associations = ['belongsTo', 'hasOne', 'hasMany', 'hasAndBelongsToMany']; // @codingStandardsIgnoreStart @@ -578,28 +578,28 @@ class Model extends CakeObject implements CakeEventListener { * * @var array */ - public $__backAssociation = array(); + public $__backAssociation = []; /** * Back inner association * * @var array */ - public $__backInnerAssociation = array(); + public $__backInnerAssociation = []; /** * Back original association * * @var array */ - public $__backOriginalAssociation = array(); + public $__backOriginalAssociation = []; /** * Back containable association * * @var array */ - public $__backContainableAssociation = array(); + public $__backContainableAssociation = []; /** * Safe update mode @@ -650,10 +650,10 @@ class Model extends CakeObject implements CakeEventListener { * * @var array */ - public $findMethods = array( + public $findMethods = [ 'all' => true, 'first' => true, 'count' => true, 'neighbors' => true, 'list' => true, 'threaded' => true - ); + ]; /** * Instance of the CakeEventManager this model is using @@ -708,24 +708,24 @@ public function __construct($id = false, $table = null, $ds = null) { if (is_array($id)) { extract(array_merge( - array( + [ 'id' => $this->id, 'table' => $this->useTable, 'ds' => $this->useDbConfig, 'name' => $this->name, 'alias' => $this->alias, 'plugin' => $this->plugin - ), + ], $id )); } if ($this->plugin === null) { - $this->plugin = (isset($plugin) ? $plugin : $this->plugin); + $this->plugin = ($plugin ?? $this->plugin); } if ($this->name === null) { - $this->name = (isset($name) ? $name : get_class($this)); + $this->name = ($name ?? static::class); } if ($this->alias === null) { - $this->alias = (isset($alias) ? $alias : $this->name); + $this->alias = ($alias ?? $this->name); } if ($this->primaryKey === null) { @@ -748,14 +748,14 @@ public function __construct($id = false, $table = null, $ds = null) { } if (is_subclass_of($this, 'AppModel')) { - $merge = array('actsAs', 'findMethods'); + $merge = ['actsAs', 'findMethods']; $parentClass = get_parent_class($this); if ($parentClass !== 'AppModel') { $this->_mergeVars($merge, $parentClass); } $this->_mergeVars($merge, 'AppModel'); } - $this->_mergeVars(array('findMethods'), 'Model'); + $this->_mergeVars(['findMethods'], 'Model'); $this->Behaviors = new BehaviorCollection(); @@ -789,16 +789,16 @@ public function __construct($id = false, $table = null, $ds = null) { * @return array */ public function implementedEvents() { - return array( - 'Model.beforeFind' => array('callable' => 'beforeFind', 'passParams' => true), - 'Model.afterFind' => array('callable' => 'afterFind', 'passParams' => true), - 'Model.beforeValidate' => array('callable' => 'beforeValidate', 'passParams' => true), - 'Model.afterValidate' => array('callable' => 'afterValidate'), - 'Model.beforeSave' => array('callable' => 'beforeSave', 'passParams' => true), - 'Model.afterSave' => array('callable' => 'afterSave', 'passParams' => true), - 'Model.beforeDelete' => array('callable' => 'beforeDelete', 'passParams' => true), - 'Model.afterDelete' => array('callable' => 'afterDelete'), - ); + return [ + 'Model.beforeFind' => ['callable' => 'beforeFind', 'passParams' => true], + 'Model.afterFind' => ['callable' => 'afterFind', 'passParams' => true], + 'Model.beforeValidate' => ['callable' => 'beforeValidate', 'passParams' => true], + 'Model.afterValidate' => ['callable' => 'afterValidate'], + 'Model.beforeSave' => ['callable' => 'beforeSave', 'passParams' => true], + 'Model.afterSave' => ['callable' => 'afterSave', 'passParams' => true], + 'Model.beforeDelete' => ['callable' => 'beforeDelete', 'passParams' => true], + 'Model.afterDelete' => ['callable' => 'afterDelete'], + ]; } /** @@ -828,7 +828,7 @@ public function getEventManager() { */ public function __call($method, $params) { $result = $this->Behaviors->dispatchMethod($this, $method, $params); - if ($result !== array('unhandled')) { + if ($result !== ['unhandled']) { return $result; } @@ -863,7 +863,7 @@ public function __isset($name) { $className = $name; } } else { - list($plugin, $class) = pluginSplit($relation['with']); + [$plugin, $class] = pluginSplit($relation['with']); if ($class === $name) { $className = $relation['with']; } @@ -882,14 +882,14 @@ public function __isset($name) { return false; } - list($plugin, $className) = pluginSplit($className); + [$plugin, $className] = pluginSplit($className); if (!ClassRegistry::isKeySet($className) && !empty($dynamic)) { - $this->{$className} = new AppModel(array( + $this->{$className} = new AppModel([ 'name' => $className, 'table' => $this->hasAndBelongsToMany[$assocKey]['joinTable'], 'ds' => $this->useDbConfig - )); + ]); } else { $this->_constructLinkedModel($name, $className, $plugin); } @@ -912,7 +912,7 @@ public function __isset($name) { */ public function __get($name) { if ($name === 'displayField') { - return $this->displayField = $this->hasField(array('title', 'name', $this->primaryKey)); + return $this->displayField = $this->hasField(['title', 'name', $this->primaryKey]); } if ($name === 'tablePrefix') { @@ -959,7 +959,7 @@ public function bindModel($params, $reset = true) { if (is_numeric($key)) { $assocName = $value; - $value = array(); + $value = []; } $this->{$assoc}[$assocName] = $value; @@ -1031,7 +1031,7 @@ protected function _createLinks() { foreach ($association as $i => $className) { $className = trim($className); unset ($association[$i]); - $association[$className] = array(); + $association[$className] = []; } } @@ -1042,14 +1042,14 @@ protected function _createLinks() { if (is_numeric($assoc)) { unset($association[$assoc]); $assoc = $value; - $value = array(); + $value = []; $association[$assoc] = $value; } - if (!isset($value['className']) && strpos($assoc, '.') !== false) { + if (!isset($value['className']) && str_contains($assoc, '.')) { unset($association[$assoc]); - list($plugin, $assoc) = pluginSplit($assoc, true); - $association[$assoc] = array('className' => $plugin . $assoc) + $value; + [$plugin, $assoc] = pluginSplit($assoc, true); + $association[$assoc] = ['className' => $plugin . $assoc] + $value; } $this->_generateAssociation($type, $assoc); @@ -1081,7 +1081,7 @@ protected function _constructLinkedModel($assoc, $className = null, $plugin = nu $plugin .= '.'; } - $model = array('class' => $plugin . $className, 'alias' => $assoc); + $model = ['class' => $plugin . $className, 'alias' => $assoc]; $this->{$assoc} = ClassRegistry::init($model); if ($plugin) { @@ -1129,7 +1129,7 @@ protected function _generateAssociation($type, $assocKey) { break; case 'joinTable': - $tables = array($this->table, $this->{$class}->table); + $tables = [$this->table, $this->{$class}->table]; sort($tables); $data = $tables[0] . '_' . $tables[1]; break; @@ -1170,11 +1170,11 @@ public function setSource($tableName) { $db->cacheSources = $restore; if (is_array($sources) && !in_array(strtolower($this->tablePrefix . $tableName), array_map('strtolower', $sources))) { - throw new MissingTableException(array( + throw new MissingTableException([ 'table' => $this->tablePrefix . $tableName, 'class' => $this->alias, 'ds' => $this->useDbConfig, - )); + ]); } if ($sources) { @@ -1220,7 +1220,7 @@ public function set($one, $two = null) { $data = $this->_setAliasData($one); } } else { - $data = array($this->alias => array($one => $two)); + $data = [$this->alias => [$one => $two]]; } foreach ($data as $modelName => $fieldSet) { @@ -1229,7 +1229,7 @@ public function set($one, $two = null) { } if (!isset($this->data[$modelName])) { - $this->data[$modelName] = array(); + $this->data[$modelName] = []; } foreach ($fieldSet as $fieldName => $fieldValue) { @@ -1277,7 +1277,7 @@ protected function _setAliasData($data) { * @return array */ protected function _normalizeXmlData(array $xml) { - $return = array(); + $return = []; foreach ($xml as $key => $value) { if (is_array($value)) { $return[Inflector::camelize($key)] = $this->_normalizeXmlData($value); @@ -1305,16 +1305,16 @@ public function deconstruct($field, $data) { $type = $this->getColumnType($field); - if (!in_array($type, array('datetime', 'timestamp', 'date', 'time'))) { + if (!in_array($type, ['datetime', 'timestamp', 'date', 'time'])) { return $data; } $useNewDate = (isset($data['year']) || isset($data['month']) || isset($data['day']) || isset($data['hour']) || isset($data['minute'])); - $dateFields = array('Y' => 'year', 'm' => 'month', 'd' => 'day', 'H' => 'hour', 'i' => 'min', 's' => 'sec'); - $timeFields = array('H' => 'hour', 'i' => 'min', 's' => 'sec'); - $date = array(); + $dateFields = ['Y' => 'year', 'm' => 'month', 'd' => 'day', 'H' => 'hour', 'i' => 'min', 's' => 'sec']; + $timeFields = ['H' => 'hour', 'i' => 'min', 's' => 'sec']; + $date = []; if (isset($data['meridian']) && empty($data['meridian'])) { return null; @@ -1359,7 +1359,7 @@ public function deconstruct($field, $data) { } } - if (!isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || substr($data[$val], 0, 1) === '-')) { + if (!isset($data[$val]) || isset($data[$val]) && (empty($data[$val]) || str_starts_with($data[$val], '-'))) { return null; } @@ -1371,7 +1371,7 @@ public function deconstruct($field, $data) { if ($useNewDate && !empty($date)) { $format = $this->getDataSource()->columns[$type]['format']; - foreach (array('m', 'd', 'H', 'i', 's') as $index) { + foreach (['m', 'd', 'H', 'i', 's'] as $index) { if (isset($date[$index])) { $date[$index] = sprintf('%02d', $date[$index]); } @@ -1403,11 +1403,7 @@ public function schema($field = false) { return $this->_schema; } - if (isset($this->_schema[$field])) { - return $this->_schema[$field]; - } - - return null; + return $this->_schema[$field] ?? null; } /** @@ -1421,7 +1417,7 @@ public function getColumnTypes() { trigger_error(__d('cake_dev', '(Model::getColumnTypes) Unable to build model field data. If you are using a model without a database table, try implementing schema()'), E_USER_WARNING); } - $cols = array(); + $cols = []; foreach ($columns as $field => $values) { $cols[$field] = $values['type']; } @@ -1444,12 +1440,12 @@ public function getColumnType($column) { $db = $this->getDataSource(); $model = null; - $startQuote = isset($db->startQuote) ? $db->startQuote : null; - $endQuote = isset($db->endQuote) ? $db->endQuote : null; - $column = str_replace(array($startQuote, $endQuote), '', $column); + $startQuote = $db->startQuote ?? null; + $endQuote = $db->endQuote ?? null; + $column = str_replace([$startQuote, $endQuote], '', $column); if (strpos($column, '.')) { - list($model, $column) = explode('.', $column); + [$model, $column] = explode('.', $column); } if (isset($model) && $model != $this->alias && isset($this->{$model})) { @@ -1528,8 +1524,8 @@ public function isVirtualField($field) { return true; } - if (strpos($field, '.') !== false) { - list($model, $field) = explode('.', $field); + if (str_contains($field, '.')) { + [$model, $field] = explode('.', $field); if ($model === $this->alias && isset($this->virtualFields[$field])) { return true; } @@ -1552,8 +1548,8 @@ public function getVirtualField($field = null) { } if ($this->isVirtualField($field)) { - if (strpos($field, '.') !== false) { - list(, $field) = pluginSplit($field); + if (str_contains($field, '.')) { + [, $field] = pluginSplit($field); } return $this->virtualFields[$field]; @@ -1573,11 +1569,11 @@ public function getVirtualField($field = null) { * @return array The current Model::data; after merging $data and/or defaults from database * @link https://book.cakephp.org/2.0/en/models/saving-your-data.html#model-create-array-data-array */ - public function create($data = array(), $filterKey = false) { - $defaults = array(); + public function create($data = [], $filterKey = false) { + $defaults = []; $this->id = false; - $this->data = array(); - $this->validationErrors = array(); + $this->data = []; + $this->validationErrors = []; if ($data !== null && $data !== false) { $schema = (array)$this->schema(); @@ -1619,7 +1615,7 @@ public function clear() { * @link https://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-read */ public function read($fields = null, $id = null) { - $this->validationErrors = array(); + $this->validationErrors = []; if ($id) { $this->id = $id; @@ -1632,10 +1628,10 @@ public function read($fields = null, $id = null) { } if ($id !== null && $id !== false) { - $this->data = $this->find('first', array( - 'conditions' => array($this->alias . '.' . $this->primaryKey => $id), + $this->data = $this->find('first', [ + 'conditions' => [$this->alias . '.' . $this->primaryKey => $id], 'fields' => $fields - )); + ]); return $this->data; } @@ -1654,8 +1650,8 @@ public function read($fields = null, $id = null) { * @link https://book.cakephp.org/2.0/en/models/retrieving-your-data.html#model-field */ public function field($name, $conditions = null, $order = null) { - if ($conditions === null && !in_array($this->id, array(false, null), true)) { - $conditions = array($this->alias . '.' . $this->primaryKey => $this->id); + if ($conditions === null && !in_array($this->id, [false, null], true)) { + $conditions = [$this->alias . '.' . $this->primaryKey => $this->id]; } $recursive = $this->recursive; @@ -1669,7 +1665,7 @@ public function field($name, $conditions = null, $order = null) { return false; } - if (strpos($name, '.') === false) { + if (!str_contains($name, '.')) { if (isset($data[$this->alias][$name])) { return $data[$this->alias][$name]; } @@ -1705,12 +1701,12 @@ public function saveField($name, $value, $validate = false) { $id = $this->id; $this->create(false); - $options = array('validate' => $validate, 'fieldList' => array($name)); + $options = ['validate' => $validate, 'fieldList' => [$name]]; if (is_array($validate)) { - $options = $validate + array('validate' => false, 'fieldList' => array($name)); + $options = $validate + ['validate' => false, 'fieldList' => [$name]]; } - return $this->save(array($this->alias => array($this->primaryKey => $id, $name => $value)), $options); + return $this->save([$this->alias => [$this->primaryKey => $id, $name => $value]], $options); } /** @@ -1738,12 +1734,12 @@ public function saveField($name, $value, $validate = false) { * @triggers Model.afterSave $this, array($created, $options) * @link https://book.cakephp.org/2.0/en/models/saving-your-data.html */ - public function save($data = null, $validate = true, $fieldList = array()) { - $defaults = array( - 'validate' => true, 'fieldList' => array(), + public function save($data = null, $validate = true, $fieldList = []) { + $defaults = [ + 'validate' => true, 'fieldList' => [], 'callbacks' => true, 'counterCache' => true, 'atomic' => true - ); + ]; if (!is_array($validate)) { $options = compact('validate', 'fieldList') + $defaults; @@ -1792,9 +1788,9 @@ public function save($data = null, $validate = true, $fieldList = array()) { * @throws PDOException * @link https://book.cakephp.org/2.0/en/models/saving-your-data.html */ - protected function _doSave($data = null, $options = array()) { + protected function _doSave($data = null, $options = []) { $_whitelist = $this->whitelist; - $fields = array(); + $fields = []; if (!empty($options['fieldList'])) { if (!empty($options['fieldList'][$this->alias]) && is_array($options['fieldList'][$this->alias])) { @@ -1803,17 +1799,17 @@ protected function _doSave($data = null, $options = array()) { $this->whitelist = $options['fieldList']; } } elseif ($options['fieldList'] === null) { - $this->whitelist = array(); + $this->whitelist = []; } $this->set($data); - if (empty($this->data) && !$this->hasField(array('created', 'updated', 'modified'))) { + if (empty($this->data) && !$this->hasField(['created', 'updated', 'modified'])) { $this->whitelist = $_whitelist; return false; } - foreach (array('created', 'updated', 'modified') as $field) { + foreach (['created', 'updated', 'modified'] as $field) { $keyPresentAndEmpty = ( isset($this->data[$this->alias]) && array_key_exists($field, $this->data[$this->alias]) && @@ -1826,7 +1822,7 @@ protected function _doSave($data = null, $options = array()) { } $exists = $this->exists($this->getID()); - $dateFields = array('modified', 'updated'); + $dateFields = ['modified', 'updated']; if (!$exists) { $dateFields[] = 'created'; @@ -1854,7 +1850,7 @@ protected function _doSave($data = null, $options = array()) { continue; } - $default = array('formatter' => 'date'); + $default = ['formatter' => 'date']; $colType = array_merge($default, $db->columns[$this->getColumnType($updateCol)]); $time = $now; @@ -1869,8 +1865,8 @@ protected function _doSave($data = null, $options = array()) { } if ($options['callbacks'] === true || $options['callbacks'] === 'before') { - $event = new CakeEvent('Model.beforeSave', $this, array($options)); - list($event->break, $event->breakOn) = array(true, array(false, null)); + $event = new CakeEvent('Model.beforeSave', $this, [$options]); + [$event->break, $event->breakOn] = [true, [false, null]]; $this->getEventManager()->dispatch($event); if (!$event->result) { $this->whitelist = $_whitelist; @@ -1881,7 +1877,7 @@ protected function _doSave($data = null, $options = array()) { if (empty($this->data[$this->alias][$this->primaryKey])) { unset($this->data[$this->alias][$this->primaryKey]); } - $joined = $fields = $values = array(); + $joined = $fields = $values = []; foreach ($this->data as $n => $v) { if (isset($this->hasAndBelongsToMany[$n])) { @@ -1890,7 +1886,7 @@ protected function _doSave($data = null, $options = array()) { } $joined[$n] = $v; } elseif ($n === $this->alias) { - foreach (array('created', 'updated', 'modified') as $field) { + foreach (['created', 'updated', 'modified'] as $field) { if (array_key_exists($field, $v) && empty($v[$field])) { unset($v[$field]); } @@ -1898,7 +1894,7 @@ protected function _doSave($data = null, $options = array()) { foreach ($v as $x => $y) { if ($this->hasField($x) && (empty($this->whitelist) || in_array($x, $this->whitelist))) { - list($fields[], $values[]) = array($x, $y); + [$fields[], $values[]] = [$x, $y]; } } } @@ -1936,7 +1932,7 @@ protected function _doSave($data = null, $options = array()) { $j = array_search($this->primaryKey, $fields); $values[$j] = CakeText::uuid(); } else { - list($fields[], $values[]) = array($this->primaryKey, CakeText::uuid()); + [$fields[], $values[]] = [$this->primaryKey, CakeText::uuid()]; } } @@ -1967,7 +1963,7 @@ protected function _doSave($data = null, $options = array()) { } if ($options['callbacks'] === true || $options['callbacks'] === 'after') { - $event = new CakeEvent('Model.afterSave', $this, array($created, $options)); + $event = new CakeEvent('Model.afterSave', $this, [$created, $options]); $this->getEventManager()->dispatch($event); } } @@ -1977,7 +1973,7 @@ protected function _doSave($data = null, $options = array()) { } $this->_clearCache(); - $this->validationErrors = array(); + $this->validationErrors = []; $this->whitelist = $_whitelist; $this->data = []; @@ -1992,7 +1988,7 @@ protected function _doSave($data = null, $options = array()) { */ protected function _isUUIDField($field) { $field = $this->schema($field); - return $field !== null && $field['length'] == 36 && in_array($field['type'], array('string', 'binary', 'uuid')); + return $field !== null && $field['length'] == 36 && in_array($field['type'], ['string', 'binary', 'uuid']); } /** @@ -2011,13 +2007,13 @@ protected function _saveMulti($joined, $id, $db) { $habtm = $this->hasAndBelongsToMany[$assoc]; - list($join) = $this->joinModel($habtm['with']); + [$join] = $this->joinModel($habtm['with']); $Model = $this->{$join}; if (!empty($habtm['with'])) { $withModel = is_array($habtm['with']) ? key($habtm['with']) : $habtm['with']; - list(, $withModel) = pluginSplit($withModel); + [, $withModel] = pluginSplit($withModel); $dbMulti = $this->{$withModel}->getDataSource(); } else { $dbMulti = $db; @@ -2025,13 +2021,13 @@ protected function _saveMulti($joined, $id, $db) { $isUUID = !empty($Model->primaryKey) && $Model->_isUUIDField($Model->primaryKey); - $newData = $newValues = $newJoins = array(); + $newData = $newValues = $newJoins = []; $primaryAdded = false; - $fields = array( + $fields = [ $dbMulti->name($habtm['foreignKey']), $dbMulti->name($habtm['associationForeignKey']) - ); + ]; $idField = $db->name($Model->primaryKey); if ($isUUID && !in_array($idField, $fields)) { @@ -2042,7 +2038,7 @@ protected function _saveMulti($joined, $id, $db) { foreach ((array)$data as $row) { if ((is_string($row) && (strlen($row) === 36 || strlen($row) === 16)) || is_numeric($row)) { $newJoins[] = $row; - $values = array($id, $row); + $values = [$id, $row]; if ($isUUID && $primaryAdded) { $values[] = CakeText::uuid(); @@ -2067,20 +2063,20 @@ protected function _saveMulti($joined, $id, $db) { $keepExisting = $habtm['unique'] === 'keepExisting'; if ($habtm['unique']) { - $conditions = array( + $conditions = [ $join . '.' . $habtm['foreignKey'] => $id - ); + ]; if (!empty($habtm['conditions'])) { $conditions = array_merge($conditions, (array)$habtm['conditions']); } $associationForeignKey = $Model->alias . '.' . $habtm['associationForeignKey']; - $links = $Model->find('all', array( + $links = $Model->find('all', [ 'conditions' => $conditions, 'recursive' => empty($habtm['conditions']) ? -1 : 0, 'fields' => $associationForeignKey, - )); + ]); $oldLinks = Hash::extract($links, "{n}.{$associationForeignKey}"); if (!empty($oldLinks)) { @@ -2101,7 +2097,7 @@ protected function _saveMulti($joined, $id, $db) { $Model->create(); } - $Model->save($data, array('atomic' => false)); + $Model->save($data, ['atomic' => false]); } } @@ -2135,11 +2131,11 @@ protected function _saveMulti($joined, $id, $db) { * 'counterScope' defined get updated * @return void */ - public function updateCounterCache($keys = array(), $created = false) { + public function updateCounterCache($keys = [], $created = false) { if (empty($keys) && isset($this->data[$this->alias])) { $keys = $this->data[$this->alias]; } - $keys['old'] = isset($keys['old']) ? $keys['old'] : array(); + $keys['old'] ??= []; foreach ($this->belongsTo as $parent => $assoc) { if (empty($assoc['counterCache'])) { @@ -2150,9 +2146,9 @@ public function updateCounterCache($keys = array(), $created = false) { if (!is_array($assoc['counterCache'])) { if (isset($assoc['counterScope'])) { - $assoc['counterCache'] = array($assoc['counterCache'] => $assoc['counterScope']); + $assoc['counterCache'] = [$assoc['counterCache'] => $assoc['counterScope']]; } else { - $assoc['counterCache'] = array($assoc['counterCache'] => array()); + $assoc['counterCache'] = [$assoc['counterCache'] => []]; } } @@ -2169,7 +2165,7 @@ public function updateCounterCache($keys = array(), $created = false) { } if ($conditions === true) { - $conditions = array(); + $conditions = []; } else { $conditions = (array)$conditions; } @@ -2185,8 +2181,8 @@ public function updateCounterCache($keys = array(), $created = false) { $count = (int)$this->find('count', compact('conditions', 'recursive')); $Model->updateAll( - array($field => $count), - array($Model->escapeField() => $keys['old'][$foreignKey]) + [$field => $count], + [$Model->escapeField() => $keys['old'][$foreignKey]] ); } @@ -2199,8 +2195,8 @@ public function updateCounterCache($keys = array(), $created = false) { $count = (int)$this->find('count', compact('conditions', 'recursive')); $Model->updateAll( - array($field => $count), - array($Model->escapeField() => $keys[$foreignKey]) + [$field => $count], + [$Model->escapeField() => $keys[$foreignKey]] ); } } @@ -2214,7 +2210,7 @@ public function updateCounterCache($keys = array(), $created = false) { * values, or empty if no foreign keys are updated. */ protected function _prepareUpdateFields($data) { - $foreignKeys = array(); + $foreignKeys = []; foreach ($this->belongsTo as $assoc => $info) { if (isset($info['counterCache']) && $info['counterCache']) { $foreignKeys[$assoc] = $info['foreignKey']; @@ -2224,16 +2220,16 @@ protected function _prepareUpdateFields($data) { $included = array_intersect($foreignKeys, array_keys($data)); if (empty($included) || empty($this->id)) { - return array(); + return []; } - $old = $this->find('first', array( - 'conditions' => array($this->alias . '.' . $this->primaryKey => $this->id), + $old = $this->find('first', [ + 'conditions' => [$this->alias . '.' . $this->primaryKey => $this->id], 'fields' => array_values($included), 'recursive' => -1 - )); + ]); - return array_merge($data, array('old' => $old[$this->alias])); + return array_merge($data, ['old' => $old[$this->alias]]); } /** @@ -2271,8 +2267,8 @@ protected function _prepareUpdateFields($data) { * @link https://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveassociated-array-data-null-array-options-array * @link https://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveall-array-data-null-array-options-array */ - public function saveAll($data = array(), $options = array()) { - $options += array('validate' => 'first'); + public function saveAll($data = [], $options = []) { + $options += ['validate' => 'first']; if (Hash::numeric(array_keys($data))) { if ($options['validate'] === 'only') { return $this->validateMany($data, $options); @@ -2310,18 +2306,18 @@ public function saveAll($data = array(), $options = array()) { * @throws PDOException * @link https://book.cakephp.org/2.0/en/models/saving-your-data.html#model-savemany-array-data-null-array-options-array */ - public function saveMany($data = null, $options = array()) { + public function saveMany($data = null, $options = []) { if (empty($data)) { $data = $this->data; } - $options += array('validate' => 'first', 'atomic' => true, 'deep' => false); - $this->validationErrors = $validationErrors = array(); + $options += ['validate' => 'first', 'atomic' => true, 'deep' => false]; + $this->validationErrors = $validationErrors = []; if (empty($data) && $options['validate'] !== false) { $result = $this->save($data, $options); if (!$options['atomic']) { - return array(!empty($result)); + return [!empty($result)]; } return !empty($result); @@ -2342,15 +2338,15 @@ public function saveMany($data = null, $options = array()) { } try { - $return = array(); + $return = []; foreach ($data as $key => $record) { $validates = $this->create(null) !== null; $saved = false; if ($validates) { if ($options['deep']) { - $saved = $this->saveAssociated($record, array('atomic' => false) + $options); + $saved = $this->saveAssociated($record, ['atomic' => false] + $options); } else { - $saved = (bool)$this->save($record, array('atomic' => false) + $options); + $saved = (bool)$this->save($record, ['atomic' => false] + $options); } } @@ -2410,7 +2406,7 @@ public function saveMany($data = null, $options = array()) { * Otherwise: array similar to the $data array passed, but values are set to true/false * depending on whether each record validated successfully. */ - public function validateMany(&$data, $options = array()) { + public function validateMany(&$data, $options = []) { return $this->validator()->validateMany($data, $options); } @@ -2443,18 +2439,18 @@ public function validateMany(&$data, $options = array()) { * @throws PDOException * @link https://book.cakephp.org/2.0/en/models/saving-your-data.html#model-saveassociated-array-data-null-array-options-array */ - public function saveAssociated($data = null, $options = array()) { + public function saveAssociated($data = null, $options = []) { if (empty($data)) { $data = $this->data; } - $options += array('validate' => 'first', 'atomic' => true, 'deep' => false); - $this->validationErrors = $validationErrors = array(); + $options += ['validate' => 'first', 'atomic' => true, 'deep' => false]; + $this->validationErrors = $validationErrors = []; if (empty($data) && $options['validate'] !== false) { $result = $this->save($data, $options); if (!$options['atomic']) { - return array(!empty($result)); + return [!empty($result)]; } return !empty($result); @@ -2477,7 +2473,7 @@ public function saveAssociated($data = null, $options = array()) { try { $associations = $this->getAssociated(); - $return = array(); + $return = []; $validates = true; foreach ($data as $association => $values) { $isEmpty = empty($values) || (isset($values[$association]) && empty($values[$association])); @@ -2491,9 +2487,9 @@ public function saveAssociated($data = null, $options = array()) { $saved = false; if ($validates) { if ($options['deep']) { - $saved = $Model->saveAssociated($values, array('atomic' => false) + $options); + $saved = $Model->saveAssociated($values, ['atomic' => false] + $options); } else { - $saved = (bool)$Model->save($values, array('atomic' => false) + $options); + $saved = (bool)$Model->save($values, ['atomic' => false] + $options); } $validates = ($saved === true || (is_array($saved) && !in_array(false, Hash::flatten($saved), true))); } @@ -2503,7 +2499,7 @@ public function saveAssociated($data = null, $options = array()) { if (isset($data[$this->alias])) { $data[$this->alias][$key] = $Model->id; } else { - $data = array_merge(array($key => $Model->id), $data, array($key => $Model->id)); + $data = array_merge([$key => $Model->id], $data, [$key => $Model->id]); } $options = $this->_addToWhiteList($key, $options); } else { @@ -2513,7 +2509,7 @@ public function saveAssociated($data = null, $options = array()) { $return[$association] = $validates; } - if ($validates && !($this->create(null) !== null && $this->save($data, array('atomic' => false) + $options))) { + if ($validates && !($this->create(null) !== null && $this->save($data, ['atomic' => false] + $options))) { $validationErrors[$this->alias] = $this->validationErrors; $validates = false; } @@ -2538,7 +2534,7 @@ public function saveAssociated($data = null, $options = array()) { if (isset($values[$association])) { $values[$association][$key] = $this->id; } else { - $values = array_merge(array($key => $this->id), $values, array($key => $this->id)); + $values = array_merge([$key => $this->id], $values, [$key => $this->id]); } $validates = $Model->create(null) !== null; @@ -2547,7 +2543,7 @@ public function saveAssociated($data = null, $options = array()) { if ($validates) { $options = $Model->_addToWhiteList($key, $options); if ($options['deep']) { - $saved = $Model->saveAssociated($values, array('atomic' => false) + $options); + $saved = $Model->saveAssociated($values, ['atomic' => false] + $options); } else { $saved = (bool)$Model->save($values, $options); } @@ -2565,12 +2561,12 @@ public function saveAssociated($data = null, $options = array()) { if (isset($values[$i][$association])) { $values[$i][$association][$key] = $this->id; } else { - $values[$i] = array_merge(array($key => $this->id), $value, array($key => $this->id)); + $values[$i] = array_merge([$key => $this->id], $value, [$key => $this->id]); } } $options = $Model->_addToWhiteList($key, $options); - $_return = $Model->saveMany($values, array('atomic' => false) + $options); + $_return = $Model->saveMany($values, ['atomic' => false] + $options); if (in_array(false, $_return, true)) { $validationErrors[$association] = $Model->validationErrors; $validates = false; @@ -2656,7 +2652,7 @@ protected function _addToWhiteList($key, $options) { * Otherwise: array similar to the $data array passed, but values are set to true/false * depending on whether each record validated successfully. */ - public function validateAssociated(&$data, $options = array()) { + public function validateAssociated(&$data, $options = []) { return $this->validator()->validateAssociated($data, $options); } @@ -2690,8 +2686,8 @@ public function delete($id = null, $cascade = true) { $id = $this->id; - $event = new CakeEvent('Model.beforeDelete', $this, array($cascade)); - list($event->break, $event->breakOn) = array(true, array(false, null)); + $event = new CakeEvent('Model.beforeDelete', $this, [$cascade]); + [$event->break, $event->breakOn] = [true, [false, null]]; $this->getEventManager()->dispatch($event); if ($event->isStopped()) { return false; @@ -2711,17 +2707,17 @@ public function delete($id = null, $cascade = true) { continue; } - $keys = $this->find('first', array( + $keys = $this->find('first', [ 'fields' => $this->_collectForeignKeys(), - 'conditions' => array($this->alias . '.' . $this->primaryKey => $id), + 'conditions' => [$this->alias . '.' . $this->primaryKey => $id], 'recursive' => -1, 'callbacks' => false - )); + ]); break; } } - if (!$this->getDataSource()->delete($this, array($this->alias . '.' . $this->primaryKey => $id))) { + if (!$this->getDataSource()->delete($this, [$this->alias . '.' . $this->primaryKey => $id])) { return false; } @@ -2750,7 +2746,7 @@ protected function _deleteDependent($id, $cascade) { if (!empty($this->__backAssociation)) { $savedAssociations = $this->__backAssociation; - $this->__backAssociation = array(); + $this->__backAssociation = []; } foreach (array_merge($this->hasMany, $this->hasOne) as $assoc => $data) { @@ -2762,10 +2758,10 @@ protected function _deleteDependent($id, $cascade) { if ($data['foreignKey'] === false && $data['conditions'] && in_array($this->name, $Model->getAssociated('belongsTo'))) { $Model->recursive = 0; - $conditions = array($this->escapeField(null, $this->name) => $id); + $conditions = [$this->escapeField(null, $this->name) => $id]; } else { $Model->recursive = -1; - $conditions = array($Model->escapeField($data['foreignKey']) => $id); + $conditions = [$Model->escapeField($data['foreignKey']) => $id]; if ($data['conditions']) { $conditions = array_merge((array)$data['conditions'], $conditions); } @@ -2774,9 +2770,9 @@ protected function _deleteDependent($id, $cascade) { if (isset($data['exclusive']) && $data['exclusive']) { $Model->deleteAll($conditions); } else { - $records = $Model->find('all', array( + $records = $Model->find('all', [ 'conditions' => $conditions, 'fields' => $Model->primaryKey - )); + ]); if (!empty($records)) { foreach ($records as $record) { @@ -2799,14 +2795,14 @@ protected function _deleteDependent($id, $cascade) { */ protected function _deleteLinks($id) { foreach ($this->hasAndBelongsToMany as $data) { - list(, $joinModel) = pluginSplit($data['with']); + [, $joinModel] = pluginSplit($data['with']); $Model = $this->{$joinModel}; - $records = $Model->find('all', array( + $records = $Model->find('all', [ 'conditions' => $this->_getConditionsForDeletingLinks($Model, $id, $data), 'fields' => $Model->primaryKey, 'recursive' => -1, 'callbacks' => false - )); + ]); if (!empty($records)) { foreach ($records as $record) { @@ -2826,7 +2822,7 @@ protected function _deleteLinks($id) { * @return array */ protected function _getConditionsForDeletingLinks(Model $Model, $id, array $relationshipConfig) { - return array($Model->escapeField($relationshipConfig['foreignKey']) => $id); + return [$Model->escapeField($relationshipConfig['foreignKey']) => $id]; } /** @@ -2849,11 +2845,11 @@ public function deleteAll($conditions, $cascade = true, $callbacks = false) { return $db->delete($this, $conditions); } - $ids = $this->find('all', array_merge(array( + $ids = $this->find('all', array_merge([ 'fields' => "{$this->alias}.{$this->primaryKey}", 'order' => false, 'group' => "{$this->alias}.{$this->primaryKey}", - 'recursive' => 0), compact('conditions')) + 'recursive' => 0], compact('conditions')) ); if ($ids === false || $ids === null) { @@ -2883,7 +2879,7 @@ public function deleteAll($conditions, $cascade = true, $callbacks = false) { } } - return $db->delete($this, array($this->alias . '.' . $this->primaryKey => $ids)); + return $db->delete($this, [$this->alias . '.' . $this->primaryKey => $ids]); } /** @@ -2893,7 +2889,7 @@ public function deleteAll($conditions, $cascade = true, $callbacks = false) { * @return array */ protected function _collectForeignKeys($type = 'belongsTo') { - $result = array(); + $result = []; foreach ($this->{$type} as $assoc => $data) { if (isset($data['foreignKey']) && is_string($data['foreignKey'])) { @@ -2927,13 +2923,13 @@ public function exists($id = null) { return false; } - return (bool)$this->find('count', array( - 'conditions' => array( + return (bool)$this->find('count', [ + 'conditions' => [ $this->alias . '.' . $this->primaryKey => $id - ), + ], 'recursive' => -1, 'callbacks' => false - )); + ]); } /** @@ -2943,7 +2939,7 @@ public function exists($id = null) { * @return bool True if such a record exists */ public function hasAny($conditions = null) { - return (bool)$this->find('count', array('conditions' => $conditions, 'recursive' => -1)); + return (bool)$this->find('count', ['conditions' => $conditions, 'recursive' => -1]); } /** @@ -3014,7 +3010,7 @@ public function hasAny($conditions = null) { * @return array|int|null Array of records, int if the type is count, or Null on failure. * @link https://book.cakephp.org/2.0/en/models/retrieving-your-data.html */ - public function find($type = 'first', $query = array()) { + public function find($type = 'first', $query = []) { $this->findQueryType = $type; $this->id = $this->getID(); @@ -3074,12 +3070,12 @@ protected function _readDataSource($type, $query) { * @triggers Model.beforeFind $this, array($query) * @see Model::find() */ - public function buildQuery($type = 'first', $query = array()) { + public function buildQuery($type = 'first', $query = []) { $query = array_merge( - array( - 'conditions' => null, 'fields' => null, 'joins' => array(), 'limit' => null, + [ + 'conditions' => null, 'fields' => null, 'joins' => [], 'limit' => null, 'offset' => null, 'order' => null, 'page' => 1, 'group' => null, 'callbacks' => true, - ), + ], (array)$query ); @@ -3100,14 +3096,14 @@ public function buildQuery($type = 'first', $query = array()) { } if (is_object($query['order'])) { - $query['order'] = array($query['order']); + $query['order'] = [$query['order']]; } else { $query['order'] = (array)$query['order']; } if ($query['callbacks'] === true || $query['callbacks'] === 'before') { - $event = new CakeEvent('Model.beforeFind', $this, array($query)); - list($event->break, $event->breakOn, $event->modParams) = array(true, array(false, null), 0); + $event = new CakeEvent('Model.beforeFind', $this, [$query]); + [$event->break, $event->breakOn, $event->modParams] = [true, [false, null], 0]; $this->getEventManager()->dispatch($event); if ($event->isStopped()) { @@ -3129,7 +3125,7 @@ public function buildQuery($type = 'first', $query = array()) { * @return array * @see Model::find() */ - protected function _findAll($state, $query, $results = array()) { + protected function _findAll($state, $query, $results = []) { if ($state === 'before') { return $query; } @@ -3146,14 +3142,14 @@ protected function _findAll($state, $query, $results = array()) { * @return array * @see Model::find() */ - protected function _findFirst($state, $query, $results = array()) { + protected function _findFirst($state, $query, $results = []) { if ($state === 'before') { $query['limit'] = 1; return $query; } if (empty($results[0])) { - return array(); + return []; } return $results[0]; @@ -3168,7 +3164,7 @@ protected function _findFirst($state, $query, $results = array()) { * @return int|false The number of records found, or false * @see Model::find() */ - protected function _findCount($state, $query, $results = array()) { + protected function _findCount($state, $query, $results = []) { if ($state === 'before') { if (!empty($query['type']) && isset($this->findMethods[$query['type']]) && $query['type'] !== 'count') { $query['operation'] = 'count'; @@ -3190,15 +3186,15 @@ protected function _findCount($state, $query, $results = array()) { if (empty($query['fields'])) { $query['fields'] = $db->calculate($this, 'count'); } elseif (method_exists($db, 'expression') && is_string($query['fields']) && !preg_match('/count/i', $query['fields'])) { - $query['fields'] = $db->calculate($this, 'count', array( + $query['fields'] = $db->calculate($this, 'count', [ $db->expression($query['fields']), 'count' - )); + ]); } return $query; } - foreach (array(0, $this->alias) as $key) { + foreach ([0, $this->alias] as $key) { if (isset($results[0][$key]['count'])) { if ($query['group']) { return count($results); @@ -3220,52 +3216,52 @@ protected function _findCount($state, $query, $results = array()) { * @return array Key/value pairs of primary keys/display field values of all records found * @see Model::find() */ - protected function _findList($state, $query, $results = array()) { + protected function _findList($state, $query, $results = []) { if ($state === 'before') { if (empty($query['fields'])) { - $query['fields'] = array("{$this->alias}.{$this->primaryKey}", "{$this->alias}.{$this->displayField}"); - $list = array("{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null); + $query['fields'] = ["{$this->alias}.{$this->primaryKey}", "{$this->alias}.{$this->displayField}"]; + $list = ["{n}.{$this->alias}.{$this->primaryKey}", "{n}.{$this->alias}.{$this->displayField}", null]; } else { if (!is_array($query['fields'])) { $query['fields'] = CakeText::tokenize($query['fields']); } if (count($query['fields']) === 1) { - if (strpos($query['fields'][0], '.') === false) { + if (!str_contains($query['fields'][0], '.')) { $query['fields'][0] = $this->alias . '.' . $query['fields'][0]; } - $list = array("{n}.{$this->alias}.{$this->primaryKey}", '{n}.' . $query['fields'][0], null); - $query['fields'] = array("{$this->alias}.{$this->primaryKey}", $query['fields'][0]); + $list = ["{n}.{$this->alias}.{$this->primaryKey}", '{n}.' . $query['fields'][0], null]; + $query['fields'] = ["{$this->alias}.{$this->primaryKey}", $query['fields'][0]]; } elseif (count($query['fields']) === 3) { for ($i = 0; $i < 3; $i++) { - if (strpos($query['fields'][$i], '.') === false) { + if (!str_contains($query['fields'][$i], '.')) { $query['fields'][$i] = $this->alias . '.' . $query['fields'][$i]; } } - $list = array('{n}.' . $query['fields'][0], '{n}.' . $query['fields'][1], '{n}.' . $query['fields'][2]); + $list = ['{n}.' . $query['fields'][0], '{n}.' . $query['fields'][1], '{n}.' . $query['fields'][2]]; } else { for ($i = 0; $i < 2; $i++) { - if (strpos($query['fields'][$i], '.') === false) { + if (!str_contains($query['fields'][$i], '.')) { $query['fields'][$i] = $this->alias . '.' . $query['fields'][$i]; } } - $list = array('{n}.' . $query['fields'][0], '{n}.' . $query['fields'][1], null); + $list = ['{n}.' . $query['fields'][0], '{n}.' . $query['fields'][1], null]; } } if (!isset($query['recursive']) || $query['recursive'] === null) { $query['recursive'] = -1; } - list($query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']) = $list; + [$query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']] = $list; return $query; } if (empty($results)) { - return array(); + return []; } return Hash::combine($results, $query['list']['keyPath'], $query['list']['valuePath'], $query['list']['groupPath']); @@ -3280,13 +3276,13 @@ protected function _findList($state, $query, $results = array()) { * @param array $results Results. * @return array */ - protected function _findNeighbors($state, $query, $results = array()) { + protected function _findNeighbors($state, $query, $results = []) { extract($query); if ($state === 'before') { $conditions = (array)$conditions; if (isset($field) && isset($value)) { - if (strpos($field, '.') === false) { + if (!str_contains($field, '.')) { $field = $this->alias . '.' . $field; } } else { @@ -3294,7 +3290,7 @@ protected function _findNeighbors($state, $query, $results = array()) { $value = $this->id; } - $query['conditions'] = array_merge($conditions, array($field . ' <' => $value)); + $query['conditions'] = array_merge($conditions, [$field . ' <' => $value]); $query['order'] = $field . ' DESC'; $query['limit'] = 1; $query['field'] = $field; @@ -3304,7 +3300,7 @@ protected function _findNeighbors($state, $query, $results = array()) { } unset($query['conditions'][$field . ' <']); - $return = array(); + $return = []; if (isset($results[0])) { $prevVal = Hash::get($results[0], $field); $query['conditions'][$field . ' >='] = $prevVal; @@ -3319,7 +3315,7 @@ protected function _findNeighbors($state, $query, $results = array()) { $query['order'] = $field . ' ASC'; $neighbors = $this->find('all', $query); if (!array_key_exists('prev', $return)) { - $return['prev'] = isset($neighbors[0]) ? $neighbors[0] : null; + $return['prev'] = $neighbors[0] ?? null; } if (count($neighbors) === 2) { @@ -3342,7 +3338,7 @@ protected function _findNeighbors($state, $query, $results = array()) { * @param array $results Results. * @return array Threaded results */ - protected function _findThreaded($state, $query, $results = array()) { + protected function _findThreaded($state, $query, $results = []) { if ($state === 'before') { return $query; } @@ -3352,10 +3348,10 @@ protected function _findThreaded($state, $query, $results = array()) { $parent = $query['parent']; } - return Hash::nest($results, array( + return Hash::nest($results, [ 'idPath' => '{n}.' . $this->alias . '.' . $this->primaryKey, 'parentPath' => '{n}.' . $this->alias . '.' . $parent - )); + ]); } /** @@ -3367,7 +3363,7 @@ protected function _findThreaded($state, $query, $results = array()) { * @triggers Model.afterFind $this, array($results, $primary) */ protected function _filterResults($results, $primary = true) { - $event = new CakeEvent('Model.afterFind', $this, array($results, $primary)); + $event = new CakeEvent('Model.afterFind', $this, [$results, $primary]); $event->modParams = 0; $this->getEventManager()->dispatch($event); return $event->result; @@ -3388,7 +3384,7 @@ public function resetAssociations() { } } - $this->__backAssociation = array(); + $this->__backAssociation = []; } foreach ($this->_associations as $type) { @@ -3399,7 +3395,7 @@ public function resetAssociations() { } } - $this->__backAssociation = array(); + $this->__backAssociation = []; return true; } @@ -3423,7 +3419,7 @@ public function isUnique($fields, $or = true) { if (!$isRule) { $args = func_get_args(); $fields = $args[1]; - $or = isset($args[2]) ? $args[2] : true; + $or = $args[2] ?? true; } } if (!is_array($fields)) { @@ -3446,21 +3442,21 @@ public function isUnique($fields, $or = true) { } } - if (strpos($field, '.') === false) { + if (!str_contains($field, '.')) { unset($fields[$field]); $fields[$this->alias . '.' . $field] = $value; } } if ($or) { - $fields = array('or' => $fields); + $fields = ['or' => $fields]; } if (!empty($this->id)) { $fields[$this->alias . '.' . $this->primaryKey . ' !='] = $this->id; } - return !$this->find('count', array('conditions' => $fields, 'recursive' => -1)); + return !$this->find('count', ['conditions' => $fields, 'recursive' => -1]); } /** @@ -3487,7 +3483,7 @@ public function query($sql) { $params[] = $this->cacheQueries; } $db = $this->getDataSource(); - return call_user_func_array(array(&$db, 'query'), $params); + return call_user_func_array([&$db, 'query'], $params); } /** @@ -3499,7 +3495,7 @@ public function query($sql) { * @param array $options An optional array of custom options to be made available in the beforeValidate callback * @return bool True if there are no errors */ - public function validates($options = array()) { + public function validates($options = []) { return $this->validator()->validates($options); } @@ -3512,7 +3508,7 @@ public function validates($options = array()) { * @return array|bool Array of invalid fields and their error messages * @see Model::validates() */ - public function invalidFields($options = array()) { + public function invalidFields($options = []) { return $this->validator()->errors($options); } @@ -3536,7 +3532,7 @@ public function invalidate($field, $value = true) { * @return bool True if the field is a foreign key listed in the belongsTo array. */ public function isForeignKey($field) { - $foreignKeys = array(); + $foreignKeys = []; if (!empty($this->belongsTo)) { foreach ($this->belongsTo as $data) { $foreignKeys[] = $data['foreignKey']; @@ -3564,7 +3560,7 @@ public function escapeField($field = null, $alias = null) { } $db = $this->getDataSource(); - if (strpos($field, $db->name($alias) . '.') === 0) { + if (str_starts_with($field, $db->name($alias) . '.')) { return $field; } @@ -3669,7 +3665,7 @@ public function setDataSource($dataSource = null) { } $schema = $db->getSchemaName(); - $defaultProperties = get_class_vars(get_class($this)); + $defaultProperties = get_class_vars(static::class); if (isset($defaultProperties['schemaName'])) { $schema = $defaultProperties['schemaName']; } @@ -3707,7 +3703,7 @@ public function associations() { */ public function getAssociated($type = null) { if (!$type) { - $associated = array(); + $associated = []; foreach ($this->_associations as $assoc) { if (!empty($this->{$assoc})) { $models = array_keys($this->{$assoc}); @@ -3722,7 +3718,7 @@ public function getAssociated($type = null) { if (in_array($type, $this->_associations)) { if (empty($this->{$type})) { - return array(); + return []; } return array_keys($this->{$type}); @@ -3757,15 +3753,15 @@ public function getAssociated($type = null) { * @param array $keys Any join keys which must be merged with the keys queried * @return array */ - public function joinModel($assoc, $keys = array()) { + public function joinModel($assoc, $keys = []) { if (is_string($assoc)) { - list(, $assoc) = pluginSplit($assoc); - return array($assoc, array_keys($this->{$assoc}->schema())); + [, $assoc] = pluginSplit($assoc); + return [$assoc, array_keys($this->{$assoc}->schema())]; } if (is_array($assoc)) { $with = key($assoc); - return array($with, array_unique(array_merge($assoc[$with], $keys))); + return [$with, array_unique(array_merge($assoc[$with], $keys))]; } trigger_error( @@ -3809,7 +3805,7 @@ public function afterFind($results, $primary = false) { * @link https://book.cakephp.org/2.0/en/models/callback-methods.html#beforesave * @see Model::save() */ - public function beforeSave($options = array()) { + public function beforeSave($options = []) { return true; } @@ -3822,7 +3818,7 @@ public function beforeSave($options = array()) { * @link https://book.cakephp.org/2.0/en/models/callback-methods.html#aftersave * @see Model::save() */ - public function afterSave($created, $options = array()) { + public function afterSave($created, $options = []) { } /** @@ -3854,7 +3850,7 @@ public function afterDelete() { * @link https://book.cakephp.org/2.0/en/models/callback-methods.html#beforevalidate * @see Model::save() */ - public function beforeValidate($options = array()) { + public function beforeValidate($options = []) { return true; } @@ -3887,18 +3883,18 @@ protected function _clearCache($type = null) { return; } $pluralized = Inflector::pluralize($this->alias); - $assoc = array( + $assoc = [ strtolower($pluralized), Inflector::underscore($pluralized) - ); + ]; foreach ($this->_associations as $association) { foreach ($this->{$association} as $className) { $pluralizedAssociation = Inflector::pluralize($className['className']); if (!in_array(strtolower($pluralizedAssociation), $assoc)) { - $assoc = array_merge($assoc, array( + $assoc = array_merge($assoc, [ strtolower($pluralizedAssociation), Inflector::underscore($pluralizedAssociation) - )); + ]); } } } diff --git a/lib/Cake/Model/ModelBehavior.php b/lib/Cake/Model/ModelBehavior.php index a5193ee031..47f3785544 100644 --- a/lib/Cake/Model/ModelBehavior.php +++ b/lib/Cake/Model/ModelBehavior.php @@ -72,7 +72,7 @@ class ModelBehavior extends CakeObject { * @var array * @see Model::$alias */ - public $settings = array(); + public $settings = []; /** * Allows the mapping of preg-compatible regular expressions to public or @@ -82,7 +82,7 @@ class ModelBehavior extends CakeObject { * * @var array */ - public $mapMethods = array(); + public $mapMethods = []; /** * Setup this behavior with the specified configuration settings. @@ -91,7 +91,7 @@ class ModelBehavior extends CakeObject { * @param array $config Configuration settings for $model * @return void */ - public function setup(Model $model, $config = array()) { + public function setup(Model $model, $config = []) { } /** @@ -143,7 +143,7 @@ public function afterFind(Model $model, $results, $primary = false) { * @return mixed False or null will abort the operation. Any other result will continue. * @see Model::save() */ - public function beforeValidate(Model $model, $options = array()) { + public function beforeValidate(Model $model, $options = []) { return true; } @@ -167,7 +167,7 @@ public function afterValidate(Model $model) { * @return mixed False if the operation should abort. Any other result will continue. * @see Model::save() */ - public function beforeSave(Model $model, $options = array()) { + public function beforeSave(Model $model, $options = []) { return true; } @@ -180,7 +180,7 @@ public function beforeSave(Model $model, $options = array()) { * @return bool * @see Model::save() */ - public function afterSave(Model $model, $created, $options = array()) { + public function afterSave(Model $model, $created, $options = []) { return true; } diff --git a/lib/Cake/Model/ModelValidator.php b/lib/Cake/Model/ModelValidator.php index 17f4026494..8a102a9f77 100644 --- a/lib/Cake/Model/ModelValidator.php +++ b/lib/Cake/Model/ModelValidator.php @@ -39,14 +39,14 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable { * * @var CakeValidationSet[] */ - protected $_fields = array(); + protected $_fields = []; /** * Holds the reference to the model this Validator is attached to * * @var Model */ - protected $_model = array(); + protected $_model = []; /** * The validators $validate property, used for checking whether validation @@ -54,7 +54,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable { * * @var array */ - protected $_validate = array(); + protected $_validate = []; /** * Holds the available custom callback methods, usually taken from model methods @@ -62,21 +62,21 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable { * * @var array */ - protected $_methods = array(); + protected $_methods = []; /** * Holds the available custom callback methods from the model * * @var array */ - protected $_modelMethods = array(); + protected $_modelMethods = []; /** * Holds the list of behavior names that were attached when this object was created * * @var array */ - protected $_behaviors = array(); + protected $_behaviors = []; /** * Constructor @@ -96,7 +96,7 @@ public function __construct(Model $Model) { * @param array $options An optional array of custom options to be made available in the beforeValidate callback * @return bool True if there are no errors */ - public function validates($options = array()) { + public function validates($options = []) { $errors = $this->errors($options); if (empty($errors) && $errors !== false) { $errors = $this->_validateWithModels($options); @@ -126,10 +126,10 @@ public function validates($options = array()) { * Otherwise: array similar to the $data array passed, but values are set to true/false * depending on whether each record validated successfully. */ - public function validateAssociated(&$data, $options = array()) { + public function validateAssociated(&$data, $options = []) { $model = $this->getModel(); - $options += array('atomic' => true, 'deep' => false); - $model->validationErrors = $validationErrors = $return = array(); + $options += ['atomic' => true, 'deep' => false]; + $model->validationErrors = $validationErrors = $return = []; $model->create(null); $return[$model->alias] = true; if (!($model->set($data) && $model->validates($options))) { @@ -147,7 +147,7 @@ public function validateAssociated(&$data, $options = array()) { foreach ($data as $association => &$values) { $validates = true; if (isset($associations[$association])) { - if (in_array($associations[$association], array('belongsTo', 'hasOne'))) { + if (in_array($associations[$association], ['belongsTo', 'hasOne'])) { if ($options['deep']) { $validates = $model->{$association}->validateAssociated($values, $options); } else { @@ -203,10 +203,10 @@ public function validateAssociated(&$data, $options = array()) { * Otherwise: array similar to the $data array passed, but values are set to true/false * depending on whether each record validated successfully. */ - public function validateMany(&$data, $options = array()) { + public function validateMany(&$data, $options = []) { $model = $this->getModel(); - $options += array('atomic' => true, 'deep' => false); - $model->validationErrors = $validationErrors = $return = array(); + $options += ['atomic' => true, 'deep' => false]; + $model->validationErrors = $validationErrors = $return = []; foreach ($data as $key => &$record) { if ($options['deep']) { $validates = $model->validateAssociated($record, $options); @@ -239,7 +239,7 @@ public function validateMany(&$data, $options = array()) { * @triggers Model.afterValidate $model * @see ModelValidator::validates() */ - public function errors($options = array()) { + public function errors($options = []) { if (!$this->_triggerBeforeValidate($options)) { return false; } @@ -265,7 +265,7 @@ public function errors($options = array()) { foreach ($fields as $field) { $field->setMethods($methods); $field->setValidationDomain($model->validationDomain); - $data = isset($model->data[$model->alias]) ? $model->data[$model->alias] : array(); + $data = $model->data[$model->alias] ?? []; $errors = $field->validate($data, $exists); foreach ($errors as $error) { $this->invalidate($field->field, $error); @@ -303,13 +303,13 @@ public function getMethods() { if (empty($this->_modelMethods)) { foreach (get_class_methods($this->_model) as $method) { - $this->_modelMethods[strtolower($method)] = array($this->_model, $method); + $this->_modelMethods[strtolower($method)] = [$this->_model, $method]; } } $methods = $this->_modelMethods; foreach (array_keys($this->_model->Behaviors->methods()) as $method) { - $methods += array(strtolower($method) => array($this->_model, $method)); + $methods += [strtolower($method) => [$this->_model, $method]]; } return $this->_methods = $methods; @@ -345,13 +345,13 @@ protected function _parseRules() { } if (empty($this->_model->validate)) { - $this->_validate = array(); - $this->_fields = array(); + $this->_validate = []; + $this->_fields = []; return false; } $this->_validate = $this->_model->validate; - $this->_fields = array(); + $this->_fields = []; $methods = $this->getMethods(); foreach ($this->_validate as $fieldName => $ruleSet) { $this->_fields[$fieldName] = new CakeValidationSet($fieldName, $ruleSet); @@ -389,13 +389,13 @@ public function getModel() { * @param array $fieldList list of fields to be used for validation * @return CakeValidationSet[] List of validation rules to be applied */ - protected function _validationList($fieldList = array()) { + protected function _validationList($fieldList = []) { if (empty($fieldList) || Hash::dimensions($fieldList) > 1) { return $this->_fields; } - $validateList = array(); - $this->validationErrors = array(); + $validateList = []; + $this->validationErrors = []; foreach ((array)$fieldList as $f) { if (!empty($this->_fields[$f])) { $validateList[$f] = $this->_fields[$f]; @@ -421,10 +421,10 @@ protected function _validateWithModels($options) { if (empty($association['with']) || !isset($model->data[$assoc])) { continue; } - list($join) = $model->joinModel($model->hasAndBelongsToMany[$assoc]['with']); + [$join] = $model->joinModel($model->hasAndBelongsToMany[$assoc]['with']); $data = $model->data[$assoc]; - $newData = array(); + $newData = []; foreach ((array)$data as $row) { if (isset($row[$model->hasAndBelongsToMany[$assoc]['associationForeignKey']])) { $newData[] = $row; @@ -448,10 +448,10 @@ protected function _validateWithModels($options) { * @return bool * @triggers Model.beforeValidate $model, array($options) */ - protected function _triggerBeforeValidate($options = array()) { + protected function _triggerBeforeValidate($options = []) { $model = $this->getModel(); - $event = new CakeEvent('Model.beforeValidate', $model, array($options)); - list($event->break, $event->breakOn) = array(true, false); + $event = new CakeEvent('Model.beforeValidate', $model, [$options]); + [$event->break, $event->breakOn] = [true, false]; $model->getEventManager()->dispatch($event); if ($event->isStopped()) { return false; @@ -560,7 +560,7 @@ public function add($field, $name, $rule = null) { } if (!isset($this->_fields[$field])) { - $rule = (is_string($name)) ? array($name => $rule) : $name; + $rule = (is_string($name)) ? [$name => $rule] : $name; $this->_fields[$field] = new CakeValidationSet($field, $rule); } else { if (is_string($name)) { diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index dc3dcf526a..7b042befb8 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -42,7 +42,7 @@ class Permission extends AppModel { * * @var array */ - public $belongsTo = array('Aro', 'Aco'); + public $belongsTo = ['Aro', 'Aco']; /** * No behaviors for this model @@ -110,18 +110,18 @@ public function check($aro, $aco, $action = '*') { $acoIDs = Hash::extract($acoPath, '{n}.' . $this->Aco->alias . '.id'); $count = count($aroPath); - $inherited = array(); + $inherited = []; for ($i = 0; $i < $count; $i++) { $permAlias = $this->alias; - $perms = $this->find('all', array( - 'conditions' => array( + $perms = $this->find('all', [ + 'conditions' => [ "{$permAlias}.aro_id" => $aroPath[$i][$this->Aro->alias]['id'], "{$permAlias}.aco_id" => $acoIDs - ), - 'order' => array($this->Aco->alias . '.lft' => 'desc'), + ], + 'order' => [$this->Aco->alias . '.lft' => 'desc'], 'recursive' => 0 - )); + ]); if (empty($perms)) { continue; @@ -173,7 +173,7 @@ public function check($aro, $aco, $action = '*') { public function allow($aro, $aco, $actions = '*', $value = 1) { $perms = $this->getAclLink($aro, $aco); $permKeys = $this->getAcoKeys($this->schema()); - $save = array(); + $save = []; if (!$perms) { $this->log(__d('cake_dev', '%s - Invalid node', 'DbAcl::allow()'), E_USER_WARNING); @@ -184,10 +184,10 @@ public function allow($aro, $aco, $actions = '*', $value = 1) { } if ($actions === '*') { - $save = array_combine($permKeys, array_pad(array(), count($permKeys), $value)); + $save = array_combine($permKeys, array_pad([], count($permKeys), $value)); } else { if (!is_array($actions)) { - $actions = array('_' . $actions); + $actions = ['_' . $actions]; } foreach ($actions as $action) { if ($action[0] !== '_') { @@ -199,7 +199,7 @@ public function allow($aro, $aco, $actions = '*', $value = 1) { $save[$action] = $value; } } - list($save['aro_id'], $save['aco_id']) = array($perms['aro'], $perms['aco']); + [$save['aro_id'], $save['aco_id']] = [$perms['aro'], $perms['aco']]; if ($perms['link'] && !empty($perms['link'])) { $save['id'] = $perms['link'][0][$this->alias]['id']; @@ -218,7 +218,7 @@ public function allow($aro, $aco, $actions = '*', $value = 1) { * @return array Indexed array with: 'aro', 'aco' and 'link' */ public function getAclLink($aro, $aco) { - $obj = array(); + $obj = []; $obj['Aro'] = $this->Aro->node($aro); $obj['Aco'] = $this->Aco->node($aco); @@ -230,14 +230,14 @@ public function getAclLink($aro, $aco) { $aro = current($aro); $aco = current($aco); - return array( + return [ 'aro' => $aro, 'aco' => $aco, - 'link' => $this->find('all', array('conditions' => array( + 'link' => $this->find('all', ['conditions' => [ $this->alias . '.aro_id' => $aro, $this->alias . '.aco_id' => $aco - ))) - ); + ]]) + ]; } /** @@ -247,10 +247,10 @@ public function getAclLink($aro, $aco) { * @return array permission keys */ public function getAcoKeys($keys) { - $newKeys = array(); + $newKeys = []; $keys = array_keys($keys); foreach ($keys as $key) { - if (!in_array($key, array('id', 'aro_id', 'aco_id'))) { + if (!in_array($key, ['id', 'aro_id', 'aco_id'])) { $newKeys[] = $key; } } diff --git a/lib/Cake/Model/Validator/CakeValidationRule.php b/lib/Cake/Model/Validator/CakeValidationRule.php index d27c7b464e..c571d06dbc 100644 --- a/lib/Cake/Model/Validator/CakeValidationRule.php +++ b/lib/Cake/Model/Validator/CakeValidationRule.php @@ -55,14 +55,14 @@ class CakeValidationRule { * * @var array */ - protected $_ruleParams = array(); + protected $_ruleParams = []; /** * Holds passed in options * * @var array */ - protected $_passedOptions = array(); + protected $_passedOptions = []; /** * The 'rule' key @@ -111,7 +111,7 @@ class CakeValidationRule { * * @param array $validator [optional] The validator properties */ - public function __construct($validator = array()) { + public function __construct($validator = []) { $this->_addValidatorProps($validator); } @@ -143,7 +143,7 @@ public function isEmptyAllowed() { * @return bool */ public function isRequired() { - if (in_array($this->required, array('create', 'update'), true)) { + if (in_array($this->required, ['create', 'update'], true)) { if ($this->required === 'create' && !$this->isUpdate() || $this->required === 'update' && $this->isUpdate()) { return true; } @@ -227,14 +227,14 @@ protected function _getPropertiesArray() { if (!is_string($rule)) { unset($rule[0]); } - return array( + return [ 'rule' => $rule, 'required' => $this->required, 'allowEmpty' => $this->allowEmpty, 'on' => $this->on, 'last' => $this->last, 'message' => $this->message - ); + ]; } /** @@ -271,10 +271,10 @@ public function process($field, &$data, &$methods) { $rule = strtolower($this->_rule); if (isset($methods[$rule])) { $this->_ruleParams[] = array_merge($validator, $this->_passedOptions); - $this->_ruleParams[0] = array($field => $this->_ruleParams[0]); + $this->_ruleParams[0] = [$field => $this->_ruleParams[0]]; $this->_valid = call_user_func_array($methods[$rule], $this->_ruleParams); } elseif (class_exists('Validation') && method_exists('Validation', $this->_rule)) { - $this->_valid = call_user_func_array(array('Validation', $this->_rule), $this->_ruleParams); + $this->_valid = call_user_func_array(['Validation', $this->_rule], $this->_ruleParams); } elseif (is_string($validator['rule'])) { $this->_valid = preg_match($this->_rule, $data[$field]); } else { @@ -315,13 +315,13 @@ public function getOptions($key) { * @param array $validator [optional] * @return void */ - protected function _addValidatorProps($validator = array()) { + protected function _addValidatorProps($validator = []) { if (!is_array($validator)) { - $validator = array('rule' => $validator); + $validator = ['rule' => $validator]; } foreach ($validator as $key => $value) { if (isset($value) || !empty($value)) { - if (in_array($key, array('rule', 'required', 'allowEmpty', 'on', 'message', 'last'))) { + if (in_array($key, ['rule', 'required', 'allowEmpty', 'on', 'message', 'last'])) { $this->{$key} = $validator[$key]; } else { $this->_passedOptions[$key] = $value; @@ -340,10 +340,10 @@ protected function _addValidatorProps($validator = array()) { protected function _parseRule($field, &$data) { if (is_array($this->rule)) { $this->_rule = $this->rule[0]; - $this->_ruleParams = array_merge(array($data[$field]), array_values(array_slice($this->rule, 1))); + $this->_ruleParams = array_merge([$data[$field]], array_values(array_slice($this->rule, 1))); } else { $this->_rule = $this->rule; - $this->_ruleParams = array($data[$field]); + $this->_ruleParams = [$data[$field]]; } } diff --git a/lib/Cake/Model/Validator/CakeValidationSet.php b/lib/Cake/Model/Validator/CakeValidationSet.php index 9ff103b56b..22a47c3cde 100644 --- a/lib/Cake/Model/Validator/CakeValidationSet.php +++ b/lib/Cake/Model/Validator/CakeValidationSet.php @@ -34,14 +34,14 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable { * * @var CakeValidationRule[] */ - protected $_rules = array(); + protected $_rules = []; /** * List of methods available for validation * * @var array */ - protected $_methods = array(); + protected $_methods = []; /** * I18n domain for validation messages. @@ -57,31 +57,25 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable { */ public $isStopped = false; -/** - * Holds the fieldname - * - * @var string - */ - public $field = null; - /** * Holds the original ruleSet * * @var array */ - public $ruleSet = array(); + public $ruleSet = []; /** - * Constructor - * - * @param string $fieldName The fieldname. - * @param array $ruleSet Rules set. - */ - public function __construct($fieldName, $ruleSet) { - $this->field = $fieldName; - + * Constructor + * + * @param string $field The fieldname. + * @param array $ruleSet Rules set. + */ + public function __construct(/** + * Holds the fieldname + */ + public $field, $ruleSet) { if (!is_array($ruleSet) || (is_array($ruleSet) && isset($ruleSet['rule']))) { - $ruleSet = array($ruleSet); + $ruleSet = [$ruleSet]; } foreach ($ruleSet as $index => $validateProp) { @@ -120,7 +114,7 @@ public function setValidationDomain($validationDomain) { */ public function validate($data, $isUpdate = false) { $this->reset(); - $errors = array(); + $errors = []; foreach ($this->getRules() as $name => $rule) { $rule->isUpdate($isUpdate); if ($rule->skip()) { @@ -236,9 +230,9 @@ public function removeRule($name) { * @param bool $mergeVars [optional] If true, merges vars instead of replace. Defaults to true. * @return self */ - public function setRules($rules = array(), $mergeVars = true) { + public function setRules($rules = [], $mergeVars = true) { if ($mergeVars === false) { - $this->_rules = array(); + $this->_rules = []; } foreach ($rules as $name => $rule) { $this->setRule($name, $rule); diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index f8f5e176c8..192e6f01c4 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -39,13 +39,13 @@ class CakeRequest implements ArrayAccess { * * @var array */ - public $params = array( + public $params = [ 'plugin' => null, 'controller' => null, 'action' => null, - 'named' => array(), - 'pass' => array(), - ); + 'named' => [], + 'pass' => [], + ]; /** * Array of POST data. Will contain form data as well as uploaded files. @@ -55,14 +55,14 @@ class CakeRequest implements ArrayAccess { * * @var array */ - public $data = array(); + public $data = []; /** * Array of querystring arguments * * @var array */ - public $query = array(); + public $query = []; /** * The URL string used for the request. @@ -100,27 +100,27 @@ class CakeRequest implements ArrayAccess { * * @var array */ - protected $_detectors = array( - 'get' => array('env' => 'REQUEST_METHOD', 'value' => 'GET'), - 'patch' => array('env' => 'REQUEST_METHOD', 'value' => 'PATCH'), - 'post' => array('env' => 'REQUEST_METHOD', 'value' => 'POST'), - 'put' => array('env' => 'REQUEST_METHOD', 'value' => 'PUT'), - 'delete' => array('env' => 'REQUEST_METHOD', 'value' => 'DELETE'), - 'head' => array('env' => 'REQUEST_METHOD', 'value' => 'HEAD'), - 'options' => array('env' => 'REQUEST_METHOD', 'value' => 'OPTIONS'), - 'ssl' => array('env' => 'HTTPS', 'value' => 1), - 'ajax' => array('env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'), - 'flash' => array('env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'), - 'mobile' => array('env' => 'HTTP_USER_AGENT', 'options' => array( + protected $_detectors = [ + 'get' => ['env' => 'REQUEST_METHOD', 'value' => 'GET'], + 'patch' => ['env' => 'REQUEST_METHOD', 'value' => 'PATCH'], + 'post' => ['env' => 'REQUEST_METHOD', 'value' => 'POST'], + 'put' => ['env' => 'REQUEST_METHOD', 'value' => 'PUT'], + 'delete' => ['env' => 'REQUEST_METHOD', 'value' => 'DELETE'], + 'head' => ['env' => 'REQUEST_METHOD', 'value' => 'HEAD'], + 'options' => ['env' => 'REQUEST_METHOD', 'value' => 'OPTIONS'], + 'ssl' => ['env' => 'HTTPS', 'value' => 1], + 'ajax' => ['env' => 'HTTP_X_REQUESTED_WITH', 'value' => 'XMLHttpRequest'], + 'flash' => ['env' => 'HTTP_USER_AGENT', 'pattern' => '/^(Shockwave|Adobe) Flash/'], + 'mobile' => ['env' => 'HTTP_USER_AGENT', 'options' => [ 'Android', 'AvantGo', 'BB10', 'BlackBerry', 'DoCoMo', 'Fennec', 'iPod', 'iPhone', 'iPad', 'J2ME', 'MIDP', 'NetFront', 'Nokia', 'Opera Mini', 'Opera Mobi', 'PalmOS', 'PalmSource', 'portalmmm', 'Plucker', 'ReqwirelessWeb', 'SonyEricsson', 'Symbian', 'UP\\.Browser', 'webOS', 'Windows CE', 'Windows Phone OS', 'Xiino' - )), - 'requested' => array('param' => 'requested', 'value' => 1), - 'json' => array('accept' => array('application/json'), 'param' => 'ext', 'value' => 'json'), - 'xml' => array('accept' => array('application/xml', 'text/xml'), 'param' => 'ext', 'value' => 'xml'), - ); + ]], + 'requested' => ['param' => 'requested', 'value' => 1], + 'json' => ['accept' => ['application/json'], 'param' => 'ext', 'value' => 'json'], + 'xml' => ['accept' => ['application/xml', 'text/xml'], 'param' => 'ext', 'value' => 'xml'], + ]; /** * Copy of php://input. Since this stream can only be read once in most SAPI's @@ -171,7 +171,7 @@ protected function _processPost() { if ($_POST) { $this->data = $_POST; } elseif (($this->is('put') || $this->is('delete')) && - strpos($this->contentType(), 'application/x-www-form-urlencoded') === 0 + str_starts_with($this->contentType(), 'application/x-www-form-urlencoded') ) { $data = $this->_readInput(); parse_str($data, $this->data); @@ -197,8 +197,8 @@ protected function _processPost() { unset($this->data['_method']); } - if ($override && !in_array($override, array('POST', 'PUT', 'PATCH', 'DELETE'))) { - $this->data = array(); + if ($override && !in_array($override, ['POST', 'PUT', 'PATCH', 'DELETE'])) { + $this->data = []; } if ($isArray && isset($this->data['data'])) { @@ -224,11 +224,11 @@ protected function _processGet() { $query = $_GET; } - $unsetUrl = '/' . str_replace(array('.', ' '), '_', urldecode($this->url)); + $unsetUrl = '/' . str_replace(['.', ' '], '_', urldecode($this->url)); unset($query[$unsetUrl]); unset($query[$this->base . $unsetUrl]); - if (strpos($this->url, '?') !== false) { - list($this->url, $querystr) = explode('?', $this->url); + if (str_contains($this->url, '?')) { + [$this->url, $querystr] = explode('?', $this->url); parse_str($querystr, $queryArgs); $query += $queryArgs; } @@ -249,7 +249,7 @@ protected function _url() { $uri = ''; if (!empty($_SERVER['PATH_INFO'])) { return $_SERVER['PATH_INFO']; - } elseif (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '://') === false) { + } elseif (isset($_SERVER['REQUEST_URI']) && !str_contains($_SERVER['REQUEST_URI'], '://')) { $uri = $_SERVER['REQUEST_URI']; } elseif (isset($_SERVER['REQUEST_URI'])) { $qPosition = strpos($_SERVER['REQUEST_URI'], '?'); @@ -257,7 +257,7 @@ protected function _url() { $uri = $_SERVER['REQUEST_URI']; } else { $baseUrl = Configure::read('App.fullBaseUrl'); - if (substr($_SERVER['REQUEST_URI'], 0, strlen($baseUrl)) === $baseUrl) { + if (str_starts_with($_SERVER['REQUEST_URI'], $baseUrl)) { $uri = substr($_SERVER['REQUEST_URI'], strlen($baseUrl)); } } @@ -271,11 +271,11 @@ protected function _url() { $base = $this->base; - if (strlen($base) > 0 && strpos($uri, $base) === 0) { + if (strlen($base) > 0 && str_starts_with($uri, $base)) { $uri = substr($uri, strlen($base)); } - if (strpos($uri, '?') !== false) { - list($uri) = explode('?', $uri, 2); + if (str_contains($uri, '?')) { + [$uri] = explode('?', $uri, 2); } if (empty($uri) || $uri === '/' || $uri === '//' || $uri === '/index.php') { $uri = '/'; @@ -349,10 +349,10 @@ protected function _base() { $docRootContainsWebroot = strpos($docRoot, $dir . DS . $webroot); if (!empty($base) || !$docRootContainsWebroot) { - if (strpos($this->webroot, '/' . $dir . '/') === false) { + if (!str_contains($this->webroot, '/' . $dir . '/')) { $this->webroot .= $dir . '/'; } - if (strpos($this->webroot, '/' . $webroot . '/') === false) { + if (!str_contains($this->webroot, '/' . $webroot . '/')) { $this->webroot .= $webroot . '/'; } } @@ -446,9 +446,9 @@ public function referer($local = false) { $base = Configure::read('App.fullBaseUrl') . $this->webroot; if (!empty($ref) && !empty($base)) { - if ($local && strpos($ref, $base) === 0) { + if ($local && str_starts_with($ref, $base)) { $ref = substr($ref, strlen($base)); - if (!strlen($ref) || strpos($ref, '//') === 0) { + if (!strlen($ref) || str_starts_with($ref, '//')) { $ref = '/'; } if ($ref[0] !== '/') { @@ -471,7 +471,7 @@ public function referer($local = false) { * @throws CakeException when an invalid method is called. */ public function __call($name, $params) { - if (strpos($name, 'is') === 0) { + if (str_starts_with($name, 'is')) { $type = strtolower(substr($name, 2)); return $this->is($type); } @@ -487,10 +487,7 @@ public function __call($name, $params) { * @return mixed Either the value of the parameter or null. */ public function __get($name) { - if (isset($this->params[$name])) { - return $this->params[$name]; - } - return null; + return $this->params[$name] ?? null; } /** @@ -555,7 +552,7 @@ public function is($type) { */ protected function _extensionDetector($detect) { if (is_string($detect['extension'])) { - $detect['extension'] = array($detect['extension']); + $detect['extension'] = [$detect['extension']]; } if (in_array($this->params['ext'], $detect['extension'])) { return true; @@ -733,7 +730,7 @@ public function addParams($params) { * @return self */ public function addPaths($paths) { - foreach (array('webroot', 'here', 'base') as $element) { + foreach (['webroot', 'here', 'base'] as $element) { if (isset($paths[$element])) { $this->{$element} = $paths[$element]; } @@ -769,12 +766,7 @@ public static function header($name) { if (isset($_SERVER[$httpName])) { return $_SERVER[$httpName]; } - // Use the provided value, in some configurations apache will - // pass Authorization with no prefix and in Titlecase. - if (isset($_SERVER[$name])) { - return $_SERVER[$name]; - } - return false; + return $_SERVER[$name] ?? false; } /** @@ -853,7 +845,7 @@ public function subdomains($tldLength = 1) { */ public function accepts($type = null) { $raw = $this->parseAccept(); - $accept = array(); + $accept = []; foreach ($raw as $types) { $accept = array_merge($accept, $types); } @@ -873,7 +865,7 @@ public function accepts($type = null) { * @return array An array of prefValue => array(content/types) */ public function parseAccept() { - return $this->_parseAcceptWithQualifier($this->header('accept')); + return static::_parseAcceptWithQualifier(static::header('accept')); } /** @@ -892,7 +884,7 @@ public function parseAccept() { */ public static function acceptLanguage($language = null) { $raw = static::_parseAcceptWithQualifier(static::header('Accept-Language')); - $accept = array(); + $accept = []; foreach ($raw as $languages) { foreach ($languages as &$lang) { if (strpos($lang, '_')) { @@ -918,7 +910,7 @@ public static function acceptLanguage($language = null) { * @return array */ protected static function _parseAcceptWithQualifier($header) { - $accept = array(); + $accept = []; $header = explode(',', $header); foreach (array_filter($header) as $value) { $prefValue = '1.0'; @@ -937,7 +929,7 @@ protected static function _parseAcceptWithQualifier($header) { } if (!isset($accept[$prefValue])) { - $accept[$prefValue] = array(); + $accept[$prefValue] = []; } if ($prefValue) { $accept[$prefValue][] = $value; diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index 6ad28da512..0aa05a09b3 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -26,14 +26,14 @@ * * @package Cake.Network */ -class CakeResponse { +class CakeResponse implements \Stringable { /** * Holds HTTP response statuses * * @var array */ - protected $_statusCodes = array( + protected $_statusCodes = [ 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', @@ -75,17 +75,17 @@ class CakeResponse { 503 => 'Service Unavailable', 504 => 'Gateway Time-out', 505 => 'Unsupported Version' - ); + ]; /** * Holds known mime type mappings * * @var array */ - protected $_mimeTypes = array( - 'html' => array('text/html', '*/*'), + protected $_mimeTypes = [ + 'html' => ['text/html', '*/*'], 'json' => 'application/json', - 'xml' => array('application/xml', 'text/xml'), + 'xml' => ['application/xml', 'text/xml'], 'rss' => 'application/rss+xml', 'ai' => 'application/postscript', 'bcpio' => 'application/x-bcpio', @@ -96,7 +96,7 @@ class CakeResponse { 'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh', - 'csv' => array('text/csv', 'application/vnd.ms-excel'), + 'csv' => ['text/csv', 'application/vnd.ms-excel'], 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dms' => 'application/octet-stream', @@ -218,7 +218,7 @@ class CakeResponse { 'f90' => 'text/plain', 'h' => 'text/plain', 'hh' => 'text/plain', - 'htm' => array('text/html', '*/*'), + 'htm' => ['text/html', '*/*'], 'ics' => 'text/calendar', 'm' => 'text/plain', 'rtf' => 'text/rtf', @@ -265,14 +265,14 @@ class CakeResponse { 'xbm' => 'image/x-xbitmap', 'xpm' => 'image/x-xpixmap', 'xwd' => 'image/x-xwindowdump', - 'psd' => array( + 'psd' => [ 'application/photoshop', 'application/psd', 'image/psd', 'image/x-photoshop', 'image/photoshop', 'zz-application/zz-winassoc-psd' - ), + ], 'ice' => 'x-conference/x-cooltalk', 'iges' => 'model/iges', 'igs' => 'model/iges', @@ -287,11 +287,11 @@ class CakeResponse { 'javascript' => 'application/javascript', 'form' => 'application/x-www-form-urlencoded', 'file' => 'multipart/form-data', - 'xhtml' => array('application/xhtml+xml', 'application/xhtml', 'text/xhtml'), + 'xhtml' => ['application/xhtml+xml', 'application/xhtml', 'text/xhtml'], 'xhtml-mobile' => 'application/vnd.wap.xhtml+xml', 'atom' => 'application/atom+xml', 'amf' => 'application/x-amf', - 'wap' => array('text/vnd.wap.wml', 'text/vnd.wap.wmlscript', 'image/vnd.wap.wbmp'), + 'wap' => ['text/vnd.wap.wml', 'text/vnd.wap.wmlscript', 'image/vnd.wap.wbmp'], 'wml' => 'text/vnd.wap.wml', 'wmlscript' => 'text/vnd.wap.wmlscript', 'wbmp' => 'image/vnd.wap.wbmp', @@ -311,7 +311,7 @@ class CakeResponse { 'mkv' => 'video/x-matroska', 'pkpass' => 'application/vnd.apple.pkpass', 'ajax' => 'text/html' - ); + ]; /** * Protocol header to send to the client @@ -340,7 +340,7 @@ class CakeResponse { * * @var array */ - protected $_headers = array(); + protected $_headers = []; /** * Buffer string for response message @@ -376,14 +376,14 @@ class CakeResponse { * * @var array */ - protected $_cacheDirectives = array(); + protected $_cacheDirectives = []; /** * Holds cookies to be sent to the client * * @var array */ - protected $_cookies = array(); + protected $_cookies = []; /** * Constructor @@ -395,7 +395,7 @@ class CakeResponse { * - type: a complete mime-type string or an extension mapped in this class * - charset: the charset for the response body */ - public function __construct(array $options = array()) { + public function __construct(array $options = []) { if (isset($options['body'])) { $this->body($options['body']); } @@ -454,8 +454,7 @@ public function send() { protected function _setCookies() { foreach ($this->_cookies as $name => $c) { setcookie( - $name, $c['value'], $c['expire'], $c['path'], - $c['domain'], $c['secure'], $c['httpOnly'] + $name, $c['value'], ['expires' => $c['expire'], 'path' => $c['path'], 'domain' => $c['domain'], 'secure' => $c['secure'], 'httponly' => $c['httpOnly']] ); } } @@ -467,16 +466,16 @@ protected function _setCookies() { * @return void */ protected function _setContentType() { - if (in_array($this->_status, array(304, 204))) { + if (in_array($this->_status, [304, 204])) { return; } - $whitelist = array( + $whitelist = [ 'application/javascript', 'application/json', 'application/xml', 'application/rss+xml' - ); + ]; $charset = false; if ($this->_charset && - (strpos($this->_contentType, 'text/') === 0 || in_array($this->_contentType, $whitelist)) + (str_starts_with($this->_contentType, 'text/') || in_array($this->_contentType, $whitelist)) ) { $charset = true; } @@ -494,7 +493,7 @@ protected function _setContentType() { * @return void */ protected function _setContent() { - if (in_array($this->_status, array(304, 204))) { + if (in_array($this->_status, [304, 204])) { $this->body(''); } } @@ -582,13 +581,13 @@ public function header($header = null, $value = null) { if ($header === null) { return $this->_headers; } - $headers = is_array($header) ? $header : array($header => $value); + $headers = is_array($header) ? $header : [$header => $value]; foreach ($headers as $header => $value) { if (is_numeric($header)) { - list($header, $value) = array($value, null); + [$header, $value] = [$value, null]; } - if ($value === null && strpos($header, ':') !== false) { - list($header, $value) = explode(':', $header, 2); + if ($value === null && str_contains($header, ':')) { + [$header, $value] = explode(':', $header, 2); } $this->_headers[$header] = is_array($value) ? array_map('trim', $value) : trim($value); } @@ -607,7 +606,7 @@ public function header($header = null, $value = null) { public function location($url = null) { if ($url === null) { $headers = $this->header(); - return isset($headers['Location']) ? $headers['Location'] : null; + return $headers['Location'] ?? null; } $this->header('Location', $url); return null; @@ -693,7 +692,7 @@ public function httpCodes($code = null) { if (!isset($this->_statusCodes[$code])) { return null; } - return array($code => $this->_statusCodes[$code]); + return [$code => $this->_statusCodes[$code]]; } /** @@ -735,7 +734,7 @@ public function type($contentType = null) { $contentType = $this->_mimeTypes[$contentType]; $contentType = is_array($contentType) ? current($contentType) : $contentType; } - if (strpos($contentType, '/') === false) { + if (!str_contains($contentType, '/')) { return false; } return $this->_contentType = $contentType; @@ -750,10 +749,7 @@ public function type($contentType = null) { * @return mixed string mapped mime type or false if $alias is not mapped */ public function getMimeType($alias) { - if (isset($this->_mimeTypes[$alias])) { - return $this->_mimeTypes[$alias]; - } - return false; + return $this->_mimeTypes[$alias] ?? false; } /** @@ -766,7 +762,7 @@ public function getMimeType($alias) { */ public function mapType($ctype) { if (is_array($ctype)) { - return array_map(array($this, 'mapType'), $ctype); + return array_map([$this, 'mapType'], $ctype); } foreach ($this->_mimeTypes as $alias => $types) { @@ -797,11 +793,11 @@ public function charset($charset = null) { * @return void */ public function disableCache() { - $this->header(array( + $this->header([ 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate("D, d M Y H:i:s") . " GMT", 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' - )); + ]); } /** @@ -815,9 +811,9 @@ public function cache($since, $time = '+1 day') { if (!is_int($time)) { $time = strtotime($time); } - $this->header(array( + $this->header([ 'Date' => gmdate("D, j M Y G:i:s ", time()) . 'GMT' - )); + ]); $this->modified($since); $this->expires($time); $this->sharable(true); @@ -875,10 +871,7 @@ public function sharedMaxAge($seconds = null) { $this->_cacheDirectives['s-maxage'] = $seconds; $this->_setCacheControl(); } - if (isset($this->_cacheDirectives['s-maxage'])) { - return $this->_cacheDirectives['s-maxage']; - } - return null; + return $this->_cacheDirectives['s-maxage'] ?? null; } /** @@ -895,10 +888,7 @@ public function maxAge($seconds = null) { $this->_cacheDirectives['max-age'] = $seconds; $this->_setCacheControl(); } - if (isset($this->_cacheDirectives['max-age'])) { - return $this->_cacheDirectives['max-age']; - } - return null; + return $this->_cacheDirectives['max-age'] ?? null; } /** @@ -958,10 +948,7 @@ public function expires($time = null) { $date = $this->_getUTCDate($time); $this->_headers['Expires'] = $date->format('D, j M Y H:i:s') . ' GMT'; } - if (isset($this->_headers['Expires'])) { - return $this->_headers['Expires']; - } - return null; + return $this->_headers['Expires'] ?? null; } /** @@ -982,10 +969,7 @@ public function modified($time = null) { $date = $this->_getUTCDate($time); $this->_headers['Last-Modified'] = $date->format('D, j M Y H:i:s') . ' GMT'; } - if (isset($this->_headers['Last-Modified'])) { - return $this->_headers['Last-Modified']; - } - return null; + return $this->_headers['Last-Modified'] ?? null; } /** @@ -998,7 +982,7 @@ public function modified($time = null) { public function notModified() { $this->statusCode(304); $this->body(''); - $remove = array( + $remove = [ 'Allow', 'Content-Encoding', 'Content-Language', @@ -1006,7 +990,7 @@ public function notModified() { 'Content-MD5', 'Content-Type', 'Last-Modified' - ); + ]; foreach ($remove as $header) { unset($this->_headers[$header]); } @@ -1058,10 +1042,7 @@ public function etag($tag = null, $weak = false) { if ($tag !== null) { $this->_headers['Etag'] = sprintf('%s"%s"', ($weak) ? 'W/' : null, $tag); } - if (isset($this->_headers['Etag'])) { - return $this->_headers['Etag']; - } - return null; + return $this->_headers['Etag'] ?? null; } /** @@ -1092,7 +1073,7 @@ protected function _getUTCDate($time = null) { public function compress() { $compressionEnabled = ini_get("zlib.output_compression") !== '1' && extension_loaded("zlib") && - (strpos(env('HTTP_ACCEPT_ENCODING'), 'gzip') !== false); + (str_contains(env('HTTP_ACCEPT_ENCODING'), 'gzip')); return $compressionEnabled && ob_start('ob_gzhandler'); } @@ -1102,7 +1083,7 @@ public function compress() { * @return bool */ public function outputCompressed() { - return strpos(env('HTTP_ACCEPT_ENCODING'), 'gzip') !== false + return str_contains(env('HTTP_ACCEPT_ENCODING'), 'gzip') && (ini_get("zlib.output_compression") === '1' || in_array('ob_gzhandler', ob_list_handlers())); } @@ -1141,10 +1122,7 @@ public function length($bytes = null) { if ($bytes !== null) { $this->_headers['Content-Length'] = $bytes; } - if (isset($this->_headers['Content-Length'])) { - return $this->_headers['Content-Length']; - } - return null; + return $this->_headers['Content-Length'] ?? null; } /** @@ -1162,12 +1140,12 @@ public function length($bytes = null) { */ public function checkNotModified(CakeRequest $request) { $ifNoneMatchHeader = $request->header('If-None-Match'); - $etags = array(); + $etags = []; if (is_string($ifNoneMatchHeader)) { $etags = preg_split('/\s*,\s*/', $ifNoneMatchHeader, 0, PREG_SPLIT_NO_EMPTY); } $modifiedSince = $request->header('If-Modified-Since'); - $checks = array(); + $checks = []; if ($responseTag = $this->etag()) { $checks[] = in_array('*', $etags) || in_array($responseTag, $etags); } @@ -1194,7 +1172,7 @@ public function checkNotModified(CakeRequest $request) { * * @return string */ - public function __toString() { + public function __toString(): string { return (string)$this->_body; } @@ -1249,7 +1227,7 @@ public function cookie($options = null) { return $this->_cookies[$options]; } - $defaults = array( + $defaults = [ 'name' => 'CakeCookie[default]', 'value' => '', 'expire' => 0, @@ -1257,7 +1235,7 @@ public function cookie($options = null) { 'domain' => '', 'secure' => false, 'httpOnly' => false - ); + ]; $options += $defaults; $this->_cookies[$options['name']] = $options; @@ -1289,7 +1267,7 @@ public function cookie($options = null) { * @param string|array $allowedHeaders List of HTTP headers allowed * @return void */ - public function cors(CakeRequest $request, $allowedDomains, $allowedMethods = array(), $allowedHeaders = array()) { + public function cors(CakeRequest $request, $allowedDomains, $allowedMethods = [], $allowedHeaders = []) { $origin = $request->header('Origin'); if (!$origin) { return; @@ -1315,10 +1293,10 @@ public function cors(CakeRequest $request, $allowedDomains, $allowedMethods = ar * @return array */ protected function _normalizeCorsDomains($domains, $requestIsSSL = false) { - $result = array(); + $result = []; foreach ($domains as $domain) { if ($domain === '*') { - $result[] = array('preg' => '@.@', 'original' => '*'); + $result[] = ['preg' => '@.@', 'original' => '*']; continue; } $original = $domain; @@ -1345,13 +1323,13 @@ protected function _normalizeCorsDomains($domains, $requestIsSSL = false) { * @return void * @throws NotFoundException */ - public function file($path, $options = array()) { - $options += array( + public function file($path, $options = []) { + $options += [ 'name' => null, 'download' => null - ); + ]; - if (strpos($path, '../') !== false || strpos($path, '..\\') !== false) { + if (str_contains($path, '../') || str_contains($path, '..\\')) { throw new NotFoundException(__d( 'cake_dev', 'The requested file contains `..` and will not be read.' @@ -1429,7 +1407,7 @@ protected function _fileRange($file, $httpRange) { preg_match('/^bytes\s*=\s*(\d+)?\s*-\s*(\d+)?$/', $httpRange, $matches); if ($matches) { $start = $matches[1]; - $end = isset($matches[2]) ? $matches[2] : ''; + $end = $matches[2] ?? ''; } if ($start === '') { @@ -1442,19 +1420,19 @@ protected function _fileRange($file, $httpRange) { if ($start > $end || $end > $lastByte || $start > $lastByte) { $this->statusCode(416); - $this->header(array( + $this->header([ 'Content-Range' => 'bytes 0-' . $lastByte . '/' . $fileSize - )); + ]); return; } - $this->header(array( + $this->header([ 'Content-Length' => $end - $start + 1, 'Content-Range' => 'bytes ' . $start . '-' . $end . '/' . $fileSize - )); + ]); $this->statusCode(206); - $this->_fileRange = array($start, $end); + $this->_fileRange = [$start, $end]; } /** @@ -1470,7 +1448,7 @@ protected function _sendFile($file, $range) { $end = $start = false; if ($range && is_array($range)) { - list($start, $end) = $range; + [$start, $end] = $range; } if ($start !== false) { $file->offset($start); diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index 7b159ab0c2..607309598c 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -39,21 +39,21 @@ class CakeSocket { * * @var array */ - protected $_baseConfig = array( + protected $_baseConfig = [ 'persistent' => false, 'host' => 'localhost', 'protocol' => 'tcp', 'port' => 80, 'timeout' => 30, 'cryptoType' => 'tls', - ); + ]; /** * Configuration settings for the socket connection * * @var array */ - public $config = array(); + public $config = []; /** * Reference to socket connection resource @@ -74,7 +74,7 @@ class CakeSocket { * * @var array */ - public $lastError = array(); + public $lastError = []; /** * True if the socket stream is encrypted after a CakeSocket::enableCrypto() call @@ -88,7 +88,7 @@ class CakeSocket { * * @var array */ - protected $_encryptMethods = array( + protected $_encryptMethods = [ // @codingStandardsIgnoreStart 'sslv2_client' => STREAM_CRYPTO_METHOD_SSLv2_CLIENT, 'sslv3_client' => STREAM_CRYPTO_METHOD_SSLv3_CLIENT, @@ -99,7 +99,7 @@ class CakeSocket { 'sslv23_server' => STREAM_CRYPTO_METHOD_SSLv23_SERVER, 'tls_server' => STREAM_CRYPTO_METHOD_TLS_SERVER, // @codingStandardsIgnoreEnd - ); + ]; /** * Used to capture connection warnings which can happen when there are @@ -107,7 +107,7 @@ class CakeSocket { * * @var array */ - protected $_connectionErrors = array(); + protected $_connectionErrors = []; /** * Constructor. @@ -115,7 +115,7 @@ class CakeSocket { * @param array $config Socket configuration, which will be merged with the base configuration * @see CakeSocket::$_baseConfig */ - public function __construct($config = array()) { + public function __construct($config = []) { $this->config = array_merge($this->_baseConfig, $config); $this->_addTlsVersions(); @@ -135,14 +135,14 @@ public function __construct($config = array()) { * @return void */ protected function _addTlsVersions() { - $conditionalCrypto = array( + $conditionalCrypto = [ 'tlsv1_1_client' => 'STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT', 'tlsv1_2_client' => 'STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT', 'tlsv1_1_server' => 'STREAM_CRYPTO_METHOD_TLSv1_1_SERVER', 'tlsv1_2_server' => 'STREAM_CRYPTO_METHOD_TLSv1_2_SERVER', 'tlsv1_3_server' => 'STREAM_CRYPTO_METHOD_TLSv1_3_SERVER', 'tlsv1_3_client' => 'STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT' - ); + ]; foreach ($conditionalCrypto as $key => $const) { if (defined($const)) { $this->_encryptMethods[$key] = constant($const); @@ -182,9 +182,9 @@ public function connect() { $this->disconnect(); } - $hasProtocol = strpos($this->config['host'], '://') !== false; + $hasProtocol = str_contains($this->config['host'], '://'); if ($hasProtocol) { - list($this->config['protocol'], $this->config['host']) = explode('://', $this->config['host']); + [$this->config['protocol'], $this->config['host']] = explode('://', $this->config['host']); } $scheme = null; if (!empty($this->config['protocol'])) { @@ -211,7 +211,7 @@ public function connect() { $connectAs |= STREAM_CLIENT_PERSISTENT; } - set_error_handler(array($this, '_connectionErrorHandler')); + set_error_handler([$this, '_connectionErrorHandler']); $this->connection = stream_socket_client( $scheme . $this->config['host'] . ':' . $this->config['port'], $errNum, @@ -240,7 +240,7 @@ public function connect() { $this->config['request']['uri']['scheme'] === 'https' && !empty($this->config['proxy']) ) { - $req = array(); + $req = []; $req[] = 'CONNECT ' . $this->config['request']['uri']['host'] . ':' . $this->config['request']['uri']['port'] . ' HTTP/1.1'; $req[] = 'Host: ' . $this->config['host']; @@ -272,7 +272,7 @@ public function connect() { */ protected function _setSslContext($host) { foreach ($this->config as $key => $value) { - if (substr($key, 0, 4) !== 'ssl_') { + if (!str_starts_with($key, 'ssl_')) { continue; } $contextKey = substr($key, 4); @@ -361,7 +361,7 @@ public function address() { */ public function addresses() { if (Validation::ip($this->config['host'])) { - return array($this->config['host']); + return [$this->config['host']]; } return gethostbynamel($this->config['host']); } @@ -386,7 +386,7 @@ public function lastError() { * @return void */ public function setLastError($errNum, $errStr) { - $this->lastError = array('num' => $errNum, 'str' => $errStr); + $this->lastError = ['num' => $errNum, 'str' => $errStr]; } /** @@ -470,9 +470,9 @@ public function __destruct() { */ public function reset($state = null) { if (empty($state)) { - static $initalState = array(); + static $initalState = []; if (empty($initalState)) { - $initalState = get_class_vars(__CLASS__); + $initalState = get_class_vars(self::class); } $state = $initalState; } diff --git a/lib/Cake/Network/Email/AbstractTransport.php b/lib/Cake/Network/Email/AbstractTransport.php index 453b74361e..ec2c93b9b4 100644 --- a/lib/Cake/Network/Email/AbstractTransport.php +++ b/lib/Cake/Network/Email/AbstractTransport.php @@ -28,7 +28,7 @@ abstract class AbstractTransport { * * @var array */ - protected $_config = array(); + protected $_config = []; /** * Send mail diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index ee4da73d9b..0ee65829f9 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -77,35 +77,35 @@ class CakeEmail { * * @var array */ - protected $_to = array(); + protected $_to = []; /** * The mail which the email is sent from * * @var array */ - protected $_from = array(); + protected $_from = []; /** * The sender email * * @var array */ - protected $_sender = array(); + protected $_sender = []; /** * The email the recipient will reply to * * @var array */ - protected $_replyTo = array(); + protected $_replyTo = []; /** * The read receipt email * * @var array */ - protected $_readReceipt = array(); + protected $_readReceipt = []; /** * The mail that will be used in case of any errors like @@ -115,7 +115,7 @@ class CakeEmail { * * @var array */ - protected $_returnPath = array(); + protected $_returnPath = []; /** * Carbon Copy @@ -125,7 +125,7 @@ class CakeEmail { * * @var array */ - protected $_cc = array(); + protected $_cc = []; /** * Blind Carbon Copy @@ -135,7 +135,7 @@ class CakeEmail { * * @var array */ - protected $_bcc = array(); + protected $_bcc = []; /** * Message ID @@ -165,7 +165,7 @@ class CakeEmail { * * @var array */ - protected $_headers = array(); + protected $_headers = []; /** * Layout for the View @@ -193,7 +193,7 @@ class CakeEmail { * * @var array */ - protected $_viewVars = array(); + protected $_viewVars = []; /** * Theme for the View @@ -207,7 +207,7 @@ class CakeEmail { * * @var array */ - protected $_helpers = array('Html'); + protected $_helpers = ['Html']; /** * Text message @@ -228,14 +228,14 @@ class CakeEmail { * * @var array */ - protected $_message = array(); + protected $_message = []; /** * Available formats to be sent. * * @var array */ - protected $_emailFormatAvailable = array('text', 'html', 'both'); + protected $_emailFormatAvailable = ['text', 'html', 'both']; /** * What format should the email be sent in @@ -287,7 +287,7 @@ class CakeEmail { * * @var array */ - protected $_attachments = array(); + protected $_attachments = []; /** * If set, boundary to use for multipart mime messages @@ -301,23 +301,23 @@ class CakeEmail { * * @var string|array */ - protected $_config = array(); + protected $_config = []; /** * 8Bit character sets * * @var array */ - protected $_charset8bit = array('UTF-8', 'SHIFT_JIS'); + protected $_charset8bit = ['UTF-8', 'SHIFT_JIS']; /** * Define Content-Type charset name * * @var array */ - protected $_contentTypeCharset = array( + protected $_contentTypeCharset = [ 'ISO-2022-JP-MS' => 'ISO-2022-JP' - ); + ]; /** * Regex for email validation @@ -593,10 +593,10 @@ protected function _setEmail($varName, $email, $name) { if ($name === null) { $name = $email; } - $this->{$varName} = array($email => $name); + $this->{$varName} = [$email => $name]; return $this; } - $list = array(); + $list = []; foreach ($email as $key => $value) { if (is_int($key)) { $key = $value; @@ -670,7 +670,7 @@ protected function _addEmail($varName, $email, $name) { $this->{$varName}[$email] = $name; return $this; } - $list = array(); + $list = []; foreach ($email as $key => $value) { if (is_int($key)) { $key = $value; @@ -743,25 +743,25 @@ public function addHeaders($headers) { * @param array $include List of headers. * @return array */ - public function getHeaders($include = array()) { + public function getHeaders($include = []) { if ($include == array_values($include)) { $include = array_fill_keys($include, true); } $defaults = array_fill_keys( - array( + [ 'from', 'sender', 'replyTo', 'readReceipt', 'returnPath', - 'to', 'cc', 'bcc', 'subject'), + 'to', 'cc', 'bcc', 'subject'], false ); $include += $defaults; - $headers = array(); - $relation = array( + $headers = []; + $relation = [ 'from' => 'From', 'replyTo' => 'Reply-To', 'readReceipt' => 'Disposition-Notification-To', 'returnPath' => 'Return-Path' - ); + ]; foreach ($relation as $var => $header) { if ($include[$var]) { $var = '_' . $var; @@ -776,7 +776,7 @@ public function getHeaders($include = array()) { } } - foreach (array('to', 'cc', 'bcc') as $var) { + foreach (['to', 'cc', 'bcc'] as $var) { if ($include[$var]) { $classVar = '_' . $var; $headers[ucfirst($var)] = implode(', ', $this->_formatAddress($this->{$classVar})); @@ -828,7 +828,7 @@ public function getHeaders($include = array()) { * @return array */ protected function _formatAddress($address) { - $return = array(); + $return = []; foreach ($address as $email => $alias) { if ($email === $alias) { $return[] = $email; @@ -836,7 +836,7 @@ protected function _formatAddress($address) { $encoded = $this->_encode($alias); if ( $encoded === $alias && preg_match('/[^a-z0-9 ]/i', $encoded) || - strpos($encoded, ',') !== false + str_contains($encoded, ',') ) { $encoded = '"' . str_replace('"', '\"', $encoded) . '"'; } @@ -855,10 +855,10 @@ protected function _formatAddress($address) { */ public function template($template = false, $layout = false) { if ($template === false) { - return array( + return [ 'template' => $this->_template, 'layout' => $this->_layout - ); + ]; } $this->_template = $template; if ($layout !== false) { @@ -966,7 +966,7 @@ public function transportClass() { if ($this->_transportClass) { return $this->_transportClass; } - list($plugin, $transportClassname) = pluginSplit($this->_transportName, true); + [$plugin, $transportClassname] = pluginSplit($this->_transportName, true); $transportClassname .= 'Transport'; App::uses($transportClassname, $plugin . 'Network/Email'); if (!class_exists($transportClassname)) { @@ -1065,10 +1065,10 @@ public function attachments($attachments = null) { if ($attachments === null) { return $this->_attachments; } - $attach = array(); + $attach = []; foreach ((array)$attachments as $name => $fileInfo) { if (!is_array($fileInfo)) { - $fileInfo = array('file' => $fileInfo); + $fileInfo = ['file' => $fileInfo]; } if (!isset($fileInfo['file'])) { if (!isset($fileInfo['data'])) { @@ -1121,15 +1121,14 @@ public function addAttachments($attachments) { * @param string $type Use MESSAGE_* constants or null to return the full message as array * @return string|array String if have type, array if type is null */ - public function message($type = null) { - switch ($type) { - case static::MESSAGE_HTML: - return $this->_htmlMessage; - case static::MESSAGE_TEXT: - return $this->_textMessage; - } - return $this->_message; - } + public function message($type = null) + { + return match ($type) { + static::MESSAGE_HTML => $this->_htmlMessage, + static::MESSAGE_TEXT => $this->_textMessage, + default => $this->_message, + }; + } /** * Configuration to use when send email @@ -1182,13 +1181,13 @@ public function send($content = null) { $contents = $this->transportClass()->send($this); if (!empty($this->_config['log'])) { - $config = array( + $config = [ 'level' => LOG_DEBUG, 'scope' => 'email' - ); + ]; if ($this->_config['log'] !== true) { if (!is_array($this->_config['log'])) { - $this->_config['log'] = array('level' => $this->_config['log']); + $this->_config['log'] = ['level' => $this->_config['log']]; } $config = $this->_config['log'] + $config; } @@ -1213,7 +1212,7 @@ public function send($content = null) { * @throws SocketException */ public static function deliver($to = null, $subject = null, $message = null, $transportConfig = 'fast', $send = true) { - $class = get_called_class(); + $class = static::class; /** @var CakeEmail $instance */ $instance = new $class($transportConfig); if ($to !== null) { @@ -1267,11 +1266,11 @@ protected function _applyConfig($config) { if (empty($this->headerCharset)) { $this->headerCharset = $this->charset; } - $simpleMethods = array( + $simpleMethods = [ 'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath', 'cc', 'bcc', 'messageId', 'domain', 'subject', 'viewRender', 'viewVars', 'attachments', 'transport', 'emailFormat', 'theme', 'helpers', 'emailPattern' - ); + ]; foreach ($simpleMethods as $method) { if (isset($config[$method])) { $this->$method($config[$method]); @@ -1299,23 +1298,23 @@ protected function _applyConfig($config) { * @return self */ public function reset() { - $this->_to = array(); - $this->_from = array(); - $this->_sender = array(); - $this->_replyTo = array(); - $this->_readReceipt = array(); - $this->_returnPath = array(); - $this->_cc = array(); - $this->_bcc = array(); + $this->_to = []; + $this->_from = []; + $this->_sender = []; + $this->_replyTo = []; + $this->_readReceipt = []; + $this->_returnPath = []; + $this->_cc = []; + $this->_bcc = []; $this->_messageId = true; $this->_subject = ''; - $this->_headers = array(); + $this->_headers = []; $this->_layout = 'default'; $this->_template = ''; $this->_viewRender = 'View'; - $this->_viewVars = array(); + $this->_viewVars = []; $this->_theme = null; - $this->_helpers = array('Html'); + $this->_helpers = ['Html']; $this->_textMessage = ''; $this->_htmlMessage = ''; $this->_message = ''; @@ -1324,8 +1323,8 @@ public function reset() { $this->_transportClass = null; $this->charset = 'utf-8'; $this->headerCharset = null; - $this->_attachments = array(); - $this->_config = array(); + $this->_attachments = []; + $this->_config = []; $this->_emailPattern = static::EMAIL_PATTERN; return $this; } @@ -1376,11 +1375,11 @@ protected function _encodeString($text, $charset) { */ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) { if (strlen($message) === 0) { - return array(''); + return ['']; } - $message = str_replace(array("\r\n", "\r"), "\n", $message); + $message = str_replace(["\r\n", "\r"], "\n", $message); $lines = explode("\n", $message); - $formatted = array(); + $formatted = []; $cut = ($wrapLength == CakeEmail::LINE_LENGTH_MUST); foreach ($lines as $line) { @@ -1446,7 +1445,7 @@ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) { $tmpLine .= $char; $tmpLineLength++; if ($tmpLineLength === $wrapLength) { - $nextChar = isset($line[$i + 1]) ? $line[$i + 1] : ''; + $nextChar = $line[$i + 1] ?? ''; if ($nextChar === ' ' || $nextChar === '<') { $formatted[] = trim($tmpLine); $tmpLine = ''; @@ -1496,12 +1495,12 @@ protected function _attachFiles($boundary = null) { $boundary = $this->_boundary; } - $msg = array(); + $msg = []; foreach ($this->_attachments as $filename => $fileInfo) { if (!empty($fileInfo['contentId'])) { continue; } - $data = isset($fileInfo['data']) ? $fileInfo['data'] : $this->_readFile($fileInfo['file']); + $data = $fileInfo['data'] ?? $this->_readFile($fileInfo['file']); $msg[] = '--' . $boundary; $msg[] = 'Content-Type: ' . $fileInfo['mimetype']; @@ -1540,12 +1539,12 @@ protected function _attachInlineFiles($boundary = null) { $boundary = $this->_boundary; } - $msg = array(); + $msg = []; foreach ($this->_attachments as $filename => $fileInfo) { if (empty($fileInfo['contentId'])) { continue; } - $data = isset($fileInfo['data']) ? $fileInfo['data'] : $this->_readFile($fileInfo['file']); + $data = $fileInfo['data'] ?? $this->_readFile($fileInfo['file']); $msg[] = '--' . $boundary; $msg[] = 'Content-Type: ' . $fileInfo['mimetype']; @@ -1572,7 +1571,7 @@ protected function _render($content) { $rendered = $this->_renderTemplates($content); $this->_createBoundary(); - $msg = array(); + $msg = []; $contentIds = array_filter((array)Hash::extract($this->_attachments, '{s}.contentId')); $hasInlineAttachments = count($contentIds) > 0; @@ -1653,9 +1652,9 @@ protected function _render($content) { * @return array Array of types. Valid types are 'text' and 'html' */ protected function _getTypes() { - $types = array($this->_emailFormat); + $types = [$this->_emailFormat]; if ($this->_emailFormat === 'both') { - $types = array('html', 'text'); + $types = ['html', 'text']; } return $types; } @@ -1670,7 +1669,7 @@ protected function _getTypes() { */ protected function _renderTemplates($content) { $types = $this->_getTypes(); - $rendered = array(); + $rendered = []; if (empty($this->_template)) { foreach ($types as $type) { $rendered[$type] = $this->_encodeString($content, $this->charset); @@ -1679,7 +1678,7 @@ protected function _renderTemplates($content) { } $viewClass = $this->_viewRender; if ($viewClass !== 'View') { - list($plugin, $viewClass) = pluginSplit($viewClass, true); + [$plugin, $viewClass] = pluginSplit($viewClass, true); $viewClass .= 'View'; App::uses($viewClass, $plugin . 'View'); } @@ -1695,8 +1694,8 @@ protected function _renderTemplates($content) { $View->loadHelpers(); - list($templatePlugin, $template) = pluginSplit($this->_template); - list($layoutPlugin, $layout) = pluginSplit($this->_layout); + [$templatePlugin, $template] = pluginSplit($this->_template); + [$layoutPlugin, $layout] = pluginSplit($this->_layout); if ($templatePlugin) { $View->plugin = $templatePlugin; } elseif ($layoutPlugin) { @@ -1718,7 +1717,7 @@ protected function _renderTemplates($content) { $View->viewPath = $View->layoutPath = 'Emails' . DS . $type; $render = $View->render($this->_template, $this->_layout); - $render = str_replace(array("\r\n", "\r"), "\n", $render); + $render = str_replace(["\r\n", "\r"], "\n", $render); $rendered[$type] = $this->_encodeString($render, $this->charset); } diff --git a/lib/Cake/Network/Email/DebugTransport.php b/lib/Cake/Network/Email/DebugTransport.php index 9c7d2cdd02..940fce47e3 100644 --- a/lib/Cake/Network/Email/DebugTransport.php +++ b/lib/Cake/Network/Email/DebugTransport.php @@ -32,10 +32,10 @@ class DebugTransport extends AbstractTransport { * @return array */ public function send(CakeEmail $email) { - $headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject')); + $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject']); $headers = $this->_headersToString($headers); $message = implode("\r\n", (array)$email->message()); - return array('headers' => $headers, 'message' => $message); + return ['headers' => $headers, 'message' => $message]; } } diff --git a/lib/Cake/Network/Email/MailTransport.php b/lib/Cake/Network/Email/MailTransport.php index a57519a819..93220dc8d7 100644 --- a/lib/Cake/Network/Email/MailTransport.php +++ b/lib/Cake/Network/Email/MailTransport.php @@ -38,7 +38,7 @@ public function send(CakeEmail $email) { if (isset($this->_config['eol'])) { $eol = $this->_config['eol']; } - $headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc')); + $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc']); $to = $headers['To']; unset($headers['To']); foreach ($headers as $key => $header) { @@ -50,12 +50,12 @@ public function send(CakeEmail $email) { $message = implode($eol, $email->message()); - $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null; + $params = $this->_config['additionalParameters'] ?? null; $this->_mail($to, $subject, $message, $headers, $params); $headers .= $eol . 'Subject: ' . $subject; $headers .= $eol . 'To: ' . $to; - return array('headers' => $headers, 'message' => $message); + return ['headers' => $headers, 'message' => $message]; } /** @@ -74,12 +74,12 @@ protected function _mail($to, $subject, $message, $headers, $params = null) { //@codingStandardsIgnoreStart if (!@mail($to, $subject, $message, $headers)) { $error = error_get_last(); - $msg = 'Could not send email: ' . (isset($error['message']) ? $error['message'] : 'unknown'); + $msg = 'Could not send email: ' . ($error['message'] ?? 'unknown'); throw new SocketException($msg); } } elseif (!@mail($to, $subject, $message, $headers, $params)) { $error = error_get_last(); - $msg = 'Could not send email: ' . (isset($error['message']) ? $error['message'] : 'unknown'); + $msg = 'Could not send email: ' . ($error['message'] ?? 'unknown'); //@codingStandardsIgnoreEnd throw new SocketException($msg); } diff --git a/lib/Cake/Network/Email/SmtpTransport.php b/lib/Cake/Network/Email/SmtpTransport.php index d69fa39030..1ce78babdb 100644 --- a/lib/Cake/Network/Email/SmtpTransport.php +++ b/lib/Cake/Network/Email/SmtpTransport.php @@ -44,7 +44,7 @@ class SmtpTransport extends AbstractTransport { * * @var array */ - protected $_lastResponse = array(); + protected $_lastResponse = []; /** * Returns the response of the last sent SMTP command. @@ -102,7 +102,7 @@ public function config($config = null) { if ($config === null) { return $this->_config; } - $default = array( + $default = [ 'host' => 'localhost', 'port' => 25, 'timeout' => 30, @@ -111,7 +111,7 @@ public function config($config = null) { 'client' => null, 'tls' => false, 'ssl_allow_self_signed' => false - ); + ]; $this->_config = array_merge($default, $this->_config, $config); return $this->_config; } @@ -123,13 +123,13 @@ public function config($config = null) { * @return void */ protected function _bufferResponseLines(array $responseLines) { - $response = array(); + $response = []; foreach ($responseLines as $responseLine) { if (preg_match('/^(\d{3})(?:[ -]+(.*))?$/', $responseLine, $match)) { - $response[] = array( + $response[] = [ 'code' => $match[1], - 'message' => isset($match[2]) ? $match[2] : null - ); + 'message' => $match[2] ?? null + ]; } } $this->_lastResponse = array_merge($this->_lastResponse, $response); @@ -151,7 +151,7 @@ protected function _connect() { if (isset($this->_config['client'])) { $host = $this->_config['client']; } elseif ($httpHost = env('HTTP_HOST')) { - list($host) = explode(':', $httpHost); + [$host] = explode(':', $httpHost); } else { $host = 'localhost'; } @@ -163,13 +163,13 @@ protected function _connect() { $this->_socket->enableCrypto('tls'); $this->_smtpSend("EHLO {$host}", '250'); } - } catch (SocketException $e) { + } catch (SocketException) { if ($this->_config['tls']) { throw new SocketException(__d('cake_dev', 'SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS.')); } try { $this->_smtpSend("HELO {$host}", '250'); - } catch (SocketException $e2) { + } catch (SocketException) { throw new SocketException(__d('cake_dev', 'SMTP server did not accept the connection.')); } } @@ -192,7 +192,7 @@ protected function _auth() { } try { $this->_smtpSend(base64_encode($this->_config['password']), '235'); - } catch (SocketException $e) { + } catch (SocketException) { throw new SocketException(__d('cake_dev', 'SMTP server did not accept the password.')); } } elseif ($replyCode == '504') { @@ -257,7 +257,7 @@ protected function _prepareRecipientAddresses(CakeEmail $email) { * @return array */ protected function _prepareMessageHeaders(CakeEmail $email) { - return $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'to', 'cc', 'subject')); + return $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'to', 'cc', 'subject']); } /** @@ -268,7 +268,7 @@ protected function _prepareMessageHeaders(CakeEmail $email) { */ protected function _prepareMessage(CakeEmail $email) { $lines = $email->message(); - $messages = array(); + $messages = []; foreach ($lines as $line) { if ((!empty($line)) && ($line[0] === '.')) { $messages[] = '.' . $line; @@ -310,7 +310,7 @@ protected function _sendData(CakeEmail $email) { $message = $this->_prepareMessage($email); $this->_smtpSend($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n."); - $this->_content = array('headers' => $headers, 'message' => $message); + $this->_content = ['headers' => $headers, 'message' => $message]; } /** @@ -343,7 +343,7 @@ protected function _generateSocket() { * @throws SocketException */ protected function _smtpSend($data, $checkCode = '250') { - $this->_lastResponse = array(); + $this->_lastResponse = []; if ($data !== null) { $this->_socket->write($data . "\r\n"); @@ -351,14 +351,14 @@ protected function _smtpSend($data, $checkCode = '250') { while ($checkCode !== false) { $response = ''; $startTime = time(); - while (substr($response, -2) !== "\r\n" && ((time() - $startTime) < $this->_config['timeout'])) { + while (!str_ends_with($response, "\r\n") && ((time() - $startTime) < $this->_config['timeout'])) { $bytes = $this->_socket->read(); if ($bytes === false || $bytes === null) { break; } $response .= $bytes; } - if (substr($response, -2) !== "\r\n") { + if (!str_ends_with($response, "\r\n")) { throw new SocketException(__d('cake_dev', 'SMTP timeout.')); } $responseLines = explode("\r\n", rtrim($response, "\r\n")); diff --git a/lib/Cake/Network/Http/DigestAuthentication.php b/lib/Cake/Network/Http/DigestAuthentication.php index 65dd5a783b..b09c1934f9 100644 --- a/lib/Cake/Network/Http/DigestAuthentication.php +++ b/lib/Cake/Network/Http/DigestAuthentication.php @@ -87,7 +87,7 @@ protected static function _generateHeader(HttpSocket $http, &$authInfo) { } $authHeader = 'Digest '; - $authHeader .= 'username="' . str_replace(array('\\', '"'), array('\\\\', '\\"'), $authInfo['user']) . '", '; + $authHeader .= 'username="' . str_replace(['\\', '"'], ['\\\\', '\\"'], $authInfo['user']) . '", '; $authHeader .= 'realm="' . $authInfo['realm'] . '", '; $authHeader .= 'nonce="' . $authInfo['nonce'] . '", '; $authHeader .= 'uri="' . $http->request['uri']['path'] . '", '; diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index a02d71db58..e22d009548 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -44,9 +44,9 @@ class HttpSocket extends CakeSocket { * * @var array */ - public $request = array( + public $request = [ 'method' => 'GET', - 'uri' => array( + 'uri' => [ 'scheme' => 'http', 'host' => null, 'port' => 80, @@ -55,18 +55,18 @@ class HttpSocket extends CakeSocket { 'path' => null, 'query' => null, 'fragment' => null - ), + ], 'version' => '1.1', 'body' => '', 'line' => null, - 'header' => array( + 'header' => [ 'Connection' => 'close', 'User-Agent' => 'CakePHP' - ), + ], 'raw' => null, 'redirect' => false, - 'cookies' => array(), - ); + 'cookies' => [], + ]; /** * Contain information about the last response (read only) @@ -87,7 +87,7 @@ class HttpSocket extends CakeSocket { * * @var array */ - public $config = array( + public $config = [ 'persistent' => false, 'host' => 'localhost', 'protocol' => 'tcp', @@ -97,30 +97,30 @@ class HttpSocket extends CakeSocket { 'ssl_allow_self_signed' => false, 'ssl_verify_depth' => 5, 'ssl_verify_host' => true, - 'request' => array( - 'uri' => array( - 'scheme' => array('http', 'https'), + 'request' => [ + 'uri' => [ + 'scheme' => ['http', 'https'], 'host' => 'localhost', - 'port' => array(80, 443) - ), + 'port' => [80, 443] + ], 'redirect' => false, - 'cookies' => array(), - ) - ); + 'cookies' => [], + ] + ]; /** * Authentication settings * * @var array */ - protected $_auth = array(); + protected $_auth = []; /** * Proxy settings * * @var array */ - protected $_proxy = array(); + protected $_proxy = []; /** * Resource to receive the content of request @@ -150,7 +150,7 @@ class HttpSocket extends CakeSocket { * * @param string|array $config Configuration information, either a string URL or an array of options. */ - public function __construct($config = array()) { + public function __construct($config = []) { if (is_string($config)) { $this->_configUri($config); } elseif (is_array($config)) { @@ -196,14 +196,14 @@ public function __construct($config = array()) { */ public function configAuth($method, $user = null, $pass = null) { if (empty($method)) { - $this->_auth = array(); + $this->_auth = []; return; } if (is_array($user)) { - $this->_auth = array($method => $user); + $this->_auth = [$method => $user]; return; } - $this->_auth = array($method => compact('user', 'pass')); + $this->_auth = [$method => compact('user', 'pass')]; } /** @@ -218,11 +218,11 @@ public function configAuth($method, $user = null, $pass = null) { */ public function configProxy($host, $port = 3128, $method = null, $user = null, $pass = null) { if (empty($host)) { - $this->_proxy = array(); + $this->_proxy = []; return; } if (is_array($host)) { - $this->_proxy = $host + array('host' => null); + $this->_proxy = $host + ['host' => null]; return; } $this->_proxy = compact('host', 'port', 'method', 'user', 'pass'); @@ -254,11 +254,11 @@ public function setContentResource($resource) { * @return false|HttpSocketResponse false on error, HttpSocketResponse on success * @throws SocketException */ - public function request($request = array()) { + public function request($request = []) { $this->reset(false); if (is_string($request)) { - $request = array('uri' => $request); + $request = ['uri' => $request]; } elseif (!is_array($request)) { return false; } @@ -276,17 +276,17 @@ public function request($request = array()) { } $request['uri'] = $this->url($request['uri']); $request['uri'] = $this->_parseUri($request['uri'], true); - $this->request = Hash::merge($this->request, array_diff_key($this->config['request'], array('cookies' => true)), $request); + $this->request = Hash::merge($this->request, array_diff_key($this->config['request'], ['cookies' => true]), $request); $this->_configUri($this->request['uri']); $Host = $this->request['uri']['host']; if (!empty($this->config['request']['cookies'][$Host])) { if (!isset($this->request['cookies'])) { - $this->request['cookies'] = array(); + $this->request['cookies'] = []; } if (!isset($request['cookies'])) { - $request['cookies'] = array(); + $request['cookies'] = []; } $this->request['cookies'] = array_merge($this->request['cookies'], $this->config['request']['cookies'][$Host], $request['cookies']); } @@ -343,7 +343,7 @@ public function request($request = array()) { if (!empty($this->request['body']) && !isset($this->request['header']['Content-Length'])) { $this->request['header']['Content-Length'] = strlen($this->request['body']); } - if (isset($this->request['uri']['scheme']) && $this->request['uri']['scheme'] === 'https' && in_array($this->config['protocol'], array(false, 'tcp'))) { + if (isset($this->request['uri']['scheme']) && $this->request['uri']['scheme'] === 'https' && in_array($this->config['protocol'], [false, 'tcp'])) { $this->config['protocol'] = 'ssl'; } @@ -404,7 +404,7 @@ public function request($request = array()) { $this->disconnect(); } - list($plugin, $responseClass) = pluginSplit($this->responseClass, true); + [$plugin, $responseClass] = pluginSplit($this->responseClass, true); App::uses($responseClass, $plugin . 'Network/Http'); if (!class_exists($responseClass)) { throw new SocketException(__d('cake_dev', 'Class %s not found.', $this->responseClass)); @@ -413,7 +413,7 @@ public function request($request = array()) { if (!empty($this->response->cookies)) { if (!isset($this->config['request']['cookies'][$Host])) { - $this->config['request']['cookies'][$Host] = array(); + $this->config['request']['cookies'][$Host] = []; } $this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies); } @@ -451,7 +451,7 @@ public function request($request = array()) { * @param array $request An indexed array with indexes such as 'method' or uri * @return false|HttpSocketResponse Result of request, either false on failure or the response to the request. */ - public function get($uri = null, $query = array(), $request = array()) { + public function get($uri = null, $query = [], $request = []) { $uri = $this->_parseUri($uri, $this->config['request']['uri']); if (isset($uri['query'])) { $uri['query'] = array_merge($uri['query'], $query); @@ -460,7 +460,7 @@ public function get($uri = null, $query = array(), $request = array()) { } $uri = $this->_buildUri($uri); - $request = Hash::merge(array('method' => 'GET', 'uri' => $uri), $request); + $request = Hash::merge(['method' => 'GET', 'uri' => $uri], $request); return $this->request($request); } @@ -475,7 +475,7 @@ public function get($uri = null, $query = array(), $request = array()) { * @param array $request An indexed array with indexes such as 'method' or uri * @return false|HttpSocketResponse Result of request, either false on failure or the response to the request. */ - public function head($uri = null, $query = array(), $request = array()) { + public function head($uri = null, $query = [], $request = []) { $uri = $this->_parseUri($uri, $this->config['request']['uri']); if (isset($uri['query'])) { $uri['query'] = array_merge($uri['query'], $query); @@ -484,7 +484,7 @@ public function head($uri = null, $query = array(), $request = array()) { } $uri = $this->_buildUri($uri); - $request = Hash::merge(array('method' => 'HEAD', 'uri' => $uri), $request); + $request = Hash::merge(['method' => 'HEAD', 'uri' => $uri], $request); return $this->request($request); } @@ -505,8 +505,8 @@ public function head($uri = null, $query = array(), $request = array()) { * @param array $request An indexed array with indexes such as 'method' or uri * @return false|HttpSocketResponse Result of request, either false on failure or the response to the request. */ - public function post($uri = null, $data = array(), $request = array()) { - $request = Hash::merge(array('method' => 'POST', 'uri' => $uri, 'body' => $data), $request); + public function post($uri = null, $data = [], $request = []) { + $request = Hash::merge(['method' => 'POST', 'uri' => $uri, 'body' => $data], $request); return $this->request($request); } @@ -518,8 +518,8 @@ public function post($uri = null, $data = array(), $request = array()) { * @param array $request An indexed array with indexes such as 'method' or uri * @return false|HttpSocketResponse Result of request */ - public function put($uri = null, $data = array(), $request = array()) { - $request = Hash::merge(array('method' => 'PUT', 'uri' => $uri, 'body' => $data), $request); + public function put($uri = null, $data = [], $request = []) { + $request = Hash::merge(['method' => 'PUT', 'uri' => $uri, 'body' => $data], $request); return $this->request($request); } @@ -531,8 +531,8 @@ public function put($uri = null, $data = array(), $request = array()) { * @param array $request An indexed array with indexes such as 'method' or uri * @return false|HttpSocketResponse Result of request */ - public function patch($uri = null, $data = array(), $request = array()) { - $request = Hash::merge(array('method' => 'PATCH', 'uri' => $uri, 'body' => $data), $request); + public function patch($uri = null, $data = [], $request = []) { + $request = Hash::merge(['method' => 'PATCH', 'uri' => $uri, 'body' => $data], $request); return $this->request($request); } @@ -544,8 +544,8 @@ public function patch($uri = null, $data = array(), $request = array()) { * @param array $request An indexed array with indexes such as 'method' or uri * @return false|HttpSocketResponse Result of request */ - public function delete($uri = null, $data = array(), $request = array()) { - $request = Hash::merge(array('method' => 'DELETE', 'uri' => $uri, 'body' => $data), $request); + public function delete($uri = null, $data = [], $request = []) { + $request = Hash::merge(['method' => 'DELETE', 'uri' => $uri, 'body' => $data], $request); return $this->request($request); } @@ -599,7 +599,7 @@ public function url($url = null, $uriTemplate = null) { return false; } - $base = array_merge($this->config['request']['uri'], array('scheme' => array('http', 'https'), 'port' => array(80, 443))); + $base = array_merge($this->config['request']['uri'], ['scheme' => ['http', 'https'], 'port' => [80, 443]]); $url = $this->_parseUri($url, $base); if (empty($url)) { @@ -623,7 +623,7 @@ protected function _setAuth() { return; } $method = key($this->_auth); - list($plugin, $authClass) = pluginSplit($method, true); + [$plugin, $authClass] = pluginSplit($method, true); $authClass = Inflector::camelize($authClass) . 'Authentication'; App::uses($authClass, $plugin . 'Network/Http'); @@ -633,7 +633,7 @@ protected function _setAuth() { if (!method_exists($authClass, 'authentication')) { throw new SocketException(__d('cake_dev', 'The %s does not support authentication.', $authClass)); } - call_user_func_array("$authClass::authentication", array($this, &$this->_auth[$method])); + call_user_func_array("$authClass::authentication", [$this, &$this->_auth[$method]]); } /** @@ -653,7 +653,7 @@ protected function _setProxy() { if (empty($this->_proxy['method']) || !isset($this->_proxy['user'], $this->_proxy['pass'])) { return; } - list($plugin, $authClass) = pluginSplit($this->_proxy['method'], true); + [$plugin, $authClass] = pluginSplit($this->_proxy['method'], true); $authClass = Inflector::camelize($authClass) . 'Authentication'; App::uses($authClass, $plugin . 'Network/Http'); @@ -663,7 +663,7 @@ protected function _setProxy() { if (!method_exists($authClass, 'proxyAuthentication')) { throw new SocketException(__d('cake_dev', 'The %s does not support proxy authentication.', $authClass)); } - call_user_func_array("$authClass::proxyAuthentication", array($this, &$this->_proxy)); + call_user_func_array("$authClass::proxyAuthentication", [$this, &$this->_proxy]); if (!empty($this->request['header']['Proxy-Authorization'])) { $this->config['proxyauth'] = $this->request['header']['Proxy-Authorization']; @@ -693,11 +693,11 @@ protected function _configUri($uri = null) { if (!isset($uri['host'])) { return false; } - $config = array( - 'request' => array( + $config = [ + 'request' => [ 'uri' => array_intersect_key($uri, $this->config['request']['uri']) - ) - ); + ] + ]; $this->config = Hash::merge($this->config, $config); $this->config = Hash::merge($this->config, array_intersect_key($this->config['request']['uri'], $this->config)); return true; @@ -710,9 +710,9 @@ protected function _configUri($uri = null) { * @param string $uriTemplate The Uri template/format to use. * @return mixed A fully qualified URL formatted according to $uriTemplate, or false on failure */ - protected function _buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { + protected function _buildUri($uri = [], $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { if (is_string($uri)) { - $uri = array('host' => $uri); + $uri = ['host' => $uri]; } $uri = $this->_parseUri($uri, true); @@ -723,12 +723,12 @@ protected function _buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pa $uri['path'] = preg_replace('/^\//', '', $uri['path']); $uri['query'] = http_build_query($uri['query'], '', '&'); $uri['query'] = rtrim($uri['query'], '='); - $stripIfEmpty = array( + $stripIfEmpty = [ 'query' => '?%query', 'fragment' => '#%fragment', 'user' => '%user:%pass@', 'host' => '%host:%port/' - ); + ]; foreach ($stripIfEmpty as $key => $strip) { if (empty($uri[$key])) { @@ -736,7 +736,7 @@ protected function _buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pa } } - $defaultPorts = array('http' => 80, 'https' => 443); + $defaultPorts = ['http' => 80, 'https' => 443]; if (array_key_exists($uri['scheme'], $defaultPorts) && $defaultPorts[$uri['scheme']] == $uri['port']) { $uriTemplate = str_replace(':%port', '', $uriTemplate); } @@ -758,17 +758,17 @@ protected function _buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pa * @param bool|array $base If true use default URI config, otherwise indexed array to set 'scheme', 'host', 'port', etc. * @return array|bool Parsed URI */ - protected function _parseUri($uri = null, $base = array()) { - $uriBase = array( - 'scheme' => array('http', 'https'), + protected function _parseUri($uri = null, $base = []) { + $uriBase = [ + 'scheme' => ['http', 'https'], 'host' => null, - 'port' => array(80, 443), + 'port' => [80, 443], 'user' => null, 'pass' => null, 'path' => '/', 'query' => null, 'fragment' => null - ); + ]; if (is_string($uri)) { $uri = parse_url($uri); @@ -828,15 +828,15 @@ protected function _parseQuery($query) { return $query; } - $parsedQuery = array(); + $parsedQuery = []; if (is_string($query) && !empty($query)) { $query = preg_replace('/^\?/', '', $query); $items = explode('&', $query); foreach ($items as $item) { - if (strpos($item, '=') !== false) { - list($key, $value) = explode('=', $item, 2); + if (str_contains($item, '=')) { + [$key, $value] = explode('=', $item, 2); } else { $key = $item; $value = null; @@ -855,13 +855,12 @@ protected function _parseQuery($query) { foreach ($subKeys as $subKey) { if (!is_array($queryNode)) { - $queryNode = array(); + $queryNode = []; } if ($subKey === '') { - $queryNode[] = array(); - end($queryNode); - $subKey = key($queryNode); + $queryNode[] = []; + $subKey = array_key_last($queryNode); } $queryNode =& $queryNode[$subKey]; } @@ -886,8 +885,8 @@ protected function _parseQuery($query) { * @return string Request line * @throws SocketException */ - protected function _buildRequestLine($request = array()) { - $asteriskMethods = array('OPTIONS'); + protected function _buildRequestLine($request = []) { + $asteriskMethods = ['OPTIONS']; if (is_string($request)) { $isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match); @@ -902,7 +901,7 @@ protected function _buildRequestLine($request = array()) { } $request['uri'] = $this->_parseUri($request['uri']); - $request += array('method' => 'GET'); + $request += ['method' => 'GET']; if (!empty($this->_proxy['host']) && $request['uri']['scheme'] !== 'https') { $request['uri'] = $this->_buildUri($request['uri'], '%scheme://%host:%port/%path?%query'); } else { @@ -912,7 +911,7 @@ protected function _buildRequestLine($request = array()) { if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) { throw new SocketException(__d('cake_dev', 'HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.', implode(',', $asteriskMethods))); } - $version = isset($request['version']) ? $request['version'] : '1.1'; + $version = $request['version'] ?? '1.1'; return $request['method'] . ' ' . $request['uri'] . ' HTTP/' . $version . "\r\n"; } @@ -930,7 +929,7 @@ protected function _buildHeader($header, $mode = 'standard') { return false; } - $fieldsInHeader = array(); + $fieldsInHeader = []; foreach ($header as $key => $value) { $lowKey = strtolower($key); if (array_key_exists($lowKey, $fieldsInHeader)) { @@ -966,16 +965,16 @@ protected function _buildHeader($header, $mode = 'standard') { * @return string Cookie header string to be sent with the request. */ public function buildCookies($cookies) { - $header = array(); + $header = []; foreach ($cookies as $name => $cookie) { if (is_array($cookie)) { - $value = $this->_escapeToken($cookie['value'], array(';')); + $value = $this->_escapeToken($cookie['value'], [';']); } else { - $value = $this->_escapeToken($cookie, array(';')); + $value = $this->_escapeToken($cookie, [';']); } $header[] = $name . '=' . $value; } - return $this->_buildHeader(array('Cookie' => implode('; ', $header)), 'pragmatic'); + return $this->_buildHeader(['Cookie' => implode('; ', $header)], 'pragmatic'); } /** @@ -1002,7 +1001,7 @@ protected function _tokenEscapeChars($hex = true, $chars = null) { if (!empty($chars)) { $escape = $chars; } else { - $escape = array('"', "(", ")", "<", ">", "@", ",", ";", ":", "\\", "/", "[", "]", "?", "=", "{", "}", " "); + $escape = ['"', "(", ")", "<", ">", "@", ",", ";", ":", "\\", "/", "[", "]", "?", "=", "{", "}", " "]; for ($i = 0; $i <= 31; $i++) { $escape[] = chr($i); } @@ -1026,9 +1025,9 @@ protected function _tokenEscapeChars($hex = true, $chars = null) { * @return bool True on success */ public function reset($full = true) { - static $initalState = array(); + static $initalState = []; if (empty($initalState)) { - $initalState = get_class_vars(__CLASS__); + $initalState = get_class_vars(self::class); } if (!$full) { $this->request = $initalState['request']; diff --git a/lib/Cake/Network/Http/HttpSocketResponse.php b/lib/Cake/Network/Http/HttpSocketResponse.php index 5b3f7dc538..755f37877b 100644 --- a/lib/Cake/Network/Http/HttpSocketResponse.php +++ b/lib/Cake/Network/Http/HttpSocketResponse.php @@ -20,7 +20,7 @@ * * @package Cake.Network.Http */ -class HttpSocketResponse implements ArrayAccess { +class HttpSocketResponse implements ArrayAccess, \Stringable { /** * Body content @@ -34,14 +34,14 @@ class HttpSocketResponse implements ArrayAccess { * * @var array */ - public $headers = array(); + public $headers = []; /** * Cookies * * @var array */ - public $cookies = array(); + public $cookies = []; /** * HTTP version @@ -77,7 +77,7 @@ class HttpSocketResponse implements ArrayAccess { * * @var array */ - public $context = array(); + public $context = []; /** * Constructor @@ -127,7 +127,7 @@ public function getHeader($name, $headers = null) { * @return bool */ public function isOk() { - return in_array($this->code, array(200, 201, 202, 203, 204, 205, 206)); + return in_array($this->code, [200, 201, 202, 203, 204, 205, 206]); } /** @@ -136,7 +136,7 @@ public function isOk() { * @return bool */ public function isRedirect() { - return in_array($this->code, array(301, 302, 303, 307)) && $this->getHeader('Location') !== null; + return in_array($this->code, [301, 302, 303, 307]) && $this->getHeader('Location') !== null; } /** @@ -155,7 +155,7 @@ public function parseResponse($message) { throw new SocketException(__d('cake_dev', 'Invalid HTTP response.')); } - list(, $statusLine, $header) = $match; + [, $statusLine, $header] = $match; $this->raw = $message; $this->body = (string)substr($message, strlen($match[0])); @@ -194,12 +194,12 @@ protected function _decodeBody($body, $encoding = 'chunked') { return false; } if (empty($encoding)) { - return array('body' => $body, 'header' => false); + return ['body' => $body, 'header' => false]; } $decodeMethod = '_decode' . Inflector::camelize(str_replace('-', '_', $encoding)) . 'Body'; - if (!is_callable(array(&$this, $decodeMethod))) { - return array('body' => $body, 'header' => false); + if (!is_callable([&$this, $decodeMethod])) { + return ['body' => $body, 'header' => false]; } return $this->{$decodeMethod}($body); } @@ -225,10 +225,10 @@ protected function _decodeChunkedBody($body) { // Handle remaining invalid data as one big chunk. preg_match('/^(.*?)\r\n/', $body, $invalidMatch); $length = isset($invalidMatch[1]) ? strlen($invalidMatch[1]) : 0; - $match = array( + $match = [ 0 => '', 1 => dechex($length) - ); + ]; } $chunkSize = 0; $hexLength = 0; @@ -252,7 +252,7 @@ protected function _decodeChunkedBody($body) { if (!empty($body)) { $entityHeader = $this->_parseHeader($body); } - return array('body' => $decodedBody, 'header' => $entityHeader); + return ['body' => $decodedBody, 'header' => $entityHeader]; } /** @@ -271,7 +271,7 @@ protected function _parseHeader($header) { preg_match_all("/(.+):(.+)(?:\r\n|\$)/Uis", $header, $matches, PREG_SET_ORDER); $lines = explode("\r\n", $header); - $header = array(); + $header = []; foreach ($lines as $line) { if (strlen($line) === 0) { continue; @@ -283,8 +283,8 @@ protected function _parseHeader($header) { if ($first === ' ' || $first === "\t") { $value .= preg_replace("/\s+/", ' ', $line); $continuation = true; - } elseif (strpos($line, ':') !== false) { - list($field, $value) = explode(':', $line, 2); + } elseif (str_contains($line, ':')) { + [$field, $value] = explode(':', $line, 2); $field = $this->_unescapeToken($field); } @@ -310,9 +310,9 @@ public function parseCookies($header) { return false; } - $cookies = array(); + $cookies = []; foreach ((array)$cookieHeader as $cookie) { - if (strpos($cookie, '";"') !== false) { + if (str_contains($cookie, '";"')) { $cookie = str_replace('";"', "{__cookie_replace__}", $cookie); $parts = str_replace("{__cookie_replace__}", '";"', explode(';', $cookie)); } else { @@ -321,14 +321,14 @@ public function parseCookies($header) { $nameParts = explode('=', array_shift($parts), 2); if (count($nameParts) < 2) { - $nameParts = array('', $nameParts[0]); + $nameParts = ['', $nameParts[0]]; } - list($name, $value) = $nameParts; + [$name, $value] = $nameParts; $cookies[$name] = compact('value'); foreach ($parts as $part) { - if (strpos($part, '=') !== false) { - list($key, $value) = explode('=', $part); + if (str_contains($part, '=')) { + [$key, $value] = explode('=', $part); } else { $key = $part; $value = true; @@ -367,7 +367,7 @@ protected function _tokenEscapeChars($hex = true, $chars = null) { if (!empty($chars)) { $escape = $chars; } else { - $escape = array('"', "(", ")", "<", ">", "@", ",", ";", ":", "\\", "/", "[", "]", "?", "=", "{", "}", " "); + $escape = ['"', "(", ")", "<", ">", "@", ",", ";", ":", "\\", "/", "[", "]", "?", "=", "{", "}", " "]; for ($i = 0; $i <= 31; $i++) { $escape[] = chr($i); } @@ -390,7 +390,7 @@ protected function _tokenEscapeChars($hex = true, $chars = null) { * @return bool */ public function offsetExists(mixed $offset) : bool { - return in_array($offset, array('raw', 'status', 'header', 'body', 'cookies')); + return in_array($offset, ['raw', 'status', 'header', 'body', 'cookies']); } /** @@ -408,18 +408,18 @@ public function offsetGet(mixed $offset) : mixed { } else { $header = substr($this->raw, $firstLineLength, strpos($this->raw, "\r\n\r\n") - $firstLineLength) . "\r\n"; } - return array( + return [ 'status-line' => $this->httpVersion . ' ' . $this->code . ' ' . $this->reasonPhrase . "\r\n", 'header' => $header, 'body' => $this->body, 'response' => $this->raw - ); + ]; case 'status': - return array( + return [ 'http-version' => $this->httpVersion, 'code' => $this->code, 'reason-phrase' => $this->reasonPhrase - ); + ]; case 'header': return $this->headers; case 'body': @@ -454,7 +454,7 @@ public function offsetUnset(mixed $offset) : void { * * @return string */ - public function __tostring() { + public function __tostring(): string { return $this->body(); } diff --git a/lib/Cake/Routing/Dispatcher.php b/lib/Cake/Routing/Dispatcher.php index 042a8ed893..cc88da978d 100644 --- a/lib/Cake/Routing/Dispatcher.php +++ b/lib/Cake/Routing/Dispatcher.php @@ -78,7 +78,7 @@ public function getEventManager() { * @return array */ public function implementedEvents() { - return array('Dispatcher.beforeDispatch' => 'parseParams'); + return ['Dispatcher.beforeDispatch' => 'parseParams']; } /** @@ -96,16 +96,16 @@ protected function _attachFilters($manager) { } foreach ($filters as $index => $filter) { - $settings = array(); + $settings = []; if (is_array($filter) && !is_int($index) && class_exists($index)) { $settings = $filter; $filter = $index; } if (is_string($filter)) { - $filter = array('callable' => $filter); + $filter = ['callable' => $filter]; } if (is_string($filter['callable'])) { - list($plugin, $callable) = pluginSplit($filter['callable'], true); + [$plugin, $callable] = pluginSplit($filter['callable'], true); App::uses($callable, $plugin . 'Routing/Filter'); if (!class_exists($callable)) { throw new MissingDispatcherFilterException($callable); @@ -113,9 +113,9 @@ protected function _attachFilters($manager) { $manager->attach(new $callable($settings)); } else { $on = strtolower($filter['on']); - $options = array(); + $options = []; if (isset($filter['priority'])) { - $options = array('priority' => $filter['priority']); + $options = ['priority' => $filter['priority']]; } $manager->attach($filter['callable'], 'Dispatcher.' . $on . 'Dispatch', $options); } @@ -142,7 +142,7 @@ protected function _attachFilters($manager) { * @triggers Dispatcher.afterDispatch $this, compact('request', 'response') * @throws MissingControllerException When the controller is missing. */ - public function dispatch(CakeRequest $request, CakeResponse $response, $additionalParams = array()) { + public function dispatch(CakeRequest $request, CakeResponse $response, $additionalParams = []) { $beforeEvent = new CakeEvent('Dispatcher.beforeDispatch', $this, compact('request', 'response', 'additionalParams')); $this->getEventManager()->dispatch($beforeEvent); @@ -158,10 +158,10 @@ public function dispatch(CakeRequest $request, CakeResponse $response, $addition $controller = $this->_getController($request, $response); if (!($controller instanceof Controller)) { - throw new MissingControllerException(array( + throw new MissingControllerException([ 'class' => Inflector::camelize($request->params['controller']) . 'Controller', 'plugin' => empty($request->params['plugin']) ? null : Inflector::camelize($request->params['plugin']) - )); + ]); } $response = $this->_invoke($controller, $request); diff --git a/lib/Cake/Routing/DispatcherFilter.php b/lib/Cake/Routing/DispatcherFilter.php index 89534041ad..db74b0d249 100644 --- a/lib/Cake/Routing/DispatcherFilter.php +++ b/lib/Cake/Routing/DispatcherFilter.php @@ -37,14 +37,14 @@ abstract class DispatcherFilter implements CakeEventListener { * * @var array */ - public $settings = array(); + public $settings = []; /** * Constructor. * * @param array $settings Configuration settings for the filter. */ - public function __construct($settings = array()) { + public function __construct($settings = []) { $this->settings = Hash::merge($this->settings, $settings); } @@ -58,10 +58,10 @@ public function __construct($settings = array()) { * @return array */ public function implementedEvents() { - return array( - 'Dispatcher.beforeDispatch' => array('callable' => 'beforeDispatch', 'priority' => $this->priority), - 'Dispatcher.afterDispatch' => array('callable' => 'afterDispatch', 'priority' => $this->priority), - ); + return [ + 'Dispatcher.beforeDispatch' => ['callable' => 'beforeDispatch', 'priority' => $this->priority], + 'Dispatcher.afterDispatch' => ['callable' => 'afterDispatch', 'priority' => $this->priority], + ]; } /** diff --git a/lib/Cake/Routing/Filter/AssetDispatcher.php b/lib/Cake/Routing/Filter/AssetDispatcher.php index c1e74066a8..95ea5ae092 100644 --- a/lib/Cake/Routing/Filter/AssetDispatcher.php +++ b/lib/Cake/Routing/Filter/AssetDispatcher.php @@ -41,7 +41,7 @@ class AssetDispatcher extends DispatcherFilter { */ public function beforeDispatch(CakeEvent $event) { $url = urldecode($event->data['request']->url); - if (strpos($url, '..') !== false || strpos($url, '.') === false) { + if (str_contains($url, '..') || !str_contains($url, '.')) { return null; } @@ -81,11 +81,11 @@ protected function _filterAsset(CakeEvent $event) { $response = $event->data['response']; $filters = Configure::read('Asset.filter'); $isCss = ( - strpos($url, 'ccss/') === 0 || + str_starts_with($url, 'ccss/') || preg_match('#^(theme/([^/]+)/ccss/)|(([^/]+)(? 'content_type', 'method' => 'request_method', 'server' => 'server_name' - ); + ]; /** * Constructor for a Route @@ -88,8 +81,10 @@ class CakeRoute { * @param array $defaults Array of defaults for the route. * @param array $options Array of additional options for the Route */ - public function __construct($template, $defaults = array(), $options = array()) { - $this->template = $template; + public function __construct(/** + * The routes template string. + */ + public $template, $defaults = [], $options = []) { $this->defaults = (array)$defaults; $this->options = (array)$options; } @@ -130,11 +125,11 @@ public function compile() { protected function _writeRoute() { if (empty($this->template) || ($this->template === '/')) { $this->_compiledRoute = '#^/*$#'; - $this->keys = array(); + $this->keys = []; return; } $route = $this->template; - $names = $routeParams = array(); + $names = $routeParams = []; $parsed = preg_quote($this->template, '#'); preg_match_all('#:([A-Za-z0-9_-]+[A-Z0-9a-z])#', $route, $namedElements); @@ -146,7 +141,7 @@ protected function _writeRoute() { $option = '?'; } $slashParam = '/\\' . $namedElements[0][$i]; - if (strpos($parsed, $slashParam) !== false) { + if (str_contains($parsed, $slashParam)) { $routeParams[$slashParam] = '(?:/(?P<' . $name . '>' . $this->options[$name] . ')' . $option . ')' . $option; } else { $routeParams[$search] = '(?:(?P<' . $name . '>' . $this->options[$name] . ')' . $option . ')' . $option; @@ -223,7 +218,7 @@ public function parse($url) { for ($i = 0; $i <= $count; $i++) { unset($route[$i]); } - $route['pass'] = $route['named'] = array(); + $route['pass'] = $route['named'] = []; // Assign defaults, set passed args to pass foreach ($this->defaults as $key => $value) { @@ -238,7 +233,7 @@ public function parse($url) { } if (isset($route['_args_'])) { - list($pass, $named) = $this->_parseArgs($route['_args_'], $route); + [$pass, $named] = $this->_parseArgs($route['_args_'], $route); $route['pass'] = array_merge($route['pass'], $pass); $route['named'] = $named; unset($route['_args_']); @@ -270,7 +265,7 @@ public function parse($url) { * @return array Array of ($pass, $named) */ protected function _parseArgs($args, $context) { - $pass = $named = array(); + $pass = $named = []; $args = explode('/', $args); $namedConfig = Router::namedConfig(); @@ -288,13 +283,13 @@ protected function _parseArgs($args, $context) { } foreach ($args as $param) { - if (empty($param) && $param !== '0' && $param !== 0) { + if (empty($param) && $param !== '0' && 0 !== 0) { continue; } - $separatorIsPresent = strpos($param, $namedConfig['separator']) !== false; + $separatorIsPresent = str_contains($param, $namedConfig['separator']); if ((!isset($this->options['named']) || !empty($this->options['named'])) && $separatorIsPresent) { - list($key, $val) = explode($namedConfig['separator'], $param, 2); + [$key, $val] = explode($namedConfig['separator'], $param, 2); $hasRule = isset($rules[$key]); $passIt = (!$hasRule && !$greedy) || ($hasRule && !$this->_matchNamed($val, $rules[$key], $context)); if ($passIt) { @@ -307,22 +302,22 @@ protected function _parseArgs($args, $context) { $arr = $val; foreach ($matches as $match) { if (empty($match[1])) { - $arr = array($arr); + $arr = [$arr]; } else { - $arr = array( + $arr = [ $match[1] => $arr - ); + ]; } } $val = $arr; } - $named = array_merge_recursive($named, array($key => $val)); + $named = array_merge_recursive($named, [$key => $val]); } } else { $pass[] = $param; } } - return array($pass, $named); + return [$pass, $named]; } /** @@ -341,7 +336,7 @@ protected function _matchNamed($val, $rule, $context) { return $rule; } if (is_string($rule)) { - $rule = array('match' => $rule); + $rule = ['match' => $rule]; } if (!is_array($rule)) { return false; @@ -412,7 +407,7 @@ public function match($url) { } // Missing defaults is a fail. - if (array_diff_key($defaults, $url) !== array()) { + if (array_diff_key($defaults, $url) !== []) { return false; } @@ -421,7 +416,7 @@ public function match($url) { $greedyNamed = $namedConfig['greedyNamed']; $allowedNamedParams = $namedConfig['rules']; - $named = $pass = array(); + $named = $pass = []; foreach ($url as $key => $value) { // keys that exist in the defaults and have different values is a match failure. @@ -492,7 +487,7 @@ protected function _writeUrl($params) { if (isset($params['prefix'])) { $prefixed = $params['prefix'] . '_'; } - if (isset($prefixed, $params['action']) && strpos($params['action'], $prefixed) === 0) { + if (isset($prefixed, $params['action']) && str_starts_with($params['action'], $prefixed)) { $params['action'] = substr($params['action'], strlen($prefixed)); unset($params['prefix']); } @@ -505,7 +500,7 @@ protected function _writeUrl($params) { $separator = $namedConfig['separator']; if (!empty($params['named']) && is_array($params['named'])) { - $named = array(); + $named = []; foreach ($params['named'] as $key => $value) { if (is_array($value)) { $flat = Hash::flatten($value, '%5D%5B'); @@ -521,13 +516,13 @@ protected function _writeUrl($params) { $out = $this->template; if (!empty($this->keys)) { - $search = $replace = array(); + $search = $replace = []; foreach ($this->keys as $key) { $string = null; if (isset($params[$key])) { $string = $params[$key]; - } elseif (strpos($out, $key) != strlen($out) - strlen($key)) { + } elseif (strpos($out, (string) $key) != strlen($out) - strlen($key)) { $key .= '/'; } $search[] = ':' . $key; @@ -536,10 +531,10 @@ protected function _writeUrl($params) { $out = str_replace($search, $replace, $out); } - if (strpos($this->template, '**') !== false) { + if (str_contains($this->template, '**')) { $out = str_replace('**', $params['pass'], $out); $out = str_replace('%2F', '/', $out); - } elseif (strpos($this->template, '*') !== false) { + } elseif (str_contains($this->template, '*')) { $out = str_replace('*', $params['pass'], $out); } $out = str_replace('//', '/', $out); @@ -556,7 +551,7 @@ protected function _writeUrl($params) { * @return CakeRoute A new instance of the route */ public static function __set_state($fields) { - $class = function_exists('get_called_class') ? get_called_class() : __CLASS__; + $class = function_exists('get_called_class') ? static::class : self::class; $obj = new $class(''); foreach ($fields as $field => $value) { $obj->$field = $value; diff --git a/lib/Cake/Routing/Route/RedirectRoute.php b/lib/Cake/Routing/Route/RedirectRoute.php index 26c865fb76..1bb424d709 100644 --- a/lib/Cake/Routing/Route/RedirectRoute.php +++ b/lib/Cake/Routing/Route/RedirectRoute.php @@ -54,7 +54,7 @@ class RedirectRoute extends CakeRoute { * @param array $defaults Array of defaults for the route. * @param array $options Array of additional options for the Route */ - public function __construct($template, $defaults = array(), $options = array()) { + public function __construct($template, $defaults = [], $options = []) { parent::__construct($template, $defaults, $options); $this->redirect = (array)$defaults; } @@ -79,7 +79,7 @@ public function parse($url) { $redirect = $this->redirect[0]; } if (isset($this->options['persist']) && is_array($redirect)) { - $redirect += array('named' => $params['named'], 'pass' => $params['pass'], 'url' => array()); + $redirect += ['named' => $params['named'], 'pass' => $params['pass'], 'url' => []]; if (is_array($this->options['persist'])) { foreach ($this->options['persist'] as $elem) { if (isset($params[$elem])) { @@ -93,7 +93,7 @@ public function parse($url) { if (isset($this->options['status']) && ($this->options['status'] >= 300 && $this->options['status'] < 400)) { $status = $this->options['status']; } - $this->response->header(array('Location' => Router::url($redirect, true))); + $this->response->header(['Location' => Router::url($redirect, true)]); $this->response->statusCode($status); $this->response->send(); $this->_stop(); diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 17256409f9..4823bb0f41 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -45,7 +45,7 @@ class Router { * * @var array */ - public static $routes = array(); + public static $routes = []; /** * Have routes been loaded @@ -68,7 +68,7 @@ class Router { * * @var array */ - protected static $_prefixes = array(); + protected static $_prefixes = []; /** * Directive for Router to parse out file extensions for mapping to Content-types. @@ -82,7 +82,7 @@ class Router { * * @var array */ - protected static $_validExtensions = array(); + protected static $_validExtensions = []; /** * Regular expression for action names @@ -131,54 +131,54 @@ class Router { * * @var array */ - protected static $_namedExpressions = array( + protected static $_namedExpressions = [ 'Action' => Router::ACTION, 'Year' => Router::YEAR, 'Month' => Router::MONTH, 'Day' => Router::DAY, 'ID' => Router::ID, 'UUID' => Router::UUID - ); + ]; /** * Stores all information necessary to decide what named arguments are parsed under what conditions. * * @var string */ - protected static $_namedConfig = array( - 'default' => array('page', 'fields', 'order', 'limit', 'recursive', 'sort', 'direction', 'step'), + protected static $_namedConfig = [ + 'default' => ['page', 'fields', 'order', 'limit', 'recursive', 'sort', 'direction', 'step'], 'greedyNamed' => true, 'separator' => ':', 'rules' => false, - ); + ]; /** * The route matching the URL of the current request * * @var array */ - protected static $_currentRoute = array(); + protected static $_currentRoute = []; /** * Default HTTP request method => controller action map. * * @var array */ - protected static $_resourceMap = array( - array('action' => 'index', 'method' => 'GET', 'id' => false), - array('action' => 'view', 'method' => 'GET', 'id' => true), - array('action' => 'add', 'method' => 'POST', 'id' => false), - array('action' => 'edit', 'method' => 'PUT', 'id' => true), - array('action' => 'delete', 'method' => 'DELETE', 'id' => true), - array('action' => 'edit', 'method' => 'POST', 'id' => true) - ); + protected static $_resourceMap = [ + ['action' => 'index', 'method' => 'GET', 'id' => false], + ['action' => 'view', 'method' => 'GET', 'id' => true], + ['action' => 'add', 'method' => 'POST', 'id' => false], + ['action' => 'edit', 'method' => 'PUT', 'id' => true], + ['action' => 'delete', 'method' => 'DELETE', 'id' => true], + ['action' => 'edit', 'method' => 'POST', 'id' => true] + ]; /** * List of resource-mapped controllers * * @var array */ - protected static $_resourceMapped = array(); + protected static $_resourceMapped = []; /** * Maintains the request object stack for the current request. @@ -186,7 +186,7 @@ class Router { * * @var array */ - protected static $_requests = array(); + protected static $_requests = []; /** * Initial state is populated the first time reload() is called which is at the bottom @@ -195,7 +195,7 @@ class Router { * * @var array */ - protected static $_initialState = array(); + protected static $_initialState = []; /** * Default route class to use @@ -341,7 +341,7 @@ public static function resourceMap($resourceMap = null) { * @return array Array of routes * @throws RouterException */ - public static function connect($route, $defaults = array(), $options = array()) { + public static function connect($route, $defaults = [], $options = []) { static::$initialized = true; foreach (static::$_prefixes as $prefix) { @@ -357,16 +357,16 @@ public static function connect($route, $defaults = array(), $options = array()) if (isset($defaults['prefix']) && !in_array($defaults['prefix'], static::$_prefixes)) { static::$_prefixes[] = $defaults['prefix']; } - $defaults += array('plugin' => null); + $defaults += ['plugin' => null]; if (empty($options['action'])) { - $defaults += array('action' => 'index'); + $defaults += ['action' => 'index']; } $routeClass = static::$_routeClass; if (isset($options['routeClass'])) { - if (strpos($options['routeClass'], '.') === false) { + if (!str_contains($options['routeClass'], '.')) { $routeClass = $options['routeClass']; } else { - list(, $routeClass) = pluginSplit($options['routeClass'], true); + [, $routeClass] = pluginSplit($options['routeClass'], true); } $routeClass = static::_validateRouteClass($routeClass); unset($options['routeClass']); @@ -410,11 +410,11 @@ public static function connect($route, $defaults = array(), $options = array()) * @see routes * @return array Array of routes */ - public static function redirect($route, $url, $options = array()) { + public static function redirect($route, $url, $options = []) { App::uses('RedirectRoute', 'Routing/Route'); $options['routeClass'] = 'RedirectRoute'; if (is_string($url)) { - $url = array('redirect' => $url); + $url = ['redirect' => $url]; } return static::connect($route, $url, $options); } @@ -471,21 +471,21 @@ public static function redirect($route, $url, $options = array()) { * @param array $options Allows to control all settings: separator, greedy, reset, default * @return array */ - public static function connectNamed($named, $options = array()) { + public static function connectNamed($named, $options = []) { if (isset($options['separator'])) { static::$_namedConfig['separator'] = $options['separator']; unset($options['separator']); } if ($named === true || $named === false) { - $options += array('default' => $named, 'reset' => true, 'greedy' => $named); - $named = array(); + $options += ['default' => $named, 'reset' => true, 'greedy' => $named]; + $named = []; } else { - $options += array('default' => false, 'reset' => false, 'greedy' => true); + $options += ['default' => false, 'reset' => false, 'greedy' => true]; } if ($options['reset'] || static::$_namedConfig['rules'] === false) { - static::$_namedConfig['rules'] = array(); + static::$_namedConfig['rules'] = []; } if ($options['default']) { @@ -529,26 +529,26 @@ public static function namedConfig() { * @param array $options Options to use when generating REST routes * @return array Array of mapped resources */ - public static function mapResources($controller, $options = array()) { + public static function mapResources($controller, $options = []) { $hasPrefix = isset($options['prefix']); - $options += array( - 'connectOptions' => array(), + $options += [ + 'connectOptions' => [], 'prefix' => '/', 'id' => static::ID . '|' . static::UUID - ); + ]; $prefix = $options['prefix']; $connectOptions = $options['connectOptions']; unset($options['connectOptions']); - if (strpos($prefix, '/') !== 0) { + if (!str_starts_with($prefix, '/')) { $prefix = '/' . $prefix; } - if (substr($prefix, -1) !== '/') { + if (!str_ends_with($prefix, '/')) { $prefix .= '/'; } foreach ((array)$controller as $name) { - list($plugin, $name) = pluginSplit($name); + [$plugin, $name] = pluginSplit($name); $urlName = Inflector::underscore($name); $plugin = Inflector::underscore($plugin); if ($plugin && !$hasPrefix) { @@ -559,14 +559,14 @@ public static function mapResources($controller, $options = array()) { $url = $prefix . $urlName . (($params['id']) ? '/:id' : ''); Router::connect($url, - array( + [ 'plugin' => $plugin, 'controller' => $urlName, 'action' => $params['action'], '[method]' => $params['method'] - ), + ], array_merge( - array('id' => $options['id'], 'pass' => array('id')), + ['id' => $options['id'], 'pass' => ['id']], $connectOptions ) ); @@ -597,13 +597,13 @@ public static function parse($url) { } $ext = null; - $out = array(); + $out = []; - if (strlen($url) && strpos($url, '/') !== 0) { + if (strlen($url) && !str_starts_with($url, '/')) { $url = '/' . $url; } - if (strpos($url, '?') !== false) { - list($url, $queryParameters) = explode('?', $url, 2); + if (str_contains($url, '?')) { + [$url, $queryParameters] = explode('?', $url, 2); parse_str($queryParameters, $queryParameters); } @@ -678,8 +678,8 @@ public static function setRequestInfo($request) { static::$_requests[] = $request; } else { $requestObj = new CakeRequest(); - $request += array(array(), array()); - $request[0] += array('controller' => false, 'action' => false, 'plugin' => null); + $request += [[], []]; + $request[0] += ['controller' => false, 'action' => false, 'plugin' => null]; $requestObj->addParams($request[0])->addPaths($request[1]); static::$_requests[] = $requestObj; } @@ -705,9 +705,9 @@ public static function popRequest() { public static function getRequest($current = false) { if ($current) { $i = count(static::$_requests) - 1; - return isset(static::$_requests[$i]) ? static::$_requests[$i] : null; + return static::$_requests[$i] ?? null; } - return isset(static::$_requests[0]) ? static::$_requests[0] : null; + return static::$_requests[0] ?? null; } /** @@ -723,7 +723,7 @@ public static function getParams($current = false) { if (isset(static::$_requests[0])) { return static::$_requests[0]->params; } - return array(); + return []; } /** @@ -735,10 +735,7 @@ public static function getParams($current = false) { */ public static function getParam($name = 'controller', $current = false) { $params = Router::getParams($current); - if (isset($params[$name])) { - return $params[$name]; - } - return null; + return $params[$name] ?? null; } /** @@ -752,9 +749,9 @@ public static function getPaths($current = false) { return static::$_requests[count(static::$_requests) - 1]; } if (!isset(static::$_requests[0])) { - return array('base' => null); + return ['base' => null]; } - return array('base' => static::$_requests[0]->base); + return ['base' => static::$_requests[0]->base]; } /** @@ -831,19 +828,19 @@ public static function url($url = null, $full = false) { static::_loadRoutes(); } - $params = array('plugin' => null, 'controller' => null, 'action' => 'index'); + $params = ['plugin' => null, 'controller' => null, 'action' => 'index']; if (is_bool($full)) { $escape = false; } else { - extract($full + array('escape' => false, 'full' => false)); + extract($full + ['escape' => false, 'full' => false]); } - $path = array('base' => null); + $path = ['base' => null]; if (!empty(static::$_requests)) { $request = static::$_requests[count(static::$_requests) - 1]; $params = $request->params; - $path = array('base' => $request->base, 'here' => $request->here); + $path = ['base' => $request->base, 'here' => $request->here]; } if (empty($path['base'])) { $path['base'] = Configure::read('App.base'); @@ -853,7 +850,7 @@ public static function url($url = null, $full = false) { $extension = $output = $q = $frag = null; if (empty($url)) { - $output = isset($path['here']) ? $path['here'] : '/'; + $output = $path['here'] ?? '/'; if ($full) { $output = static::fullBaseUrl() . $output; } @@ -894,12 +891,12 @@ public static function url($url = null, $full = false) { } elseif (isset($url[$prefix]) && !$url[$prefix]) { unset($url[$prefix]); } - if (isset($url[$prefix]) && strpos($url['action'], $prefix . '_') === 0) { + if (isset($url[$prefix]) && str_starts_with($url['action'], $prefix . '_')) { $url['action'] = substr($url['action'], strlen($prefix) + 1); } } - $url += array('controller' => $params['controller'], 'plugin' => $params['plugin']); + $url += ['controller' => $params['controller'], 'plugin' => $params['plugin']]; $match = false; @@ -921,7 +918,7 @@ public static function url($url = null, $full = false) { if (preg_match('/^([a-z][a-z0-9.+\-]+:|:?\/\/|[#?])/i', $url)) { return $url; } - if (substr($url, 0, 1) === '/') { + if (str_starts_with($url, '/')) { $output = substr($url, 1); } else { foreach (static::$_prefixes as $prefix) { @@ -947,7 +944,7 @@ public static function url($url = null, $full = false) { $output = rtrim($output, '/'); } } - return $output . $extension . static::queryString($q, array(), $escape) . $frag; + return $output . $extension . static::queryString($q, [], $escape) . $frag; } /** @@ -985,9 +982,9 @@ public static function fullBaseUrl($base = null) { * @see Router::url() */ protected static function _handleNoRoute($url) { - $named = $args = array(); + $named = $args = []; $skip = array_merge( - array('bare', 'action', 'controller', 'plugin', 'prefix'), + ['bare', 'action', 'controller', 'plugin', 'prefix'], static::$_prefixes ); @@ -1002,10 +999,10 @@ protected static function _handleNoRoute($url) { } } - list($args, $named) = array(Hash::filter($args), Hash::filter($named)); + [$args, $named] = [Hash::filter($args), Hash::filter($named)]; foreach (static::$_prefixes as $prefix) { $prefixed = $prefix . '_'; - if (!empty($url[$prefix]) && strpos($url['action'], $prefixed) === 0) { + if (!empty($url[$prefix]) && str_starts_with($url['action'], $prefixed)) { $url['action'] = substr($url['action'], strlen($prefixed) * -1); break; } @@ -1015,7 +1012,7 @@ protected static function _handleNoRoute($url) { $url['action'] = null; } - $urlOut = array_filter(array($url['controller'], $url['action'])); + $urlOut = array_filter([$url['controller'], $url['action']]); if (isset($url['plugin'])) { array_unshift($urlOut, $url['plugin']); @@ -1057,7 +1054,7 @@ protected static function _handleNoRoute($url) { * @param bool $escape Whether or not to use escaped & * @return string|null */ - public static function queryString($q, $extra = array(), $escape = false) { + public static function queryString($q, $extra = [], $escape = false) { if (empty($q) && empty($extra)) { return null; } @@ -1107,8 +1104,8 @@ public static function reverseToArray($params) { } else { $url = $params['url']; } - $pass = isset($params['pass']) ? $params['pass'] : array(); - $named = isset($params['named']) ? $params['named'] : array(); + $pass = $params['pass'] ?? []; + $named = $params['named'] ?? []; unset( $params['pass'], $params['named'], $params['paging'], $params['models'], $params['url'], $url['url'], $params['autoRender'], $params['bare'], $params['requested'], $params['return'], @@ -1137,7 +1134,7 @@ public static function reverseToArray($params) { * @return string The string that is the reversed result of the array */ public static function reverse($params, $full = false) { - $params = Router::reverseToArray($params, $full); + $params = Router::reverseToArray($params); return Router::url($params, $full); } @@ -1164,7 +1161,7 @@ public static function normalize($url = '/') { } $url = '/' . $url; - while (strpos($url, '//') !== false) { + while (str_contains($url, '//')) { $url = str_replace('//', '/', $url); } $url = preg_replace('/(?:(\/$))/', '', $url); diff --git a/lib/Cake/Test/Case/AllDatabaseTest.php b/lib/Cake/Test/Case/AllDatabaseTest.php index 26c6eef15f..3ffeef1e58 100644 --- a/lib/Cake/Test/Case/AllDatabaseTest.php +++ b/lib/Cake/Test/Case/AllDatabaseTest.php @@ -34,7 +34,7 @@ public static function suite() { $suite = new \PHPUnit\Framework\TestSuite('Datasources, Schema and DbAcl tests'); $path = CORE_TEST_CASES . DS . 'Model' . DS; - $tasks = array( + $tasks = [ 'AclNode', 'CakeSchema', 'ConnectionManager', @@ -46,7 +46,7 @@ public static function suite() { 'Datasource' . DS . 'CakeSession', 'Datasource' . DS . 'Session' . DS . 'CacheSession', 'Datasource' . DS . 'Session' . DS . 'DatabaseSession', - ); + ]; foreach ($tasks as $task) { $suite->addTestFile($path . $task . 'Test.php'); } diff --git a/lib/Cake/Test/Case/BasicsTest.php b/lib/Cake/Test/Case/BasicsTest.php index 2bcce45490..7cfd72ba4a 100644 --- a/lib/Cake/Test/Case/BasicsTest.php +++ b/lib/Cake/Test/Case/BasicsTest.php @@ -36,9 +36,9 @@ class BasicsTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - App::build(array( - 'Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS) - )); + App::build([ + 'Locale' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS] + ]); } /** @@ -47,28 +47,28 @@ public function setUp() : void { * @return void */ public function testArrayDiffKey() { - $one = array('one' => 1, 'two' => 2, 'three' => 3); - $two = array('one' => 'one', 'two' => 'two'); + $one = ['one' => 1, 'two' => 2, 'three' => 3]; + $two = ['one' => 'one', 'two' => 'two']; $result = array_diff_key($one, $two); - $expected = array('three' => 3); + $expected = ['three' => 3]; $this->assertEquals($expected, $result); - $one = array('one' => array('value', 'value-two'), 'two' => 2, 'three' => 3); - $two = array('two' => 'two'); + $one = ['one' => ['value', 'value-two'], 'two' => 2, 'three' => 3]; + $two = ['two' => 'two']; $result = array_diff_key($one, $two); - $expected = array('one' => array('value', 'value-two'), 'three' => 3); + $expected = ['one' => ['value', 'value-two'], 'three' => 3]; $this->assertEquals($expected, $result); - $one = array('one' => null, 'two' => 2, 'three' => '', 'four' => 0); - $two = array('two' => 'two'); + $one = ['one' => null, 'two' => 2, 'three' => '', 'four' => 0]; + $two = ['two' => 'two']; $result = array_diff_key($one, $two); - $expected = array('one' => null, 'three' => '', 'four' => 0); + $expected = ['one' => null, 'three' => '', 'four' => 0]; $this->assertEquals($expected, $result); - $one = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true); - $two = array('minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true); + $one = ['minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true]; + $two = ['minYear' => null, 'maxYear' => null, 'separator' => '-', 'interval' => 1, 'monthNames' => true]; $result = array_diff_key($one, $two); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -115,18 +115,18 @@ public function testEnv() { $_SERVER['HTTP_HOST'] = 'double.subdomain.example.com.ar'; $this->assertEquals(env('HTTP_BASE'), '.subdomain.example.com.ar'); - $_SERVER = $_ENV = array(); + $_SERVER = $_ENV = []; $_SERVER['SCRIPT_NAME'] = '/a/test/test.php'; $this->assertEquals(env('SCRIPT_NAME'), '/a/test/test.php'); - $_SERVER = $_ENV = array(); + $_SERVER = $_ENV = []; $_ENV['CGI_MODE'] = 'BINARY'; $_ENV['SCRIPT_URL'] = '/a/test/test.php'; $this->assertEquals(env('SCRIPT_NAME'), '/a/test/test.php'); - $_SERVER = $_ENV = array(); + $_SERVER = $_ENV = []; $this->assertFalse(env('HTTPS')); @@ -151,7 +151,7 @@ public function testEnv() { $_SERVER['HTTPS'] = ''; $this->assertFalse(env('HTTPS')); - $_SERVER = array(); + $_SERVER = []; $_ENV['SCRIPT_URI'] = 'https://domain.test/a/test.php'; $this->assertTrue(env('HTTPS')); @@ -159,7 +159,7 @@ public function testEnv() { $_ENV['SCRIPT_URI'] = 'http://domain.test/a/test.php'; $this->assertFalse(env('HTTPS')); - $_SERVER = $_ENV = array(); + $_SERVER = $_ENV = []; $this->assertNull(env('TEST_ME')); @@ -186,9 +186,9 @@ public function testH() { $result = h($string); $this->assertEquals('<foo>', $result); - $in = array('this & that', '

Which one

'); + $in = ['this & that', '

Which one

']; $result = h($in); - $expected = array('this & that', '<p>Which one</p>'); + $expected = ['this & that', '<p>Which one</p>']; $this->assertEquals($expected, $result); $string = ' &  '; @@ -203,35 +203,35 @@ public function testH() { $result = h($string, 'UTF-8'); $this->assertEquals('<foo> & &nbsp;', $result); - $arr = array('', ' '); + $arr = ['', ' ']; $result = h($arr); - $expected = array( + $expected = [ '<foo>', '&nbsp;' - ); + ]; $this->assertEquals($expected, $result); - $arr = array('', ' '); + $arr = ['', ' ']; $result = h($arr, false); - $expected = array( + $expected = [ '<foo>', ' ' - ); + ]; $this->assertEquals($expected, $result); - $arr = array('f' => '', 'n' => ' '); + $arr = ['f' => '', 'n' => ' ']; $result = h($arr, false); - $expected = array( + $expected = [ 'f' => '<foo>', 'n' => ' ' - ); + ]; $this->assertEquals($expected, $result); // Test that boolean values are not converted to strings $result = h(false); $this->assertFalse($result); - $arr = array('foo' => false, 'bar' => true); + $arr = ['foo' => false, 'bar' => true]; $result = h($arr); $this->assertFalse($result['foo']); $this->assertTrue($result['bar']); @@ -240,7 +240,7 @@ public function testH() { $result = h($obj); $this->assertEquals('(object)stdClass', $result); - $obj = new CakeResponse(array('body' => 'Body content')); + $obj = new CakeResponse(['body' => 'Body content']); $result = h($obj); $this->assertEquals('Body content', $result); @@ -254,12 +254,12 @@ public function testH() { * @return void */ public function testAm() { - $result = am(array('one', 'two'), 2, 3, 4); - $expected = array('one', 'two', 2, 3, 4); + $result = am(['one', 'two'], 2, 3, 4); + $expected = ['one', 'two', 2, 3, 4]; $this->assertEquals($expected, $result); - $result = am(array('one' => array(2, 3), 'two' => array('foo')), array('one' => array(4, 5))); - $expected = array('one' => array(4, 5), 'two' => array('foo')); + $result = am(['one' => [2, 3], 'two' => ['foo']], ['one' => [4, 5]]); + $expected = ['one' => [4, 5], 'two' => ['foo']]; $this->assertEquals($expected, $result); } @@ -316,7 +316,7 @@ public function testClearCache() { cache('views' . DS . 'basics_test_3.cache', 'simple cache write 3'); $this->assertTrue(file_exists(CACHE . 'views' . DS . 'basics_test_3.cache')); - $result = clearCache(array('basics_test', 'basics_test_2'), 'views', '.cache'); + $result = clearCache(['basics_test', 'basics_test_2'], 'views', '.cache'); $this->assertTrue($result); $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test.cache')); $this->assertFalse(file_exists(CACHE . 'views' . DS . 'basics_test.cache')); @@ -392,7 +392,7 @@ public function testTranslate() { $expected = 'Some string with multiple arguments, first being null'; $this->assertEquals($expected, $result); - $result = __('Some string with %s %s', array('multiple', 'arguments')); + $result = __('Some string with %s %s', ['multiple', 'arguments']); $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); @@ -400,7 +400,7 @@ public function testTranslate() { $expected = 'Testing different order'; $this->assertEquals($expected, $result); - $result = __('Testing %2$s %1$s', array('order', 'different')); + $result = __('Testing %2$s %1$s', ['order', 'different']); $expected = 'Testing different order'; $this->assertEquals($expected, $result); @@ -612,7 +612,7 @@ public function testTranslatePlural() { $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); - $result = __n('%d item for id %s', '%d items for id %s', 2, array(2, '1234')); + $result = __n('%d item for id %s', '%d items for id %s', 2, [2, '1234']); $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); } @@ -645,7 +645,7 @@ public function testTranslateDomain() { $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); - $result = __d('core', 'Some string with %s %s', array('multiple', 'arguments')); + $result = __d('core', 'Some string with %s %s', ['multiple', 'arguments']); $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); } @@ -682,7 +682,7 @@ public function testTranslateDomainPlural() { $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); - $result = __dn('core', '%d item for id %s', '%d items for id %s', 2, array(2, '1234')); + $result = __dn('core', '%d item for id %s', '%d items for id %s', 2, [2, '1234']); $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); } @@ -711,7 +711,7 @@ public function testTranslateCategory() { $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); - $result = __c('Some string with %s %s', 6, array('multiple', 'arguments')); + $result = __c('Some string with %s %s', 6, ['multiple', 'arguments']); $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); } @@ -748,7 +748,7 @@ public function testTranslateDomainCategory() { $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); - $result = __dc('core', 'Some string with %s %s', 6, array('multiple', 'arguments')); + $result = __dc('core', 'Some string with %s %s', 6, ['multiple', 'arguments']); $expected = 'Some string with multiple arguments'; $this->assertEquals($expected, $result); } @@ -781,7 +781,7 @@ public function testTranslateDomainCategoryPlural() { $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); - $result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, array(2, '1234')); + $result = __dcn('core', '%d item for id %s', '%d items for id %s', 2, 6, [2, '1234']); $expected = '2 items for id 1234'; $this->assertEquals($expected, $result); } @@ -1054,7 +1054,7 @@ public function testPr() { $this->assertEquals($expected, $result); ob_start(); - pr(array('this' => 'is', 'a' => 'test')); + pr(['this' => 'is', 'a' => 'test']); $result = ob_get_clean(); $expected = "
Array\n(\n    [this] => is\n    [a] => test\n)\n
"; $this->assertEquals($expected, $result); @@ -1074,7 +1074,7 @@ public function testPrCli() { $this->assertEquals($expected, $result); ob_start(); - pr(array('this' => 'is', 'a' => 'test')); + pr(['this' => 'is', 'a' => 'test']); $result = ob_get_clean(); $expected = "\nArray\n(\n [this] => is\n [a] => test\n)\n\n"; $this->assertEquals($expected, $result); @@ -1094,26 +1094,26 @@ public function testStripslashesDeep() { $this->assertEquals(stripslashes_deep("tes\'t"), "tes't"); $this->assertEquals(stripslashes_deep('te\\st'), 'test'); - $nested = array( + $nested = [ 'a' => "tes\'t", 'b' => 'tes\\' . chr(0) . 't', - 'c' => array( + 'c' => [ 'd' => 'tes\"t', 'e' => "te\'s\'t", - array('f' => "tes\'t") - ), + ['f' => "tes\'t"] + ], 'g' => 'te\\st' - ); - $expected = array( + ]; + $expected = [ 'a' => "tes't", 'b' => 'tes' . chr(0) . 't', - 'c' => array( + 'c' => [ 'd' => 'tes"t', 'e' => "te's't", - array('f' => "tes't") - ), + ['f' => "tes't"] + ], 'g' => 'test' - ); + ]; $this->assertEquals($expected, stripslashes_deep($nested)); } @@ -1129,26 +1129,26 @@ public function testStripslashesDeepSybase() { $this->assertEquals(stripslashes_deep("tes\'t"), "tes\'t"); - $nested = array( + $nested = [ 'a' => "tes't", 'b' => "tes''t", - 'c' => array( + 'c' => [ 'd' => "tes'''t", 'e' => "tes''''t", - array('f' => "tes''t") - ), + ['f' => "tes''t"] + ], 'g' => "te'''''st" - ); - $expected = array( + ]; + $expected = [ 'a' => "tes't", 'b' => "tes't", - 'c' => array( + 'c' => [ 'd' => "tes''t", 'e' => "tes''t", - array('f' => "tes't") - ), + ['f' => "tes't"] + ], 'g' => "te'''st" - ); + ]; $this->assertEquals($expected, stripslashes_deep($nested)); } @@ -1159,13 +1159,13 @@ public function testStripslashesDeepSybase() { */ public function testStackTrace() { ob_start(); - list(, $expected) = array(stackTrace(), Debugger::trace()); + [, $expected] = [stackTrace(), Debugger::trace()]; $result = ob_get_clean(); $this->assertEquals($expected, $result); - $opts = array('args' => true); + $opts = ['args' => true]; ob_start(); - list(, $expected) = array(stackTrace($opts), Debugger::trace($opts)); + [, $expected] = [stackTrace($opts), Debugger::trace($opts)]; $result = ob_get_clean(); $this->assertEquals($expected, $result); } @@ -1177,24 +1177,24 @@ public function testStackTrace() { */ public function testPluginSplit() { $result = pluginSplit('Something.else'); - $this->assertEquals(array('Something', 'else'), $result); + $this->assertEquals(['Something', 'else'], $result); $result = pluginSplit('Something.else.more.dots'); - $this->assertEquals(array('Something', 'else.more.dots'), $result); + $this->assertEquals(['Something', 'else.more.dots'], $result); $result = pluginSplit('Somethingelse'); - $this->assertEquals(array(null, 'Somethingelse'), $result); + $this->assertEquals([null, 'Somethingelse'], $result); $result = pluginSplit('Something.else', true); - $this->assertEquals(array('Something.', 'else'), $result); + $this->assertEquals(['Something.', 'else'], $result); $result = pluginSplit('Something.else.more.dots', true); - $this->assertEquals(array('Something.', 'else.more.dots'), $result); + $this->assertEquals(['Something.', 'else.more.dots'], $result); $result = pluginSplit('Post', false, 'Blog'); - $this->assertEquals(array('Blog', 'Post'), $result); + $this->assertEquals(['Blog', 'Post'], $result); $result = pluginSplit('Blog.Post', false, 'Ultimate'); - $this->assertEquals(array('Blog', 'Post'), $result); + $this->assertEquals(['Blog', 'Post'], $result); } } diff --git a/lib/Cake/Test/Case/Cache/CacheTest.php b/lib/Cake/Test/Case/Cache/CacheTest.php index 3bd850217d..ea2e0e4f8a 100644 --- a/lib/Cake/Test/Case/Cache/CacheTest.php +++ b/lib/Cake/Test/Case/Cache/CacheTest.php @@ -38,7 +38,7 @@ public function setUp() : void { Configure::write('Cache.disable', false); $this->_defaultCacheConfig = Cache::config('default'); - Cache::config('default', array('engine' => 'File', 'path' => TMP . 'tests')); + Cache::config('default', ['engine' => 'File', 'path' => TMP . 'tests']); } /** @@ -61,7 +61,7 @@ public function tearDown() : void { * @return void */ public function testConfig() { - $settings = array('engine' => 'File', 'path' => TMP . 'tests', 'prefix' => 'cake_test_'); + $settings = ['engine' => 'File', 'path' => TMP . 'tests', 'prefix' => 'cake_test_']; $results = Cache::config('new', $settings); $this->assertEquals(Cache::config('new'), $results); $this->assertTrue(isset($results['engine'])); @@ -75,7 +75,7 @@ public function testConfig() { */ public function testConfigInvalidEngine() { $this->expectException(CacheException::class); - $settings = array('engine' => 'Imaginary'); + $settings = ['engine' => 'Imaginary']; Cache::config('imaginary', $settings); } @@ -86,7 +86,7 @@ public function testConfigInvalidEngine() { */ public function testNonFatalErrorsWithCachedisable() { Configure::write('Cache.disable', true); - Cache::config('test', array('engine' => 'File', 'path' => TMP, 'prefix' => 'error_test_')); + Cache::config('test', ['engine' => 'File', 'path' => TMP, 'prefix' => 'error_test_']); Cache::write('no_save', 'Noooo!', 'test'); Cache::read('no_save', 'test'); @@ -102,17 +102,17 @@ public function testNonFatalErrorsWithCachedisable() { * @return void */ public function testConfigWithLibAndPluginEngines() { - App::build(array( - 'Lib' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Lib' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); - $settings = array('engine' => 'TestAppCache', 'path' => TMP, 'prefix' => 'cake_test_'); + $settings = ['engine' => 'TestAppCache', 'path' => TMP, 'prefix' => 'cake_test_']; $result = Cache::config('libEngine', $settings); $this->assertEquals(Cache::config('libEngine'), $result); - $settings = array('engine' => 'TestPlugin.TestPluginCache', 'path' => TMP, 'prefix' => 'cake_test_'); + $settings = ['engine' => 'TestPlugin.TestPluginCache', 'path' => TMP, 'prefix' => 'cake_test_']; $result = Cache::config('pluginLibEngine', $settings); $this->assertEquals(Cache::config('pluginLibEngine'), $result); @@ -136,14 +136,14 @@ public function testInvalidConfig() { $debug = Configure::read('debug'); Configure::write('debug', 0); - Cache::config('invalid', array( + Cache::config('invalid', [ 'engine' => 'File', 'duration' => '+1 year', 'prefix' => 'testing_invalid_', 'path' => 'data/', 'serialize' => true, 'random' => 'wii' - )); + ]); Cache::read('Test', 'invalid'); Configure::write('debug', $debug); @@ -168,10 +168,10 @@ public function testReadNonExistingConfig() { */ public function testAttemptingToConfigureANonCacheEngineClass() { $this->expectException(CacheException::class); - $this->getMock('StdClass', array(), array(), 'RubbishEngine'); - Cache::config('Garbage', array( + $this->getMock('StdClass', [], [], 'RubbishEngine'); + Cache::config('Garbage', [ 'engine' => 'Rubbish' - )); + ]); } /** @@ -183,10 +183,10 @@ public function testConfigChange() { $_cacheConfigSessions = Cache::config('sessions'); $_cacheConfigTests = Cache::config('tests'); - $result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions')); + $result = Cache::config('sessions', ['engine' => 'File', 'path' => TMP . 'sessions']); $this->assertEquals(Cache::settings('sessions'), $result['settings']); - $result = Cache::config('tests', array('engine' => 'File', 'path' => TMP . 'tests')); + $result = Cache::config('tests', ['engine' => 'File', 'path' => TMP . 'tests']); $this->assertEquals(Cache::settings('tests'), $result['settings']); if ($_cacheConfigSessions !== false) { @@ -203,7 +203,7 @@ public function testConfigChange() { * @return void */ public function testConfigSettingDefaultConfigKey() { - Cache::config('test_name', array('engine' => 'File', 'prefix' => 'test_name_')); + Cache::config('test_name', ['engine' => 'File', 'prefix' => 'test_name_']); Cache::write('value_one', 'I am cached', 'test_name'); $result = Cache::read('value_one', 'test_name'); @@ -233,7 +233,7 @@ public function testWritingWithConfig() { Cache::write('test_something', 'this is the test data', 'tests'); - $expected = array( + $expected = [ 'path' => TMP . 'sessions' . DS, 'prefix' => 'cake_', 'lock' => true, @@ -243,8 +243,8 @@ public function testWritingWithConfig() { 'engine' => 'File', 'isWindows' => DIRECTORY_SEPARATOR === '\\', 'mask' => 0664, - 'groups' => array() - ); + 'groups' => [] + ]; $this->assertEquals($expected, Cache::settings('sessions')); Cache::config('sessions', $_cacheConfigSessions['settings']); @@ -256,53 +256,53 @@ public function testWritingWithConfig() { * @return void */ public function testGroupConfigs() { - Cache::config('latest', array( + Cache::config('latest', [ 'duration' => 300, 'engine' => 'File', - 'groups' => array( + 'groups' => [ 'posts', 'comments', - ), - )); + ], + ]); - $expected = array( - 'posts' => array('latest'), - 'comments' => array('latest'), - ); + $expected = [ + 'posts' => ['latest'], + 'comments' => ['latest'], + ]; $result = Cache::groupConfigs(); $this->assertEquals($expected, $result); $result = Cache::groupConfigs('posts'); - $this->assertEquals(array('posts' => array('latest')), $result); + $this->assertEquals(['posts' => ['latest']], $result); - Cache::config('page', array( + Cache::config('page', [ 'duration' => 86400, 'engine' => 'File', - 'groups' => array( + 'groups' => [ 'posts', 'archive' - ), - )); + ], + ]); $result = Cache::groupConfigs(); - $expected = array( - 'posts' => array('latest', 'page'), - 'comments' => array('latest'), - 'archive' => array('page'), - ); + $expected = [ + 'posts' => ['latest', 'page'], + 'comments' => ['latest'], + 'archive' => ['page'], + ]; $this->assertEquals($expected, $result); $result = Cache::groupConfigs('archive'); - $this->assertEquals(array('archive' => array('page')), $result); + $this->assertEquals(['archive' => ['page']], $result); - Cache::config('archive', array( + Cache::config('archive', [ 'duration' => 86400 * 30, 'engine' => 'File', - 'groups' => array( + 'groups' => [ 'posts', 'archive', 'comments', - ), - )); + ], + ]); $result = Cache::groupConfigs('archive'); - $this->assertEquals(array('archive' => array('archive', 'page')), $result); + $this->assertEquals(['archive' => ['archive', 'page']], $result); } /** @@ -334,7 +334,7 @@ public function testConfigured() { */ public function testInitSettings() { $initial = Cache::settings(); - $override = array('engine' => 'File', 'path' => TMP . 'tests'); + $override = ['engine' => 'File', 'path' => TMP . 'tests']; Cache::config('for_test', $override); $settings = Cache::settings(); @@ -349,10 +349,10 @@ public function testInitSettings() { * @return void */ public function testDrop() { - App::build(array( - 'Lib' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Lib' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); $result = Cache::drop('some_config_that_does_not_exist'); $this->assertFalse($result); @@ -361,9 +361,9 @@ public function testDrop() { $result = Cache::drop('tests'); $this->assertTrue($result); - Cache::config('unconfigTest', array( + Cache::config('unconfigTest', [ 'engine' => 'TestAppCache' - )); + ]); $this->assertTrue(Cache::isInitialized('unconfigTest')); $this->assertTrue(Cache::drop('unconfigTest')); @@ -401,16 +401,16 @@ public function testWriteEmptyValues() { * @return void */ public function testWriteTriggerError() { - App::build(array( - 'Lib' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Lib' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); - Cache::config('test_trigger', array('engine' => 'TestAppCache', 'prefix' => '')); + Cache::config('test_trigger', ['engine' => 'TestAppCache', 'prefix' => '']); try { Cache::write('fail', 'value', 'test_trigger'); $this->fail('No exception thrown'); - } catch (PHPUnit\Framework\Error\Error $e) { + } catch (PHPUnit\Framework\Error\Error) { $this->assertTrue(true); } Cache::drop('test_trigger'); @@ -427,7 +427,7 @@ public function testWriteTriggerError() { */ public function testCacheDisable() { Configure::write('Cache.disable', false); - Cache::config('test_cache_disable_1', array('engine' => 'File', 'path' => TMP . 'tests')); + Cache::config('test_cache_disable_1', ['engine' => 'File', 'path' => TMP . 'tests']); $this->assertTrue(Cache::write('key_1', 'hello', 'test_cache_disable_1')); $this->assertSame(Cache::read('key_1', 'test_cache_disable_1'), 'hello'); @@ -443,7 +443,7 @@ public function testCacheDisable() { $this->assertSame(Cache::read('key_3', 'test_cache_disable_1'), 'hello'); Configure::write('Cache.disable', true); - Cache::config('test_cache_disable_2', array('engine' => 'File', 'path' => TMP . 'tests')); + Cache::config('test_cache_disable_2', ['engine' => 'File', 'path' => TMP . 'tests']); $this->assertFalse(Cache::write('key_4', 'hello', 'test_cache_disable_2')); $this->assertFalse(Cache::read('key_4', 'test_cache_disable_2')); @@ -467,7 +467,7 @@ public function testCacheDisable() { public function testSet() { $_cacheSet = Cache::set(); - Cache::set(array('duration' => '+1 year')); + Cache::set(['duration' => '+1 year']); $data = Cache::read('test_cache'); $this->assertFalse($data); @@ -475,7 +475,7 @@ public function testSet() { $write = Cache::write('test_cache', $data); $this->assertTrue($write); - Cache::set(array('duration' => '+1 year')); + Cache::set(['duration' => '+1 year']); $data = Cache::read('test_cache'); $this->assertEquals('this is just a simple test of the cache system', $data); @@ -492,8 +492,8 @@ public function testSet() { * @return void */ public function testSetOnAlternateConfigs() { - Cache::config('file_config', array('engine' => 'File', 'prefix' => 'test_file_')); - Cache::set(array('duration' => '+1 year'), 'file_config'); + Cache::config('file_config', ['engine' => 'File', 'prefix' => 'test_file_']); + Cache::set(['duration' => '+1 year'], 'file_config'); $settings = Cache::settings('file_config'); $this->assertEquals('test_file_', $settings['prefix']); @@ -507,11 +507,11 @@ public function testSetOnAlternateConfigs() { */ public function testRemember() { $expected = 'This is some data 0'; - $result = Cache::remember('test_key', array($this, 'cacher'), 'default'); + $result = Cache::remember('test_key', [$this, 'cacher'], 'default'); $this->assertEquals($expected, $result); $this->_count = 1; - $result = Cache::remember('test_key', array($this, 'cacher'), 'default'); + $result = Cache::remember('test_key', [$this, 'cacher'], 'default'); $this->assertEquals($expected, $result); } @@ -574,11 +574,11 @@ public function testEngineSuccessMemcached() { $this->skipIf(!$socket, 'Memcached is not running.'); fclose($socket); - Cache::config('memcached', array( + Cache::config('memcached', [ 'engine' => 'Memcached', 'prefix' => 'cake_', 'duration' => 3600 - )); + ]); $actual = Cache::engine('memcached'); $this->assertInstanceOf('MemcachedEngine', $actual); diff --git a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php index 038fa6561b..6dc7bb3978 100644 --- a/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/ApcEngineTest.php @@ -52,7 +52,7 @@ public function setUp() : void { $this->_cacheDisable = Configure::read('Cache.disable'); Configure::write('Cache.disable', false); - Cache::config('apc', array('engine' => 'Apc', 'prefix' => 'cake_')); + Cache::config('apc', ['engine' => 'Apc', 'prefix' => 'cake_']); } /** @@ -74,7 +74,7 @@ public function tearDown() : void { * @return void */ public function testReadAndWriteCache() { - Cache::set(array('duration' => 1), 'apc'); + Cache::set(['duration' => 1], 'apc'); $result = Cache::read('test', 'apc'); $expecting = ''; @@ -97,7 +97,7 @@ public function testReadAndWriteCache() { * @return void */ public function testReadWriteDurationZero() { - Cache::config('apc', array('engine' => 'Apc', 'duration' => 0, 'prefix' => 'cake_')); + Cache::config('apc', ['engine' => 'Apc', 'duration' => 0, 'prefix' => 'cake_']); Cache::write('zero', 'Should save', 'apc'); sleep(1); @@ -111,7 +111,7 @@ public function testReadWriteDurationZero() { * @return void */ public function testExpiry() { - Cache::set(array('duration' => 1), 'apc'); + Cache::set(['duration' => 1], 'apc'); $result = Cache::read('test', 'apc'); $this->assertFalse($result); @@ -124,7 +124,7 @@ public function testExpiry() { $result = Cache::read('other_test', 'apc'); $this->assertFalse($result); - Cache::set(array('duration' => 1), 'apc'); + Cache::set(['duration' => 1], 'apc'); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('other_test', $data, 'apc'); @@ -232,12 +232,12 @@ public function testClear() { */ public function testGroupsReadWrite() { $incFunc = $this->_apcExtension . '_inc'; - Cache::config('apc_groups', array( + Cache::config('apc_groups', [ 'engine' => 'Apc', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups')); $this->assertEquals('value', Cache::read('test_groups', 'apc_groups')); @@ -258,12 +258,12 @@ public function testGroupsReadWrite() { * @return void */ public function testGroupDelete() { - Cache::config('apc_groups', array( + Cache::config('apc_groups', [ 'engine' => 'Apc', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups')); $this->assertEquals('value', Cache::read('test_groups', 'apc_groups')); $this->assertTrue(Cache::delete('test_groups', 'apc_groups')); @@ -277,12 +277,12 @@ public function testGroupDelete() { * @return void */ public function testGroupClear() { - Cache::config('apc_groups', array( + Cache::config('apc_groups', [ 'engine' => 'Apc', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'apc_groups')); $this->assertTrue(Cache::clearGroup('group_a', 'apc_groups')); diff --git a/lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php index e6e056f949..7f499174bf 100644 --- a/lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/FileEngineTest.php @@ -30,7 +30,7 @@ class FileEngineTest extends CakeTestCase { * * @var array */ - public $config = array(); + public $config = []; /** * setUp method @@ -40,7 +40,7 @@ class FileEngineTest extends CakeTestCase { public function setUp() : void { parent::setUp(); Configure::write('Cache.disable', false); - Cache::config('file_test', array('engine' => 'File', 'path' => CACHE)); + Cache::config('file_test', ['engine' => 'File', 'path' => CACHE]); } /** @@ -63,10 +63,10 @@ public function tearDown() : void { * @return void */ public function testCacheDirChange() { - $result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'sessions')); + $result = Cache::config('sessions', ['engine' => 'File', 'path' => TMP . 'sessions']); $this->assertEquals(Cache::settings('sessions'), $result['settings']); - $result = Cache::config('sessions', array('engine' => 'File', 'path' => TMP . 'tests')); + $result = Cache::config('sessions', ['engine' => 'File', 'path' => TMP . 'tests']); $this->assertEquals(Cache::settings('sessions'), $result['settings']); $this->assertNotEquals(Cache::settings('default'), $result['settings']); } @@ -82,7 +82,7 @@ public function testReadAndWriteCache() { $result = Cache::write(null, 'here', 'file_test'); $this->assertFalse($result); - Cache::set(array('duration' => 1), 'file_test'); + Cache::set(['duration' => 1], 'file_test'); $result = Cache::read('test', 'file_test'); $expecting = ''; @@ -122,7 +122,7 @@ public function testConsecutiveReadWrite() { * @return void */ public function testExpiry() { - Cache::set(array('duration' => 1), 'file_test'); + Cache::set(['duration' => 1], 'file_test'); $result = Cache::read('test', 'file_test'); $this->assertFalse($result); @@ -135,7 +135,7 @@ public function testExpiry() { $result = Cache::read('other_test', 'file_test'); $this->assertFalse($result); - Cache::set(array('duration' => "+1 second"), 'file_test'); + Cache::set(['duration' => "+1 second"], 'file_test'); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('other_test', $data, 'file_test'); @@ -170,12 +170,12 @@ public function testDeleteCache() { * @return void */ public function testSerialize() { - Cache::config('file_test', array('engine' => 'File', 'serialize' => true)); + Cache::config('file_test', ['engine' => 'File', 'serialize' => true]); $data = 'this is a test of the emergency broadcasting system'; $write = Cache::write('serialize_test', $data, 'file_test'); $this->assertTrue($write); - Cache::config('file_test', array('serialize' => false)); + Cache::config('file_test', ['serialize' => false]); $read = Cache::read('serialize_test', 'file_test'); $newread = Cache::read('serialize_test', 'file_test'); @@ -193,7 +193,7 @@ public function testSerialize() { * @return void */ public function testClear() { - Cache::config('file_test', array('engine' => 'File', 'duration' => 1)); + Cache::config('file_test', ['engine' => 'File', 'duration' => 1]); $data = 'this is a test of the emergency broadcasting system'; Cache::write('serialize_test1', $data, 'file_test'); @@ -231,15 +231,15 @@ public function testClear() { */ public function testClearWithPrefixes() { $FileOne = new FileEngine(); - $FileOne->init(array( + $FileOne->init([ 'prefix' => 'prefix_one_', 'duration' => DAY - )); + ]); $FileTwo = new FileEngine(); - $FileTwo->init(array( + $FileTwo->init([ 'prefix' => 'prefix_two_', 'duration' => DAY - )); + ]); $dataOne = $dataTwo = $expected = 'content to cache'; $FileOne->write('prefix_one_key_one', $dataOne, DAY); @@ -260,11 +260,11 @@ public function testClearWithPrefixes() { */ public function testClearWithGroups() { $engine = new FileEngine(); - $engine->init(array( + $engine->init([ 'prefix' => 'cake_test_', 'duration' => DAY, - 'groups' => array('short', 'round') - )); + 'groups' => ['short', 'round'] + ]); $key = 'cake_test_test_key'; $engine->write($key, 'it works', DAY); $engine->clear(false); @@ -278,11 +278,11 @@ public function testClearWithGroups() { */ public function testClearWithNoKeys() { $engine = new FileEngine(); - $engine->init(array( + $engine->init([ 'prefix' => 'cake_test_', 'duration' => DAY, - 'groups' => array('one', 'two') - )); + 'groups' => ['one', 'two'] + ]); $key = 'cake_test_test_key'; $engine->clear(false); $this->assertFalse($engine->read($key), 'No errors should be found'); @@ -319,10 +319,10 @@ public function testKeyPath() { * @return void */ public function testRemoveWindowsSlashesFromCache() { - Cache::config('windows_test', array('engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP)); + Cache::config('windows_test', ['engine' => 'File', 'isWindows' => true, 'prefix' => null, 'path' => TMP]); - $expected = array( - 'C:\dev\prj2\sites\cake\libs' => array( + $expected = [ + 'C:\dev\prj2\sites\cake\libs' => [ 0 => 'C:\dev\prj2\sites\cake\libs', 1 => 'C:\dev\prj2\sites\cake\libs\view', 2 => 'C:\dev\prj2\sites\cake\libs\view\scaffolds', 3 => 'C:\dev\prj2\sites\cake\libs\view\pages', 4 => 'C:\dev\prj2\sites\cake\libs\view\layouts', 5 => 'C:\dev\prj2\sites\cake\libs\view\layouts\xml', @@ -334,21 +334,21 @@ public function testRemoveWindowsSlashesFromCache() { 16 => 'C:\dev\prj2\sites\cake\libs\view\elements\email\html', 17 => 'C:\dev\prj2\sites\cake\libs\model', 18 => 'C:\dev\prj2\sites\cake\libs\model\datasources', 19 => 'C:\dev\prj2\sites\cake\libs\model\datasources\dbo', 20 => 'C:\dev\prj2\sites\cake\libs\model\behaviors', 21 => 'C:\dev\prj2\sites\cake\libs\controller', - 22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'), - 'C:\dev\prj2\sites\main_site\vendors' => array( + 22 => 'C:\dev\prj2\sites\cake\libs\controller\components', 23 => 'C:\dev\prj2\sites\cake\libs\cache'], + 'C:\dev\prj2\sites\main_site\vendors' => [ 0 => 'C:\dev\prj2\sites\main_site\vendors', 1 => 'C:\dev\prj2\sites\main_site\vendors\shells', 2 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates', 3 => 'C:\dev\prj2\sites\main_site\vendors\shells\templates\cdc_project', 4 => 'C:\dev\prj2\sites\main_site\vendors\shells\tasks', 5 => 'C:\dev\prj2\sites\main_site\vendors\js', - 6 => 'C:\dev\prj2\sites\main_site\vendors\css'), - 'C:\dev\prj2\sites\vendors' => array( + 6 => 'C:\dev\prj2\sites\main_site\vendors\css'], + 'C:\dev\prj2\sites\vendors' => [ 0 => 'C:\dev\prj2\sites\vendors', 1 => 'C:\dev\prj2\sites\vendors\simpletest', 2 => 'C:\dev\prj2\sites\vendors\simpletest\test', 3 => 'C:\dev\prj2\sites\vendors\simpletest\test\support', 4 => 'C:\dev\prj2\sites\vendors\simpletest\test\support\collector', 5 => 'C:\dev\prj2\sites\vendors\simpletest\extensions', 6 => 'C:\dev\prj2\sites\vendors\simpletest\extensions\testdox', 7 => 'C:\dev\prj2\sites\vendors\simpletest\docs', - 8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'), - 'C:\dev\prj2\sites\main_site\views\helpers' => array( - 0 => 'C:\dev\prj2\sites\main_site\views\helpers') - ); + 8 => 'C:\dev\prj2\sites\vendors\simpletest\docs\fr', 9 => 'C:\dev\prj2\sites\vendors\simpletest\docs\en'], + 'C:\dev\prj2\sites\main_site\views\helpers' => [ + 0 => 'C:\dev\prj2\sites\main_site\views\helpers'] + ]; Cache::write('test_dir_map', $expected, 'windows_test'); $data = Cache::read('test_dir_map', 'windows_test'); @@ -364,13 +364,13 @@ public function testRemoveWindowsSlashesFromCache() { * @return void */ public function testWriteQuotedString() { - Cache::config('file_test', array('engine' => 'File', 'path' => TMP . 'tests')); + Cache::config('file_test', ['engine' => 'File', 'path' => TMP . 'tests']); Cache::write('App.doubleQuoteTest', '"this is a quoted string"', 'file_test'); $this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"'); Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test'); $this->assertSame(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'"); - Cache::config('file_test', array('isWindows' => true, 'path' => TMP . 'tests')); + Cache::config('file_test', ['isWindows' => true, 'path' => TMP . 'tests']); $this->assertSame(Cache::read('App.doubleQuoteTest', 'file_test'), '"this is a quoted string"'); Cache::write('App.singleQuoteTest', "'this is a quoted string'", 'file_test'); $this->assertSame(Cache::read('App.singleQuoteTest', 'file_test'), "'this is a quoted string'"); @@ -386,10 +386,10 @@ public function testWriteQuotedString() { public function testPathDoesNotExist() { $this->skipIf(is_dir(TMP . 'tests' . DS . 'autocreate'), 'Cannot run if test directory exists.'); - Cache::config('autocreate', array( + Cache::config('autocreate', [ 'engine' => 'File', 'path' => TMP . 'tests' . DS . 'autocreate' - )); + ]); Cache::drop('autocreate'); } @@ -403,7 +403,7 @@ public function testMaskSetting() { if (DS === '\\') { $this->markTestSkipped('File permission testing does not work on Windows.'); } - Cache::config('mask_test', array('engine' => 'File', 'path' => TMP . 'tests')); + Cache::config('mask_test', ['engine' => 'File', 'path' => TMP . 'tests']); $data = 'This is some test content'; $write = Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); @@ -412,7 +412,7 @@ public function testMaskSetting() { Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); - Cache::config('mask_test', array('engine' => 'File', 'mask' => 0666, 'path' => TMP . 'tests')); + Cache::config('mask_test', ['engine' => 'File', 'mask' => 0666, 'path' => TMP . 'tests']); Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0666'; @@ -420,7 +420,7 @@ public function testMaskSetting() { Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); - Cache::config('mask_test', array('engine' => 'File', 'mask' => 0644, 'path' => TMP . 'tests')); + Cache::config('mask_test', ['engine' => 'File', 'mask' => 0644, 'path' => TMP . 'tests']); Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0644'; @@ -428,7 +428,7 @@ public function testMaskSetting() { Cache::delete('masking_test', 'mask_test'); Cache::drop('mask_test'); - Cache::config('mask_test', array('engine' => 'File', 'mask' => 0640, 'path' => TMP . 'tests')); + Cache::config('mask_test', ['engine' => 'File', 'mask' => 0640, 'path' => TMP . 'tests']); Cache::write('masking_test', $data, 'mask_test'); $result = substr(sprintf('%o', fileperms(TMP . 'tests' . DS . 'cake_masking_test')), -4); $expected = '0640'; @@ -443,7 +443,7 @@ public function testMaskSetting() { * @return void */ public function testGroupsReadWrite() { - Cache::config('file_groups', array('engine' => 'File', 'duration' => 3600, 'groups' => array('group_a', 'group_b'))); + Cache::config('file_groups', ['engine' => 'File', 'duration' => 3600, 'groups' => ['group_a', 'group_b']]); $this->assertTrue(Cache::write('test_groups', 'value', 'file_groups')); $this->assertEquals('value', Cache::read('test_groups', 'file_groups')); @@ -457,9 +457,9 @@ public function testGroupsReadWrite() { * @return void */ public function testClearingWithRepeatWrites() { - Cache::config('repeat', array( - 'engine' => 'File', 'groups' => array('users') - )); + Cache::config('repeat', [ + 'engine' => 'File', 'groups' => ['users'] + ]); $this->assertTrue(Cache::write('user', 'rchavik', 'repeat')); $this->assertEquals('rchavik', Cache::read('user', 'repeat')); @@ -485,11 +485,11 @@ public function testClearingWithRepeatWrites() { * @return void */ public function testGroupDelete() { - Cache::config('file_groups', array( + Cache::config('file_groups', [ 'engine' => 'File', 'duration' => 3600, - 'groups' => array('group_a', 'group_b') - )); + 'groups' => ['group_a', 'group_b'] + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'file_groups')); $this->assertEquals('value', Cache::read('test_groups', 'file_groups')); $this->assertTrue(Cache::delete('test_groups', 'file_groups')); @@ -503,14 +503,14 @@ public function testGroupDelete() { * @return void */ public function testGroupClear() { - Cache::config('file_groups', array('engine' => 'File', 'duration' => 3600, 'groups' => array('group_a', 'group_b'))); - Cache::config('file_groups2', array('engine' => 'File', 'duration' => 3600, 'groups' => array('group_b'))); - Cache::config('file_groups3', array( + Cache::config('file_groups', ['engine' => 'File', 'duration' => 3600, 'groups' => ['group_a', 'group_b']]); + Cache::config('file_groups2', ['engine' => 'File', 'duration' => 3600, 'groups' => ['group_b']]); + Cache::config('file_groups3', [ 'engine' => 'File', 'duration' => 3600, - 'groups' => array('group_b'), + 'groups' => ['group_b'], 'prefix' => 'leading_', - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'file_groups')); $this->assertTrue(Cache::write('test_groups2', 'value 2', 'file_groups2')); @@ -537,12 +537,12 @@ public function testGroupClear() { * @return void */ public function testGroupClearNoPrefix() { - Cache::config('file_groups', array( + Cache::config('file_groups', [ 'engine' => 'File', 'duration' => 3600, 'prefix' => '', - 'groups' => array('group_a', 'group_b') - )); + 'groups' => ['group_a', 'group_b'] + ]); Cache::write('key_1', 'value', 'file_groups'); Cache::write('key_2', 'value', 'file_groups'); Cache::clearGroup('group_a', 'file_groups'); diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php index 05a6dbf24c..6848b1c43d 100644 --- a/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php @@ -60,11 +60,11 @@ public function setUp() : void { $this->_cacheDisable = Configure::read('Cache.disable'); Configure::write('Cache.disable', false); - Cache::config('memcache', array( + Cache::config('memcache', [ 'engine' => 'Memcache', 'prefix' => 'cake_', 'duration' => 3600 - )); + ]); } /** @@ -89,16 +89,16 @@ public function tearDown() : void { public function testSettings() { $settings = Cache::settings('memcache'); unset($settings['serialize'], $settings['path']); - $expecting = array( + $expecting = [ 'prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, - 'servers' => array('127.0.0.1'), + 'servers' => ['127.0.0.1'], 'persistent' => true, 'compress' => false, 'engine' => 'Memcache', - 'groups' => array() - ); + 'groups' => [] + ]; $this->assertEquals($expecting, $settings); } @@ -108,12 +108,12 @@ public function testSettings() { * @return void */ public function testMultipleServers() { - $servers = array('127.0.0.1:11211', '127.0.0.1:11222'); + $servers = ['127.0.0.1:11211', '127.0.0.1:11222']; $available = true; $Memcache = new Memcache(); foreach ($servers as $server) { - list($host, $port) = explode(':', $server); + [$host, $port] = explode(':', $server); //@codingStandardsIgnoreStart if (!@$Memcache->connect($host, $port)) { $available = false; @@ -124,7 +124,7 @@ public function testMultipleServers() { $this->skipIf(!$available, 'Need memcache servers at ' . implode(', ', $servers) . ' to run this test.'); $Memcache = new MemcacheEngine(); - $Memcache->init(array('engine' => 'Memcache', 'servers' => $servers)); + $Memcache->init(['engine' => 'Memcache', 'servers' => $servers]); $settings = $Memcache->settings(); $this->assertEquals($settings['servers'], $servers); @@ -150,14 +150,14 @@ public function testConnect() { */ public function testConnectIpv6() { $Memcache = new MemcacheEngine(); - $result = $Memcache->init(array( + $result = $Memcache->init([ 'prefix' => 'cake_', 'duration' => 200, 'engine' => 'Memcache', - 'servers' => array( + 'servers' => [ '[::1]:11211' - ) - )); + ] + ]); $this->assertTrue($result); } @@ -169,7 +169,7 @@ public function testConnectIpv6() { public function testParseServerStringWithU() { $Memcached = new TestMemcachedEngine(); $result = $Memcached->parseServerString('udomain.net:13211'); - $this->assertEquals(array('udomain.net', '13211'), $result); + $this->assertEquals(['udomain.net', '13211'], $result); } /** @@ -180,10 +180,10 @@ public function testParseServerStringWithU() { public function testParseServerStringNonLatin() { $Memcache = new TestMemcacheEngine(); $result = $Memcache->parseServerString('schülervz.net:13211'); - $this->assertEquals(array('schülervz.net', '13211'), $result); + $this->assertEquals(['schülervz.net', '13211'], $result); $result = $Memcache->parseServerString('sülül:1111'); - $this->assertEquals(array('sülül', '1111'), $result); + $this->assertEquals(['sülül', '1111'], $result); } /** @@ -194,7 +194,7 @@ public function testParseServerStringNonLatin() { public function testParseServerStringUnix() { $Memcache = new TestMemcacheEngine(); $result = $Memcache->parseServerString('unix:///path/to/memcached.sock'); - $this->assertEquals(array('unix:///path/to/memcached.sock', 0), $result); + $this->assertEquals(['unix:///path/to/memcached.sock', 0], $result); } /** @@ -203,7 +203,7 @@ public function testParseServerStringUnix() { * @return void */ public function testReadAndWriteCache() { - Cache::set(array('duration' => 1), null, 'memcache'); + Cache::set(['duration' => 1], null, 'memcache'); $result = Cache::read('test', 'memcache'); $expecting = ''; @@ -226,7 +226,7 @@ public function testReadAndWriteCache() { * @return void */ public function testExpiry() { - Cache::set(array('duration' => 1), 'memcache'); + Cache::set(['duration' => 1], 'memcache'); $result = Cache::read('test', 'memcache'); $this->assertFalse($result); @@ -239,7 +239,7 @@ public function testExpiry() { $result = Cache::read('other_test', 'memcache'); $this->assertFalse($result); - Cache::set(array('duration' => "+1 second"), 'memcache'); + Cache::set(['duration' => "+1 second"], 'memcache'); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('other_test', $data, 'memcache'); @@ -249,12 +249,12 @@ public function testExpiry() { $result = Cache::read('other_test', 'memcache'); $this->assertFalse($result); - Cache::config('memcache', array('duration' => '+1 second')); + Cache::config('memcache', ['duration' => '+1 second']); $result = Cache::read('other_test', 'memcache'); $this->assertFalse($result); - Cache::config('memcache', array('duration' => '+29 days')); + Cache::config('memcache', ['duration' => '+29 days']); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('long_expiry_test', $data, 'memcache'); $this->assertTrue($result); @@ -264,7 +264,7 @@ public function testExpiry() { $expecting = $data; $this->assertEquals($expecting, $result); - Cache::config('memcache', array('duration' => 3600)); + Cache::config('memcache', ['duration' => 3600]); } /** @@ -331,17 +331,17 @@ public function testIncrement() { * @return void */ public function testConfigurationConflict() { - Cache::config('long_memcache', array( + Cache::config('long_memcache', [ 'engine' => 'Memcache', 'duration' => '+2 seconds', - 'servers' => array('127.0.0.1:11211'), - )); - Cache::config('short_memcache', array( + 'servers' => ['127.0.0.1:11211'], + ]); + Cache::config('short_memcache', [ 'engine' => 'Memcache', 'duration' => '+1 seconds', - 'servers' => array('127.0.0.1:11211'), - )); - Cache::config('some_file', array('engine' => 'File')); + 'servers' => ['127.0.0.1:11211'], + ]); + Cache::config('some_file', ['engine' => 'File']); $this->assertTrue(Cache::write('duration_test', 'yay', 'long_memcache')); $this->assertTrue(Cache::write('short_duration_test', 'boo', 'short_memcache')); @@ -366,11 +366,11 @@ public function testConfigurationConflict() { * @return void */ public function testClear() { - Cache::config('memcache2', array( + Cache::config('memcache2', [ 'engine' => 'Memcache', 'prefix' => 'cake2_', 'duration' => 3600 - )); + ]); Cache::write('some_value', 'cache1', 'memcache'); $result = Cache::clear(true, 'memcache'); @@ -396,7 +396,7 @@ public function testClear() { * @return void */ public function testZeroDuration() { - Cache::config('memcache', array('duration' => 0)); + Cache::config('memcache', ['duration' => 0]); $result = Cache::write('test_key', 'written!', 'memcache'); $this->assertTrue($result); @@ -431,17 +431,17 @@ public function testLongDurationEqualToZero() { * @return void */ public function testGroupReadWrite() { - Cache::config('memcache_groups', array( + Cache::config('memcache_groups', [ 'engine' => 'Memcache', 'duration' => 3600, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); - Cache::config('memcache_helper', array( + ]); + Cache::config('memcache_helper', [ 'engine' => 'Memcache', 'duration' => 3600, 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'memcache_groups')); $this->assertEquals('value', Cache::read('test_groups', 'memcache_groups')); @@ -462,11 +462,11 @@ public function testGroupReadWrite() { * @return void */ public function testGroupDelete() { - Cache::config('memcache_groups', array( + Cache::config('memcache_groups', [ 'engine' => 'Memcache', 'duration' => 3600, - 'groups' => array('group_a', 'group_b') - )); + 'groups' => ['group_a', 'group_b'] + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'memcache_groups')); $this->assertEquals('value', Cache::read('test_groups', 'memcache_groups')); $this->assertTrue(Cache::delete('test_groups', 'memcache_groups')); @@ -480,11 +480,11 @@ public function testGroupDelete() { * @return void */ public function testGroupClear() { - Cache::config('memcache_groups', array( + Cache::config('memcache_groups', [ 'engine' => 'Memcache', 'duration' => 3600, - 'groups' => array('group_a', 'group_b') - )); + 'groups' => ['group_a', 'group_b'] + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'memcache_groups')); $this->assertTrue(Cache::clearGroup('group_a', 'memcache_groups')); diff --git a/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php index 2d91071394..88d2525484 100644 --- a/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/MemcachedEngineTest.php @@ -70,11 +70,11 @@ public function setUp() : void { $this->skipIf(!$socket, 'Memcached is not running.'); fclose($socket); - Cache::config('memcached', array( + Cache::config('memcached', [ 'engine' => 'Memcached', 'prefix' => 'cake_', 'duration' => 3600 - )); + ]); } /** @@ -98,20 +98,20 @@ public function tearDown() : void { public function testSettings() { $settings = Cache::settings('memcached'); unset($settings['path']); - $expecting = array( + $expecting = [ 'prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, - 'servers' => array('127.0.0.1'), + 'servers' => ['127.0.0.1'], 'persistent' => false, 'compress' => false, 'engine' => 'Memcached', 'login' => null, 'password' => null, - 'groups' => array(), + 'groups' => [], 'serialize' => 'php', - 'options' => array() - ); + 'options' => [] + ]; $this->assertEquals($expecting, $settings); } @@ -122,20 +122,20 @@ public function testSettings() { */ public function testCompressionSetting() { $Memcached = new TestMemcachedEngine(); - $Memcached->init(array( + $Memcached->init([ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'compress' => false - )); + ]); $this->assertFalse($Memcached->getMemcached()->getOption(Memcached::OPT_COMPRESSION)); $MemcachedCompressed = new TestMemcachedEngine(); - $MemcachedCompressed->init(array( + $MemcachedCompressed->init([ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'compress' => true - )); + ]); $this->assertTrue($MemcachedCompressed->getMemcached()->getOption(Memcached::OPT_COMPRESSION)); } @@ -147,13 +147,13 @@ public function testCompressionSetting() { */ public function testOptionsSetting() { $memcached = new TestMemcachedEngine(); - $memcached->init(array( + $memcached->init([ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), - 'options' => array( + 'servers' => ['127.0.0.1:11211'], + 'options' => [ Memcached::OPT_BINARY_PROTOCOL => true - ) - )); + ] + ]); $this->assertEquals(1, $memcached->getMemcached()->getOption(Memcached::OPT_BINARY_PROTOCOL)); } @@ -164,12 +164,12 @@ public function testOptionsSetting() { */ public function testInvalidSerializerSetting() { $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'serialize' => 'invalid_serializer' - ); + ]; $this->expectException('CacheException'); $this->expectExceptionMessage('invalid_serializer is not a valid serializer engine for Memcached'); @@ -183,12 +183,12 @@ public function testInvalidSerializerSetting() { */ public function testPhpSerializerSetting() { $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'serialize' => 'php' - ); + ]; $Memcached->init($settings); $this->assertEquals(Memcached::SERIALIZER_PHP, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER)); @@ -206,12 +206,12 @@ public function testJsonSerializerSetting() { ); $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'serialize' => 'json' - ); + ]; $Memcached->init($settings); $this->assertEquals(Memcached::SERIALIZER_JSON, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER)); @@ -229,12 +229,12 @@ public function testIgbinarySerializerSetting() { ); $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'serialize' => 'igbinary' - ); + ]; $Memcached->init($settings); $this->assertEquals(Memcached::SERIALIZER_IGBINARY, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER)); @@ -252,12 +252,12 @@ public function testMsgpackSerializerSetting() { ); $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'serialize' => 'msgpack' - ); + ]; $Memcached->init($settings); $this->assertEquals(Memcached::SERIALIZER_MSGPACK, $Memcached->getMemcached()->getOption(Memcached::OPT_SERIALIZER)); @@ -275,12 +275,12 @@ public function testJsonSerializerThrowException() { ); $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'serialize' => 'json' - ); + ]; $this->expectException('CacheException'); $this->expectExceptionMessage('Memcached extension is not compiled with json support'); @@ -299,12 +299,12 @@ public function testMsgpackSerializerThrowException() { ); $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'serialize' => 'msgpack' - ); + ]; $this->expectException('CacheException'); $this->expectExceptionMessage('msgpack is not a valid serializer engine for Memcached'); @@ -323,12 +323,12 @@ public function testIgbinarySerializerThrowException() { ); $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'serialize' => 'igbinary' - ); + ]; $this->expectException('CacheException'); $this->expectExceptionMessage('Memcached extension is not compiled with igbinary support'); @@ -344,13 +344,13 @@ public function testIgbinarySerializerThrowException() { public function testSaslAuthException() { $this->skipIf(version_compare(PHP_VERSION, '7.0.0', '>=')); $Memcached = new TestMemcachedEngine(); - $settings = array( + $settings = [ 'engine' => 'Memcached', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'persistent' => false, 'login' => 'test', 'password' => 'password' - ); + ]; $this->expectWarning(); $Memcached->init($settings); @@ -362,12 +362,12 @@ public function testSaslAuthException() { * @return void */ public function testMultipleServers() { - $servers = array('127.0.0.1:11211', '127.0.0.1:11222'); + $servers = ['127.0.0.1:11211', '127.0.0.1:11222']; $available = true; $Memcached = new Memcached(); foreach ($servers as $server) { - list($host, $port) = explode(':', $server); + [$host, $port] = explode(':', $server); //@codingStandardsIgnoreStart if (!$Memcached->addServer($host, $port)) { $available = false; @@ -378,7 +378,7 @@ public function testMultipleServers() { $this->skipIf(!$available, 'Need memcached servers at ' . implode(', ', $servers) . ' to run this test.'); $Memcached = new MemcachedEngine(); - $Memcached->init(array('engine' => 'Memcached', 'servers' => $servers)); + $Memcached->init(['engine' => 'Memcached', 'servers' => $servers]); $settings = $Memcached->settings(); $this->assertEquals($settings['servers'], $servers); @@ -392,14 +392,14 @@ public function testMultipleServers() { */ public function testConnectIpv6() { $Memcached = new MemcachedEngine(); - $result = $Memcached->init(array( + $result = $Memcached->init([ 'prefix' => 'cake_', 'duration' => 200, 'engine' => 'Memcached', - 'servers' => array( + 'servers' => [ '[::1]:11211' - ) - )); + ] + ]); $this->assertTrue($result); } @@ -411,7 +411,7 @@ public function testConnectIpv6() { public function testParseServerStringWithU() { $Memcached = new TestMemcachedEngine(); $result = $Memcached->parseServerString('udomain.net:13211'); - $this->assertEquals(array('udomain.net', '13211'), $result); + $this->assertEquals(['udomain.net', '13211'], $result); } /** @@ -422,10 +422,10 @@ public function testParseServerStringWithU() { public function testParseServerStringNonLatin() { $Memcached = new TestMemcachedEngine(); $result = $Memcached->parseServerString('schülervz.net:13211'); - $this->assertEquals(array('schülervz.net', '13211'), $result); + $this->assertEquals(['schülervz.net', '13211'], $result); $result = $Memcached->parseServerString('sülül:1111'); - $this->assertEquals(array('sülül', '1111'), $result); + $this->assertEquals(['sülül', '1111'], $result); } /** @@ -436,7 +436,7 @@ public function testParseServerStringNonLatin() { public function testParseServerStringUnix() { $Memcached = new TestMemcachedEngine(); $result = $Memcached->parseServerString('unix:///path/to/memcachedd.sock'); - $this->assertEquals(array('/path/to/memcachedd.sock', 0), $result); + $this->assertEquals(['/path/to/memcachedd.sock', 0], $result); } /** @@ -445,7 +445,7 @@ public function testParseServerStringUnix() { * @return void */ public function testReadAndWriteCache() { - Cache::set(array('duration' => 1), null, 'memcached'); + Cache::set(['duration' => 1], null, 'memcached'); $result = Cache::read('test', 'memcached'); $expecting = ''; @@ -468,7 +468,7 @@ public function testReadAndWriteCache() { * @return void */ public function testExpiry() { - Cache::set(array('duration' => 1), 'memcached'); + Cache::set(['duration' => 1], 'memcached'); $result = Cache::read('test', 'memcached'); $this->assertFalse($result); @@ -481,7 +481,7 @@ public function testExpiry() { $result = Cache::read('other_test', 'memcached'); $this->assertFalse($result); - Cache::set(array('duration' => "+1 second"), 'memcached'); + Cache::set(['duration' => "+1 second"], 'memcached'); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('other_test', $data, 'memcached'); @@ -491,12 +491,12 @@ public function testExpiry() { $result = Cache::read('other_test', 'memcached'); $this->assertFalse($result); - Cache::config('memcached', array('duration' => '+1 second')); + Cache::config('memcached', ['duration' => '+1 second']); $result = Cache::read('other_test', 'memcached'); $this->assertFalse($result); - Cache::config('memcached', array('duration' => '+29 days')); + Cache::config('memcached', ['duration' => '+29 days']); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('long_expiry_test', $data, 'memcached'); $this->assertTrue($result); @@ -506,7 +506,7 @@ public function testExpiry() { $expecting = $data; $this->assertEquals($expecting, $result); - Cache::config('memcached', array('duration' => 3600)); + Cache::config('memcached', ['duration' => 3600]); } /** @@ -553,12 +553,12 @@ public function testDecrement() { * @return void */ public function testDecrementCompressedKeys() { - Cache::config('compressed_memcached', array( + Cache::config('compressed_memcached', [ 'engine' => 'Memcached', 'duration' => '+2 seconds', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'compress' => true - )); + ]); $result = Cache::write('test_decrement', 5, 'compressed_memcached'); $this->assertTrue($result); @@ -608,12 +608,12 @@ public function testIncrement() { * @return void */ public function testIncrementCompressedKeys() { - Cache::config('compressed_memcached', array( + Cache::config('compressed_memcached', [ 'engine' => 'Memcached', 'duration' => '+2 seconds', - 'servers' => array('127.0.0.1:11211'), + 'servers' => ['127.0.0.1:11211'], 'compress' => true - )); + ]); $result = Cache::write('test_increment', 5, 'compressed_memcached'); $this->assertTrue($result); @@ -639,17 +639,17 @@ public function testIncrementCompressedKeys() { * @return void */ public function testConfigurationConflict() { - Cache::config('long_memcached', array( + Cache::config('long_memcached', [ 'engine' => 'Memcached', 'duration' => '+2 seconds', - 'servers' => array('127.0.0.1:11211'), - )); - Cache::config('short_memcached', array( + 'servers' => ['127.0.0.1:11211'], + ]); + Cache::config('short_memcached', [ 'engine' => 'Memcached', 'duration' => '+1 seconds', - 'servers' => array('127.0.0.1:11211'), - )); - Cache::config('some_file', array('engine' => 'File')); + 'servers' => ['127.0.0.1:11211'], + ]); + Cache::config('some_file', ['engine' => 'File']); $this->assertTrue(Cache::write('duration_test', 'yay', 'long_memcached')); $this->assertTrue(Cache::write('short_duration_test', 'boo', 'short_memcached')); @@ -674,11 +674,11 @@ public function testConfigurationConflict() { * @return void */ public function testClear() { - Cache::config('memcached2', array( + Cache::config('memcached2', [ 'engine' => 'Memcached', 'prefix' => 'cake2_', 'duration' => 3600 - )); + ]); Cache::write('some_value', 'cache1', 'memcached'); $result = Cache::clear(true, 'memcached'); @@ -704,7 +704,7 @@ public function testClear() { * @return void */ public function testZeroDuration() { - Cache::config('memcached', array('duration' => 0)); + Cache::config('memcached', ['duration' => 0]); $result = Cache::write('test_key', 'written!', 'memcached'); $this->assertTrue($result); @@ -741,17 +741,17 @@ public function testLongDurationEqualToZero() { * @return void */ public function testGroupReadWrite() { - Cache::config('memcached_groups', array( + Cache::config('memcached_groups', [ 'engine' => 'Memcached', 'duration' => 3600, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); - Cache::config('memcached_helper', array( + ]); + Cache::config('memcached_helper', [ 'engine' => 'Memcached', 'duration' => 3600, 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups')); $this->assertEquals('value', Cache::read('test_groups', 'memcached_groups')); @@ -772,11 +772,11 @@ public function testGroupReadWrite() { * @return void */ public function testGroupDelete() { - Cache::config('memcached_groups', array( + Cache::config('memcached_groups', [ 'engine' => 'Memcached', 'duration' => 3600, - 'groups' => array('group_a', 'group_b') - )); + 'groups' => ['group_a', 'group_b'] + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups')); $this->assertEquals('value', Cache::read('test_groups', 'memcached_groups')); $this->assertTrue(Cache::delete('test_groups', 'memcached_groups')); @@ -790,11 +790,11 @@ public function testGroupDelete() { * @return void */ public function testGroupClear() { - Cache::config('memcached_groups', array( + Cache::config('memcached_groups', [ 'engine' => 'Memcached', 'duration' => 3600, - 'groups' => array('group_a', 'group_b') - )); + 'groups' => ['group_a', 'group_b'] + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'memcached_groups')); $this->assertTrue(Cache::clearGroup('group_a', 'memcached_groups')); @@ -811,7 +811,7 @@ public function testGroupClear() { * @return void */ public function testAdd() { - Cache::set(array('duration' => 1), null, 'memcached'); + Cache::set(['duration' => 1], null, 'memcached'); Cache::delete('test_add_key', 'default'); $result = Cache::add('test_add_key', 'test data', 'default'); diff --git a/lib/Cake/Test/Case/Cache/Engine/RedisEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/RedisEngineTest.php index 00c5ffb3ea..58f50761cd 100644 --- a/lib/Cake/Test/Case/Cache/Engine/RedisEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/RedisEngineTest.php @@ -44,11 +44,11 @@ public function setUp() : void { $this->skipIf(!$socket, 'Redis is not running.'); fclose($socket); - Cache::config('redis', array( + Cache::config('redis', [ 'engine' => 'Redis', 'prefix' => 'cake_', 'duration' => 3600 - )); + ]); } /** @@ -72,11 +72,11 @@ public function tearDown() : void { */ public function testSettings() { $settings = Cache::settings('redis'); - $expecting = array( + $expecting = [ 'prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, - 'groups' => array(), + 'groups' => [], 'engine' => 'Redis', 'server' => '127.0.0.1', 'port' => 6379, @@ -85,7 +85,7 @@ public function testSettings() { 'password' => false, 'database' => 0, 'unix_socket' => false, - ); + ]; $this->assertEquals($expecting, $settings); } @@ -105,20 +105,20 @@ public function testConnect() { * @return void */ public function testMultiDatabaseOperations() { - Cache::config('redisdb0', array( + Cache::config('redisdb0', [ 'engine' => 'Redis', 'prefix' => 'cake2_', 'duration' => 3600, 'persistent' => false, - )); + ]); - Cache::config('redisdb1', array( + Cache::config('redisdb1', [ 'engine' => 'Redis', 'database' => 1, 'prefix' => 'cake2_', 'duration' => 3600, 'persistent' => false, - )); + ]); $result = Cache::write('save_in_0', true, 'redisdb0'); $exist = Cache::read('save_in_0', 'redisdb0'); @@ -166,7 +166,7 @@ public function testWriteNumbers() { * @return void */ public function testReadAndWriteCache() { - Cache::set(array('duration' => 1), null, 'redis'); + Cache::set(['duration' => 1], null, 'redis'); $result = Cache::read('test', 'redis'); $expecting = ''; @@ -180,7 +180,7 @@ public function testReadAndWriteCache() { $expecting = $data; $this->assertEquals($expecting, $result); - $data = array(1, 2, 3); + $data = [1, 2, 3]; $this->assertTrue(Cache::write('array_data', $data, 'redis')); $this->assertEquals($data, Cache::read('array_data', 'redis')); @@ -193,7 +193,7 @@ public function testReadAndWriteCache() { * @return void */ public function testExpiry() { - Cache::set(array('duration' => 1), 'redis'); + Cache::set(['duration' => 1], 'redis'); $result = Cache::read('test', 'redis'); $this->assertFalse($result); @@ -206,7 +206,7 @@ public function testExpiry() { $result = Cache::read('other_test', 'redis'); $this->assertFalse($result); - Cache::set(array('duration' => "+1 second"), 'redis'); + Cache::set(['duration' => "+1 second"], 'redis'); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('other_test', $data, 'redis'); @@ -216,13 +216,13 @@ public function testExpiry() { $result = Cache::read('other_test', 'redis'); $this->assertFalse($result); - Cache::config('redis', array('duration' => '+1 second')); + Cache::config('redis', ['duration' => '+1 second']); sleep(2); $result = Cache::read('other_test', 'redis'); $this->assertFalse($result); - Cache::config('redis', array('duration' => '+29 days')); + Cache::config('redis', ['duration' => '+29 days']); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('long_expiry_test', $data, 'redis'); $this->assertTrue($result); @@ -232,7 +232,7 @@ public function testExpiry() { $expecting = $data; $this->assertEquals($expecting, $result); - Cache::config('redis', array('duration' => 3600)); + Cache::config('redis', ['duration' => 3600]); } /** @@ -298,11 +298,11 @@ public function testIncrement() { * @return void */ public function testClear() { - Cache::config('redis2', array( + Cache::config('redis2', [ 'engine' => 'Redis', 'prefix' => 'cake2_', 'duration' => 3600 - )); + ]); Cache::write('some_value', 'cache1', 'redis'); $result = Cache::clear(true, 'redis'); @@ -324,7 +324,7 @@ public function testClear() { * @return void */ public function testZeroDuration() { - Cache::config('redis', array('duration' => 0)); + Cache::config('redis', ['duration' => 0]); $result = Cache::write('test_key', 'written!', 'redis'); $this->assertTrue($result); @@ -340,17 +340,17 @@ public function testZeroDuration() { * @return void */ public function testGroupReadWrite() { - Cache::config('redis_groups', array( + Cache::config('redis_groups', [ 'engine' => 'Redis', 'duration' => 3600, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); - Cache::config('redis_helper', array( + ]); + Cache::config('redis_helper', [ 'engine' => 'Redis', 'duration' => 3600, 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'redis_groups')); $this->assertEquals('value', Cache::read('test_groups', 'redis_groups')); @@ -371,11 +371,11 @@ public function testGroupReadWrite() { * @return void */ public function testGroupDelete() { - Cache::config('redis_groups', array( + Cache::config('redis_groups', [ 'engine' => 'Redis', 'duration' => 3600, - 'groups' => array('group_a', 'group_b') - )); + 'groups' => ['group_a', 'group_b'] + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'redis_groups')); $this->assertEquals('value', Cache::read('test_groups', 'redis_groups')); $this->assertTrue(Cache::delete('test_groups', 'redis_groups')); @@ -389,11 +389,11 @@ public function testGroupDelete() { * @return void */ public function testGroupClear() { - Cache::config('redis_groups', array( + Cache::config('redis_groups', [ 'engine' => 'Redis', 'duration' => 3600, - 'groups' => array('group_a', 'group_b') - )); + 'groups' => ['group_a', 'group_b'] + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'redis_groups')); $this->assertTrue(Cache::clearGroup('group_a', 'redis_groups')); diff --git a/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php index ba4b6da18c..3395dd4a86 100644 --- a/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/WincacheEngineTest.php @@ -35,7 +35,7 @@ public function setUp() : void { $this->skipIf(!function_exists('wincache_ucache_set'), 'Wincache is not installed or configured properly.'); $this->_cacheDisable = Configure::read('Cache.disable'); Configure::write('Cache.disable', false); - Cache::config('wincache', array('engine' => 'Wincache', 'prefix' => 'cake_')); + Cache::config('wincache', ['engine' => 'Wincache', 'prefix' => 'cake_']); } /** @@ -57,7 +57,7 @@ public function tearDown() : void { * @return void */ public function testReadAndWriteCache() { - Cache::set(array('duration' => 1), 'wincache'); + Cache::set(['duration' => 1], 'wincache'); $result = Cache::read('test', 'wincache'); $expecting = ''; @@ -80,7 +80,7 @@ public function testReadAndWriteCache() { * @return void */ public function testExpiry() { - Cache::set(array('duration' => 1), 'wincache'); + Cache::set(['duration' => 1], 'wincache'); $result = Cache::read('test', 'wincache'); $this->assertFalse($result); @@ -93,7 +93,7 @@ public function testExpiry() { $result = Cache::read('other_test', 'wincache'); $this->assertFalse($result); - Cache::set(array('duration' => 1), 'wincache'); + Cache::set(['duration' => 1], 'wincache'); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('other_test', $data, 'wincache'); @@ -199,12 +199,12 @@ public function testClear() { * @return void */ public function testGroupsReadWrite() { - Cache::config('wincache_groups', array( + Cache::config('wincache_groups', [ 'engine' => 'Wincache', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'wincache_groups')); $this->assertEquals('value', Cache::read('test_groups', 'wincache_groups')); @@ -225,12 +225,12 @@ public function testGroupsReadWrite() { * @return void */ public function testGroupDelete() { - Cache::config('wincache_groups', array( + Cache::config('wincache_groups', [ 'engine' => 'Wincache', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'wincache_groups')); $this->assertEquals('value', Cache::read('test_groups', 'wincache_groups')); $this->assertTrue(Cache::delete('test_groups', 'wincache_groups')); @@ -244,12 +244,12 @@ public function testGroupDelete() { * @return void */ public function testGroupClear() { - Cache::config('wincache_groups', array( + Cache::config('wincache_groups', [ 'engine' => 'Wincache', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'wincache_groups')); $this->assertTrue(Cache::clearGroup('group_a', 'wincache_groups')); diff --git a/lib/Cake/Test/Case/Cache/Engine/XcacheEngineTest.php b/lib/Cake/Test/Case/Cache/Engine/XcacheEngineTest.php index 645a7fe024..61d00b8632 100644 --- a/lib/Cake/Test/Case/Cache/Engine/XcacheEngineTest.php +++ b/lib/Cake/Test/Case/Cache/Engine/XcacheEngineTest.php @@ -37,7 +37,7 @@ public function setUp() : void { } $this->_cacheDisable = Configure::read('Cache.disable'); Configure::write('Cache.disable', false); - Cache::config('xcache', array('engine' => 'Xcache', 'prefix' => 'cake_')); + Cache::config('xcache', ['engine' => 'Xcache', 'prefix' => 'cake_']); } /** @@ -60,12 +60,12 @@ public function tearDown() : void { */ public function testSettings() { $settings = Cache::settings(); - $expecting = array( + $expecting = [ 'prefix' => 'cake_', 'duration' => 3600, 'probability' => 100, 'engine' => 'Xcache', - ); + ]; $this->assertTrue(isset($settings['PHP_AUTH_USER'])); $this->assertTrue(isset($settings['PHP_AUTH_PW'])); @@ -79,7 +79,7 @@ public function testSettings() { * @return void */ public function testReadAndWriteCache() { - Cache::set(array('duration' => 1)); + Cache::set(['duration' => 1]); $result = Cache::read('test'); $expecting = ''; @@ -102,7 +102,7 @@ public function testReadAndWriteCache() { * @return void */ public function testExpiry() { - Cache::set(array('duration' => 1)); + Cache::set(['duration' => 1]); $result = Cache::read('test'); $this->assertFalse($result); @@ -114,7 +114,7 @@ public function testExpiry() { $result = Cache::read('other_test'); $this->assertFalse($result); - Cache::set(array('duration' => "+1 second")); + Cache::set(['duration' => "+1 second"]); $data = 'this is a test of the emergency broadcasting system'; $result = Cache::write('other_test', $data); @@ -208,12 +208,12 @@ public function testIncrement() { * @return void */ public function testGroupsReadWrite() { - Cache::config('xcache_groups', array( + Cache::config('xcache_groups', [ 'engine' => 'Xcache', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups')); $this->assertEquals('value', Cache::read('test_groups', 'xcache_groups')); @@ -234,12 +234,12 @@ public function testGroupsReadWrite() { * @return void */ public function testGroupDelete() { - Cache::config('xcache_groups', array( + Cache::config('xcache_groups', [ 'engine' => 'Xcache', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups')); $this->assertEquals('value', Cache::read('test_groups', 'xcache_groups')); $this->assertTrue(Cache::delete('test_groups', 'xcache_groups')); @@ -253,12 +253,12 @@ public function testGroupDelete() { * @return void */ public function testGroupClear() { - Cache::config('xcache_groups', array( + Cache::config('xcache_groups', [ 'engine' => 'Xcache', 'duration' => 0, - 'groups' => array('group_a', 'group_b'), + 'groups' => ['group_a', 'group_b'], 'prefix' => 'test_' - )); + ]); $this->assertTrue(Cache::write('test_groups', 'value', 'xcache_groups')); $this->assertTrue(Cache::clearGroup('group_a', 'xcache_groups')); @@ -275,7 +275,7 @@ public function testGroupClear() { * @return void */ public function testAdd() { - Cache::set(array('duration' => 1), null); + Cache::set(['duration' => 1], null); Cache::delete('test_add_key', 'default'); $result = Cache::add('test_add_key', 'test data', 'default'); diff --git a/lib/Cake/Test/Case/Configure/IniReaderTest.php b/lib/Cake/Test/Case/Configure/IniReaderTest.php index 2644392337..63b72bd994 100644 --- a/lib/Cake/Test/Case/Configure/IniReaderTest.php +++ b/lib/Cake/Test/Case/Configure/IniReaderTest.php @@ -30,20 +30,20 @@ class IniReaderTest extends CakeTestCase { * * @var array */ - public $testData = array( - 'One' => array( + public $testData = [ + 'One' => [ 'two' => 'value', - 'three' => array( + 'three' => [ 'four' => 'value four' - ), + ], 'is_null' => null, 'bool_false' => false, 'bool_true' => true, - ), - 'Asset' => array( + ], + 'Asset' => [ 'timestamp' => 'force' - ), - ); + ], + ]; /** * setup @@ -119,10 +119,10 @@ public function testReadWithoutSection() { $reader = new IniReader($this->path); $config = $reader->read('no_section.ini'); - $expected = array( + $expected = [ 'some_key' => 'some_value', 'bool_key' => true - ); + ]; $this->assertEquals($expected, $config); } @@ -193,7 +193,7 @@ public function testReadWithNonExistentFile() { public function testReadEmptyFile() { $reader = new IniReader($this->path); $config = $reader->read('empty'); - $this->assertEquals(array(), $config); + $this->assertEquals([], $config); } /** @@ -213,9 +213,9 @@ public function testReadWithDots() { * @return void */ public function testReadPluginValue() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $reader = new IniReader($this->path); $result = $reader->read('TestPlugin.nested'); @@ -236,9 +236,9 @@ public function testReadPluginValue() { * @return void */ public function testReadPluginSpecialAclIniPhpValue() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $reader = new IniReader($this->path); $result = $reader->read('TestPlugin.acl.ini.php'); diff --git a/lib/Cake/Test/Case/Configure/PhpReaderTest.php b/lib/Cake/Test/Case/Configure/PhpReaderTest.php index 4c5c65f140..90cdd054a5 100644 --- a/lib/Cake/Test/Case/Configure/PhpReaderTest.php +++ b/lib/Cake/Test/Case/Configure/PhpReaderTest.php @@ -30,20 +30,20 @@ class PhpReaderTest extends CakeTestCase { * * @var array */ - public $testData = array( - 'One' => array( + public $testData = [ + 'One' => [ 'two' => 'value', - 'three' => array( + 'three' => [ 'four' => 'value four' - ), + ], 'is_null' => null, 'bool_false' => false, 'bool_true' => true, - ), - 'Asset' => array( + ], + 'Asset' => [ 'timestamp' => 'force' - ), - ); + ], + ]; /** * Setup. @@ -120,9 +120,9 @@ public function testReadWithDots() { * @return void */ public function testReadPluginValue() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $reader = new PhpReader($this->path); $result = $reader->read('TestPlugin.load'); diff --git a/lib/Cake/Test/Case/Console/AllConsoleLibsTest.php b/lib/Cake/Test/Case/Console/AllConsoleLibsTest.php index 76077e0b1c..773b2c7fc3 100644 --- a/lib/Cake/Test/Case/Console/AllConsoleLibsTest.php +++ b/lib/Cake/Test/Case/Console/AllConsoleLibsTest.php @@ -33,12 +33,12 @@ class AllConsoleLibsTest extends \PHPUnit\Framework\TestSuite { public static function suite() { $suite = new CakeTestSuite('All console lib classes'); - foreach (new DirectoryIterator(dirname(__FILE__)) as $file) { - if (!$file->isFile() || strpos($file, 'All') === 0) { + foreach (new DirectoryIterator(__DIR__) as $file) { + if (!$file->isFile() || str_starts_with($file, 'All')) { continue; } $fileName = $file->getRealPath(); - if (substr($fileName, -4) === '.php') { + if (str_ends_with($fileName, '.php')) { $suite->addTestFile($file->getRealPath()); } } diff --git a/lib/Cake/Test/Case/Console/Command/AclShellTest.php b/lib/Cake/Test/Case/Console/Command/AclShellTest.php index 688d3acc3d..1ebd386d01 100644 --- a/lib/Cake/Test/Case/Console/Command/AclShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/AclShellTest.php @@ -35,7 +35,7 @@ class AclShellTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.aco', 'core.aro', 'core.aros_aco'); + public $fixtures = ['core.aco', 'core.aro', 'core.aros_aco']; /** * setUp method @@ -47,13 +47,13 @@ public function setUp() : void { Configure::write('Acl.database', 'test'); Configure::write('Acl.classname', 'DbAcl'); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock( 'AclShell', - array('in', 'out', 'hr', 'createFile', 'error', 'err', 'clear', 'dispatchShell'), - array($out, $out, $in) + ['in', 'out', 'hr', 'createFile', 'error', 'err', 'clear', 'dispatchShell'], + [$out, $out, $in] ); $collection = new ComponentCollection(); $this->Task->Acl = new AclComponent($collection); @@ -68,11 +68,11 @@ public function setUp() : void { public function testViewWithModelForeignKeyOutput() { $this->Task->command = 'view'; $this->Task->startup(); - $data = array( + $data = [ 'parent_id' => null, 'model' => 'MyModel', 'foreign_key' => 2, - ); + ]; $this->Task->Acl->Aro->create($data); $this->Task->Acl->Aro->save(); $this->Task->args[0] = 'aro'; @@ -96,7 +96,7 @@ public function testViewWithModelForeignKeyOutput() { * @return void */ public function testViewWithArgument() { - $this->Task->args = array('aro', 'admins'); + $this->Task->args = ['aro', 'admins']; $this->Task->expects($this->at(0))->method('out')->with('Aro tree:'); $this->Task->expects($this->at(2))->method('out')->with(' [2] admins'); @@ -113,7 +113,7 @@ public function testViewWithArgument() { */ public function testParsingModelAndForeignKey() { $result = $this->Task->parseIdentifier('Model.foreignKey'); - $expected = array('model' => 'Model', 'foreign_key' => 'foreignKey'); + $expected = ['model' => 'Model', 'foreign_key' => 'foreignKey']; $this->assertEquals($expected, $result); $result = $this->Task->parseIdentifier('mySuperUser'); @@ -129,7 +129,7 @@ public function testParsingModelAndForeignKey() { * @return void */ public function testCreate() { - $this->Task->args = array('aro', 'root', 'User.1'); + $this->Task->args = ['aro', 'root', 'User.1']; $this->Task->expects($this->at(0))->method('out')->with("New Aro 'User.1' created.", 2); $this->Task->expects($this->at(1))->method('out')->with("New Aro 'User.3' created.", 2); $this->Task->expects($this->at(2))->method('out')->with("New Aro 'somealias' created.", 2); @@ -144,7 +144,7 @@ public function testCreate() { $this->assertEquals(null, $result['Aro']['parent_id']); $id = $result['Aro']['id']; - $this->Task->args = array('aro', 'User.1', 'User.3'); + $this->Task->args = ['aro', 'User.1', 'User.3']; $this->Task->create(); $Aro = ClassRegistry::init('Aro'); @@ -153,7 +153,7 @@ public function testCreate() { $this->assertEquals(3, $result['Aro']['foreign_key']); $this->assertEquals($id, $result['Aro']['parent_id']); - $this->Task->args = array('aro', 'root', 'somealias'); + $this->Task->args = ['aro', 'root', 'somealias']; $this->Task->create(); $Aro = ClassRegistry::init('Aro'); @@ -170,14 +170,14 @@ public function testCreate() { * @return void */ public function testDelete() { - $this->Task->args = array('aro', 'AuthUser.1'); + $this->Task->args = ['aro', 'AuthUser.1']; $this->Task->expects($this->at(0))->method('out') ->with("Aro deleted.", 2); $this->Task->delete(); $Aro = ClassRegistry::init('Aro'); $result = $Aro->findById(3); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -186,7 +186,7 @@ public function testDelete() { * @return void */ public function testSetParent() { - $this->Task->args = array('aro', 'AuthUser.2', 'root'); + $this->Task->args = ['aro', 'AuthUser.2', 'root']; $this->Task->setParent(); $Aro = ClassRegistry::init('Aro'); @@ -200,11 +200,11 @@ public function testSetParent() { * @return void */ public function testGrant() { - $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); + $this->Task->args = ['AuthUser.2', 'ROOT/Controller1', 'create']; $this->Task->expects($this->at(0))->method('out') ->with($this->matchesRegularExpression('/granted/'), true); $this->Task->grant(); - $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); + $node = $this->Task->Acl->Aro->node(['model' => 'AuthUser', 'foreign_key' => 2]); $node = $this->Task->Acl->Aro->read(null, $node[0]['Aro']['id']); $this->assertFalse(empty($node['Aco'][0])); @@ -217,13 +217,13 @@ public function testGrant() { * @return void */ public function testDeny() { - $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); + $this->Task->args = ['AuthUser.2', 'ROOT/Controller1', 'create']; $this->Task->expects($this->at(0))->method('out') ->with($this->stringContains('Permission denied'), true); $this->Task->deny(); - $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); + $node = $this->Task->Acl->Aro->node(['model' => 'AuthUser', 'foreign_key' => 2]); $node = $this->Task->Acl->Aro->read(null, $node[0]['Aro']['id']); $this->assertFalse(empty($node['Aco'][0])); $this->assertEquals(-1, $node['Aco'][0]['Permission']['_create']); @@ -244,16 +244,16 @@ public function testCheck() { $this->Task->expects($this->at(3))->method('out') ->with($this->matchesRegularExpression('/not.*allowed/'), true); - $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', '*'); + $this->Task->args = ['AuthUser.2', 'ROOT/Controller1', '*']; $this->Task->check(); - $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); + $this->Task->args = ['AuthUser.2', 'ROOT/Controller1', 'create']; $this->Task->grant(); - $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); + $this->Task->args = ['AuthUser.2', 'ROOT/Controller1', 'create']; $this->Task->check(); - $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'delete'); + $this->Task->args = ['AuthUser.2', 'ROOT/Controller1', 'delete']; $this->Task->check(); } @@ -268,13 +268,13 @@ public function testInherit() { $this->Task->expects($this->at(1))->method('out') ->with($this->matchesRegularExpression('/Permission .*inherited/'), true); - $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'create'); + $this->Task->args = ['AuthUser.2', 'ROOT/Controller1', 'create']; $this->Task->grant(); - $this->Task->args = array('AuthUser.2', 'ROOT/Controller1', 'all'); + $this->Task->args = ['AuthUser.2', 'ROOT/Controller1', 'all']; $this->Task->inherit(); - $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); + $node = $this->Task->Acl->Aro->node(['model' => 'AuthUser', 'foreign_key' => 2]); $node = $this->Task->Acl->Aro->read(null, $node[0]['Aro']['id']); $this->assertFalse(empty($node['Aco'][0])); $this->assertEquals(0, $node['Aco'][0]['Permission']['_create']); @@ -286,8 +286,8 @@ public function testInherit() { * @return void */ public function testGetPath() { - $this->Task->args = array('aro', 'AuthUser.2'); - $node = $this->Task->Acl->Aro->node(array('model' => 'AuthUser', 'foreign_key' => 2)); + $this->Task->args = ['aro', 'AuthUser.2']; + $node = $this->Task->Acl->Aro->node(['model' => 'AuthUser', 'foreign_key' => 2]); $first = $node[0]['Aro']['id']; $second = $node[1]['Aro']['id']; $last = $node[2]['Aro']['id']; diff --git a/lib/Cake/Test/Case/Console/Command/ApiShellTest.php b/lib/Cake/Test/Case/Console/Command/ApiShellTest.php index 0d67608147..e191326fd2 100644 --- a/lib/Cake/Test/Case/Console/Command/ApiShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/ApiShellTest.php @@ -36,13 +36,13 @@ class ApiShellTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Shell = $this->getMock( 'ApiShell', - array('in', 'out', 'createFile', 'hr', '_stop'), - array($out, $out, $in) + ['in', 'out', 'createFile', 'hr', '_stop'], + [$out, $out, $in] ); } @@ -55,7 +55,7 @@ public function testMethodNameDetection() { $this->Shell->expects($this->any())->method('in')->will($this->returnValue('q')); $this->Shell->expects($this->at(0))->method('out')->with('Controller'); - $expected = array( + $expected = [ '1. afterFilter()', '2. afterScaffoldSave($method)', '3. afterScaffoldSaveError($method)', @@ -85,10 +85,10 @@ public function testMethodNameDetection() { '27. startupProcess()', '28. validate()', '29. validateErrors()' - ); + ]; $this->Shell->expects($this->at(2))->method('out')->with($expected); - $this->Shell->args = array('controller'); + $this->Shell->args = ['controller']; $this->Shell->paths['controller'] = CAKE . 'Controller' . DS; $this->Shell->main(); } diff --git a/lib/Cake/Test/Case/Console/Command/BakeShellTest.php b/lib/Cake/Test/Case/Console/Command/BakeShellTest.php index 060d6217e5..efff82ecd7 100644 --- a/lib/Cake/Test/Case/Console/Command/BakeShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/BakeShellTest.php @@ -38,7 +38,7 @@ class BakeShellTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.user'); + public $fixtures = ['core.user']; /** * setup test @@ -47,13 +47,13 @@ class BakeShellTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Shell = $this->getMock( 'BakeShell', - array('in', 'out', 'hr', 'err', 'createFile', '_stop', '_checkUnitTest'), - array($out, $out, $in) + ['in', 'out', 'hr', 'err', 'createFile', '_stop', '_checkUnitTest'], + [$out, $out, $in] ); } @@ -77,10 +77,10 @@ public function testAllWithModelName() { $userExists = class_exists('User'); $this->skipIf($userExists, 'User class exists, cannot test `bake all [param]`.'); - $this->Shell->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher)); - $this->Shell->Controller = $this->getMock('ControllerTask', array(), array(&$this->Dispatcher)); - $this->Shell->View = $this->getMock('ModelTask', array(), array(&$this->Dispatcher)); - $this->Shell->DbConfig = $this->getMock('DbConfigTask', array(), array(&$this->Dispatcher)); + $this->Shell->Model = $this->getMock('ModelTask', [], [&$this->Dispatcher]); + $this->Shell->Controller = $this->getMock('ControllerTask', [], [&$this->Dispatcher]); + $this->Shell->View = $this->getMock('ModelTask', [], [&$this->Dispatcher]); + $this->Shell->DbConfig = $this->getMock('DbConfigTask', [], [&$this->Dispatcher]); $this->Shell->DbConfig->expects($this->once()) ->method('getConfig') @@ -110,8 +110,8 @@ public function testAllWithModelName() { ->with('Bake All complete'); $this->Shell->connection = ''; - $this->Shell->params = array(); - $this->Shell->args = array('User'); + $this->Shell->params = []; + $this->Shell->args = ['User']; $this->Shell->all(); $this->assertEquals('User', $this->Shell->View->args[0]); diff --git a/lib/Cake/Test/Case/Console/Command/CommandListShellTest.php b/lib/Cake/Test/Case/Console/Command/CommandListShellTest.php index 2032af3f62..47bb0ed77a 100644 --- a/lib/Cake/Test/Case/Console/Command/CommandListShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/CommandListShellTest.php @@ -51,29 +51,29 @@ class CommandListShellTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ), - 'Console/Command' => array( + ], + 'Console/Command' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS - ) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + ] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $out = new TestStringOutput(); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Shell = $this->getMock( 'CommandListShell', - array('in', '_stop', 'clear'), - array($out, $out, $in) + ['in', '_stop', 'clear'], + [$out, $out, $in] ); $this->Shell->Command = $this->getMock( 'CommandTask', - array('in', '_stop', 'clear'), - array($out, $out, $in) + ['in', '_stop', 'clear'], + [$out, $out, $in] ); } diff --git a/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php b/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php index 427066a7a3..4ade5914d8 100644 --- a/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/CompletionShellTest.php @@ -53,29 +53,29 @@ class CompletionShellTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ), - 'Console/Command' => array( + ], + 'Console/Command' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS - ) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + ] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $out = new TestCompletionStringOutput(); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Shell = $this->getMock( 'CompletionShell', - array('in', '_stop', 'clear'), - array($out, $out, $in) + ['in', '_stop', 'clear'], + [$out, $out, $in] ); $this->Shell->Command = $this->getMock( 'CommandTask', - array('in', '_stop', 'clear'), - array($out, $out, $in) + ['in', '_stop', 'clear'], + [$out, $out, $in] ); } @@ -96,7 +96,7 @@ public function tearDown() : void { * @return void */ public function testStartup() { - $this->Shell->runCommand('main', array()); + $this->Shell->runCommand('main', []); $output = $this->Shell->stdout->output; $needle = 'Welcome to CakePHP'; @@ -109,7 +109,7 @@ public function testStartup() { * @return void */ public function testMain() { - $this->Shell->runCommand('main', array()); + $this->Shell->runCommand('main', []); $output = $this->Shell->stdout->output; $expected = "/This command is not intended to be called manually/"; @@ -122,7 +122,7 @@ public function testMain() { * @return void */ public function testCommands() { - $this->Shell->runCommand('commands', array()); + $this->Shell->runCommand('commands', []); $output = $this->Shell->stdout->output; $expected = "TestPlugin.example TestPlugin.test_plugin TestPluginTwo.example TestPluginTwo.welcome acl api bake command_list completion console i18n schema server test testsuite upgrade sample\n"; @@ -135,7 +135,7 @@ public function testCommands() { * @return void */ public function testOptionsNoArguments() { - $this->Shell->runCommand('options', array()); + $this->Shell->runCommand('options', []); $output = $this->Shell->stdout->output; $expected = "--help -h --verbose -v --quiet -q\n"; @@ -148,7 +148,7 @@ public function testOptionsNoArguments() { * @return void */ public function testOptionsNonExistingCommand() { - $this->Shell->runCommand('options', array('options', 'foo')); + $this->Shell->runCommand('options', ['options', 'foo']); $output = $this->Shell->stdout->output; $expected = "--help -h --verbose -v --quiet -q\n"; @@ -161,7 +161,7 @@ public function testOptionsNonExistingCommand() { * @return void */ public function testOptions() { - $this->Shell->runCommand('options', array('options', 'bake')); + $this->Shell->runCommand('options', ['options', 'bake']); $output = $this->Shell->stdout->output; $expected = "--help -h --verbose -v --quiet -q --connection -c --theme -t\n"; @@ -174,7 +174,7 @@ public function testOptions() { * @return void */ public function testSubCommandsCorePlugin() { - $this->Shell->runCommand('subCommands', array('subCommands', 'CORE.bake')); + $this->Shell->runCommand('subCommands', ['subCommands', 'CORE.bake']); $output = $this->Shell->stdout->output; $expected = "controller db_config fixture model plugin project test view\n"; @@ -187,7 +187,7 @@ public function testSubCommandsCorePlugin() { * @return void */ public function testSubCommandsAppPlugin() { - $this->Shell->runCommand('subCommands', array('subCommands', 'app.sample')); + $this->Shell->runCommand('subCommands', ['subCommands', 'app.sample']); $output = $this->Shell->stdout->output; $expected = ''; @@ -200,7 +200,7 @@ public function testSubCommandsAppPlugin() { * @return void */ public function testSubCommandsPlugin() { - $this->Shell->runCommand('subCommands', array('subCommands', 'TestPluginTwo.welcome')); + $this->Shell->runCommand('subCommands', ['subCommands', 'TestPluginTwo.welcome']); $output = $this->Shell->stdout->output; $expected = "say_hello\n"; @@ -213,7 +213,7 @@ public function testSubCommandsPlugin() { * @return void */ public function testSubCommandsNoArguments() { - $this->Shell->runCommand('subCommands', array()); + $this->Shell->runCommand('subCommands', []); $output = $this->Shell->stdout->output; $expected = ''; @@ -226,7 +226,7 @@ public function testSubCommandsNoArguments() { * @return void */ public function testSubCommandsNonExistingCommand() { - $this->Shell->runCommand('subCommands', array('subCommands', 'foo')); + $this->Shell->runCommand('subCommands', ['subCommands', 'foo']); $output = $this->Shell->stdout->output; $expected = ''; @@ -239,7 +239,7 @@ public function testSubCommandsNonExistingCommand() { * @return void */ public function testSubCommands() { - $this->Shell->runCommand('subCommands', array('subCommands', 'bake')); + $this->Shell->runCommand('subCommands', ['subCommands', 'bake']); $output = $this->Shell->stdout->output; $expected = "controller db_config fixture model plugin project test view\n"; @@ -252,7 +252,7 @@ public function testSubCommands() { * @return void */ public function testFuzzy() { - $this->Shell->runCommand('fuzzy', array()); + $this->Shell->runCommand('fuzzy', []); $output = $this->Shell->stdout->output; $expected = ''; diff --git a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php index 2c3a07de23..9b69306a0a 100644 --- a/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/SchemaShellTest.php @@ -42,42 +42,42 @@ class SchemaShellTestSchema extends CakeSchema { * * @var array */ - public $comments = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'user_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => false, 'length' => 100), - 'comment' => array('type' => 'text', 'null' => false, 'default' => null), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - ); + public $comments = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'post_id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'user_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => false, 'length' => 100], + 'comment' => ['type' => 'text', 'null' => false, 'default' => null], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + ]; /** * posts property * * @var array */ - public $articles = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'user_id' => array('type' => 'integer', 'null' => true, 'default' => ''), - 'title' => array('type' => 'string', 'null' => false, 'default' => 'Title'), - 'body' => array('type' => 'text', 'null' => true, 'default' => null), - 'summary' => array('type' => 'text', 'null' => true), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - ); - - public $newone = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'testit' => array('type' => 'string', 'null' => false, 'default' => 'Title'), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - ); + public $articles = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'user_id' => ['type' => 'integer', 'null' => true, 'default' => ''], + 'title' => ['type' => 'string', 'null' => false, 'default' => 'Title'], + 'body' => ['type' => 'text', 'null' => true, 'default' => null], + 'summary' => ['type' => 'text', 'null' => true], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + ]; + + public $newone = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'testit' => ['type' => 'string', 'null' => false, 'default' => 'Title'], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + ]; } /** @@ -92,10 +92,10 @@ class SchemaShellTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.article', 'core.user', 'core.post', 'core.auth_user', 'core.author', 'core.comment', 'core.test_plugin_comment', 'core.aco', 'core.aro', 'core.aros_aco', - ); + ]; /** * setUp method @@ -105,12 +105,12 @@ class SchemaShellTest extends CakeTestCase { public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Shell = $this->getMock( 'SchemaShell', - array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop'), - array($out, $out, $in) + ['in', 'out', 'hr', 'createFile', 'error', 'err', '_stop'], + [$out, $out, $in] ); } @@ -140,9 +140,9 @@ public function testStartup() { $this->assertEquals('schema.php', $this->Shell->Schema->file); $this->Shell->Schema = null; - $this->Shell->params = array( + $this->Shell->params = [ 'name' => 'TestSchema' - ); + ]; $this->Shell->startup(); $this->assertEquals('TestSchema', $this->Shell->Schema->name); $this->assertEquals('test_schema.php', $this->Shell->Schema->file); @@ -150,11 +150,11 @@ public function testStartup() { $this->assertEquals(CONFIG . 'Schema', $this->Shell->Schema->path); $this->Shell->Schema = null; - $this->Shell->params = array( + $this->Shell->params = [ 'file' => 'other_file.php', 'connection' => 'test', 'path' => '/test/path' - ); + ]; $this->Shell->startup(); $this->assertEquals(Inflector::camelize(Inflector::slug(APP_DIR)), $this->Shell->Schema->name); $this->assertEquals('other_file.php', $this->Shell->Schema->file); @@ -182,18 +182,18 @@ public function testView() { * @return void */ public function testViewWithPlugins() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); - $this->Shell->args = array('TestPlugin.schema'); + $this->Shell->args = ['TestPlugin.schema']; $this->Shell->startup(); $this->Shell->expects($this->exactly(2))->method('_stop'); $this->Shell->expects($this->atLeastOnce())->method('out'); $this->Shell->view(); - $this->Shell->args = array(); - $this->Shell->params = array('plugin' => 'TestPlugin'); + $this->Shell->args = []; + $this->Shell->params = ['plugin' => 'TestPlugin']; $this->Shell->startup(); $this->Shell->view(); @@ -207,11 +207,11 @@ public function testViewWithPlugins() { * @return void */ public function testDumpWithFileWriting() { - $this->Shell->params = array( + $this->Shell->params = [ 'name' => 'i18n', 'connection' => 'test', 'write' => TMP . 'tests' . DS . 'i18n.sql' - ); + ]; $this->Shell->expects($this->once())->method('_stop'); $this->Shell->startup(); $this->Shell->dump(); @@ -234,15 +234,15 @@ public function testDumpWithFileWriting() { * @return void */ public function testDumpFileWritingWithPlugins() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); - $this->Shell->args = array('TestPlugin.TestPluginApp'); - $this->Shell->params = array( + $this->Shell->args = ['TestPlugin.TestPluginApp']; + $this->Shell->params = [ 'connection' => 'test', 'write' => TMP . 'tests' . DS . 'dump_test.sql' - ); + ]; $this->Shell->startup(); $this->Shell->expects($this->once())->method('_stop'); $this->Shell->dump(); @@ -268,13 +268,13 @@ public function testGenerateSnapshot() { $this->Shell->path = TMP; $this->Shell->params['file'] = 'schema.php'; $this->Shell->params['force'] = false; - $this->Shell->args = array('snapshot'); + $this->Shell->args = ['snapshot']; $this->Shell->Schema = $this->getMock('CakeSchema'); - $this->Shell->Schema->expects($this->at(0))->method('read')->will($this->returnValue(array('schema data'))); + $this->Shell->Schema->expects($this->at(0))->method('read')->will($this->returnValue(['schema data'])); $this->Shell->Schema->expects($this->at(0))->method('write')->will($this->returnValue(true)); $this->Shell->Schema->expects($this->at(1))->method('read'); - $this->Shell->Schema->expects($this->at(1))->method('write')->with(array('schema data', 'file' => 'schema_0.php')); + $this->Shell->Schema->expects($this->at(1))->method('write')->with(['schema data', 'file' => 'schema_0.php']); $this->Shell->generate(); } @@ -288,7 +288,7 @@ public function testGenerateNoOverwrite() { touch(TMP . 'schema.php'); $this->Shell->params['file'] = 'schema.php'; $this->Shell->params['force'] = false; - $this->Shell->args = array(); + $this->Shell->args = []; $this->Shell->expects($this->once())->method('in')->will($this->returnValue('q')); $this->Shell->Schema = $this->getMock('CakeSchema'); @@ -308,7 +308,7 @@ public function testGenerateOverwrite() { touch(TMP . 'schema.php'); $this->Shell->params['file'] = 'schema.php'; $this->Shell->params['force'] = false; - $this->Shell->args = array(); + $this->Shell->args = []; $this->Shell->expects($this->once())->method('in')->will($this->returnValue('o')); @@ -317,12 +317,12 @@ public function testGenerateOverwrite() { $this->Shell->Schema = $this->getMock('CakeSchema'); $this->Shell->Schema->path = TMP; - $this->Shell->Schema->expects($this->once())->method('read')->will($this->returnValue(array('schema data'))); + $this->Shell->Schema->expects($this->once())->method('read')->will($this->returnValue(['schema data'])); $this->Shell->Schema->expects($this->once())->method('write')->will($this->returnValue(true)); $this->Shell->Schema->expects($this->once())->method('read'); $this->Shell->Schema->expects($this->once())->method('write') - ->with(array('schema data', 'file' => 'schema.php')); + ->with(['schema data', 'file' => 'schema.php']); $this->Shell->generate(); unlink(TMP . 'schema.php'); @@ -335,17 +335,17 @@ public function testGenerateOverwrite() { * @return void */ public function testGenerateWithPlugins() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $this->db->cacheSources = false; - $this->Shell->params = array( + $this->Shell->params = [ 'plugin' => 'TestPlugin', 'connection' => 'test', 'force' => false - ); + ]; $this->Shell->startup(); $this->Shell->Schema->path = TMP . 'tests' . DS; @@ -369,19 +369,19 @@ public function testGenerateWithPlugins() { * @return void */ public function testGenerateModels() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $this->db->cacheSources = false; - $this->Shell->params = array( + $this->Shell->params = [ 'plugin' => 'TestPlugin', 'connection' => 'test', 'models' => 'TestPluginComment', 'force' => false, 'overwrite' => true - ); + ]; $this->Shell->startup(); $this->Shell->Schema->path = TMP . 'tests' . DS; @@ -405,13 +405,13 @@ public function testGenerateModels() { public function testGenerateExclude() { Configure::write('Acl.database', 'test'); $this->db->cacheSources = false; - $this->Shell->params = array( + $this->Shell->params = [ 'connection' => 'test', 'force' => false, 'models' => 'Aro, Aco, Permission', 'overwrite' => true, 'exclude' => 'acos, aros', - ); + ]; $this->Shell->startup(); $this->Shell->Schema->path = TMP . 'tests' . DS; @@ -432,15 +432,15 @@ public function testGenerateExclude() { public function testCreateOptionYes() { $this->Shell = $this->getMock( 'SchemaShell', - array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'), - array(&$this->Dispatcher) + ['in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'], + [&$this->Dispatcher] ); - $this->Shell->params = array( + $this->Shell->params = [ 'connection' => 'test', 'yes' => true, - ); - $this->Shell->args = array('i18n'); + ]; + $this->Shell->args = ['i18n']; $this->Shell->expects($this->never())->method('in'); $this->Shell->expects($this->exactly(2))->method('_run'); $this->Shell->startup(); @@ -453,10 +453,10 @@ public function testCreateOptionYes() { * @return void */ public function testCreateNoArgs() { - $this->Shell->params = array( + $this->Shell->params = [ 'connection' => 'test' - ); - $this->Shell->args = array('i18n'); + ]; + $this->Shell->args = ['i18n']; $this->Shell->startup(); $this->Shell->expects($this->any())->method('in')->will($this->returnValue('y')); $this->Shell->create(); @@ -482,12 +482,12 @@ public function testCreateWithTableArgs() { if (in_array('i18n', $sources)) { $this->markTestSkipped('i18n table already exists, cannot try to create it again.'); } - $this->Shell->params = array( + $this->Shell->params = [ 'connection' => 'test', 'name' => 'I18n', 'path' => CONFIG . 'Schema' - ); - $this->Shell->args = array('I18n', 'i18n'); + ]; + $this->Shell->args = ['I18n', 'i18n']; $this->Shell->startup(); $this->Shell->expects($this->any())->method('in')->will($this->returnValue('y')); $this->Shell->create(); @@ -509,15 +509,15 @@ public function testCreateWithTableArgs() { public function testUpdateWithTable() { $this->Shell = $this->getMock( 'SchemaShell', - array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'), - array(&$this->Dispatcher) + ['in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'], + [&$this->Dispatcher] ); - $this->Shell->params = array( + $this->Shell->params = [ 'connection' => 'test', 'force' => true - ); - $this->Shell->args = array('SchemaShellTest', 'articles'); + ]; + $this->Shell->args = ['SchemaShellTest', 'articles']; $this->Shell->startup(); $this->Shell->expects($this->any()) ->method('in') @@ -537,15 +537,15 @@ public function testUpdateWithTable() { public function testUpdateWithTableCreate() { $this->Shell = $this->getMock( 'SchemaShell', - array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'), - array(&$this->Dispatcher) + ['in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'], + [&$this->Dispatcher] ); - $this->Shell->params = array( + $this->Shell->params = [ 'connection' => 'test', 'force' => true - ); - $this->Shell->args = array('SchemaShellTest', 'newone'); + ]; + $this->Shell->args = ['SchemaShellTest', 'newone']; $this->Shell->startup(); $this->Shell->expects($this->any()) ->method('in') @@ -565,16 +565,16 @@ public function testUpdateWithTableCreate() { public function testUpdateWithOptionYes() { $this->Shell = $this->getMock( 'SchemaShell', - array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'), - array(&$this->Dispatcher) + ['in', 'out', 'hr', 'createFile', 'error', 'err', '_stop', '_run'], + [&$this->Dispatcher] ); - $this->Shell->params = array( + $this->Shell->params = [ 'connection' => 'test', 'force' => true, 'yes' => true, - ); - $this->Shell->args = array('SchemaShellTest', 'articles'); + ]; + $this->Shell->args = ['SchemaShellTest', 'articles']; $this->Shell->startup(); $this->Shell->expects($this->never())->method('in'); $this->Shell->expects($this->once()) @@ -590,14 +590,14 @@ public function testUpdateWithOptionYes() { * @return void */ public function testPluginParam() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); - $this->Shell->params = array( + $this->Shell->params = [ 'plugin' => 'TestPlugin', 'connection' => 'test' - ); + ]; $this->Shell->startup(); $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Config' . DS . 'Schema'; $this->assertEquals($expected, $this->Shell->Schema->path); @@ -610,17 +610,17 @@ public function testPluginParam() { * @return void */ public function testName() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); - $this->Shell->params = array( + $this->Shell->params = [ 'plugin' => 'TestPlugin', 'connection' => 'test', 'name' => 'custom_names', 'force' => false, 'overwrite' => true, - ); + ]; $this->Shell->startup(); if (file_exists($this->Shell->Schema->path . DS . 'custom_names.php')) { unlink($this->Shell->Schema->path . DS . 'custom_names.php'); @@ -640,18 +640,18 @@ public function testName() { * @return void */ public function testNameAndFile() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); - $this->Shell->params = array( + $this->Shell->params = [ 'plugin' => 'TestPlugin', 'connection' => 'test', 'name' => 'custom_name', 'file' => 'other_name', 'force' => false, 'overwrite' => true, - ); + ]; $this->Shell->startup(); $file = $this->Shell->Schema->path . DS . 'other_name.php'; if (file_exists($file)) { @@ -675,14 +675,14 @@ public function testNameAndFile() { * @return void */ public function testPluginDotSyntaxWithCreate() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); - $this->Shell->params = array( + $this->Shell->params = [ 'connection' => 'test' - ); - $this->Shell->args = array('TestPlugin.TestPluginApp'); + ]; + $this->Shell->args = ['TestPlugin.TestPluginApp']; $this->Shell->startup(); $this->Shell->expects($this->any())->method('in')->will($this->returnValue('y')); $this->Shell->create(); diff --git a/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php index 5dbc7a59de..41b9e9b85c 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/CommandTaskTest.php @@ -30,23 +30,23 @@ class CommandTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ), - 'Console/Command' => array( + ], + 'Console/Command' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS - ) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + ] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->CommandTask = $this->getMock( 'CommandTask', - array('in', '_stop', 'clear'), - array($out, $out, $in) + ['in', '_stop', 'clear'], + [$out, $out, $in] ); } @@ -69,8 +69,8 @@ public function tearDown() : void { public function testGetShellList() { $result = $this->CommandTask->getShellList(); - $expected = array( - 'CORE' => array( + $expected = [ + 'CORE' => [ 'acl', 'api', 'bake', @@ -83,19 +83,19 @@ public function testGetShellList() { 'test', 'testsuite', 'upgrade' - ), - 'TestPlugin' => array( + ], + 'TestPlugin' => [ 'example', 'test_plugin' - ), - 'TestPluginTwo' => array( + ], + 'TestPluginTwo' => [ 'example', 'welcome' - ), - 'app' => array( + ], + 'app' => [ 'sample' - ), - ); + ], + ]; $this->assertEquals($expected, $result); } @@ -107,7 +107,7 @@ public function testGetShellList() { public function testCommands() { $result = $this->CommandTask->commands(); - $expected = array( + $expected = [ 'TestPlugin.example', 'TestPlugin.test_plugin', 'TestPluginTwo.example', @@ -125,7 +125,7 @@ public function testCommands() { 'testsuite', 'upgrade', 'sample' - ); + ]; $this->assertEquals($expected, $result); } @@ -137,7 +137,7 @@ public function testCommands() { public function testSubCommands() { $result = $this->CommandTask->subCommands('acl'); - $expected = array( + $expected = [ 'check', 'create', 'db_config', @@ -151,7 +151,7 @@ public function testSubCommands() { 'parseIdentifier', 'setParent', 'view' - ); + ]; $this->assertEquals($expected, $result); } @@ -163,7 +163,7 @@ public function testSubCommands() { public function testSubCommandsUnknownCommand() { $result = $this->CommandTask->subCommands('yoghurt'); - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); } @@ -205,7 +205,7 @@ public function testGetShellCore() { public function testOptions() { $result = $this->CommandTask->options('bake'); - $expected = array( + $expected = [ '--help', '-h', '--verbose', @@ -216,7 +216,7 @@ public function testOptions() { '-c', '--theme', '-t' - ); + ]; $this->assertEquals($expected, $result); } @@ -228,14 +228,14 @@ public function testOptions() { public function testOptionsUnknownCommand() { $result = $this->CommandTask->options('pie'); - $expected = array( + $expected = [ '--help', '-h', '--verbose', '-v', '--quiet', '-q' - ); + ]; $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php index e9fbc57a67..41c191c333 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php @@ -43,9 +43,9 @@ */ class BakeArticle extends Model { - public $hasMany = array('BakeComment'); + public $hasMany = ['BakeComment']; - public $hasAndBelongsToMany = array('BakeTag'); + public $hasAndBelongsToMany = ['BakeTag']; } } @@ -62,7 +62,7 @@ class ControllerTaskTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.bake_article', 'core.bake_articles_bake_tag', 'core.bake_comment', 'core.bake_tag'); + public $fixtures = ['core.bake_article', 'core.bake_articles_bake_tag', 'core.bake_comment', 'core.bake_tag']; /** * setUp method @@ -71,25 +71,25 @@ class ControllerTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ControllerTask', - array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'), - array($out, $out, $in) + ['in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'], + [$out, $out, $in] ); $this->Task->name = 'Controller'; $this->Task->Template = new TemplateTask($out, $out, $in); $this->Task->Template->params['theme'] = 'default'; $this->Task->Model = $this->getMock('ModelTask', - array('in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest'), - array($out, $out, $in) + ['in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest'], + [$out, $out, $in] ); $this->Task->Project = $this->getMock('ProjectTask', - array('in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest', 'getPrefix'), - array($out, $out, $in) + ['in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest', 'getPrefix'], + [$out, $out, $in] ); - $this->Task->Test = $this->getMock('TestTask', array(), array($out, $out, $in)); + $this->Task->Test = $this->getMock('TestTask', [], [$out, $out, $in]); if (!defined('ARTICLE_MODEL_CREATED')) { $this->markTestSkipped('Could not run as an Article, Tag or Comment model was already loaded.'); @@ -126,14 +126,14 @@ public function testListAll() { $this->Task->expects($this->at(4))->method('out')->with(' 3. BakeComments'); $this->Task->expects($this->at(5))->method('out')->with(' 4. BakeTags'); - $expected = array('BakeArticles', 'BakeArticlesBakeTags', 'BakeComments', 'BakeTags'); + $expected = ['BakeArticles', 'BakeArticlesBakeTags', 'BakeComments', 'BakeTags']; $result = $this->Task->listAll('test'); $this->assertEquals($expected, $result); $this->Task->interactive = false; $result = $this->Task->listAll(); - $expected = array('bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags'); + $expected = ['bake_articles', 'bake_articles_bake_tags', 'bake_comments', 'bake_tags']; $this->assertEquals($expected, $result); } @@ -185,7 +185,7 @@ public function testGetNameInvalidIndex() { public function testDoHelpersNo() { $this->Task->expects($this->any())->method('in')->will($this->returnValue('n')); $result = $this->Task->doHelpers(); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -197,7 +197,7 @@ public function testDoHelpersTrailingSpace() { $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Text, Number, CustomOne ')); $result = $this->Task->doHelpers(); - $expected = array('Text', 'Number', 'CustomOne'); + $expected = ['Text', 'Number', 'CustomOne']; $this->assertEquals($expected, $result); } @@ -210,7 +210,7 @@ public function testDoHelpersTrailingCommas() { $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' Text, Number, CustomOne, , ')); $result = $this->Task->doHelpers(); - $expected = array('Text', 'Number', 'CustomOne'); + $expected = ['Text', 'Number', 'CustomOne']; $this->assertEquals($expected, $result); } @@ -222,7 +222,7 @@ public function testDoHelpersTrailingCommas() { public function testDoComponentsNo() { $this->Task->expects($this->any())->method('in')->will($this->returnValue('n')); $result = $this->Task->doComponents(); - $this->assertSame(array('Paginator'), $result); + $this->assertSame(['Paginator'], $result); } /** @@ -235,7 +235,7 @@ public function testDoComponentsTrailingSpaces() { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security ')); $result = $this->Task->doComponents(); - $expected = array('Paginator', 'RequestHandler', 'Security'); + $expected = ['Paginator', 'RequestHandler', 'Security']; $this->assertEquals($expected, $result); } @@ -249,7 +249,7 @@ public function testDoComponentsTrailingCommas() { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue(' RequestHandler, Security, , ')); $result = $this->Task->doComponents(); - $expected = array('Paginator', 'RequestHandler', 'Security'); + $expected = ['Paginator', 'RequestHandler', 'Security']; $this->assertEquals($expected, $result); } @@ -261,8 +261,8 @@ public function testDoComponentsTrailingCommas() { public function testConfirmController() { $controller = 'Posts'; $scaffold = false; - $helpers = array('Js', 'Time'); - $components = array('Acl', 'Auth'); + $helpers = ['Js', 'Time']; + $components = ['Acl', 'Auth']; $this->Task->expects($this->at(4))->method('out')->with("Controller Name:\n\t$controller"); $this->Task->expects($this->at(5))->method('out')->with("Helpers:\n\tJs, Time"); @@ -276,15 +276,15 @@ public function testConfirmController() { * @return void */ public function testBake() { - $helpers = array('Js', 'Time'); - $components = array('Acl', 'Auth'); + $helpers = ['Js', 'Time']; + $components = ['Acl', 'Auth']; $this->Task->expects($this->any())->method('createFile')->will($this->returnValue(true)); $result = $this->Task->bake('Articles', null, $helpers, $components); $expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'NoActions.ctp'); $this->assertTextEquals($expected, $result); - $result = $this->Task->bake('Articles', null, array(), array()); + $result = $this->Task->bake('Articles', null, [], []); $expected = file_get_contents(CAKE . 'Test' . DS . 'bake_compare' . DS . 'Controller' . DS . 'NoHelpersOrComponents.ctp'); $this->assertTextEquals($expected, $result); @@ -302,7 +302,7 @@ public function testBakeWithPlugin() { $this->Task->plugin = 'ControllerTest'; //fake plugin path - CakePlugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS)); + CakePlugin::load('ControllerTest', ['path' => APP . 'Plugin' . DS . 'ControllerTest' . DS]); $path = APP . 'Plugin' . DS . 'ControllerTest' . DS . 'Controller' . DS . 'ArticlesController.php'; $this->Task->expects($this->at(1))->method('createFile')->with( @@ -314,11 +314,11 @@ public function testBakeWithPlugin() { $this->stringContains('ArticlesController extends ControllerTestAppController') )->will($this->returnValue(true)); - $this->Task->bake('Articles', '--actions--', array(), array(), array()); + $this->Task->bake('Articles', '--actions--', [], [], []); $this->Task->plugin = 'ControllerTest'; $path = APP . 'Plugin' . DS . 'ControllerTest' . DS . 'Controller' . DS . 'ArticlesController.php'; - $result = $this->Task->bake('Articles', '--actions--', array(), array(), array()); + $result = $this->Task->bake('Articles', '--actions--', [], [], []); $this->assertStringContainsString("App::uses('ControllerTestAppController', 'ControllerTest.Controller');", $result); $this->assertEquals('ControllerTest', $this->Task->Template->templateVars['plugin']); @@ -464,7 +464,7 @@ public function testExecuteIntoAll() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); + $this->Task->args = ['all']; $this->Task->expects($this->any())->method('_checkUnitTest')->will($this->returnValue(true)); $this->Task->Test->expects($this->once())->method('bake'); @@ -491,7 +491,7 @@ public function testExecuteIntoAllAdmin() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); + $this->Task->args = ['all']; $this->Task->params['admin'] = true; $this->Task->Project->expects($this->any()) @@ -519,7 +519,7 @@ public function testExecuteIntoAllAdmin() { public function testExecuteWithController() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('BakeArticles'); + $this->Task->args = ['BakeArticles']; $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( @@ -536,9 +536,9 @@ public function testExecuteWithController() { * @return void */ public static function nameVariations() { - return array( - array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles') - ); + return [ + ['BakeArticles'], ['BakeArticle'], ['bake_article'], ['bake_articles'] + ]; } /** @@ -550,7 +550,7 @@ public static function nameVariations() { public function testExecuteWithControllerNameVariations($name) { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array($name); + $this->Task->args = [$name]; $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( @@ -567,8 +567,8 @@ public function testExecuteWithControllerNameVariations($name) { public function testExecuteWithPublicParam() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('BakeArticles'); - $this->Task->params = array('public' => true); + $this->Task->args = ['BakeArticles']; + $this->Task->params = ['public' => true]; $filename = '/my/path/BakeArticlesController.php'; $expected = new PHPUnit\Framework\Constraint\LogicalNot($this->stringContains('$scaffold')); @@ -587,8 +587,8 @@ public function testExecuteWithControllerAndBoth() { $this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_')); $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('BakeArticles'); - $this->Task->params = array('public' => true, 'admin' => true); + $this->Task->args = ['BakeArticles']; + $this->Task->params = ['public' => true, 'admin' => true]; $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( @@ -606,8 +606,8 @@ public function testExecuteWithControllerAndAdmin() { $this->Task->Project->expects($this->any())->method('getPrefix')->will($this->returnValue('admin_')); $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('BakeArticles'); - $this->Task->params = array('admin' => true); + $this->Task->args = ['BakeArticles']; + $this->Task->params = ['admin' => true]; $filename = '/my/path/BakeArticlesController.php'; $this->Task->expects($this->once())->method('createFile')->with( diff --git a/lib/Cake/Test/Case/Console/Command/Task/DbConfigTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/DbConfigTaskTest.php index 2e1ebe8611..11c1bed6b0 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/DbConfigTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/DbConfigTaskTest.php @@ -36,12 +36,12 @@ class DbConfigTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('DbConfigTask', - array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest', '_verify'), - array($out, $out, $in) + ['in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest', '_verify'], + [$out, $out, $in] ); $this->Task->path = CONFIG; @@ -90,11 +90,11 @@ public function testInitialize() { public function testExecuteIntoInteractive() { $this->Task->initialize(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock( 'DbConfigTask', - array('in', '_stop', 'createFile', 'bake'), array($out, $out, $in) + ['in', '_stop', 'createFile', 'bake'], [$out, $out, $in] ); $this->Task->expects($this->once())->method('_stop'); @@ -111,8 +111,8 @@ public function testExecuteIntoInteractive() { $this->Task->expects($this->at(13))->method('in')->will($this->returnValue('y')); //looks good $this->Task->expects($this->at(14))->method('in')->will($this->returnValue('n')); //another $this->Task->expects($this->at(15))->method('bake') - ->with(array( - array( + ->with([ + [ 'name' => 'default', 'datasource' => 'mysql', 'persistent' => 'false', @@ -124,8 +124,8 @@ public function testExecuteIntoInteractive() { 'encoding' => null, 'port' => '', 'schema' => null - ) - )); + ] + ]); $this->Task->execute(); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php index 53ba40ab60..c49950fb2d 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ExtractTaskTest.php @@ -39,13 +39,13 @@ class ExtractTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock( 'ExtractTask', - array('in', 'out', 'err', '_stop'), - array($out, $out, $in) + ['in', 'out', 'err', '_stop'], + [$out, $out, $in] ); $this->path = TMP . 'tests' . DS . 'extract_task_test'; new Folder($this->path . DS . 'locale', true); @@ -306,14 +306,14 @@ public function testExtractMultiplePaths() { * @return void */ public function testExtractExcludePlugins() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); - $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $this->in = $this->getMock('ConsoleInput', array(), array(), '', false); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); + $this->out = $this->getMock('ConsoleOutput', [], [], '', false); + $this->in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ExtractTask', - array('_isExtractingApp', '_extractValidationMessages', 'in', 'out', 'err', 'clear', '_stop'), - array($this->out, $this->out, $this->in) + ['_isExtractingApp', '_extractValidationMessages', 'in', 'out', 'err', 'clear', '_stop'], + [$this->out, $this->out, $this->in] ); $this->Task->expects($this->exactly(2))->method('_isExtractingApp')->will($this->returnValue(true)); @@ -332,15 +332,15 @@ public function testExtractExcludePlugins() { * @return void */ public function testExtractPlugin() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); - $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $this->in = $this->getMock('ConsoleInput', array(), array(), '', false); + $this->out = $this->getMock('ConsoleOutput', [], [], '', false); + $this->in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ExtractTask', - array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'), - array($this->out, $this->out, $this->in) + ['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'], + [$this->out, $this->out, $this->in] ); $this->Task->params['output'] = $this->path . DS; @@ -360,15 +360,15 @@ public function testExtractPlugin() { * @return void */ public function testExtractModelValidation() { - App::build(array( - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $this->in = $this->getMock('ConsoleInput', array(), array(), '', false); + App::build([ + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + $this->out = $this->getMock('ConsoleOutput', [], [], '', false); + $this->in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ExtractTask', - array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'), - array($this->out, $this->out, $this->in) + ['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'], + [$this->out, $this->out, $this->in] ); $this->Task->expects($this->exactly(2))->method('_isExtractingApp')->will($this->returnValue(true)); @@ -397,14 +397,14 @@ public function testExtractModelValidation() { * @return void */ public function testExtractModelValidationWithDomainInModel() { - App::build(array( - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Model' . DS) - )); - $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $this->in = $this->getMock('ConsoleInput', array(), array(), '', false); + App::build([ + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS . 'Model' . DS] + ]); + $this->out = $this->getMock('ConsoleOutput', [], [], '', false); + $this->in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ExtractTask', - array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'), - array($this->out, $this->out, $this->in) + ['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'], + [$this->out, $this->out, $this->in] ); $this->Task->expects($this->exactly(2))->method('_isExtractingApp')->will($this->returnValue(true)); @@ -429,14 +429,14 @@ public function testExtractModelValidationWithDomainInModel() { * @return void */ public function testExtractModelValidationInPlugin() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); - $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $this->in = $this->getMock('ConsoleInput', array(), array(), '', false); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); + $this->out = $this->getMock('ConsoleOutput', [], [], '', false); + $this->in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ExtractTask', - array('_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'), - array($this->out, $this->out, $this->in) + ['_isExtractingApp', 'in', 'out', 'err', 'clear', '_stop'], + [$this->out, $this->out, $this->in] ); $this->Task->params['output'] = $this->path . DS; diff --git a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php index 9c5aba39e5..87ccefe723 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/FixtureTaskTest.php @@ -37,7 +37,7 @@ class FixtureTaskTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.article', 'core.comment', 'core.datatype', 'core.binary_test', 'core.user'); + public $fixtures = ['core.article', 'core.comment', 'core.datatype', 'core.binary_test', 'core.user']; /** * Whether backup global state for each test method or not @@ -53,19 +53,19 @@ class FixtureTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('FixtureTask', - array('in', 'err', 'createFile', '_stop', 'clear'), - array($out, $out, $in) + ['in', 'err', 'createFile', '_stop', 'clear'], + [$out, $out, $in] ); $this->Task->Model = $this->getMock('ModelTask', - array('in', 'out', 'err', 'createFile', 'getName', 'getTable', 'listAll'), - array($out, $out, $in) + ['in', 'out', 'err', 'createFile', 'getName', 'getTable', 'listAll'], + [$out, $out, $in] ); $this->Task->Template = new TemplateTask($out, $out, $in); - $this->Task->DbConfig = $this->getMock('DbConfigTask', array(), array($out, $out, $in)); + $this->Task->DbConfig = $this->getMock('DbConfigTask', [], [$out, $out, $in]); $this->Task->Template->initialize(); } @@ -85,8 +85,8 @@ public function tearDown() : void { * @return void */ public function testConstruct() { - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $Task = new FixtureTask($out, $out, $in); $this->assertEquals(APP . 'Test' . DS . 'Fixture' . DS, $Task->path); @@ -103,7 +103,7 @@ public function testImportOptionsSchemaRecords() { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue('y')); $result = $this->Task->importOptions('Article'); - $expected = array('schema' => 'Article', 'records' => true); + $expected = ['schema' => 'Article', 'records' => true]; $this->assertEquals($expected, $result); } @@ -119,7 +119,7 @@ public function testImportOptionsNothing() { $this->Task->expects($this->at(2))->method('in')->will($this->returnValue('n')); $result = $this->Task->importOptions('Article'); - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); } @@ -129,10 +129,10 @@ public function testImportOptionsNothing() { * @return void */ public function testImportOptionsWithCommandLineOptions() { - $this->Task->params = array('schema' => true, 'records' => true); + $this->Task->params = ['schema' => true, 'records' => true]; $result = $this->Task->importOptions('Article'); - $expected = array('schema' => 'Article', 'fromTable' => true); + $expected = ['schema' => 'Article', 'fromTable' => true]; $this->assertEquals($expected, $result); } @@ -142,10 +142,10 @@ public function testImportOptionsWithCommandLineOptions() { * @return void */ public function testImportOptionsWithCommandLineOptionsPlugin() { - $this->Task->params = array('schema' => true, 'records' => true, 'plugin' => 'TestPlugin'); + $this->Task->params = ['schema' => true, 'records' => true, 'plugin' => 'TestPlugin']; $result = $this->Task->importOptions('Article'); - $expected = array('schema' => 'TestPlugin.Article', 'fromTable' => true); + $expected = ['schema' => 'TestPlugin.Article', 'fromTable' => true]; $this->assertEquals($expected, $result); } @@ -156,12 +156,12 @@ public function testImportOptionsWithCommandLineOptionsPlugin() { */ public function testImportOptionsWithSchema() { $this->Task->interactive = true; - $this->Task->params = array('schema' => true); + $this->Task->params = ['schema' => true]; $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n')); $this->Task->expects($this->at(1))->method('in')->will($this->returnValue('n')); $result = $this->Task->importOptions('Article'); - $expected = array('schema' => 'Article'); + $expected = ['schema' => 'Article']; $this->assertEquals($expected, $result); } @@ -172,11 +172,11 @@ public function testImportOptionsWithSchema() { */ public function testImportOptionsWithRecords() { $this->Task->interactive = true; - $this->Task->params = array('records' => true); + $this->Task->params = ['records' => true]; $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n')); $result = $this->Task->importOptions('Article'); - $expected = array('fromTable' => true); + $expected = ['fromTable' => true]; $this->assertEquals($expected, $result); } @@ -191,7 +191,7 @@ public function testImportOptionsTable() { $this->Task->expects($this->at(1))->method('in')->will($this->returnValue('n')); $this->Task->expects($this->at(2))->method('in')->will($this->returnValue('y')); $result = $this->Task->importOptions('Article'); - $expected = array('fromTable' => true); + $expected = ['fromTable' => true]; $this->assertEquals($expected, $result); } @@ -211,9 +211,9 @@ public function testImportRecordsFromDatabaseWithConditionsPoo() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $result = $this->Task->bake('Article', false, array( + $result = $this->Task->bake('Article', false, [ 'fromTable' => true, 'schema' => 'Article', 'records' => false - )); + ]); $this->assertStringContainsString('class ArticleFixture extends CakeTestFixture', $result); $this->assertStringContainsString('public $records', $result); @@ -229,7 +229,7 @@ public function testImportRecordsFromDatabaseWithConditionsPoo() { */ public function testImportOptionsAlternateConnection() { $this->Task->connection = 'test'; - $result = $this->Task->bake('Article', false, array('schema' => 'Article')); + $result = $this->Task->bake('Article', false, ['schema' => 'Article']); $this->assertStringContainsString("'connection' => 'test'", $result); } @@ -245,7 +245,7 @@ public function testImportRecordsNoEscaping() { } $Article = ClassRegistry::init('Article'); - $Article->updateAll(array('body' => "'Body \"value\"'")); + $Article->updateAll(['body' => "'Body \"value\"'"]); $this->Task->interactive = true; $this->Task->expects($this->at(0)) @@ -254,11 +254,11 @@ public function testImportRecordsNoEscaping() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $result = $this->Task->bake('Article', false, array( + $result = $this->Task->bake('Article', false, [ 'fromTable' => true, 'schema' => 'Article', 'records' => false - )); + ]); $this->assertStringContainsString("'body' => 'Body \"value\"'", $result, 'Data has bad escaping'); } @@ -270,11 +270,11 @@ public function testImportRecordsNoEscaping() { public function testExecuteWithImportSchema() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('article'); - $this->Task->params = array( + $this->Task->args = ['article']; + $this->Task->params = [ 'schema' => true, 'records' => false, - ); + ]; $filename = '/my/path/ArticleFixture.php'; $this->Task->expects($this->never()) @@ -298,11 +298,11 @@ public function testExecuteWithImportSchema() { public function testExecuteWithImportRecords() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('article'); - $this->Task->params = array( + $this->Task->args = ['article']; + $this->Task->params = [ 'schema' => true, 'records' => true, - ); + ]; $filename = '/my/path/ArticleFixture.php'; $this->Task->expects($this->never()) @@ -326,7 +326,7 @@ public function testExecuteWithImportRecords() { public function testExecuteWithNamedModel() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('article'); + $this->Task->args = ['article']; $filename = '/my/path/ArticleFixture.php'; $this->Task->expects($this->at(0))->method('createFile') @@ -343,10 +343,10 @@ public function testExecuteWithNamedModel() { public function testExecuteIntoAll() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); + $this->Task->args = ['all']; $this->Task->Model->expects($this->any()) ->method('listAll') - ->will($this->returnValue(array('articles', 'comments'))); + ->will($this->returnValue(['articles', 'comments'])); $filename = '/my/path/ArticleFixture.php'; $this->Task->expects($this->at(0)) @@ -369,11 +369,11 @@ public function testExecuteIntoAll() { public function testAllWithCountAndRecordsFlags() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); - $this->Task->params = array('count' => 10, 'records' => true); + $this->Task->args = ['all']; + $this->Task->params = ['count' => 10, 'records' => true]; $this->Task->Model->expects($this->any())->method('listAll') - ->will($this->returnValue(array('Articles', 'comments'))); + ->will($this->returnValue(['Articles', 'comments'])); $filename = '/my/path/ArticleFixture.php'; $this->Task->expects($this->at(0))->method('createFile') @@ -395,11 +395,11 @@ public function testAllWithCountAndRecordsFlags() { public function testAllWithSchemaImport() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); - $this->Task->params = array('schema' => true); + $this->Task->args = ['all']; + $this->Task->params = ['schema' => true]; $this->Task->Model->expects($this->any())->method('listAll') - ->will($this->returnValue(array('Articles', 'comments'))); + ->will($this->returnValue(['Articles', 'comments'])); $filename = '/my/path/ArticleFixture.php'; $this->Task->expects($this->at(0))->method('createFile') @@ -455,15 +455,15 @@ public function testBake() { $this->assertStringContainsString('public $table = \'comments\';', $result); $this->assertStringContainsString('public $fields = array(', $result); - $result = $this->Task->bake('Article', 'comments', array('records' => true)); + $result = $this->Task->bake('Article', 'comments', ['records' => true]); $this->assertStringContainsString("public \$import = array('records' => true, 'connection' => 'test');", $result); $this->assertStringNotContainsString('public $records', $result); - $result = $this->Task->bake('Article', 'comments', array('schema' => 'Article')); + $result = $this->Task->bake('Article', 'comments', ['schema' => 'Article']); $this->assertStringContainsString("public \$import = array('model' => 'Article', 'connection' => 'test');", $result); $this->assertStringNotContainsString('public $fields', $result); - $result = $this->Task->bake('Article', 'comments', array('schema' => 'Article', 'records' => true)); + $result = $this->Task->bake('Article', 'comments', ['schema' => 'Article', 'records' => true]); $this->assertStringContainsString("public \$import = array('model' => 'Article', 'records' => true, 'connection' => 'test');", $result); $this->assertStringNotContainsString('public $fields', $result); $this->assertStringNotContainsString('public $records', $result); @@ -505,8 +505,8 @@ public function testGenerateFixtureFile() { $this->Task->expects($this->at(1))->method('createFile') ->with($filename, $this->stringContains('Task->generateFixtureFile('Article', array()); - $this->Task->generateFixtureFile('Article', array()); + $this->Task->generateFixtureFile('Article', []); + $this->Task->generateFixtureFile('Article', []); } /** @@ -521,11 +521,11 @@ public function testGeneratePluginFixtureFile() { $filename = APP . 'Plugin' . DS . 'TestFixture' . DS . 'Test' . DS . 'Fixture' . DS . 'ArticleFixture.php'; //fake plugin path - CakePlugin::load('TestFixture', array('path' => APP . 'Plugin' . DS . 'TestFixture' . DS)); + CakePlugin::load('TestFixture', ['path' => APP . 'Plugin' . DS . 'TestFixture' . DS]); $this->Task->expects($this->at(0))->method('createFile') ->with($filename, $this->stringContains('class Article')); - $this->Task->generateFixtureFile('Article', array()); + $this->Task->generateFixtureFile('Article', []); CakePlugin::unload(); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php index 2df4980d05..2f9e9cdaf5 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php @@ -39,10 +39,10 @@ class ModelTaskTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.bake_article', 'core.bake_comment', 'core.bake_articles_bake_tag', 'core.bake_tag', 'core.category_thread', 'core.number_tree' - ); + ]; /** * setUp method @@ -51,12 +51,12 @@ class ModelTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ModelTask', - array('in', 'err', 'createFile', '_stop', '_checkUnitTest'), - array($out, $out, $in) + ['in', 'err', 'createFile', '_stop', '_checkUnitTest'], + [$out, $out, $in] ); $this->_setupOtherMocks(); } @@ -67,12 +67,12 @@ public function setUp() : void { * @return void */ protected function _useMockedOut() { - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ModelTask', - array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'), - array($out, $out, $in) + ['in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'], + [$out, $out, $in] ); $this->_setupOtherMocks(); } @@ -83,11 +83,11 @@ protected function _useMockedOut() { * @return void */ protected function _setupOtherMocks() { - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); - $this->Task->Fixture = $this->getMock('FixtureTask', array(), array($out, $out, $in)); - $this->Task->Test = $this->getMock('FixtureTask', array(), array($out, $out, $in)); + $this->Task->Fixture = $this->getMock('FixtureTask', [], [$out, $out, $in]); + $this->Task->Test = $this->getMock('FixtureTask', [], [$out, $out, $in]); $this->Task->Template = new TemplateTask($out, $out, $in); $this->Task->name = 'Model'; @@ -206,11 +206,11 @@ public function testGetTableNameCustom() { * @return void */ public function testGetTableOddTableInteractive() { - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ModelTask', - array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables'), - array($out, $out, $in) + ['in', 'err', '_stop', '_checkUnitTest', 'getAllTables'], + [$out, $out, $in] ); $this->_setupOtherMocks(); @@ -218,7 +218,7 @@ public function testGetTableOddTableInteractive() { $this->Task->path = '/my/path/'; $this->Task->interactive = true; - $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd'))); + $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(['articles', 'bake_odd'])); $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls( 2 // bake_odd @@ -239,20 +239,20 @@ public function testGetTableOddTableInteractive() { * @return void */ public function testGetTableOddTable() { - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ModelTask', - array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables'), - array($out, $out, $in) + ['in', 'err', '_stop', '_checkUnitTest', 'getAllTables'], + [$out, $out, $in] ); $this->_setupOtherMocks(); $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; $this->Task->interactive = false; - $this->Task->args = array('BakeOdd'); + $this->Task->args = ['BakeOdd']; - $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd'))); + $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(['articles', 'bake_odd'])); $this->Task->listAll(); @@ -281,28 +281,28 @@ public function testFieldValidationGuessing() { $this->Task->interactive = false; $this->Task->initValidations(); - $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notBlank' => 'notBlank'); + $result = $this->Task->fieldValidation('text', ['type' => 'string', 'length' => 10, 'null' => false]); + $expected = ['notBlank' => 'notBlank']; $this->assertEquals($expected, $result); - $result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false)); - $expected = array('date' => 'date'); + $result = $this->Task->fieldValidation('text', ['type' => 'date', 'length' => 10, 'null' => false]); + $expected = ['date' => 'date']; $this->assertEquals($expected, $result); - $result = $this->Task->fieldValidation('text', array('type' => 'time', 'length' => 10, 'null' => false)); - $expected = array('time' => 'time'); + $result = $this->Task->fieldValidation('text', ['type' => 'time', 'length' => 10, 'null' => false]); + $expected = ['time' => 'time']; $this->assertEquals($expected, $result); - $result = $this->Task->fieldValidation('email', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('email' => 'email'); + $result = $this->Task->fieldValidation('email', ['type' => 'string', 'length' => 10, 'null' => false]); + $expected = ['email' => 'email']; $this->assertEquals($expected, $result); - $result = $this->Task->fieldValidation('test', array('type' => 'integer', 'length' => 10, 'null' => false)); - $expected = array('numeric' => 'numeric'); + $result = $this->Task->fieldValidation('test', ['type' => 'integer', 'length' => 10, 'null' => false]); + $expected = ['numeric' => 'numeric']; $this->assertEquals($expected, $result); - $result = $this->Task->fieldValidation('test', array('type' => 'boolean', 'length' => 10, 'null' => false)); - $expected = array('boolean' => 'boolean'); + $result = $this->Task->fieldValidation('test', ['type' => 'boolean', 'length' => 10, 'null' => false]); + $expected = ['boolean' => 'boolean']; $this->assertEquals($expected, $result); } @@ -317,8 +317,8 @@ public function testInteractiveFieldValidation() { $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls('26', 'y', '18', 'n')); - $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notBlank' => 'notBlank', 'maxLength' => 'maxLength'); + $result = $this->Task->fieldValidation('text', ['type' => 'string', 'length' => 10, 'null' => false]); + $expected = ['notBlank' => 'notBlank', 'maxLength' => 'maxLength']; $this->assertEquals($expected, $result); } @@ -338,8 +338,8 @@ public function testInteractiveFieldValidationWithBogusResponse() { $this->Task->expects($this->at(10))->method('out') ->with($this->stringContains('make a valid')); - $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notBlank' => 'notBlank'); + $result = $this->Task->fieldValidation('text', ['type' => 'string', 'length' => 10, 'null' => false]); + $expected = ['notBlank' => 'notBlank']; $this->assertEquals($expected, $result); } @@ -354,8 +354,8 @@ public function testInteractiveFieldValidationWithRegexp() { $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls('/^[a-z]{0,9}$/', 'n')); - $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('a_z_0_9' => '/^[a-z]{0,9}$/'); + $result = $this->Task->fieldValidation('text', ['type' => 'string', 'length' => 10, 'null' => false]); + $expected = ['a_z_0_9' => '/^[a-z]{0,9}$/']; $this->assertEquals($expected, $result); } @@ -370,8 +370,8 @@ public function testSkippingChoiceInteractiveFieldValidation() { $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls('26', 'y', 's')); - $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notBlank' => 'notBlank', '_skipFields' => true); + $result = $this->Task->fieldValidation('text', ['type' => 'string', 'length' => 10, 'null' => false]); + $expected = ['notBlank' => 'notBlank', '_skipFields' => true]; $this->assertEquals($expected, $result); } @@ -386,8 +386,8 @@ public function testSkippingAnotherInteractiveFieldValidation() { $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls('26', 's')); - $result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false)); - $expected = array('notBlank' => 'notBlank', '_skipFields' => true); + $result = $this->Task->fieldValidation('text', ['type' => 'string', 'length' => 10, 'null' => false]); + $expected = ['notBlank' => 'notBlank', '_skipFields' => true]; $this->assertEquals($expected, $result); } @@ -406,50 +406,50 @@ public function testInteractiveDoValidationWithSkipping() { $Model->primaryKey = 'id'; $Model->expects($this->any()) ->method('schema') - ->will($this->returnValue(array( - 'id' => array( + ->will($this->returnValue([ + 'id' => [ 'type' => 'integer', 'length' => 11, 'null' => false, 'key' => 'primary', - ), - 'name' => array( + ], + 'name' => [ 'type' => 'string', 'length' => 20, 'null' => false, - ), - 'email' => array( + ], + 'email' => [ 'type' => 'string', 'length' => 255, 'null' => false, - ), - 'some_date' => array( + ], + 'some_date' => [ 'type' => 'date', 'length' => '', 'null' => false, - ), - 'some_time' => array( + ], + 'some_time' => [ 'type' => 'time', 'length' => '', 'null' => false, - ), - 'created' => array( + ], + 'created' => [ 'type' => 'datetime', 'length' => '', 'null' => false, - ) - ) + ] + ] )); $result = $this->Task->doValidation($Model); - $expected = array( - 'name' => array( + $expected = [ + 'name' => [ 'notBlank' => 'notBlank' - ), - 'email' => array( + ], + 'email' => [ 'email' => 'email', - ), - ); + ], + ]; $this->assertEquals($expected, $result); } @@ -463,57 +463,57 @@ public function testNonInteractiveDoValidation() { $Model->primaryKey = 'id'; $Model->expects($this->any()) ->method('schema') - ->will($this->returnValue(array( - 'id' => array( + ->will($this->returnValue([ + 'id' => [ 'type' => 'integer', 'length' => 11, 'null' => false, 'key' => 'primary', - ), - 'name' => array( + ], + 'name' => [ 'type' => 'string', 'length' => 20, 'null' => false, - ), - 'email' => array( + ], + 'email' => [ 'type' => 'string', 'length' => 255, 'null' => false, - ), - 'some_date' => array( + ], + 'some_date' => [ 'type' => 'date', 'length' => '', 'null' => false, - ), - 'some_time' => array( + ], + 'some_time' => [ 'type' => 'time', 'length' => '', 'null' => false, - ), - 'created' => array( + ], + 'created' => [ 'type' => 'datetime', 'length' => '', 'null' => false, - ) - ) + ] + ] )); $this->Task->interactive = false; $result = $this->Task->doValidation($Model); - $expected = array( - 'name' => array( + $expected = [ + 'name' => [ 'notBlank' => 'notBlank' - ), - 'email' => array( + ], + 'email' => [ 'email' => 'email', - ), - 'some_date' => array( + ], + 'some_date' => [ 'date' => 'date' - ), - 'some_time' => array( + ], + 'some_time' => [ 'time' => 'time' - ), - ); + ], + ]; $this->assertEquals($expected, $result); } @@ -523,11 +523,11 @@ public function testNonInteractiveDoValidation() { * @return void */ public function testFindPrimaryKey() { - $fields = array( - 'one' => array(), - 'two' => array(), - 'key' => array('key' => 'primary') - ); + $fields = [ + 'one' => [], + 'two' => [], + 'key' => ['key' => 'primary'] + ]; $anything = new \PHPUnit\Framework\Constraint\IsAnything(); $this->Task->expects($this->once())->method('in') ->with($anything, null, 'key') @@ -544,10 +544,10 @@ public function testFindPrimaryKey() { * @return void */ public function testFindDisplayFieldNone() { - $fields = array( - 'id' => array(), 'tagname' => array(), 'body' => array(), - 'created' => array(), 'modified' => array() - ); + $fields = [ + 'id' => [], 'tagname' => [], 'body' => [], + 'created' => [], 'modified' => [] + ]; $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('n')); $result = $this->Task->findDisplayField($fields); $this->assertFalse($result); @@ -559,10 +559,10 @@ public function testFindDisplayFieldNone() { * @return void */ public function testFindDisplayName() { - $fields = array( - 'id' => array(), 'tagname' => array(), 'body' => array(), - 'created' => array(), 'modified' => array() - ); + $fields = [ + 'id' => [], 'tagname' => [], 'body' => [], + 'created' => [], 'modified' => [] + ]; $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls('y', 2)); @@ -576,35 +576,35 @@ public function testFindDisplayName() { * @return void */ public function testBelongsToGeneration() { - $model = new Model(array('ds' => 'test', 'name' => 'BakeComment')); - $result = $this->Task->findBelongsTo($model, array()); - $expected = array( - 'belongsTo' => array( - array( + $model = new Model(['ds' => 'test', 'name' => 'BakeComment']); + $result = $this->Task->findBelongsTo($model, []); + $expected = [ + 'belongsTo' => [ + [ 'alias' => 'BakeArticle', 'className' => 'BakeArticle', 'foreignKey' => 'bake_article_id', - ), - array( + ], + [ 'alias' => 'BakeUser', 'className' => 'BakeUser', 'foreignKey' => 'bake_user_id', - ), - ) - ); + ], + ] + ]; $this->assertEquals($expected, $result); - $model = new Model(array('ds' => 'test', 'name' => 'CategoryThread')); - $result = $this->Task->findBelongsTo($model, array()); - $expected = array( - 'belongsTo' => array( - array( + $model = new Model(['ds' => 'test', 'name' => 'CategoryThread']); + $result = $this->Task->findBelongsTo($model, []); + $expected = [ + 'belongsTo' => [ + [ 'alias' => 'ParentCategoryThread', 'className' => 'CategoryThread', 'foreignKey' => 'parent_id', - ), - ) - ); + ], + ] + ]; $this->assertEquals($expected, $result); } @@ -614,46 +614,46 @@ public function testBelongsToGeneration() { * @return void */ public function testHasManyHasOneGeneration() { - $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle')); + $model = new Model(['ds' => 'test', 'name' => 'BakeArticle']); $this->Task->connection = 'test'; $this->Task->listAll(); - $result = $this->Task->findHasOneAndMany($model, array()); - $expected = array( - 'hasMany' => array( - array( + $result = $this->Task->findHasOneAndMany($model, []); + $expected = [ + 'hasMany' => [ + [ 'alias' => 'BakeComment', 'className' => 'BakeComment', 'foreignKey' => 'bake_article_id', - ), - ), - 'hasOne' => array( - array( + ], + ], + 'hasOne' => [ + [ 'alias' => 'BakeComment', 'className' => 'BakeComment', 'foreignKey' => 'bake_article_id', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $result); - $model = new Model(array('ds' => 'test', 'name' => 'CategoryThread')); - $result = $this->Task->findHasOneAndMany($model, array()); - $expected = array( - 'hasOne' => array( - array( + $model = new Model(['ds' => 'test', 'name' => 'CategoryThread']); + $result = $this->Task->findHasOneAndMany($model, []); + $expected = [ + 'hasOne' => [ + [ 'alias' => 'ChildCategoryThread', 'className' => 'CategoryThread', 'foreignKey' => 'parent_id', - ), - ), - 'hasMany' => array( - array( + ], + ], + 'hasMany' => [ + [ 'alias' => 'ChildCategoryThread', 'className' => 'CategoryThread', 'foreignKey' => 'parent_id', - ), - ) - ); + ], + ] + ]; $this->assertEquals($expected, $result); } @@ -663,21 +663,21 @@ public function testHasManyHasOneGeneration() { * @return void */ public function testHasAndBelongsToManyGeneration() { - $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle')); + $model = new Model(['ds' => 'test', 'name' => 'BakeArticle']); $this->Task->connection = 'test'; $this->Task->listAll(); - $result = $this->Task->findHasAndBelongsToMany($model, array()); - $expected = array( - 'hasAndBelongsToMany' => array( - array( + $result = $this->Task->findHasAndBelongsToMany($model, []); + $expected = [ + 'hasAndBelongsToMany' => [ + [ 'alias' => 'BakeTag', 'className' => 'BakeTag', 'foreignKey' => 'bake_article_id', 'joinTable' => 'bake_articles_bake_tags', 'associationForeignKey' => 'bake_tag_id', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $result); } @@ -689,33 +689,33 @@ public function testHasAndBelongsToManyGeneration() { public function testDoAssociationsNonInteractive() { $this->Task->connection = 'test'; $this->Task->interactive = false; - $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle')); + $model = new Model(['ds' => 'test', 'name' => 'BakeArticle']); $result = $this->Task->doAssociations($model); - $expected = array( - 'belongsTo' => array( - array( + $expected = [ + 'belongsTo' => [ + [ 'alias' => 'BakeUser', 'className' => 'BakeUser', 'foreignKey' => 'bake_user_id', - ), - ), - 'hasMany' => array( - array( + ], + ], + 'hasMany' => [ + [ 'alias' => 'BakeComment', 'className' => 'BakeComment', 'foreignKey' => 'bake_article_id', - ), - ), - 'hasAndBelongsToMany' => array( - array( + ], + ], + 'hasAndBelongsToMany' => [ + [ 'alias' => 'BakeTag', 'className' => 'BakeTag', 'foreignKey' => 'bake_article_id', 'joinTable' => 'bake_articles_bake_tags', 'associationForeignKey' => 'bake_tag_id', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $result); } @@ -727,10 +727,10 @@ public function testDoAssociationsNonInteractive() { public function testDoActsAs() { $this->Task->connection = 'test'; $this->Task->interactive = false; - $model = new Model(array('ds' => 'test', 'name' => 'NumberTree')); + $model = new Model(['ds' => 'test', 'name' => 'NumberTree']); $result = $this->Task->doActsAs($model); - $this->assertEquals(array('Tree'), $result); + $this->assertEquals(['Tree'], $result); } /** @@ -772,30 +772,30 @@ public function testBakeTest() { * @return void */ public function testConfirmAssociations() { - $associations = array( - 'hasOne' => array( - array( + $associations = [ + 'hasOne' => [ + [ 'alias' => 'ChildCategoryThread', 'className' => 'CategoryThread', 'foreignKey' => 'parent_id', - ), - ), - 'hasMany' => array( - array( + ], + ], + 'hasMany' => [ + [ 'alias' => 'ChildCategoryThread', 'className' => 'CategoryThread', 'foreignKey' => 'parent_id', - ), - ), - 'belongsTo' => array( - array( + ], + ], + 'belongsTo' => [ + [ 'alias' => 'User', 'className' => 'User', 'foreignKey' => 'user_id', - ), - ) - ); - $model = new Model(array('ds' => 'test', 'name' => 'CategoryThread')); + ], + ] + ]; + $model = new Model(['ds' => 'test', 'name' => 'CategoryThread']); $this->Task->expects($this->any())->method('in') ->will($this->onConsecutiveCalls('n', 'y', 'n', 'n', 'n')); @@ -816,7 +816,7 @@ public function testConfirmAssociations() { public function testInOptions() { $this->_useMockedOut(); - $options = array('one', 'two', 'three'); + $options = ['one', 'two', 'three']; $this->Task->expects($this->at(0))->method('out')->with('1. one'); $this->Task->expects($this->at(1))->method('out')->with('2. two'); $this->Task->expects($this->at(2))->method('out')->with('3. three'); @@ -836,20 +836,20 @@ public function testInOptions() { * @return void */ public function testBakeValidation() { - $validate = array( - 'name' => array( + $validate = [ + 'name' => [ 'notBlank' => 'notBlank' - ), - 'email' => array( + ], + 'email' => [ 'email' => 'email', - ), - 'some_date' => array( + ], + 'some_date' => [ 'date' => 'date' - ), - 'some_time' => array( + ], + 'some_time' => [ 'time' => 'time' - ) - ); + ] + ]; $result = $this->Task->bake('BakeArticle', compact('validate')); $this->assertMatchesRegularExpression('/class BakeArticle extends AppModel \{/', $result); $this->assertMatchesRegularExpression('/\$validate \= array\(/', $result); @@ -873,43 +873,43 @@ public function testBakeValidation() { * @return void */ public function testBakeRelations() { - $associations = array( - 'belongsTo' => array( - array( + $associations = [ + 'belongsTo' => [ + [ 'alias' => 'SomethingElse', 'className' => 'SomethingElse', 'foreignKey' => 'something_else_id', - ), - array( + ], + [ 'alias' => 'BakeUser', 'className' => 'BakeUser', 'foreignKey' => 'bake_user_id', - ), - ), - 'hasOne' => array( - array( + ], + ], + 'hasOne' => [ + [ 'alias' => 'OtherModel', 'className' => 'OtherModel', 'foreignKey' => 'other_model_id', - ), - ), - 'hasMany' => array( - array( + ], + ], + 'hasMany' => [ + [ 'alias' => 'BakeComment', 'className' => 'BakeComment', 'foreignKey' => 'parent_id', - ), - ), - 'hasAndBelongsToMany' => array( - array( + ], + ], + 'hasAndBelongsToMany' => [ + [ 'alias' => 'BakeTag', 'className' => 'BakeTag', 'foreignKey' => 'bake_article_id', 'joinTable' => 'bake_articles_bake_tags', 'associationForeignKey' => 'bake_tag_id', - ), - ) - ); + ], + ] + ]; $result = $this->Task->bake('BakeArticle', compact('associations')); $this->assertStringContainsString(' * @property BakeUser $BakeUser', $result); $this->assertStringContainsString(' * @property OtherModel $OtherModel', $result); @@ -934,12 +934,12 @@ public function testBakeWithPlugin() { $this->Task->plugin = 'ControllerTest'; //fake plugin path - CakePlugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS)); + CakePlugin::load('ControllerTest', ['path' => APP . 'Plugin' . DS . 'ControllerTest' . DS]); $path = APP . 'Plugin' . DS . 'ControllerTest' . DS . 'Model' . DS . 'BakeArticle.php'; $this->Task->expects($this->once())->method('createFile') ->with($path, $this->stringContains('BakeArticle extends ControllerTestAppModel')); - $result = $this->Task->bake('BakeArticle', array(), array()); + $result = $this->Task->bake('BakeArticle', [], []); $this->assertStringContainsString("App::uses('ControllerTestAppModel', 'ControllerTest.Model');", $result); $this->assertEquals(count(ClassRegistry::keys()), 0); @@ -952,7 +952,7 @@ public function testBakeWithPlugin() { * @return void */ public function testBakeWithBehaviors() { - $result = $this->Task->bake('NumberTree', array('actsAs' => array('Tree', 'PluginName.Sluggable'))); + $result = $this->Task->bake('NumberTree', ['actsAs' => ['Tree', 'PluginName.Sluggable']]); $expected = <<Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('BakeArticle'); + $this->Task->args = ['BakeArticle']; $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); @@ -994,9 +994,9 @@ public function testExecuteWithNamedModel() { * @return void */ public static function nameVariations() { - return array( - array('BakeArticles'), array('BakeArticle'), array('bake_article'), array('bake_articles') - ); + return [ + ['BakeArticles'], ['BakeArticle'], ['bake_article'], ['bake_articles'] + ]; } /** @@ -1010,7 +1010,7 @@ public function testExecuteWithNamedModelVariations($name) { $this->Task->path = '/my/path/'; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); - $this->Task->args = array($name); + $this->Task->args = [$name]; $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->at(0))->method('createFile') @@ -1026,7 +1026,7 @@ public function testExecuteWithNamedModelVariations($name) { public function testExecuteWithNamedModelHasManyCreated() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('BakeArticle'); + $this->Task->args = ['BakeArticle']; $filename = '/my/path/BakeArticle.php'; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(1)); @@ -1049,7 +1049,7 @@ public function testExecuteIntoAll() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); + $this->Task->args = ['all']; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); $this->Task->Fixture->expects($this->exactly(6))->method('bake'); @@ -1099,44 +1099,44 @@ public function testExecuteIntoAll() { * @return void */ public function testExecuteIntoAllOddTables() { - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ModelTask', - array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'), - array($out, $out, $in) + ['in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'], + [$out, $out, $in] ); $this->_setupOtherMocks(); $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); + $this->Task->args = ['all']; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); - $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('bake_odd'))); - $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test')); + $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(['bake_odd'])); + $object = new Model(['name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test']); $this->Task->expects($this->once())->method('_getModelObject')->with('BakeOdd', 'bake_odd')->will($this->returnValue($object)); $this->Task->expects($this->at(3))->method('bake')->with($object, false)->will($this->returnValue(true)); $this->Task->expects($this->once())->method('bakeFixture')->with('BakeOdd', 'bake_odd'); $this->Task->execute(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ModelTask', - array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'doActsAs', 'createFile'), - array($out, $out, $in) + ['in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'doActsAs', 'createFile'], + [$out, $out, $in] ); $this->_setupOtherMocks(); $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); + $this->Task->args = ['all']; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); - $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('bake_odd'))); - $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test')); + $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(['bake_odd'])); + $object = new Model(['name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test']); $this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object)); - $this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array())); - $this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array())); - $this->Task->expects($this->once())->method('doActsAs')->will($this->returnValue(array())); + $this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue([])); + $this->Task->expects($this->once())->method('doValidation')->will($this->returnValue([])); + $this->Task->expects($this->once())->method('doActsAs')->will($this->returnValue([])); $filename = '/my/path/BakeOdd.php'; $this->Task->expects($this->once())->method('createFile') @@ -1155,44 +1155,44 @@ public function testExecuteIntoAllOddTables() { * @return void */ public function testExecuteIntoBakeOddTables() { - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ModelTask', - array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'), - array($out, $out, $in) + ['in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'bake', 'bakeFixture'], + [$out, $out, $in] ); $this->_setupOtherMocks(); $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('BakeOdd'); + $this->Task->args = ['BakeOdd']; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); - $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd'))); - $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test')); + $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(['articles', 'bake_odd'])); + $object = new Model(['name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test']); $this->Task->expects($this->once())->method('_getModelObject')->with('BakeOdd', 'bake_odd')->will($this->returnValue($object)); $this->Task->expects($this->once())->method('bake')->with($object, false)->will($this->returnValue(true)); $this->Task->expects($this->once())->method('bakeFixture')->with('BakeOdd', 'bake_odd'); $this->Task->execute(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ModelTask', - array('in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'doActsAs', 'createFile'), - array($out, $out, $in) + ['in', 'err', '_stop', '_checkUnitTest', 'getAllTables', '_getModelObject', 'doAssociations', 'doValidation', 'doActsAs', 'createFile'], + [$out, $out, $in] ); $this->_setupOtherMocks(); $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('BakeOdd'); + $this->Task->args = ['BakeOdd']; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); - $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(array('articles', 'bake_odd'))); - $object = new Model(array('name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test')); + $this->Task->expects($this->once())->method('getAllTables')->will($this->returnValue(['articles', 'bake_odd'])); + $object = new Model(['name' => 'BakeOdd', 'table' => 'bake_odd', 'ds' => 'test']); $this->Task->expects($this->once())->method('_getModelObject')->will($this->returnValue($object)); - $this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue(array())); - $this->Task->expects($this->once())->method('doValidation')->will($this->returnValue(array())); - $this->Task->expects($this->once())->method('doActsAs')->will($this->returnValue(array())); + $this->Task->expects($this->once())->method('doAssociations')->will($this->returnValue([])); + $this->Task->expects($this->once())->method('doValidation')->will($this->returnValue([])); + $this->Task->expects($this->once())->method('doActsAs')->will($this->returnValue([])); $filename = '/my/path/BakeOdd.php'; $this->Task->expects($this->once())->method('createFile') @@ -1218,9 +1218,9 @@ public function testSkipTablesAndAll() { $this->Task->connection = 'test'; $this->Task->path = '/my/path/'; - $this->Task->args = array('all'); + $this->Task->args = ['all']; $this->Task->expects($this->once())->method('_checkUnitTest')->will($this->returnValue(true)); - $this->Task->skipTables = array('bake_tags', 'number_trees'); + $this->Task->skipTables = ['bake_tags', 'number_trees']; $this->Task->Fixture->expects($this->exactly(4))->method('bake'); $this->Task->Test->expects($this->exactly(4))->method('bake'); diff --git a/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php index c5e879d180..5fc5db79ec 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/PluginTaskTest.php @@ -41,12 +41,12 @@ class PluginTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $this->in = $this->getMock('ConsoleInput', array(), array(), '', false); + $this->out = $this->getMock('ConsoleOutput', [], [], '', false); + $this->in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('PluginTask', - array('in', 'err', 'createFile', '_stop', 'clear'), - array($this->out, $this->out, $this->in) + ['in', 'err', 'createFile', '_stop', 'clear'], + [$this->out, $this->out, $this->in] ); $this->Task->path = TMP . 'tests' . DS; $this->Task->bootstrap = TMP . 'tests' . DS . 'bootstrap.php'; @@ -59,7 +59,7 @@ public function setUp() : void { } } $this->_testPath = array_push($paths, TMP . 'tests' . DS) - 1; - App::build(array('plugins' => $paths)); + App::build(['plugins' => $paths]); } /** @@ -104,7 +104,7 @@ public function testBakeFoldersAndFiles() { $path = $this->Task->path . 'BakeTestPlugin'; $this->assertTrue(is_dir($path), 'No plugin dir %s'); - $directories = array( + $directories = [ 'Config' . DS . 'Schema', 'Console' . DS . 'Command' . DS . 'Task', 'Console' . DS . 'Templates', @@ -125,7 +125,7 @@ public function testBakeFoldersAndFiles() { 'webroot' . DS . 'css', 'webroot' . DS . 'js', 'webroot' . DS . 'img', - ); + ]; foreach ($directories as $dir) { $this->assertTrue(is_dir($path . DS . $dir), 'Missing directory for ' . $dir); } @@ -154,7 +154,7 @@ public function testExecuteWithNoArgs() { $this->Task->expects($this->at(4))->method('createFile') ->with($file, $this->anything()); - $this->Task->args = array(); + $this->Task->args = []; $this->Task->execute(); $Folder = new Folder($path); @@ -182,7 +182,7 @@ public function testExecuteWithOneArg() { $this->Task->expects($this->at(3))->method('createFile') ->with($file, new \PHPUnit\Framework\Constraint\IsAnything()); - $this->Task->args = array('BakeTestPlugin'); + $this->Task->args = ['BakeTestPlugin']; $this->Task->execute(); @@ -203,8 +203,8 @@ public function testFindPathNonExistant() { $paths[] = '/fake/path2'; $this->Task = $this->getMock('PluginTask', - array('in', 'out', 'err', 'createFile', '_stop'), - array($this->out, $this->out, $this->in) + ['in', 'out', 'err', 'createFile', '_stop'], + [$this->out, $this->out, $this->in] ); $this->Task->path = TMP . 'tests' . DS; diff --git a/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php index 72c5563c1b..525fa48bc0 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ProjectTaskTest.php @@ -40,12 +40,12 @@ class ProjectTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ProjectTask', - array('in', 'err', 'createFile', '_stop'), - array($out, $out, $in) + ['in', 'err', 'createFile', '_stop'], + [$out, $out, $in] ); $this->Task->path = TMP . 'tests' . DS; } @@ -84,7 +84,7 @@ public function testBake() { $path = $this->Task->path . 'bake_test_app'; $this->assertTrue(is_dir($path), 'No project dir %s'); - $dirs = array( + $dirs = [ 'Config', 'Config' . DS . 'Schema', 'Console', @@ -122,7 +122,7 @@ public function testBake() { 'webroot' . DS . 'img', 'webroot' . DS . 'js', - ); + ]; foreach ($dirs as $dir) { $this->assertTrue(is_dir($path . DS . $dir), 'Missing ' . $dir); } @@ -185,7 +185,7 @@ public function testBakeEmptyFlag() { $this->_setupTestProject(); $path = $this->Task->path . 'bake_test_app'; - $empty = array( + $empty = [ 'Console' . DS . 'Command' . DS . 'Task' => 'empty', 'Controller' . DS . 'Component' => 'empty', 'Lib' => 'empty', @@ -206,7 +206,7 @@ public function testBakeEmptyFlag() { 'tmp' . DS . 'tests' => 'empty', 'webroot' . DS . 'js' => 'empty', 'webroot' . DS . 'files' => 'empty' - ); + ]; foreach ($empty as $dir => $file) { $this->assertTrue(is_file($path . DS . $dir . DS . $file), sprintf('Missing %s file in %s', $file, $dir)); @@ -290,7 +290,7 @@ public function testIndexPhpGeneration() { * @return void */ public function testGetPrefix() { - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); $result = $this->Task->getPrefix(); $this->assertEquals('admin_', $result); @@ -322,7 +322,7 @@ public function testCakeAdmin() { $result = $this->Task->cakeAdmin('my_prefix'); $this->assertTrue($result); - $this->assertEquals(Configure::read('Routing.prefixes'), array('my_prefix')); + $this->assertEquals(Configure::read('Routing.prefixes'), ['my_prefix']); $File->delete(); } @@ -332,7 +332,7 @@ public function testCakeAdmin() { * @return void */ public function testGetPrefixWithMultiplePrefixes() { - Configure::write('Routing.prefixes', array('admin', 'ninja', 'shinobi')); + Configure::write('Routing.prefixes', ['admin', 'ninja', 'shinobi']); $this->_setupTestProject(); $this->Task->configPath = $this->Task->path . 'bake_test_app' . DS . 'Config' . DS; $this->Task->expects($this->once())->method('in')->will($this->returnValue(2)); diff --git a/lib/Cake/Test/Case/Console/Command/Task/TemplateTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/TemplateTaskTest.php index e90968f060..ef1a3c7b13 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/TemplateTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/TemplateTaskTest.php @@ -38,12 +38,12 @@ class TemplateTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('TemplateTask', - array('in', 'err', 'createFile', '_stop', 'clear'), - array($out, $out, $in) + ['in', 'err', 'createFile', '_stop', 'clear'], + [$out, $out, $in] ); } @@ -67,16 +67,16 @@ public function testSet() { $this->assertTrue(isset($this->Task->templateVars['one'])); $this->assertEquals('two', $this->Task->templateVars['one']); - $this->Task->set(array('one' => 'three', 'four' => 'five')); + $this->Task->set(['one' => 'three', 'four' => 'five']); $this->assertTrue(isset($this->Task->templateVars['one'])); $this->assertEquals('three', $this->Task->templateVars['one']); $this->assertTrue(isset($this->Task->templateVars['four'])); $this->assertEquals('five', $this->Task->templateVars['four']); - $this->Task->templateVars = array(); - $this->Task->set(array(3 => 'three', 4 => 'four')); - $this->Task->set(array(1 => 'one', 2 => 'two')); - $expected = array(3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two'); + $this->Task->templateVars = []; + $this->Task->set([3 => 'three', 4 => 'four']); + $this->Task->set([1 => 'one', 2 => 'two']); + $expected = [3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two']; $this->assertEquals($expected, $this->Task->templateVars); } @@ -99,19 +99,19 @@ public function testFindingInstalledThemesForBake() { */ public function testGetThemePath() { $defaultTheme = CAKE . 'Console' . DS . 'Templates' . DS . 'default' . DS; - $this->Task->templatePaths = array('default' => $defaultTheme); + $this->Task->templatePaths = ['default' => $defaultTheme]; $this->Task->expects($this->exactly(1))->method('in')->will($this->returnValue('1')); $result = $this->Task->getThemePath(); $this->assertEquals($defaultTheme, $result); - $this->Task->templatePaths = array('other' => '/some/path', 'default' => $defaultTheme); + $this->Task->templatePaths = ['other' => '/some/path', 'default' => $defaultTheme]; $this->Task->params['theme'] = 'other'; $result = $this->Task->getThemePath(); $this->assertEquals('/some/path', $result); - $this->Task->params = array(); + $this->Task->params = []; $result = $this->Task->getThemePath(); $this->assertEquals('/some/path', $result); $this->assertEquals('other', $this->Task->params['theme']); @@ -123,15 +123,15 @@ public function testGetThemePath() { * @return void */ public function testGenerate() { - App::build(array( - 'Console' => array( + App::build([ + 'Console' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS - ) - )); + ] + ]); $this->Task->initialize(); $this->Task->expects($this->any())->method('in')->will($this->returnValue(1)); - $result = $this->Task->generate('classes', 'test_object', array('test' => 'foo')); + $result = $this->Task->generate('classes', 'test_object', ['test' => 'foo']); $expected = "I got rendered\nfoo"; $this->assertTextEquals($expected, $result); } @@ -143,21 +143,21 @@ public function testGenerate() { * @return void */ public function testGenerateWithTemplateFallbacks() { - App::build(array( - 'Console' => array( + App::build([ + 'Console' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS, CAKE_CORE_INCLUDE_PATH . DS . 'console' . DS - ) - )); + ] + ]); $this->Task->initialize(); $this->Task->params['theme'] = 'test'; - $this->Task->set(array( + $this->Task->set([ 'model' => 'Article', 'table' => 'articles', 'import' => false, 'records' => false, 'schema' => '' - )); + ]); $result = $this->Task->generate('classes', 'fixture'); $this->assertMatchesRegularExpression('/ArticleFixture extends CakeTestFixture/', $result); } diff --git a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php index e53693da1c..da68554a0e 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php @@ -46,26 +46,26 @@ class TestTaskArticle extends Model { * * @var array */ - public $hasMany = array( - 'Comment' => array( + public $hasMany = [ + 'Comment' => [ 'className' => 'TestTask.TestTaskComment', 'foreignKey' => 'article_id', - ) - ); + ] + ]; /** * Has and Belongs To Many Associations * * @var array */ - public $hasAndBelongsToMany = array( - 'Tag' => array( + public $hasAndBelongsToMany = [ + 'Tag' => [ 'className' => 'TestTaskTag', 'joinTable' => 'articles_tags', 'foreignKey' => 'article_id', 'associationForeignKey' => 'tag_id' - ) - ); + ] + ]; /** * Example public method @@ -112,14 +112,14 @@ class TestTaskTag extends Model { * * @var array */ - public $hasAndBelongsToMany = array( - 'Article' => array( + public $hasAndBelongsToMany = [ + 'Article' => [ 'className' => 'TestTaskArticle', 'joinTable' => 'articles_tags', 'foreignKey' => 'tag_id', 'associationForeignKey' => 'article_id' - ) - ); + ] + ]; } /** @@ -149,12 +149,12 @@ class TestTaskComment extends TestTaskAppModel { * * @var array */ - public $belongsTo = array( - 'Article' => array( + public $belongsTo = [ + 'Article' => [ 'className' => 'TestTaskArticle', 'foreignKey' => 'article_id', - ) - ); + ] + ]; } /** @@ -169,7 +169,7 @@ class TestTaskCommentsController extends Controller { * * @var array */ - public $uses = array('TestTaskComment', 'TestTaskTag'); + public $uses = ['TestTaskComment', 'TestTaskTag']; } /** @@ -184,7 +184,7 @@ class TestTaskTest extends CakeTestCase { * * @var string */ - public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag'); + public $fixtures = ['core.article', 'core.comment', 'core.articles_tag', 'core.tag']; /** * setUp method @@ -193,12 +193,12 @@ class TestTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('TestTask', - array('in', 'err', 'createFile', '_stop', 'isLoadableClass'), - array($out, $out, $in) + ['in', 'err', 'createFile', '_stop', 'isLoadableClass'], + [$out, $out, $in] ); $this->Task->name = 'Test'; $this->Task->Template = new TemplateTask($out, $out, $in); @@ -249,7 +249,7 @@ public function testFilePathGenerationModelRepeated() { */ public function testMethodIntrospection() { $result = $this->Task->getTestableMethods('TestTaskArticle'); - $expected = array('dosomething', 'dosomethingelse'); + $expected = ['dosomething', 'dosomethingelse']; $this->assertEquals($expected, array_map('strtolower', $result)); } @@ -261,8 +261,8 @@ public function testMethodIntrospection() { public function testFixtureArrayGenerationFromModel() { $subject = ClassRegistry::init('TestTaskArticle'); $result = $this->Task->generateFixtureList($subject); - $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags', - 'app.test_task_article', 'app.test_task_tag'); + $expected = ['plugin.test_task.test_task_comment', 'app.articles_tags', + 'app.test_task_article', 'app.test_task_tag']; $this->assertEquals(sort($expected), sort($result)); } @@ -275,8 +275,8 @@ public function testFixtureArrayGenerationFromModel() { public function testFixtureArrayGenerationFromController() { $subject = new TestTaskCommentsController(); $result = $this->Task->generateFixtureList($subject); - $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags', - 'app.test_task_article', 'app.test_task_tag'); + $expected = ['plugin.test_task.test_task_comment', 'app.articles_tags', + 'app.test_task_article', 'app.test_task_tag']; $this->assertEquals(sort($expected), sort($result)); } @@ -305,14 +305,14 @@ public function testGetObjectType() { public function testRegistryClearWhenBuildingTestObjects() { ClassRegistry::flush(); $model = ClassRegistry::init('TestTaskComment'); - $model->bindModel(array( - 'belongsTo' => array( - 'Random' => array( + $model->bindModel([ + 'belongsTo' => [ + 'Random' => [ 'className' => 'TestTaskArticle', 'foreignKey' => 'article_id', - ) - ) - )); + ] + ] + ]); $keys = ClassRegistry::keys(); $this->assertTrue(in_array('test_task_comment', $keys)); $this->Task->buildTestSubject('Model', 'TestTaskComment'); @@ -352,7 +352,7 @@ public function testGetUserFixtures() { ->will($this->returnValue('app.pizza, app.topping, app.side_dish')); $result = $this->Task->getUserFixtures(); - $expected = array('app.pizza', 'app.topping', 'app.side_dish'); + $expected = ['app.pizza', 'app.topping', 'app.side_dish']; $this->assertEquals($expected, $result); } @@ -520,15 +520,15 @@ public function testBakeHelperTest() { */ public function testGenerateConstructor() { $result = $this->Task->generateConstructor('controller', 'PostsController', null); - $expected = array('', '', ''); + $expected = ['', '', '']; $this->assertEquals($expected, $result); $result = $this->Task->generateConstructor('model', 'Post', null); - $expected = array('', "ClassRegistry::init('Post');\n", ''); + $expected = ['', "ClassRegistry::init('Post');\n", '']; $this->assertEquals($expected, $result); $result = $this->Task->generateConstructor('helper', 'FormHelper', null); - $expected = array("\$View = new View();\n", "new FormHelper(\$View);\n", ''); + $expected = ["\$View = new View();\n", "new FormHelper(\$View);\n", '']; $this->assertEquals($expected, $result); } @@ -539,31 +539,31 @@ public function testGenerateConstructor() { */ public function testGenerateUses() { $result = $this->Task->generateUses('model', 'Model', 'Post'); - $expected = array( - array('Post', 'Model') - ); + $expected = [ + ['Post', 'Model'] + ]; $this->assertEquals($expected, $result); $result = $this->Task->generateUses('controller', 'Controller', 'PostsController'); - $expected = array( - array('PostsController', 'Controller') - ); + $expected = [ + ['PostsController', 'Controller'] + ]; $this->assertEquals($expected, $result); $result = $this->Task->generateUses('helper', 'View/Helper', 'FormHelper'); - $expected = array( - array('View', 'View'), - array('Helper', 'View'), - array('FormHelper', 'View/Helper'), - ); + $expected = [ + ['View', 'View'], + ['Helper', 'View'], + ['FormHelper', 'View/Helper'], + ]; $this->assertEquals($expected, $result); $result = $this->Task->generateUses('component', 'Controller/Component', 'AuthComponent'); - $expected = array( - array('ComponentCollection', 'Controller'), - array('Component', 'Controller'), - array('AuthComponent', 'Controller/Component') - ); + $expected = [ + ['ComponentCollection', 'Controller'], + ['Component', 'Controller'], + ['AuthComponent', 'Controller/Component'] + ]; $this->assertEquals($expected, $result); } @@ -586,7 +586,7 @@ public function testBakeWithPlugin() { $this->Task->plugin = 'TestTest'; //fake plugin path - CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS)); + CakePlugin::load('TestTest', ['path' => APP . 'Plugin' . DS . 'TestTest' . DS]); $path = APP . 'Plugin' . DS . 'TestTest' . DS . 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php'; $this->Task->expects($this->once())->method('createFile') ->with($path, $this->anything()); @@ -602,9 +602,9 @@ public function testBakeWithPlugin() { */ public function testInteractiveWithPlugin() { $testApp = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS; - App::build(array( - 'Plugin' => array($testApp) - ), App::RESET); + App::build([ + 'Plugin' => [$testApp] + ], App::RESET); CakePlugin::load('TestPlugin'); $this->Task->plugin = 'TestPlugin'; @@ -628,18 +628,18 @@ public function testInteractiveWithPlugin() { } public static function caseFileNameProvider() { - return array( - array('Model', 'Post', 'Case' . DS . 'Model' . DS . 'PostTest.php'), - array('Helper', 'Form', 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php'), - array('Controller', 'Posts', 'Case' . DS . 'Controller' . DS . 'PostsControllerTest.php'), - array('Behavior', 'Containable', 'Case' . DS . 'Model' . DS . 'Behavior' . DS . 'ContainableBehaviorTest.php'), - array('Component', 'Auth', 'Case' . DS . 'Controller' . DS . 'Component' . DS . 'AuthComponentTest.php'), - array('model', 'Post', 'Case' . DS . 'Model' . DS . 'PostTest.php'), - array('helper', 'Form', 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php'), - array('controller', 'Posts', 'Case' . DS . 'Controller' . DS . 'PostsControllerTest.php'), - array('behavior', 'Containable', 'Case' . DS . 'Model' . DS . 'Behavior' . DS . 'ContainableBehaviorTest.php'), - array('component', 'Auth', 'Case' . DS . 'Controller' . DS . 'Component' . DS . 'AuthComponentTest.php'), - ); + return [ + ['Model', 'Post', 'Case' . DS . 'Model' . DS . 'PostTest.php'], + ['Helper', 'Form', 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php'], + ['Controller', 'Posts', 'Case' . DS . 'Controller' . DS . 'PostsControllerTest.php'], + ['Behavior', 'Containable', 'Case' . DS . 'Model' . DS . 'Behavior' . DS . 'ContainableBehaviorTest.php'], + ['Component', 'Auth', 'Case' . DS . 'Controller' . DS . 'Component' . DS . 'AuthComponentTest.php'], + ['model', 'Post', 'Case' . DS . 'Model' . DS . 'PostTest.php'], + ['helper', 'Form', 'Case' . DS . 'View' . DS . 'Helper' . DS . 'FormHelperTest.php'], + ['controller', 'Posts', 'Case' . DS . 'Controller' . DS . 'PostsControllerTest.php'], + ['behavior', 'Containable', 'Case' . DS . 'Model' . DS . 'Behavior' . DS . 'ContainableBehaviorTest.php'], + ['component', 'Auth', 'Case' . DS . 'Controller' . DS . 'Component' . DS . 'AuthComponentTest.php'], + ]; } /** @@ -664,7 +664,7 @@ public function testTestCaseFileName($type, $class, $expected) { public function testTestCaseFileNamePlugin() { $this->Task->path = DS . 'my' . DS . 'path' . DS . 'tests' . DS; - CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS)); + CakePlugin::load('TestTest', ['path' => APP . 'Plugin' . DS . 'TestTest' . DS]); $this->Task->plugin = 'TestTest'; $result = $this->Task->testCaseFileName('Model', 'Post'); $expected = APP . 'Plugin' . DS . 'TestTest' . DS . 'Test' . DS . 'Case' . DS . 'Model' . DS . 'PostTest.php'; @@ -694,7 +694,7 @@ public function testExecuteWithOneArg() { * @return void */ public function testExecuteWithTwoArgs() { - $this->Task->args = array('Model', 'TestTaskTag'); + $this->Task->args = ['Model', 'TestTaskTag']; $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('TestTaskTag')); $this->Task->expects($this->once())->method('createFile') ->with( @@ -711,7 +711,7 @@ public function testExecuteWithTwoArgs() { * @return void */ public function testExecuteWithTwoArgsLowerCase() { - $this->Task->args = array('model', 'TestTaskTag'); + $this->Task->args = ['model', 'TestTaskTag']; $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('TestTaskTag')); $this->Task->expects($this->once())->method('createFile') ->with( @@ -728,19 +728,19 @@ public function testExecuteWithTwoArgsLowerCase() { * @return array */ public static function mapTypeProvider() { - return array( - array('controller', null, 'Controller'), - array('Controller', null, 'Controller'), - array('component', null, 'Controller/Component'), - array('Component', null, 'Controller/Component'), - array('model', null, 'Model'), - array('Model', null, 'Model'), - array('behavior', null, 'Model/Behavior'), - array('Behavior', null, 'Model/Behavior'), - array('helper', null, 'View/Helper'), - array('Helper', null, 'View/Helper'), - array('Helper', 'DebugKit', 'DebugKit.View/Helper'), - ); + return [ + ['controller', null, 'Controller'], + ['Controller', null, 'Controller'], + ['component', null, 'Controller/Component'], + ['Component', null, 'Controller/Component'], + ['model', null, 'Model'], + ['Model', null, 'Model'], + ['behavior', null, 'Model/Behavior'], + ['Behavior', null, 'Model/Behavior'], + ['helper', null, 'View/Helper'], + ['Helper', null, 'View/Helper'], + ['Helper', 'DebugKit', 'DebugKit.View/Helper'], + ]; } /** diff --git a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php index 639e849212..a18c5e3a22 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/ViewTaskTest.php @@ -50,12 +50,12 @@ class ViewTaskComment extends Model { * * @var array */ - public $belongsTo = array( - 'Article' => array( + public $belongsTo = [ + 'Article' => [ 'className' => 'TestTest.ViewTaskArticle', 'foreignKey' => 'article_id' - ) - ); + ] + ]; } /** @@ -175,7 +175,7 @@ class ViewTaskTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag'); + public $fixtures = ['core.article', 'core.comment', 'core.articles_tag', 'core.tag']; /** * setUp method @@ -186,21 +186,21 @@ class ViewTaskTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Task = $this->getMock('ViewTask', - array('in', 'err', 'createFile', '_stop'), - array($out, $out, $in) + ['in', 'err', 'createFile', '_stop'], + [$out, $out, $in] ); $this->Task->Template = new TemplateTask($out, $out, $in); - $this->Task->Controller = $this->getMock('ControllerTask', array(), array($out, $out, $in)); - $this->Task->Project = $this->getMock('ProjectTask', array(), array($out, $out, $in)); - $this->Task->DbConfig = $this->getMock('DbConfigTask', array(), array($out, $out, $in)); + $this->Task->Controller = $this->getMock('ControllerTask', [], [$out, $out, $in]); + $this->Task->Project = $this->getMock('ProjectTask', [], [$out, $out, $in]); + $this->Task->DbConfig = $this->getMock('DbConfigTask', [], [$out, $out, $in]); $this->Task->path = TMP; $this->Task->Template->params['theme'] = 'default'; - $this->Task->Template->templatePaths = array('default' => CAKE . 'Console' . DS . 'Templates' . DS . 'default' . DS); + $this->Task->Template->templatePaths = ['default' => CAKE . 'Console' . DS . 'Templates' . DS . 'default' . DS]; } /** @@ -219,18 +219,18 @@ public function tearDown() : void { * @return void */ public function testGetContent() { - $vars = array( + $vars = [ 'modelClass' => 'TestViewModel', - 'schema' => array(), + 'schema' => [], 'primaryKey' => 'id', 'displayField' => 'name', 'singularVar' => 'testViewModel', 'pluralVar' => 'testViewModels', 'singularHumanName' => 'Test View Model', 'pluralHumanName' => 'Test View Models', - 'fields' => array('id', 'name', 'body'), - 'associations' => array() - ); + 'fields' => ['id', 'name', 'body'], + 'associations' => [] + ]; $result = $this->Task->getContent('view', $vars); $this->assertMatchesRegularExpression('/Delete Test View Model/', $result); @@ -250,19 +250,19 @@ public function testGetContent() { */ public function testGetContentWithAdminAction() { $_back = Configure::read('Routing'); - Configure::write('Routing.prefixes', array('admin')); - $vars = array( + Configure::write('Routing.prefixes', ['admin']); + $vars = [ 'modelClass' => 'TestViewModel', - 'schema' => array(), + 'schema' => [], 'primaryKey' => 'id', 'displayField' => 'name', 'singularVar' => 'testViewModel', 'pluralVar' => 'testViewModels', 'singularHumanName' => 'Test View Model', 'pluralHumanName' => 'Test View Models', - 'fields' => array('id', 'name', 'body'), - 'associations' => array() - ); + 'fields' => ['id', 'name', 'body'], + 'associations' => [] + ]; $result = $this->Task->getContent('admin_view', $vars); $this->assertMatchesRegularExpression('/Delete Test View Model/', $result); @@ -355,7 +355,7 @@ public function testBakeWithPlugin() { $this->Task->name = 'View'; //fake plugin path - CakePlugin::load('TestTest', array('path' => APP . 'Plugin' . DS . 'TestTest' . DS)); + CakePlugin::load('TestTest', ['path' => APP . 'Plugin' . DS . 'TestTest' . DS]); $path = APP . 'Plugin' . DS . 'TestTest' . DS . 'View' . DS . 'ViewTaskComments' . DS . 'view.ctp'; $result = $this->Task->getContent('index'); @@ -393,7 +393,7 @@ public function testBakeActions() { $this->stringContains('ViewTaskComment') ); - $this->Task->bakeActions(array('view', 'edit', 'index'), array()); + $this->Task->bakeActions(['view', 'edit', 'index'], []); } /** @@ -425,7 +425,7 @@ public function testExecuteIntoAll() { $this->Task->args[0] = 'all'; $this->Task->Controller->expects($this->once())->method('listAll') - ->will($this->returnValue(array('view_task_comments'))); + ->will($this->returnValue(['view_task_comments'])); $this->Task->expects($this->at(0))->method('createFile') ->with( @@ -448,10 +448,10 @@ public function testExecuteIntoAll() { * @return void */ public function testExecuteIntoAllWithActionName() { - $this->Task->args = array('all', 'index'); + $this->Task->args = ['all', 'index']; $this->Task->Controller->expects($this->once())->method('listAll') - ->will($this->returnValue(array('view_task_comments'))); + ->will($this->returnValue(['view_task_comments'])); $this->Task->expects($this->once())->method('createFile') ->with( @@ -509,7 +509,7 @@ public function testExecuteWithController() { * @return void */ public static function nameVariations() { - return array(array('ViewTaskComments'), array('ViewTaskComment'), array('view_task_comment')); + return [['ViewTaskComments'], ['ViewTaskComment'], ['view_task_comment']]; } /** @@ -519,7 +519,7 @@ public static function nameVariations() { * @return void */ public function testExecuteWithControllerVariations($name) { - $this->Task->args = array($name); + $this->Task->args = [$name]; $this->Task->expects($this->at(0))->method('createFile') ->with( @@ -542,7 +542,7 @@ public function testExecuteWithControllerVariations($name) { */ public function testExecuteWithControllerAndAdminFlag() { $_back = Configure::read('Routing'); - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); $this->Task->args[0] = 'ViewTaskArticles'; $this->Task->params['admin'] = 1; @@ -550,7 +550,7 @@ public function testExecuteWithControllerAndAdminFlag() { $this->Task->expects($this->exactly(4))->method('createFile'); - $views = array('admin_index.ctp', 'admin_add.ctp', 'admin_view.ctp', 'admin_edit.ctp'); + $views = ['admin_index.ctp', 'admin_add.ctp', 'admin_view.ctp', 'admin_edit.ctp']; foreach ($views as $i => $view) { $this->Task->expects($this->at($i))->method('createFile') ->with( @@ -569,8 +569,8 @@ public function testExecuteWithControllerAndAdminFlag() { */ public function testExecuteInteractive() { $this->Task->connection = 'test'; - $this->Task->args = array(); - $this->Task->params = array(); + $this->Task->args = []; + $this->Task->params = []; $this->Task->Controller->expects($this->once())->method('getName') ->will($this->returnValue('ViewTaskComments')); @@ -613,8 +613,8 @@ public function testExecuteInteractive() { */ public function testExecuteWithAlternateTemplates() { $this->Task->connection = 'test'; - $this->Task->args = array('ViewTaskComments', 'index', 'list'); - $this->Task->params = array(); + $this->Task->args = ['ViewTaskComments', 'index', 'list']; + $this->Task->params = []; $this->Task->expects($this->once())->method('createFile') ->with( @@ -630,9 +630,9 @@ public function testExecuteWithAlternateTemplates() { * @return void */ public function testExecuteInteractiveWithAdmin() { - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); $this->Task->connection = 'test'; - $this->Task->args = array(); + $this->Task->args = []; $this->Task->Controller->expects($this->once())->method('getName') ->will($this->returnValue('ViewTaskComments')); @@ -683,14 +683,14 @@ public function testGetTemplate() { $result = $this->Task->getTemplate('add'); $this->assertEquals('form', $result); - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); $result = $this->Task->getTemplate('admin_add'); $this->assertEquals('form', $result); - $this->Task->Template->templatePaths = array( + $this->Task->Template->templatePaths = [ 'test' => CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Templates' . DS . 'test' . DS - ); + ]; $this->Task->Template->params['theme'] = 'test'; $result = $this->Task->getTemplate('admin_edit'); diff --git a/lib/Cake/Test/Case/Console/Command/TestShellTest.php b/lib/Cake/Test/Case/Console/Command/TestShellTest.php index 46a4d64f6b..1df08c84cd 100644 --- a/lib/Cake/Test/Case/Console/Command/TestShellTest.php +++ b/lib/Cake/Test/Case/Console/Command/TestShellTest.php @@ -55,15 +55,15 @@ public function setUp() : void { // Therefore, TestShell and CakeTestLoader are unnecessary. $this->skipIf(version_compare(\PHPUnit\Runner\Version::id(), '9.0.0', '>='), 'This test can not be run with PHPUnit 9+'); parent::setUp(); - $out = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $out = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Shell = $this->getMock( 'TestTestShell', - array('in', 'out', 'hr', 'help', 'error', 'err', '_stop', 'initialize', '_run', 'clear'), - array($out, $out, $in) + ['in', 'out', 'hr', 'help', 'error', 'err', '_stop', 'initialize', '_run', 'clear'], + [$out, $out, $in] ); - $this->Shell->OptionParser = $this->getMock('ConsoleOptionParser', array(), array(null, false)); + $this->Shell->OptionParser = $this->getMock('ConsoleOptionParser', [], [null, false]); } /** @@ -300,7 +300,7 @@ public function testMapNotTestToNothing() { */ public function testAvailableWithEmptyList() { $this->Shell->startup(); - $this->Shell->args = array('unexistant-category'); + $this->Shell->args = ['unexistant-category']; $this->Shell->expects($this->at(0))->method('out')->with(__d('cake_console', "No test cases available \n\n")); $this->Shell->OptionParser->expects($this->once())->method('help'); $this->Shell->available(); @@ -313,7 +313,7 @@ public function testAvailableWithEmptyList() { */ public function testAvailableCoreCategory() { $this->Shell->startup(); - $this->Shell->args = array('core'); + $this->Shell->args = ['core']; $this->Shell->expects($this->at(0))->method('out')->with('Core Test Cases:'); $this->Shell->expects($this->at(1))->method('out') ->with($this->stringContains('[1]')); @@ -326,7 +326,7 @@ public function testAvailableCoreCategory() { $this->Shell->expects($this->once())->method('_run'); $this->Shell->available(); - $this->assertEquals(array('core', 'AllBehaviors'), $this->Shell->args); + $this->assertEquals(['core', 'AllBehaviors'], $this->Shell->args); } /** @@ -336,13 +336,13 @@ public function testAvailableCoreCategory() { */ public function testRunnerOptions() { $this->Shell->startup(); - $this->Shell->args = array('core', 'Basics'); - $this->Shell->params = array('filter' => 'myFilter', 'colors' => true, 'verbose' => true); + $this->Shell->args = ['core', 'Basics']; + $this->Shell->params = ['filter' => 'myFilter', 'colors' => true, 'verbose' => true]; $this->Shell->expects($this->once())->method('_run') ->with( - array('app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'), - array('--filter', 'myFilter', '--colors', '--verbose') + ['app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'], + ['--filter', 'myFilter', '--colors', '--verbose'] ); $this->Shell->main(); } @@ -354,13 +354,13 @@ public function testRunnerOptions() { */ public function testRunnerOptionsQuiet() { $this->Shell->startup(); - $this->Shell->args = array('core', 'Basics'); - $this->Shell->params = array('quiet' => true); + $this->Shell->args = ['core', 'Basics']; + $this->Shell->params = ['quiet' => true]; $this->Shell->expects($this->once())->method('_run') ->with( - array('app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'), - array('--colors') + ['app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'], + ['--colors'] ); $this->Shell->main(); } @@ -372,13 +372,13 @@ public function testRunnerOptionsQuiet() { */ public function testRunnerOptionsDirective() { $this->Shell->startup(); - $this->Shell->args = array('core', 'Basics'); - $this->Shell->params = array('directive' => 'memory_limit=128M'); + $this->Shell->args = ['core', 'Basics']; + $this->Shell->params = ['directive' => 'memory_limit=128M']; $this->Shell->expects($this->once())->method('_run') ->with( - array('app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'), - array('-d', 'memory_limit=128M', '--colors') + ['app' => false, 'plugin' => null, 'core' => true, 'output' => 'text', 'case' => 'Basics'], + ['-d', 'memory_limit=128M', '--colors'] ); $this->Shell->main(); } diff --git a/lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php b/lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php index dae3907e3f..fc7abfbfb5 100644 --- a/lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleErrorHandlerTest.php @@ -32,8 +32,8 @@ class ConsoleErrorHandlerTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->Error = $this->getMock('ConsoleErrorHandler', array('_stop')); - ConsoleErrorHandler::$stderr = $this->getMock('ConsoleOutput', array(), array(), '', false); + $this->Error = $this->getMock('ConsoleErrorHandler', ['_stop']); + ConsoleErrorHandler::$stderr = $this->getMock('ConsoleOutput', [], [], '', false); } /** diff --git a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php index 3be8d9672f..db969dab84 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php @@ -37,7 +37,7 @@ public function testDescription() { $this->assertEquals($parser, $result, 'Setting description is not chainable'); $this->assertEquals('A test', $parser->description(), 'getting value is wrong.'); - $parser->description(array('A test', 'something')); + $parser->description(['A test', 'something']); $this->assertEquals("A test\nsomething", $parser->description(), 'getting value is wrong.'); } @@ -53,7 +53,7 @@ public function testEpilog() { $this->assertEquals($parser, $result, 'Setting epilog is not chainable'); $this->assertEquals('A test', $parser->epilog(), 'getting value is wrong.'); - $parser->epilog(array('A test', 'something')); + $parser->epilog(['A test', 'something']); $this->assertEquals("A test\nsomething", $parser->epilog(), 'getting value is wrong.'); } @@ -75,11 +75,11 @@ public function testAddOptionReturnSelf() { */ public function testAddOptionLong() { $parser = new ConsoleOptionParser('test', false); - $parser->addOption('test', array( + $parser->addOption('test', [ 'short' => 't' - )); - $result = $parser->parse(array('--test', 'value')); - $this->assertEquals(array('test' => 'value', 'help' => false), $result[0], 'Long parameter did not parse out'); + ]); + $result = $parser->parse(['--test', 'value']); + $this->assertEquals(['test' => 'value', 'help' => false], $result[0], 'Long parameter did not parse out'); } /** @@ -89,9 +89,9 @@ public function testAddOptionLong() { */ public function testAddOptionZero() { $parser = new ConsoleOptionParser('test', false); - $parser->addOption('count', array()); - $result = $parser->parse(array('--count', '0')); - $this->assertEquals(array('count' => '0', 'help' => false), $result[0], 'Zero parameter did not parse out'); + $parser->addOption('count', []); + $result = $parser->parse(['--count', '0']); + $this->assertEquals(['count' => '0', 'help' => false], $result[0], 'Zero parameter did not parse out'); } /** @@ -102,8 +102,8 @@ public function testAddOptionZero() { public function testAddOptionObject() { $parser = new ConsoleOptionParser('test', false); $parser->addOption(new ConsoleInputOption('test', 't')); - $result = $parser->parse(array('--test=value')); - $this->assertEquals(array('test' => 'value', 'help' => false), $result[0], 'Long parameter did not parse out'); + $result = $parser->parse(['--test=value']); + $this->assertEquals(['test' => 'value', 'help' => false], $result[0], 'Long parameter did not parse out'); } /** @@ -113,11 +113,11 @@ public function testAddOptionObject() { */ public function testAddOptionLongEquals() { $parser = new ConsoleOptionParser('test', false); - $parser->addOption('test', array( + $parser->addOption('test', [ 'short' => 't' - )); - $result = $parser->parse(array('--test=value')); - $this->assertEquals(array('test' => 'value', 'help' => false), $result[0], 'Long parameter did not parse out'); + ]); + $result = $parser->parse(['--test=value']); + $this->assertEquals(['test' => 'value', 'help' => false], $result[0], 'Long parameter did not parse out'); } /** @@ -127,18 +127,18 @@ public function testAddOptionLongEquals() { */ public function testAddOptionDefault() { $parser = new ConsoleOptionParser('test', false); - $parser->addOption('test', array( + $parser->addOption('test', [ 'default' => 'default value', - )); - $result = $parser->parse(array('--test')); - $this->assertEquals(array('test' => 'default value', 'help' => false), $result[0], 'Default value did not parse out'); + ]); + $result = $parser->parse(['--test']); + $this->assertEquals(['test' => 'default value', 'help' => false], $result[0], 'Default value did not parse out'); $parser = new ConsoleOptionParser('test', false); - $parser->addOption('test', array( + $parser->addOption('test', [ 'default' => 'default value', - )); - $result = $parser->parse(array()); - $this->assertEquals(array('test' => 'default value', 'help' => false), $result[0], 'Default value did not parse out'); + ]); + $result = $parser->parse([]); + $this->assertEquals(['test' => 'default value', 'help' => false], $result[0], 'Default value did not parse out'); } /** @@ -148,11 +148,11 @@ public function testAddOptionDefault() { */ public function testAddOptionShort() { $parser = new ConsoleOptionParser('test', false); - $parser->addOption('test', array( + $parser->addOption('test', [ 'short' => 't' - )); - $result = $parser->parse(array('-t', 'value')); - $this->assertEquals(array('test' => 'value', 'help' => false), $result[0], 'Short parameter did not parse out'); + ]); + $result = $parser->parse(['-t', 'value']); + $this->assertEquals(['test' => 'value', 'help' => false], $result[0], 'Short parameter did not parse out'); } /** @@ -164,7 +164,7 @@ public function testAddOptionShort() { public function testAddOptionShortOneLetter() { $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); - $parser->addOption('test', array('short' => 'te')); + $parser->addOption('test', ['short' => 'te']); } /** @@ -174,16 +174,16 @@ public function testAddOptionShortOneLetter() { */ public function testAddOptionBoolean() { $parser = new ConsoleOptionParser('test', false); - $parser->addOption('test', array( + $parser->addOption('test', [ 'boolean' => true, - )); + ]); - $result = $parser->parse(array('--test', 'value')); - $expected = array(array('test' => true, 'help' => false), array('value')); + $result = $parser->parse(['--test', 'value']); + $expected = [['test' => true, 'help' => false], ['value']]; $this->assertEquals($expected, $result); - $result = $parser->parse(array('value')); - $expected = array(array('test' => false, 'help' => false), array('value')); + $result = $parser->parse(['value']); + $expected = [['test' => false, 'help' => false], ['value']]; $this->assertEquals($expected, $result); } @@ -194,15 +194,15 @@ public function testAddOptionBoolean() { */ public function testAddOptionMultipleShort() { $parser = new ConsoleOptionParser('test', false); - $parser->addOption('test', array('short' => 't', 'boolean' => true)) - ->addOption('file', array('short' => 'f', 'boolean' => true)) - ->addOption('output', array('short' => 'o', 'boolean' => true)); + $parser->addOption('test', ['short' => 't', 'boolean' => true]) + ->addOption('file', ['short' => 'f', 'boolean' => true]) + ->addOption('output', ['short' => 'o', 'boolean' => true]); - $result = $parser->parse(array('-o', '-t', '-f')); - $expected = array('file' => true, 'test' => true, 'output' => true, 'help' => false); + $result = $parser->parse(['-o', '-t', '-f']); + $expected = ['file' => true, 'test' => true, 'output' => true, 'help' => false]; $this->assertEquals($expected, $result[0], 'Short parameter did not parse out'); - $result = $parser->parse(array('-otf')); + $result = $parser->parse(['-otf']); $this->assertEquals($expected, $result[0], 'Short parameter did not parse out'); } @@ -215,10 +215,10 @@ public function testMultipleOptions() { $parser = new ConsoleOptionParser('test', false); $parser->addOption('test') ->addOption('connection') - ->addOption('table', array('short' => 't', 'default' => true)); + ->addOption('table', ['short' => 't', 'default' => true]); - $result = $parser->parse(array('--test', 'value', '-t', '--connection', 'postgres')); - $expected = array('test' => 'value', 'table' => true, 'connection' => 'postgres', 'help' => false); + $result = $parser->parse(['--test', 'value', '-t', '--connection', 'postgres']); + $expected = ['test' => 'value', 'table' => true, 'connection' => 'postgres', 'help' => false]; $this->assertEquals($expected, $result[0], 'multiple options did not parse'); } @@ -229,10 +229,10 @@ public function testMultipleOptions() { */ public function testAddOptions() { $parser = new ConsoleOptionParser('something', false); - $result = $parser->addOptions(array( - 'name' => array('help' => 'The name'), - 'other' => array('help' => 'The other arg') - )); + $result = $parser->addOptions([ + 'name' => ['help' => 'The name'], + 'other' => ['help' => 'The other arg'] + ]); $this->assertEquals($parser, $result, 'addOptions is not chainable.'); $result = $parser->options(); @@ -246,11 +246,11 @@ public function testAddOptions() { */ public function testOptionWithBooleanParam() { $parser = new ConsoleOptionParser('test', false); - $parser->addOption('no-commit', array('boolean' => true)) - ->addOption('table', array('short' => 't')); + $parser->addOption('no-commit', ['boolean' => true]) + ->addOption('table', ['short' => 't']); - $result = $parser->parse(array('--table', 'posts', '--no-commit', 'arg1', 'arg2')); - $expected = array(array('table' => 'posts', 'no-commit' => true, 'help' => false), array('arg1', 'arg2')); + $result = $parser->parse(['--table', 'posts', '--no-commit', 'arg1', 'arg2']); + $expected = [['table' => 'posts', 'no-commit' => true, 'help' => false], ['arg1', 'arg2']]; $this->assertEquals($expected, $result, 'Boolean option did not parse correctly.'); } @@ -262,9 +262,9 @@ public function testOptionWithBooleanParam() { public function testOptionThatDoesNotExist() { $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); - $parser->addOption('no-commit', array('boolean' => true)); + $parser->addOption('no-commit', ['boolean' => true]); - $parser->parse(array('--fail', 'other')); + $parser->parse(['--fail', 'other']); } /** @@ -275,9 +275,9 @@ public function testOptionThatDoesNotExist() { public function testShortOptionThatDoesNotExist() { $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); - $parser->addOption('no-commit', array('boolean' => true)); + $parser->addOption('no-commit', ['boolean' => true]); - $parser->parse(array('-f')); + $parser->parse(['-f']); } /** @@ -288,13 +288,13 @@ public function testShortOptionThatDoesNotExist() { public function testOptionWithChoices() { $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); - $parser->addOption('name', array('choices' => array('mark', 'jose'))); + $parser->addOption('name', ['choices' => ['mark', 'jose']]); - $result = $parser->parse(array('--name', 'mark')); - $expected = array('name' => 'mark', 'help' => false); + $result = $parser->parse(['--name', 'mark']); + $expected = ['name' => 'mark', 'help' => false]; $this->assertEquals($expected, $result[0], 'Got the correct value.'); - $parser->parse(array('--name', 'jimmy')); + $parser->parse(['--name', 'jimmy']); } /** @@ -307,8 +307,8 @@ public function testOptionWithValueStartingWithMinus() { $parser->addOption('name') ->addOption('age'); - $result = $parser->parse(array('--name', '-foo', '--age', 'old')); - $expected = array('name' => '-foo', 'age' => 'old', 'help' => false); + $result = $parser->parse(['--name', '-foo', '--age', 'old']); + $expected = ['name' => '-foo', 'age' => 'old', 'help' => false]; $this->assertEquals($expected, $result[0], 'Option values starting with "-" are broken.'); } @@ -319,7 +319,7 @@ public function testOptionWithValueStartingWithMinus() { */ public function testPositionalArgument() { $parser = new ConsoleOptionParser('test', false); - $result = $parser->addArgument('name', array('help' => 'An argument')); + $result = $parser->addArgument('name', ['help' => 'An argument']); $this->assertEquals($parser, $result, 'Should return this'); } @@ -343,16 +343,16 @@ public function testAddArgumentObject() { */ public function testAddArgumentOutOfOrder() { $parser = new ConsoleOptionParser('test', false); - $parser->addArgument('name', array('index' => 1, 'help' => 'first argument')) - ->addArgument('bag', array('index' => 2, 'help' => 'second argument')) - ->addArgument('other', array('index' => 0, 'help' => 'Zeroth argument')); + $parser->addArgument('name', ['index' => 1, 'help' => 'first argument']) + ->addArgument('bag', ['index' => 2, 'help' => 'second argument']) + ->addArgument('other', ['index' => 0, 'help' => 'Zeroth argument']); $result = $parser->arguments(); $this->assertCount(3, $result); $this->assertEquals('other', $result[0]->name()); $this->assertEquals('name', $result[1]->name()); $this->assertEquals('bag', $result[2]->name()); - $this->assertSame(array(0, 1, 2), array_keys($result)); + $this->assertSame([0, 1, 2], array_keys($result)); } /** @@ -362,8 +362,8 @@ public function testAddArgumentOutOfOrder() { */ public function testPositionalArgOverwrite() { $parser = new ConsoleOptionParser('test', false); - $parser->addArgument('name', array('help' => 'An argument')) - ->addArgument('other', array('index' => 0)); + $parser->addArgument('name', ['help' => 'An argument']) + ->addArgument('other', ['index' => 0]); $result = $parser->arguments(); $this->assertEquals(1, count($result), 'Overwrite did not occur'); @@ -377,14 +377,14 @@ public function testPositionalArgOverwrite() { public function testParseArgumentTooMany() { $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); - $parser->addArgument('name', array('help' => 'An argument')) + $parser->addArgument('name', ['help' => 'An argument']) ->addArgument('other'); - $expected = array('one', 'two'); + $expected = ['one', 'two']; $result = $parser->parse($expected); $this->assertEquals($expected, $result[1], 'Arguments are not as expected'); - $parser->parse(array('one', 'two', 'three')); + $parser->parse(['one', 'two', 'three']); } /** @@ -395,7 +395,7 @@ public function testParseArgumentTooMany() { public function testParseArgumentZero() { $parser = new ConsoleOptionParser('test', false); - $expected = array('one', 'two', 0, 'after', 'zero'); + $expected = ['one', 'two', 0, 'after', 'zero']; $result = $parser->parse($expected); $this->assertEquals($expected, $result[1], 'Arguments are not as expected'); } @@ -408,10 +408,10 @@ public function testParseArgumentZero() { public function testPositionalArgNotEnough() { $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); - $parser->addArgument('name', array('required' => true)) - ->addArgument('other', array('required' => true)); + $parser->addArgument('name', ['required' => true]) + ->addArgument('other', ['required' => true]); - $parser->parse(array('one')); + $parser->parse(['one']); } /** @@ -422,15 +422,15 @@ public function testPositionalArgNotEnough() { public function testPositionalArgWithChoices() { $this->expectException(ConsoleException::class); $parser = new ConsoleOptionParser('test', false); - $parser->addArgument('name', array('choices' => array('mark', 'jose'))) - ->addArgument('alias', array('choices' => array('cowboy', 'samurai'))) - ->addArgument('weapon', array('choices' => array('gun', 'sword'))); + $parser->addArgument('name', ['choices' => ['mark', 'jose']]) + ->addArgument('alias', ['choices' => ['cowboy', 'samurai']]) + ->addArgument('weapon', ['choices' => ['gun', 'sword']]); - $result = $parser->parse(array('mark', 'samurai', 'sword')); - $expected = array('mark', 'samurai', 'sword'); + $result = $parser->parse(['mark', 'samurai', 'sword']); + $expected = ['mark', 'samurai', 'sword']; $this->assertEquals($expected, $result[1], 'Got the correct value.'); - $parser->parse(array('jose', 'coder')); + $parser->parse(['jose', 'coder']); } /** @@ -440,10 +440,10 @@ public function testPositionalArgWithChoices() { */ public function testAddArguments() { $parser = new ConsoleOptionParser('test', false); - $result = $parser->addArguments(array( - 'name' => array('help' => 'The name'), - 'other' => array('help' => 'The other arg') - )); + $result = $parser->addArguments([ + 'name' => ['help' => 'The name'], + 'other' => ['help' => 'The other arg'] + ]); $this->assertEquals($parser, $result, 'addArguments is not chainable.'); $result = $parser->arguments(); @@ -457,9 +457,9 @@ public function testAddArguments() { */ public function testSubcommand() { $parser = new ConsoleOptionParser('test', false); - $result = $parser->addSubcommand('initdb', array( + $result = $parser->addSubcommand('initdb', [ 'help' => 'Initialize the database' - )); + ]); $this->assertEquals($parser, $result, 'Adding a subcommand is not chainable'); } @@ -498,10 +498,10 @@ public function testRemoveSubcommand() { */ public function testAddSubcommands() { $parser = new ConsoleOptionParser('test', false); - $result = $parser->addSubcommands(array( - 'initdb' => array('help' => 'Initialize the database'), - 'create' => array('help' => 'Create something') - )); + $result = $parser->addSubcommands([ + 'initdb' => ['help' => 'Initialize the database'], + 'create' => ['help' => 'Create something'] + ]); $this->assertEquals($parser, $result, 'Adding a subcommands is not chainable'); $result = $parser->subcommands(); $this->assertEquals(2, count($result), 'Not enough subcommands'); @@ -514,10 +514,10 @@ public function testAddSubcommands() { */ public function testHelpNoExceptionWhenGettingHelp() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addOption('test', array('help' => 'A test option.')) - ->addArgument('model', array('help' => 'The model to make.', 'required' => true)); + $parser->addOption('test', ['help' => 'A test option.']) + ->addArgument('model', ['help' => 'The model to make.', 'required' => true]); - $result = $parser->parse(array('--help')); + $result = $parser->parse(['--help']); $this->assertTrue($result[0]['help']); } @@ -528,14 +528,14 @@ public function testHelpNoExceptionWhenGettingHelp() { */ public function testHelpSubcommandHelp() { $subParser = new ConsoleOptionParser('method', false); - $subParser->addOption('connection', array('help' => 'Db connection.')); + $subParser->addOption('connection', ['help' => 'Db connection.']); $parser = new ConsoleOptionParser('mycommand', false); - $parser->addSubcommand('method', array( + $parser->addSubcommand('method', [ 'help' => 'This is another command', 'parser' => $subParser - )) - ->addOption('test', array('help' => 'A test option.')); + ]) + ->addOption('test', ['help' => 'A test option.']); $result = $parser->help('method'); $expected = << 'test', - 'arguments' => array( - 'name' => array('help' => 'The name'), - 'other' => array('help' => 'The other arg') - ), - 'options' => array( - 'name' => array('help' => 'The name'), - 'other' => array('help' => 'The other arg') - ), - 'subcommands' => array( - 'initdb' => array('help' => 'make database') - ), + 'arguments' => [ + 'name' => ['help' => 'The name'], + 'other' => ['help' => 'The other arg'] + ], + 'options' => [ + 'name' => ['help' => 'The name'], + 'other' => ['help' => 'The other arg'] + ], + 'subcommands' => [ + 'initdb' => ['help' => 'make database'] + ], 'description' => 'description text', 'epilog' => 'epilog text' - ); + ]; $parser = ConsoleOptionParser::buildFromArray($spec); $this->assertEquals($spec['description'], $parser->description()); @@ -619,27 +619,27 @@ public function testCommandInflection() { public function testParsingWithSubParser() { $parser = new ConsoleOptionParser('test', false); $parser->addOption('primary') - ->addArgument('one', array('required' => true, 'choices' => array('a', 'b'))) - ->addArgument('two', array('required' => true)) - ->addSubcommand('sub', array( - 'parser' => array( - 'options' => array( - 'secondary' => array('boolean' => true), - 'fourth' => array('help' => 'fourth option') - ), - 'arguments' => array( - 'sub_arg' => array('choices' => array('c', 'd')) - ) - ) - )); - - $result = $parser->parse(array('--secondary', '--fourth', '4', 'c'), 'sub'); - $expected = array(array( + ->addArgument('one', ['required' => true, 'choices' => ['a', 'b']]) + ->addArgument('two', ['required' => true]) + ->addSubcommand('sub', [ + 'parser' => [ + 'options' => [ + 'secondary' => ['boolean' => true], + 'fourth' => ['help' => 'fourth option'] + ], + 'arguments' => [ + 'sub_arg' => ['choices' => ['c', 'd']] + ] + ] + ]); + + $result = $parser->parse(['--secondary', '--fourth', '4', 'c'], 'sub'); + $expected = [[ 'secondary' => true, 'fourth' => '4', 'help' => false, 'verbose' => false, - 'quiet' => false), array('c')); + 'quiet' => false], ['c']]; $this->assertEquals($expected, $result, 'Sub parser did not parse request.'); } diff --git a/lib/Cake/Test/Case/Console/ConsoleOutputTest.php b/lib/Cake/Test/Case/Console/ConsoleOutputTest.php index f6ac6fc319..f0d3de1be2 100644 --- a/lib/Cake/Test/Case/Console/ConsoleOutputTest.php +++ b/lib/Cake/Test/Case/Console/ConsoleOutputTest.php @@ -32,7 +32,7 @@ class ConsoleOutputTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->output = $this->getMock('ConsoleOutput', array('_write')); + $this->output = $this->getMock('ConsoleOutput', ['_write']); $this->output->outputAs(ConsoleOutput::COLOR); } @@ -91,7 +91,7 @@ public function testWriteArray() { $this->output->expects($this->once())->method('_write') ->with('Line' . PHP_EOL . 'Line' . PHP_EOL . 'Line' . PHP_EOL); - $this->output->write(array('Line', 'Line', 'Line')); + $this->output->write(['Line', 'Line', 'Line']); } /** @@ -122,14 +122,14 @@ public function testOverwrite() { */ public function testStylesGet() { $result = $this->output->styles('error'); - $expected = array('text' => 'red', 'underline' => true); + $expected = ['text' => 'red', 'underline' => true]; $this->assertEquals($expected, $result); $this->assertNull($this->output->styles('made_up_goop')); $result = $this->output->styles(); - $this->assertNotEmpty($result, 'error', 'Error is missing'); - $this->assertNotEmpty($result, 'warning', 'Warning is missing'); + $this->assertNotEmpty($result, 'error'); + $this->assertNotEmpty($result, 'warning'); } /** @@ -138,9 +138,9 @@ public function testStylesGet() { * @return void */ public function testStylesAdding() { - $this->output->styles('test', array('text' => 'red', 'background' => 'black')); + $this->output->styles('test', ['text' => 'red', 'background' => 'black']); $result = $this->output->styles('test'); - $expected = array('text' => 'red', 'background' => 'black'); + $expected = ['text' => 'red', 'background' => 'black']; $this->assertEquals($expected, $result); $this->assertTrue($this->output->styles('test', false), 'Removing a style should return true.'); @@ -177,12 +177,12 @@ public function testFormattingNotEatingTags() { * @return void */ public function testFormattingCustom() { - $this->output->styles('annoying', array( + $this->output->styles('annoying', [ 'text' => 'magenta', 'background' => 'cyan', 'blink' => true, 'underline' => true - )); + ]); $this->output->expects($this->once())->method('_write') ->with("\033[35;46;5;4mAnnoy:\033[0m Something bad"); @@ -259,7 +259,7 @@ public function testOutputAsPlain() { * @return void */ public function testOutputAsPlainWhenOutputStream() { - $output = $this->getMock('ConsoleOutput', array('_write'), array('php://output')); + $output = $this->getMock('ConsoleOutput', ['_write'], ['php://output']); $this->assertEquals(ConsoleOutput::PLAIN, $output->outputAs()); } diff --git a/lib/Cake/Test/Case/Console/HelpFormatterTest.php b/lib/Cake/Test/Case/Console/HelpFormatterTest.php index ddc2dca241..c5fbcc76d3 100644 --- a/lib/Cake/Test/Case/Console/HelpFormatterTest.php +++ b/lib/Cake/Test/Case/Console/HelpFormatterTest.php @@ -34,9 +34,9 @@ class HelpFormatterTest extends CakeTestCase { public function testWidthFormatting() { $parser = new ConsoleOptionParser('test', false); $parser->description('This is fifteen This is fifteen This is fifteen') - ->addOption('four', array('help' => 'this is help text this is help text')) - ->addArgument('four', array('help' => 'this is help text this is help text')) - ->addSubcommand('four', array('help' => 'this is help text this is help text')); + ->addOption('four', ['help' => 'this is help text this is help text']) + ->addArgument('four', ['help' => 'this is help text this is help text']) + ->addSubcommand('four', ['help' => 'this is help text this is help text']); $formatter = new HelpFormatter($parser); $result = $formatter->text(30); @@ -77,13 +77,13 @@ public function testWidthFormatting() { */ public function testHelpWithChoices() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addOption('test', array('help' => 'A test option.', 'choices' => array('one', 'two'))) - ->addArgument('type', array( + $parser->addOption('test', ['help' => 'A test option.', 'choices' => ['one', 'two']]) + ->addArgument('type', [ 'help' => 'Resource type.', - 'choices' => array('aco', 'aro'), + 'choices' => ['aco', 'aro'], 'required' => true - )) - ->addArgument('other_longer', array('help' => 'Another argument.')); + ]) + ->addArgument('other_longer', ['help' => 'Another argument.']); $formatter = new HelpFormatter($parser); $result = $formatter->text(); @@ -114,8 +114,8 @@ public function testHelpDescriptionAndEpilog() { $parser = new ConsoleOptionParser('mycommand', false); $parser->description('Description text') ->epilog('epilog text') - ->addOption('test', array('help' => 'A test option.')) - ->addArgument('model', array('help' => 'The model to make.', 'required' => true)); + ->addOption('test', ['help' => 'A test option.']) + ->addArgument('model', ['help' => 'The model to make.', 'required' => true]); $formatter = new HelpFormatter($parser); $result = $formatter->text(); @@ -147,8 +147,8 @@ public function testHelpDescriptionAndEpilog() { */ public function testHelpSubcommand() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addSubcommand('method', array('help' => 'This is another command')) - ->addOption('test', array('help' => 'A test option.')); + $parser->addSubcommand('method', ['help' => 'This is another command']) + ->addOption('test', ['help' => 'A test option.']); $formatter = new HelpFormatter($parser); $result = $formatter->text(); @@ -178,10 +178,10 @@ public function testHelpSubcommand() { */ public function testHelpWithOptions() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addOption('test', array('help' => 'A test option.')) - ->addOption('connection', array( + $parser->addOption('test', ['help' => 'A test option.']) + ->addOption('connection', [ 'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default' - )); + ]); $formatter = new HelpFormatter($parser); $result = $formatter->text(); @@ -207,9 +207,9 @@ public function testHelpWithOptions() { */ public function testHelpWithOptionsAndArguments() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addOption('test', array('help' => 'A test option.')) - ->addArgument('model', array('help' => 'The model to make.', 'required' => true)) - ->addArgument('other_longer', array('help' => 'Another argument.')); + $parser->addOption('test', ['help' => 'A test option.']) + ->addArgument('model', ['help' => 'The model to make.', 'required' => true]) + ->addArgument('other_longer', ['help' => 'Another argument.']); $formatter = new HelpFormatter($parser); $result = $formatter->text(); @@ -239,15 +239,15 @@ public function testHelpWithOptionsAndArguments() { public function testHelpWithLotsOfOptions() { $parser = new ConsoleOptionParser('mycommand', false); $parser - ->addOption('test', array('help' => 'A test option.')) - ->addOption('test2', array('help' => 'A test option.')) - ->addOption('test3', array('help' => 'A test option.')) - ->addOption('test4', array('help' => 'A test option.')) - ->addOption('test5', array('help' => 'A test option.')) - ->addOption('test6', array('help' => 'A test option.')) - ->addOption('test7', array('help' => 'A test option.')) - ->addArgument('model', array('help' => 'The model to make.', 'required' => true)) - ->addArgument('other_longer', array('help' => 'Another argument.')); + ->addOption('test', ['help' => 'A test option.']) + ->addOption('test2', ['help' => 'A test option.']) + ->addOption('test3', ['help' => 'A test option.']) + ->addOption('test4', ['help' => 'A test option.']) + ->addOption('test5', ['help' => 'A test option.']) + ->addOption('test6', ['help' => 'A test option.']) + ->addOption('test7', ['help' => 'A test option.']) + ->addArgument('model', ['help' => 'The model to make.', 'required' => true]) + ->addArgument('other_longer', ['help' => 'Another argument.']); $formatter = new HelpFormatter($parser); $result = $formatter->text(); @@ -263,15 +263,15 @@ public function testHelpWithLotsOfOptions() { public function testHelpWithLotsOfArguments() { $parser = new ConsoleOptionParser('mycommand', false); $parser - ->addArgument('test', array('help' => 'A test option.')) - ->addArgument('test2', array('help' => 'A test option.')) - ->addArgument('test3', array('help' => 'A test option.')) - ->addArgument('test4', array('help' => 'A test option.')) - ->addArgument('test5', array('help' => 'A test option.')) - ->addArgument('test6', array('help' => 'A test option.')) - ->addArgument('test7', array('help' => 'A test option.')) - ->addArgument('model', array('help' => 'The model to make.', 'required' => true)) - ->addArgument('other_longer', array('help' => 'Another argument.')); + ->addArgument('test', ['help' => 'A test option.']) + ->addArgument('test2', ['help' => 'A test option.']) + ->addArgument('test3', ['help' => 'A test option.']) + ->addArgument('test4', ['help' => 'A test option.']) + ->addArgument('test5', ['help' => 'A test option.']) + ->addArgument('test6', ['help' => 'A test option.']) + ->addArgument('test7', ['help' => 'A test option.']) + ->addArgument('model', ['help' => 'The model to make.', 'required' => true]) + ->addArgument('other_longer', ['help' => 'Another argument.']); $formatter = new HelpFormatter($parser); $result = $formatter->text(); @@ -286,13 +286,13 @@ public function testHelpWithLotsOfArguments() { */ public function testXmlHelpWithChoices() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addOption('test', array('help' => 'A test option.', 'choices' => array('one', 'two'))) - ->addArgument('type', array( + $parser->addOption('test', ['help' => 'A test option.', 'choices' => ['one', 'two']]) + ->addArgument('type', [ 'help' => 'Resource type.', - 'choices' => array('aco', 'aro'), + 'choices' => ['aco', 'aro'], 'required' => true - )) - ->addArgument('other_longer', array('help' => 'Another argument.')); + ]) + ->addArgument('other_longer', ['help' => 'Another argument.']); $formatter = new HelpFormatter($parser); $result = $formatter->xml(); @@ -341,8 +341,8 @@ public function testXmlHelpDescriptionAndEpilog() { $parser = new ConsoleOptionParser('mycommand', false); $parser->description('Description text') ->epilog('epilog text') - ->addOption('test', array('help' => 'A test option.')) - ->addArgument('model', array('help' => 'The model to make.', 'required' => true)); + ->addOption('test', ['help' => 'A test option.']) + ->addArgument('model', ['help' => 'The model to make.', 'required' => true]); $formatter = new HelpFormatter($parser); $result = $formatter->xml(); @@ -380,8 +380,8 @@ public function testXmlHelpDescriptionAndEpilog() { */ public function testXmlHelpSubcommand() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addSubcommand('method', array('help' => 'This is another command')) - ->addOption('test', array('help' => 'A test option.')); + $parser->addSubcommand('method', ['help' => 'This is another command']) + ->addOption('test', ['help' => 'A test option.']); $formatter = new HelpFormatter($parser); $result = $formatter->xml(); @@ -417,10 +417,10 @@ public function testXmlHelpSubcommand() { */ public function testXmlHelpWithOptions() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addOption('test', array('help' => 'A test option.')) - ->addOption('connection', array( + $parser->addOption('test', ['help' => 'A test option.']) + ->addOption('connection', [ 'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default' - )); + ]); $formatter = new HelpFormatter($parser); $result = $formatter->xml(); @@ -458,9 +458,9 @@ public function testXmlHelpWithOptions() { */ public function testXmlHelpWithOptionsAndArguments() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addOption('test', array('help' => 'A test option.')) - ->addArgument('model', array('help' => 'The model to make.', 'required' => true)) - ->addArgument('other_longer', array('help' => 'Another argument.')); + $parser->addOption('test', ['help' => 'A test option.']) + ->addArgument('model', ['help' => 'The model to make.', 'required' => true]) + ->addArgument('other_longer', ['help' => 'Another argument.']); $formatter = new HelpFormatter($parser); $result = $formatter->xml(); @@ -501,9 +501,9 @@ public function testXmlHelpWithOptionsAndArguments() { */ public function testXmlHelpAsObject() { $parser = new ConsoleOptionParser('mycommand', false); - $parser->addOption('test', array('help' => 'A test option.')) - ->addArgument('model', array('help' => 'The model to make.', 'required' => true)) - ->addArgument('other_longer', array('help' => 'Another argument.')); + $parser->addOption('test', ['help' => 'A test option.']) + ->addArgument('model', ['help' => 'The model to make.', 'required' => true]) + ->addArgument('other_longer', ['help' => 'Another argument.']); $formatter = new HelpFormatter($parser); $result = $formatter->xml(false); diff --git a/lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php b/lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php index 03e9c6dc56..28c6e7cf90 100644 --- a/lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php +++ b/lib/Cake/Test/Case/Console/Helper/ProgressShellHelperTest.php @@ -41,7 +41,7 @@ public function setUp() : void { */ public function testOutputFailure() { $this->expectException(\RuntimeException::class); - $this->helper->output(array('not a callback')); + $this->helper->output(['not a callback']); } /** @@ -50,10 +50,10 @@ public function testOutputFailure() { * @return void */ public function testOutputSuccess() { - $this->helper->output(array(function ($progress) { + $this->helper->output([function ($progress) { $progress->increment(20); - })); - $expected = array( + }]); + $expected = [ '', '==============> 20%', '', @@ -65,7 +65,7 @@ public function testOutputSuccess() { '', '==========================================================================> 100%', '', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -75,14 +75,14 @@ public function testOutputSuccess() { * @return void */ public function testOutputSuccessOptions() { - $this->helper->output(array( + $this->helper->output([ 'total' => 10, 'width' => 20, 'callback' => function ($progress) { $progress->increment(2); } - )); - $expected = array( + ]); + $expected = [ '', '==> 20%', '', @@ -94,7 +94,7 @@ public function testOutputSuccessOptions() { '', '==============> 100%', '', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -111,14 +111,14 @@ public function testIncrementAndRender() { $this->helper->draw(); $this->helper->increment(40); $this->helper->draw(); - $expected = array( + $expected = [ '', '==============> 20%', '', '============================================> 60%', '', '==========================================================================> 100%', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -135,14 +135,14 @@ public function testIncrementWithNegatives() { $this->helper->draw(); $this->helper->increment(80); $this->helper->draw(); - $expected = array( + $expected = [ '', '=============================> 40%', '', ' 0%', '', '===========================================================> 80%', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -152,10 +152,10 @@ public function testIncrementWithNegatives() { * @return void */ public function testIncrementWithOptions() { - $this->helper->init(array( + $this->helper->init([ 'total' => 10, 'width' => 20, - )); + ]); $this->helper->increment(4); $this->helper->draw(); $this->helper->increment(4); @@ -163,14 +163,14 @@ public function testIncrementWithOptions() { $this->helper->increment(4); $this->helper->draw(); - $expected = array( + $expected = [ '', '=====> 40%', '', '===========> 80%', '', '==============> 100%', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -181,9 +181,9 @@ public function testIncrementWithOptions() { * @return void */ public function testIncrementFloatPad() { - $this->helper->init(array( + $this->helper->init([ 'total' => 50 - )); + ]); $this->helper->increment(7); $this->helper->draw(); $this->helper->increment(7); @@ -200,7 +200,7 @@ public function testIncrementFloatPad() { $this->helper->draw(); $this->helper->increment(8); $this->helper->draw(); - $expected = array( + $expected = [ '', '=========> 14%', '', @@ -217,7 +217,7 @@ public function testIncrementFloatPad() { '==============================================================> 84%', '', '==========================================================================> 100%', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } } diff --git a/lib/Cake/Test/Case/Console/Helper/TableShellHelperTest.php b/lib/Cake/Test/Case/Console/Helper/TableShellHelperTest.php index 755fcb90ae..fcb98bf793 100644 --- a/lib/Cake/Test/Case/Console/Helper/TableShellHelperTest.php +++ b/lib/Cake/Test/Case/Console/Helper/TableShellHelperTest.php @@ -40,20 +40,20 @@ public function setUp() : void { * @return void */ public function testDefaultOutput() { - $data = array( - array('Header 1', 'Header', 'Long Header'), - array('short', 'Longish thing', 'short'), - array('Longer thing', 'short', 'Longest Value'), - ); + $data = [ + ['Header 1', 'Header', 'Long Header'], + ['short', 'Longish thing', 'short'], + ['Longer thing', 'short', 'Longest Value'], + ]; $this->helper->output($data); - $expected = array( + $expected = [ '+--------------+---------------+---------------+', '| Header 1 | Header | Long Header |', '+--------------+---------------+---------------+', '| short | Longish thing | short |', '| Longer thing | short | Longest Value |', '+--------------+---------------+---------------+', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -63,20 +63,20 @@ public function testDefaultOutput() { * @return void */ public function testOutputUtf8() { - $data = array( - array('Header 1', 'Head', 'Long Header'), - array('short', 'ÄÄÄÜÜÜ', 'short'), - array('Longer thing', 'longerish', 'Longest Value'), - ); + $data = [ + ['Header 1', 'Head', 'Long Header'], + ['short', 'ÄÄÄÜÜÜ', 'short'], + ['Longer thing', 'longerish', 'Longest Value'], + ]; $this->helper->output($data); - $expected = array( + $expected = [ '+--------------+-----------+---------------+', '| Header 1 | Head | Long Header |', '+--------------+-----------+---------------+', '| short | ÄÄÄÜÜÜ | short |', '| Longer thing | longerish | Longest Value |', '+--------------+-----------+---------------+', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -86,21 +86,21 @@ public function testOutputUtf8() { * @return void */ public function testOutputWithoutHeaderStyle() { - $data = array( - array('Header 1', 'Header', 'Long Header'), - array('short', 'Longish thing', 'short'), - array('Longer thing', 'short', 'Longest Value'), - ); - $this->helper->config(array('headerStyle' => false)); + $data = [ + ['Header 1', 'Header', 'Long Header'], + ['short', 'Longish thing', 'short'], + ['Longer thing', 'short', 'Longest Value'], + ]; + $this->helper->config(['headerStyle' => false]); $this->helper->output($data); - $expected = array( + $expected = [ '+--------------+---------------+---------------+', '| Header 1 | Header | Long Header |', '+--------------+---------------+---------------+', '| short | Longish thing | short |', '| Longer thing | short | Longest Value |', '+--------------+---------------+---------------+', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -110,21 +110,21 @@ public function testOutputWithoutHeaderStyle() { * @return void */ public function testOutputWithDifferentHeaderStyle() { - $data = array( - array('Header 1', 'Header', 'Long Header'), - array('short', 'Longish thing', 'short'), - array('Longer thing', 'short', 'Longest Value'), - ); - $this->helper->config(array('headerStyle' => 'error')); + $data = [ + ['Header 1', 'Header', 'Long Header'], + ['short', 'Longish thing', 'short'], + ['Longer thing', 'short', 'Longest Value'], + ]; + $this->helper->config(['headerStyle' => 'error']); $this->helper->output($data); - $expected = array( + $expected = [ '+--------------+---------------+---------------+', '| Header 1 | Header | Long Header |', '+--------------+---------------+---------------+', '| short | Longish thing | short |', '| Longer thing | short | Longest Value |', '+--------------+---------------+---------------+', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -134,18 +134,18 @@ public function testOutputWithDifferentHeaderStyle() { * @return void */ public function testOutputWithoutHeaders() { - $data = array( - array('short', 'Longish thing', 'short'), - array('Longer thing', 'short', 'Longest Value'), - ); - $this->helper->config(array('headers' => false)); + $data = [ + ['short', 'Longish thing', 'short'], + ['Longer thing', 'short', 'Longest Value'], + ]; + $this->helper->config(['headers' => false]); $this->helper->output($data); - $expected = array( + $expected = [ '+--------------+---------------+---------------+', '| short | Longish thing | short |', '| Longer thing | short | Longest Value |', '+--------------+---------------+---------------+', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -155,14 +155,14 @@ public function testOutputWithoutHeaders() { * @return void */ public function testOutputWithRowSeparator() { - $data = array( - array('Header 1', 'Header', 'Long Header'), - array('short', 'Longish thing', 'short'), - array('Longer thing', 'short', 'Longest Value') - ); - $this->helper->config(array('rowSeparator' => true)); + $data = [ + ['Header 1', 'Header', 'Long Header'], + ['short', 'Longish thing', 'short'], + ['Longer thing', 'short', 'Longest Value'] + ]; + $this->helper->config(['rowSeparator' => true]); $this->helper->output($data); - $expected = array( + $expected = [ '+--------------+---------------+---------------+', '| Header 1 | Header | Long Header |', '+--------------+---------------+---------------+', @@ -170,7 +170,7 @@ public function testOutputWithRowSeparator() { '+--------------+---------------+---------------+', '| Longer thing | short | Longest Value |', '+--------------+---------------+---------------+', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } @@ -180,14 +180,14 @@ public function testOutputWithRowSeparator() { * @return void */ public function testOutputWithRowSeparatorAndHeaders() { - $data = array( - array('Header 1', 'Header', 'Long Header'), - array('short', 'Longish thing', 'short'), - array('Longer thing', 'short', 'Longest Value'), - ); - $this->helper->config(array('rowSeparator' => true)); + $data = [ + ['Header 1', 'Header', 'Long Header'], + ['short', 'Longish thing', 'short'], + ['Longer thing', 'short', 'Longest Value'], + ]; + $this->helper->config(['rowSeparator' => true]); $this->helper->output($data); - $expected = array( + $expected = [ '+--------------+---------------+---------------+', '| Header 1 | Header | Long Header |', '+--------------+---------------+---------------+', @@ -195,7 +195,7 @@ public function testOutputWithRowSeparatorAndHeaders() { '+--------------+---------------+---------------+', '| Longer thing | short | Longest Value |', '+--------------+---------------+---------------+', - ); + ]; $this->assertEquals($expected, $this->consoleOutput->messages()); } } diff --git a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php index eb5edd0da1..6810eb5cf8 100644 --- a/lib/Cake/Test/Case/Console/ShellDispatcherTest.php +++ b/lib/Cake/Test/Case/Console/ShellDispatcherTest.php @@ -30,7 +30,7 @@ class TestShellDispatcher extends ShellDispatcher { * * @var array */ - public $params = array(); + public $params = []; /** * stopped property @@ -89,10 +89,7 @@ public function getShell($shell) { * @return mixed */ protected function _getShell($shell) { - if (isset($this->TestShell)) { - return $this->TestShell; - } - return parent::_getShell($shell); + return $this->TestShell ?? parent::_getShell($shell); } } @@ -111,14 +108,14 @@ class ShellDispatcherTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ), - 'Console/Command' => array( + ], + 'Console/Command' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Console' . DS . 'Command' . DS - ) - ), App::RESET); + ] + ], App::RESET); CakePlugin::load('TestPlugin'); } @@ -139,20 +136,20 @@ public function tearDown() : void { */ public function testParseParamsAppWorkingAbsolute() { $Dispatcher = new TestShellDispatcher(); - $params = array( + $params = [ '/cake/1.2.x.x/cake/console/cake.php', 'bake', '-app', 'new', '-working', '/var/www/htdocs' - ); - $expected = array( + ]; + $expected = [ 'app' => 'new', 'webroot' => 'webroot', 'working' => str_replace('/', DS, '/var/www/htdocs/new'), 'root' => str_replace('/', DS, '/var/www/htdocs') - ); + ]; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); } @@ -164,14 +161,14 @@ public function testParseParamsAppWorkingAbsolute() { */ public function testParseParamsNone() { $Dispatcher = new TestShellDispatcher(); - $params = array('cake.php'); - $expected = array( + $params = ['cake.php']; + $expected = [ 'app' => 'app', 'webroot' => 'webroot', 'working' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH) . DS . 'app'), 'root' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH)), - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); } @@ -183,18 +180,18 @@ public function testParseParamsNone() { */ public function testParseParamsApp() { $Dispatcher = new TestShellDispatcher(); - $params = array( + $params = [ 'cake.php', '-app', 'new', - ); - $expected = array( + ]; + $expected = [ 'app' => 'new', 'webroot' => 'webroot', 'working' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH) . DS . 'new'), 'root' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH)) - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); } @@ -206,21 +203,21 @@ public function testParseParamsApp() { */ public function testParseParamsAppWorkingRelative() { $Dispatcher = new TestShellDispatcher(); - $params = array( + $params = [ './cake.php', 'bake', '-app', 'new', '-working', '/cake/1.2.x.x/cake/console' - ); - $expected = array( + ]; + $expected = [ 'app' => 'new', 'webroot' => 'webroot', 'working' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH) . DS . 'new'), 'root' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH)) - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); } @@ -233,25 +230,25 @@ public function testParseParamsAppWorkingRelative() { public function testParseParams() { $Dispatcher = new TestShellDispatcher(); - $params = array( + $params = [ './console/cake.php', 'bake', '-app', 'new', '-working', '/cake/1.2.x.x/cake' - ); - $expected = array( + ]; + $expected = [ 'app' => 'new', 'webroot' => 'webroot', 'working' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH) . DS . 'new'), 'root' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH)) - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); - $params = array( + $params = [ './console/cake.php', 'bake', '-app', @@ -259,18 +256,18 @@ public function testParseParams() { '-dry', '-working', '/cake/1.2.x.x/cake' - ); - $expected = array( + ]; + $expected = [ 'app' => 'new', 'working' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH) . DS . 'new'), 'root' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH)), 'webroot' => 'webroot' - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); - $params = array( + $params = [ './console/cake.php', '-working', '/cake/1.2.x.x/cake', @@ -281,23 +278,23 @@ public function testParseParams() { '-f', '-name', 'DbAcl' - ); - $expected = array( + ]; + $expected = [ 'app' => 'app', 'webroot' => 'webroot', 'working' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH) . DS . 'app'), 'root' => str_replace('\\', DS, dirname(CAKE_CORE_INCLUDE_PATH)), - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); - $expected = array( + $expected = [ './console/cake.php', 'schema', 'run', 'create', '-dry', '-f', '-name', 'DbAcl' - ); + ]; $this->assertEquals($expected, $Dispatcher->args); - $params = array( + $params = [ '/cake/1.2.x.x/cake/console/cake.php', '-working', '/cake/1.2.x.x/app', @@ -307,55 +304,55 @@ public function testParseParams() { '-dry', '-name', 'DbAcl' - ); - $expected = array( + ]; + $expected = [ 'app' => 'app', 'webroot' => 'webroot', 'working' => str_replace('/', DS, '/cake/1.2.x.x/app'), 'root' => str_replace('/', DS, '/cake/1.2.x.x'), - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); - $params = array( + $params = [ 'cake.php', '-working', 'C:/wamp/www/cake/app', 'bake', '-app', 'C:/wamp/www/apps/cake/app', - ); - $expected = array( + ]; + $expected = [ 'app' => 'app', 'webroot' => 'webroot', 'working' => 'C:\wamp\www\apps\cake\app', 'root' => 'C:\wamp\www\apps\cake' - ); + ]; - $Dispatcher->params = $Dispatcher->args = array(); + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); - $params = array( + $params = [ 'cake.php', '-working', 'C:\wamp\www\cake\app', 'bake', '-app', 'C:\wamp\www\apps\cake\app', - ); - $expected = array( + ]; + $expected = [ 'app' => 'app', 'webroot' => 'webroot', 'working' => 'C:\wamp\www\apps\cake\app', 'root' => 'C:\wamp\www\apps\cake' - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); - $params = array( + $params = [ 'cake.php', '-working', 'C:\wamp\www\apps', @@ -364,18 +361,18 @@ public function testParseParams() { 'cake\app', '-url', 'http://example.com/some/url/with/a/path' - ); - $expected = array( + ]; + $expected = [ 'app' => 'app', 'webroot' => 'webroot', 'working' => 'C:\wamp\www\apps\cake\app', 'root' => 'C:\wamp\www\apps\cake', - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); - $params = array( + $params = [ '/home/amelo/dev/cake-common/cake/console/cake.php', '-root', '/home/amelo/dev/lsbu-vacancy', @@ -383,18 +380,18 @@ public function testParseParams() { '/home/amelo/dev/lsbu-vacancy', '-app', 'app', - ); - $expected = array( + ]; + $expected = [ 'app' => 'app', 'webroot' => 'webroot', 'working' => '/home/amelo/dev/lsbu-vacancy/app', 'root' => '/home/amelo/dev/lsbu-vacancy', - ); - $Dispatcher->params = $Dispatcher->args = array(); + ]; + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); - $params = array( + $params = [ '/cake/1.2.x.x/cake/console/cake.php', 'bake', '-app', @@ -403,32 +400,32 @@ public function testParseParams() { 'old', '-working', '/var/www/htdocs' - ); - $expected = array( + ]; + $expected = [ 'app' => 'old', 'webroot' => 'webroot', 'working' => str_replace('/', DS, '/var/www/htdocs/old'), 'root' => str_replace('/', DS, '/var/www/htdocs') - ); + ]; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); if (DS === '\\') { - $params = array( + $params = [ 'cake.php', '-working', 'D:\www', 'bake', 'my_app', - ); - $expected = array( + ]; + $expected = [ 'working' => 'D:\\\\www', 'app' => 'www', 'root' => 'D:\\', 'webroot' => 'webroot' - ); + ]; - $Dispatcher->params = $Dispatcher->args = array(); + $Dispatcher->params = $Dispatcher->args = []; $Dispatcher->parseParams($params); $this->assertEquals($expected, $Dispatcher->params); } @@ -478,15 +475,15 @@ public function testDispatchShellWithMain() { $Shell->expects($this->once())->method('initialize'); $Shell->expects($this->once())->method('runCommand') - ->with(null, array()) + ->with(null, []) ->will($this->returnValue(true)); $Dispatcher->TestShell = $Shell; - $Dispatcher->args = array('mock_with_main'); + $Dispatcher->args = ['mock_with_main']; $result = $Dispatcher->dispatch(); $this->assertTrue($result); - $this->assertEquals(array(), $Dispatcher->args); + $this->assertEquals([], $Dispatcher->args); } /** @@ -500,12 +497,12 @@ public function testDispatchShellWithoutMain() { $Shell->expects($this->once())->method('initialize'); $Shell->expects($this->once())->method('runCommand') - ->with('initdb', array('initdb')) + ->with('initdb', ['initdb']) ->will($this->returnValue(true)); $Dispatcher->TestShell = $Shell; - $Dispatcher->args = array('mock_without_main', 'initdb'); + $Dispatcher->args = ['mock_without_main', 'initdb']; $result = $Dispatcher->dispatch(); $this->assertTrue($result); } @@ -526,17 +523,17 @@ public function testDispatchNotAShellWithMain() { $Shell->expects($this->once())->method('main')->will($this->returnValue(true)); $Dispatcher->TestShell = $Shell; - $Dispatcher->args = array('mock_with_main_not_a'); + $Dispatcher->args = ['mock_with_main_not_a']; $result = $Dispatcher->dispatch(); $this->assertTrue($result); - $this->assertEquals(array(), $Dispatcher->args); + $this->assertEquals([], $Dispatcher->args); $Shell = $this->getMock('CakeObject', $methods); $Shell->expects($this->once())->method('initdb')->will($this->returnValue(true)); $Shell->expects($this->once())->method('startup'); $Dispatcher->TestShell = $Shell; - $Dispatcher->args = array('mock_with_main_not_a', 'initdb'); + $Dispatcher->args = ['mock_with_main_not_a', 'initdb']; $result = $Dispatcher->dispatch(); $this->assertTrue($result); } @@ -557,17 +554,17 @@ public function testDispatchNotAShellWithoutMain() { $Shell->expects($this->once())->method('main')->will($this->returnValue(true)); $Dispatcher->TestShell = $Shell; - $Dispatcher->args = array('mock_without_main_not_a'); + $Dispatcher->args = ['mock_without_main_not_a']; $result = $Dispatcher->dispatch(); $this->assertTrue($result); - $this->assertEquals(array(), $Dispatcher->args); + $this->assertEquals([], $Dispatcher->args); $Shell = $this->getMock('CakeObject', $methods); $Shell->expects($this->once())->method('initdb')->will($this->returnValue(true)); $Shell->expects($this->once())->method('startup'); $Dispatcher->TestShell = $Shell; - $Dispatcher->args = array('mock_without_main_not_a', 'initdb'); + $Dispatcher->args = ['mock_without_main_not_a', 'initdb']; $result = $Dispatcher->dispatch(); $this->assertTrue($result); } @@ -580,25 +577,25 @@ public function testDispatchNotAShellWithoutMain() { public function testShiftArgs() { $Dispatcher = new TestShellDispatcher(); - $Dispatcher->args = array('a', 'b', 'c'); + $Dispatcher->args = ['a', 'b', 'c']; $this->assertEquals('a', $Dispatcher->shiftArgs()); - $this->assertSame($Dispatcher->args, array('b', 'c')); + $this->assertSame($Dispatcher->args, ['b', 'c']); - $Dispatcher->args = array('a' => 'b', 'c', 'd'); + $Dispatcher->args = ['a' => 'b', 'c', 'd']; $this->assertEquals('b', $Dispatcher->shiftArgs()); - $this->assertSame($Dispatcher->args, array('c', 'd')); + $this->assertSame($Dispatcher->args, ['c', 'd']); - $Dispatcher->args = array('a', 'b' => 'c', 'd'); + $Dispatcher->args = ['a', 'b' => 'c', 'd']; $this->assertEquals('a', $Dispatcher->shiftArgs()); - $this->assertSame($Dispatcher->args, array('b' => 'c', 'd')); + $this->assertSame($Dispatcher->args, ['b' => 'c', 'd']); - $Dispatcher->args = array(0 => 'a', 2 => 'b', 30 => 'c'); + $Dispatcher->args = [0 => 'a', 2 => 'b', 30 => 'c']; $this->assertEquals('a', $Dispatcher->shiftArgs()); - $this->assertSame($Dispatcher->args, array(0 => 'b', 1 => 'c')); + $this->assertSame($Dispatcher->args, [0 => 'b', 1 => 'c']); - $Dispatcher->args = array(); + $Dispatcher->args = []; $this->assertNull($Dispatcher->shiftArgs()); - $this->assertSame(array(), $Dispatcher->args); + $this->assertSame([], $Dispatcher->args); } } diff --git a/lib/Cake/Test/Case/Console/ShellTest.php b/lib/Cake/Test/Case/Console/ShellTest.php index 1886eac575..4da60a976a 100644 --- a/lib/Cake/Test/Case/Console/ShellTest.php +++ b/lib/Cake/Test/Case/Console/ShellTest.php @@ -93,9 +93,9 @@ public function useLogger($enable = true) { */ class TestMergeShell extends Shell { - public $tasks = array('DbConfig', 'Fixture'); + public $tasks = ['DbConfig', 'Fixture']; - public $uses = array('Comment'); + public $uses = ['Comment']; } @@ -127,10 +127,10 @@ class ShellTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.post', 'core.comment', 'core.article', 'core.user', 'core.tag', 'core.articles_tag', 'core.attachment' - ); + ]; /** * setUp method @@ -140,9 +140,9 @@ class ShellTest extends CakeTestCase { public function setUp() : void { parent::setUp(); - $output = $this->getMock('ConsoleOutput', array(), array(), '', false); - $error = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $output = $this->getMock('ConsoleOutput', [], [], '', false); + $error = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); $this->Shell = new ShellTestShell($output, $error, $in); if (is_dir(TMP . 'shell_test')) { @@ -169,17 +169,17 @@ public function testConstruct() { * @return void */ public function testMergeVars() { - $this->Shell->tasks = array('DbConfig' => array('one', 'two')); - $this->Shell->uses = array('Posts'); - $this->Shell->mergeVars(array('tasks'), 'TestMergeShell'); - $this->Shell->mergeVars(array('uses'), 'TestMergeShell', false); + $this->Shell->tasks = ['DbConfig' => ['one', 'two']]; + $this->Shell->uses = ['Posts']; + $this->Shell->mergeVars(['tasks'], 'TestMergeShell'); + $this->Shell->mergeVars(['uses'], 'TestMergeShell', false); - $expected = array('DbConfig' => null, 'Fixture' => null, 'DbConfig' => array('one', 'two')); + $expected = ['DbConfig' => null, 'Fixture' => null, 'DbConfig' => ['one', 'two']]; $this->assertEquals($expected, $this->Shell->tasks); - $expected = array('Fixture' => null, 'DbConfig' => array('one', 'two')); + $expected = ['Fixture' => null, 'DbConfig' => ['one', 'two']]; $this->assertEquals($expected, Hash::normalize($this->Shell->tasks), 'Normalized results are wrong.'); - $this->assertEquals(array('Comment', 'Posts'), $this->Shell->uses, 'Merged models are wrong.'); + $this->assertEquals(['Comment', 'Posts'], $this->Shell->uses, 'Merged models are wrong.'); } /** @@ -188,14 +188,14 @@ public function testMergeVars() { * @return void */ public function testInitialize() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); - $this->Shell->tasks = array('DbConfig' => array('one', 'two')); - $this->Shell->uses = array('TestPlugin.TestPluginPost'); + $this->Shell->tasks = ['DbConfig' => ['one', 'two']]; + $this->Shell->uses = ['TestPlugin.TestPluginPost']; $this->Shell->initialize(); $this->assertTrue(isset($this->Shell->TestPluginPost)); @@ -203,7 +203,7 @@ public function testInitialize() { $this->assertEquals('TestPluginPost', $this->Shell->modelClass); CakePlugin::unload('TestPlugin'); - $this->Shell->uses = array('Comment'); + $this->Shell->uses = ['Comment']; $this->Shell->initialize(); $this->assertTrue(isset($this->Shell->Comment)); $this->assertInstanceOf('Comment', $this->Shell->Comment); @@ -219,10 +219,10 @@ public function testInitialize() { * @return void */ public function testLoadModel() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS] + ], App::RESET); $Shell = new TestMergeShell(); $this->assertEquals('Comment', $Shell->Comment->alias); @@ -269,10 +269,10 @@ public function testIn() { ->method('read') ->will($this->returnValue('0')); - $result = $this->Shell->in('Just a test?', array('y', 'n'), 'n'); + $result = $this->Shell->in('Just a test?', ['y', 'n'], 'n'); $this->assertEquals('n', $result); - $result = $this->Shell->in('Just a test?', array('y', 'n'), 'n'); + $result = $this->Shell->in('Just a test?', ['y', 'n'], 'n'); $this->assertEquals('Y', $result); $result = $this->Shell->in('Just a test?', 'y,n', 'n'); @@ -284,7 +284,7 @@ public function testIn() { $result = $this->Shell->in('Just a test?', 'y', 'y'); $this->assertEquals('y', $result); - $result = $this->Shell->in('Just a test?', array(0, 1, 2), '0'); + $result = $this->Shell->in('Just a test?', [0, 1, 2], '0'); $this->assertEquals('0', $result); } @@ -312,11 +312,11 @@ public function testOut() { $this->Shell->stdout->expects($this->at(1)) ->method('write') - ->with(array('Just', 'a', 'test'), 1); + ->with(['Just', 'a', 'test'], 1); $this->Shell->stdout->expects($this->at(2)) ->method('write') - ->with(array('Just', 'a', 'test'), 2); + ->with(['Just', 'a', 'test'], 2); $this->Shell->stdout->expects($this->at(3)) ->method('write') @@ -324,9 +324,9 @@ public function testOut() { $this->Shell->out('Just a test'); - $this->Shell->out(array('Just', 'a', 'test')); + $this->Shell->out(['Just', 'a', 'test']); - $this->Shell->out(array('Just', 'a', 'test'), 2); + $this->Shell->out(['Just', 'a', 'test'], 2); $this->Shell->out(); } @@ -411,11 +411,11 @@ public function testErr() { $this->Shell->stderr->expects($this->at(1)) ->method('write') - ->with(array('Just', 'a', 'test'), 1); + ->with(['Just', 'a', 'test'], 1); $this->Shell->stderr->expects($this->at(2)) ->method('write') - ->with(array('Just', 'a', 'test'), 2); + ->with(['Just', 'a', 'test'], 2); $this->Shell->stderr->expects($this->at(3)) ->method('write') @@ -423,9 +423,9 @@ public function testErr() { $this->Shell->err('Just a test'); - $this->Shell->err(array('Just', 'a', 'test')); + $this->Shell->err(['Just', 'a', 'test']); - $this->Shell->err(array('Just', 'a', 'test'), 2); + $this->Shell->err(['Just', 'a', 'test'], 2); $this->Shell->err(); } @@ -518,10 +518,10 @@ public function testLoadTasks() { $this->Shell->tasks = true; $this->assertTrue($this->Shell->loadTasks()); - $this->Shell->tasks = array(); + $this->Shell->tasks = []; $this->assertTrue($this->Shell->loadTasks()); - $this->Shell->tasks = array('TestApple'); + $this->Shell->tasks = ['TestApple']; $this->assertTrue($this->Shell->loadTasks()); $this->assertInstanceOf('TestAppleTask', $this->Shell->TestApple); @@ -532,7 +532,7 @@ public function testLoadTasks() { unset($this->Shell->ShellTestApple, $this->Shell->TestBanana); - $this->Shell->tasks = array('TestApple', 'TestBanana'); + $this->Shell->tasks = ['TestApple', 'TestBanana']; $this->assertTrue($this->Shell->loadTasks()); $this->assertInstanceOf('TestAppleTask', $this->Shell->TestApple); $this->assertInstanceOf('TestBananaTask', $this->Shell->TestBanana); @@ -544,13 +544,13 @@ public function testLoadTasks() { * @return void */ public function testMagicGetArgAndParamReferences() { - $this->Shell->tasks = array('TestApple'); - $this->Shell->args = array('one'); - $this->Shell->params = array('help' => false); + $this->Shell->tasks = ['TestApple']; + $this->Shell->args = ['one']; + $this->Shell->params = ['help' => false]; $this->Shell->loadTasks(); $result = $this->Shell->TestApple; - $this->Shell->args = array('one', 'two'); + $this->Shell->args = ['one', 'two']; $this->assertSame($this->Shell->args, $result->args); $this->assertSame($this->Shell->params, $result->params); @@ -692,7 +692,7 @@ public function testCreateFileNoPermissions() { * @return void */ public function testHasTask() { - $this->Shell->tasks = array('Extract', 'DbConfig'); + $this->Shell->tasks = ['Extract', 'DbConfig']; $this->Shell->loadTasks(); $this->assertTrue($this->Shell->hasTask('extract')); @@ -721,10 +721,10 @@ public function testHasMethod() { * @return void */ public function testRunCommandMain() { - $Mock = $this->getMock('Shell', array('main', 'startup'), array(), '', false); + $Mock = $this->getMock('Shell', ['main', 'startup'], [], '', false); $Mock->expects($this->once())->method('main')->will($this->returnValue(true)); - $result = $Mock->runCommand('', array()); + $result = $Mock->runCommand('', []); $this->assertTrue($result); } @@ -734,10 +734,10 @@ public function testRunCommandMain() { * @return void */ public function testRunCommandWithMethod() { - $Mock = $this->getMock('Shell', array('hit_me', 'startup'), array(), '', false); + $Mock = $this->getMock('Shell', ['hit_me', 'startup'], [], '', false); $Mock->expects($this->once())->method('hit_me')->will($this->returnValue(true)); - $result = $Mock->runCommand('hit_me', array()); + $result = $Mock->runCommand('hit_me', []); $this->assertTrue($result); } @@ -747,13 +747,13 @@ public function testRunCommandWithMethod() { * @return void */ public function testRunCommandBaseclassMethod() { - $Mock = $this->getMock('Shell', array('startup', 'getOptionParser', 'out'), array(), '', false); - $Parser = $this->getMock('ConsoleOptionParser', array(), array(), '', false); + $Mock = $this->getMock('Shell', ['startup', 'getOptionParser', 'out'], [], '', false); + $Parser = $this->getMock('ConsoleOptionParser', [], [], '', false); $Parser->expects($this->once())->method('help'); $Mock->expects($this->once())->method('getOptionParser') ->will($this->returnValue($Parser)); $Mock->expects($this->once())->method('out'); - $Mock->runCommand('hr', array()); + $Mock->runCommand('hr', []); } /** @@ -762,13 +762,13 @@ public function testRunCommandBaseclassMethod() { * @return void */ public function testRunCommandMissingMethod() { - $Mock = $this->getMock('Shell', array('startup', 'getOptionParser', 'out'), array(), '', false); - $Parser = $this->getMock('ConsoleOptionParser', array(), array(), '', false); + $Mock = $this->getMock('Shell', ['startup', 'getOptionParser', 'out'], [], '', false); + $Parser = $this->getMock('ConsoleOptionParser', [], [], '', false); $Parser->expects($this->once())->method('help'); $Mock->expects($this->once())->method('getOptionParser') ->will($this->returnValue($Parser)); $Mock->expects($this->once())->method('out'); - $result = $Mock->runCommand('idontexist', array()); + $result = $Mock->runCommand('idontexist', []); $this->assertFalse($result); } @@ -778,24 +778,24 @@ public function testRunCommandMissingMethod() { * @return void */ public function testRunCommandUnknownOption() { - $output = $this->getMock('ConsoleOutput', array(), array(), '', false); - $error = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); + $output = $this->getMock('ConsoleOutput', [], [], '', false); + $error = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); - $Parser = $this->getMock('ConsoleOptionParser', array(), array(), '', false); + $Parser = $this->getMock('ConsoleOptionParser', [], [], '', false); $Parser->expects($this->once())->method('parse') - ->with(array('--unknown')) + ->with(['--unknown']) ->will($this->throwException(new ConsoleException('Unknown option `unknown`'))); $Parser->expects($this->once())->method('help'); - $Shell = $this->getMock('ShellTestShell', array('getOptionParser'), array($output, $error, $in)); + $Shell = $this->getMock('ShellTestShell', ['getOptionParser'], [$output, $error, $in]); $Shell->expects($this->once())->method('getOptionParser') ->will($this->returnValue($Parser)); $Shell->stderr->expects($this->once())->method('write'); $Shell->stdout->expects($this->once())->method('write'); - $Shell->runCommand('do_something', array('do_something', '--unknown')); + $Shell->runCommand('do_something', ['do_something', '--unknown']); } /** @@ -804,18 +804,18 @@ public function testRunCommandUnknownOption() { * @return void */ public function testRunCommandTriggeringHelp() { - $Parser = $this->getMock('ConsoleOptionParser', array(), array(), '', false); + $Parser = $this->getMock('ConsoleOptionParser', [], [], '', false); $Parser->expects($this->once())->method('parse') - ->with(array('--help')) - ->will($this->returnValue(array(array('help' => true), array()))); + ->with(['--help']) + ->will($this->returnValue([['help' => true], []])); $Parser->expects($this->once())->method('help'); - $Shell = $this->getMock('Shell', array('getOptionParser', 'out', 'startup', '_welcome'), array(), '', false); + $Shell = $this->getMock('Shell', ['getOptionParser', 'out', 'startup', '_welcome'], [], '', false); $Shell->expects($this->once())->method('getOptionParser') ->will($this->returnValue($Parser)); $Shell->expects($this->once())->method('out'); - $Shell->runCommand('', array('--help')); + $Shell->runCommand('', ['--help']); } /** @@ -824,11 +824,11 @@ public function testRunCommandTriggeringHelp() { * @return void */ public function testRunCommandHittingTask() { - $Shell = $this->getMock('Shell', array('hasTask', 'startup'), array(), '', false); - $task = $this->getMock('Shell', array('execute', 'runCommand'), array(), '', false); + $Shell = $this->getMock('Shell', ['hasTask', 'startup'], [], '', false); + $task = $this->getMock('Shell', ['execute', 'runCommand'], [], '', false); $task->expects($this->any()) ->method('runCommand') - ->with('execute', array('one', 'value')); + ->with('execute', ['one', 'value']); $Shell->expects($this->once())->method('startup'); $Shell->expects($this->any()) @@ -837,7 +837,7 @@ public function testRunCommandHittingTask() { $Shell->RunCommand = $task; - $Shell->runCommand('run_command', array('run_command', 'one', 'value')); + $Shell->runCommand('run_command', ['run_command', 'one', 'value']); } /** @@ -855,7 +855,7 @@ public function testWrapText() { TEXT; $this->assertTextEquals($expected, $result, 'Text not wrapped.'); - $result = $this->Shell->wrapText($text, array('indent' => ' ', 'width' => 33)); + $result = $this->Shell->wrapText($text, ['indent' => ' ', 'width' => 33]); $expected = <<Shell->tasks = array('TestApple'); + $this->Shell->tasks = ['TestApple']; $this->Shell->loadTasks(); $expected = 'TestApple'; $this->assertEquals($expected, $this->Shell->TestApple->name); @@ -882,12 +882,12 @@ public function testShellNaming() { * @dataProvider paramReadingDataProvider */ public function testParamReading($toRead, $expected) { - $this->Shell->params = array( + $this->Shell->params = [ 'key' => 'value', 'help' => false, 'emptykey' => '', 'truthy' => true - ); + ]; $this->assertSame($expected, $this->Shell->param($toRead)); } @@ -897,28 +897,28 @@ public function testParamReading($toRead, $expected) { * @return array */ public function paramReadingDataProvider() { - return array( - array( + return [ + [ 'key', 'value', - ), - array( + ], + [ 'help', false, - ), - array( + ], + [ 'emptykey', '', - ), - array( + ], + [ 'truthy', true, - ), - array( + ], + [ 'does_not_exist', null, - ) - ); + ] + ]; } /** @@ -951,13 +951,13 @@ public function testFileAndConsoleLogging() { // both file and console logging require_once CORE_TEST_CASES . DS . 'Log' . DS . 'Engine' . DS . 'ConsoleLogTest.php'; - $mock = $this->getMock('ConsoleLog', array('write'), array( - array('types' => 'error'), - )); - TestCakeLog::config('console', array( + $mock = $this->getMock('ConsoleLog', ['write'], [ + ['types' => 'error'], + ]); + TestCakeLog::config('console', [ 'engine' => 'Console', 'stream' => 'php://stderr', - )); + ]); TestCakeLog::replace('console', $mock); $mock->expects($this->once()) ->method('write') @@ -993,12 +993,12 @@ public function testProtectedUseLogger() { * @return void */ public function testQuietLog() { - $output = $this->getMock('ConsoleOutput', array(), array(), '', false); - $error = $this->getMock('ConsoleOutput', array(), array(), '', false); - $in = $this->getMock('ConsoleInput', array(), array(), '', false); - $this->Shell = $this->getMock('ShellTestShell', array('_useLogger'), array($output, $error, $in)); + $output = $this->getMock('ConsoleOutput', [], [], '', false); + $error = $this->getMock('ConsoleOutput', [], [], '', false); + $in = $this->getMock('ConsoleInput', [], [], '', false); + $this->Shell = $this->getMock('ShellTestShell', ['_useLogger'], [$output, $error, $in]); $this->Shell->expects($this->once())->method('_useLogger')->with(false); - $this->Shell->runCommand('foo', array('--quiet')); + $this->Shell->runCommand('foo', ['--quiet']); } /** @@ -1028,12 +1028,12 @@ public function testGetInvalidHelper() { */ public function testShellLoggersDoNotGetOverridden() { $shell = $this->getMock( - "Shell", array( + "Shell", [ "_loggerIsConfigured", "_configureStdOutLogger", "_configureStdErrLogger", - ), - array(), + ], + [], "", false ); diff --git a/lib/Cake/Test/Case/Console/TaskCollectionTest.php b/lib/Cake/Test/Case/Console/TaskCollectionTest.php index 8444427ce0..9bda388c08 100644 --- a/lib/Cake/Test/Case/Console/TaskCollectionTest.php +++ b/lib/Cake/Test/Case/Console/TaskCollectionTest.php @@ -39,8 +39,8 @@ class TaskCollectionTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $shell = $this->getMock('Shell', array(), array(), '', false); - $dispatcher = $this->getMock('ShellDispatcher', array(), array(), '', false); + $shell = $this->getMock('Shell', [], [], '', false); + $dispatcher = $this->getMock('ShellDispatcher', [], [], '', false); $this->Tasks = new TaskCollection($shell, $dispatcher); } @@ -65,7 +65,7 @@ public function testLoad() { $this->assertInstanceOf('DbConfigTask', $this->Tasks->DbConfig); $result = $this->Tasks->loaded(); - $this->assertEquals(array('DbConfig'), $result, 'loaded() results are wrong.'); + $this->assertEquals(['DbConfig'], $result, 'loaded() results are wrong.'); } /** @@ -74,7 +74,7 @@ public function testLoad() { * @return void */ public function testLoadWithEnableFalse() { - $result = $this->Tasks->load('DbConfig', array('enabled' => false)); + $result = $this->Tasks->load('DbConfig', ['enabled' => false]); $this->assertInstanceOf('DbConfigTask', $result); $this->assertInstanceOf('DbConfigTask', $this->Tasks->DbConfig); @@ -97,11 +97,11 @@ public function testLoadMissingTask() { * @return void */ public function testLoadPluginTask() { - $dispatcher = $this->getMock('ShellDispatcher', array(), array(), '', false); - $shell = $this->getMock('Shell', array(), array(), '', false); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + $dispatcher = $this->getMock('ShellDispatcher', [], [], '', false); + $shell = $this->getMock('Shell', [], [], '', false); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); $this->Tasks = new TaskCollection($shell, $dispatcher); @@ -121,14 +121,14 @@ public function testUnload() { $this->Tasks->load('DbConfig'); $result = $this->Tasks->loaded(); - $this->assertEquals(array('Extract', 'DbConfig'), $result, 'loaded tasks is wrong'); + $this->assertEquals(['Extract', 'DbConfig'], $result, 'loaded tasks is wrong'); $this->Tasks->unload('DbConfig'); $this->assertFalse(isset($this->Tasks->DbConfig)); $this->assertTrue(isset($this->Tasks->Extract)); $result = $this->Tasks->loaded(); - $this->assertEquals(array('Extract'), $result, 'loaded tasks is wrong'); + $this->assertEquals(['Extract'], $result, 'loaded tasks is wrong'); } /** @@ -137,19 +137,19 @@ public function testUnload() { * @return void */ public function testLoadWithAlias() { - $result = $this->Tasks->load('DbConfig', array('className' => 'DbConfigAliased')); + $result = $this->Tasks->load('DbConfig', ['className' => 'DbConfigAliased']); $this->assertInstanceOf('DbConfigAliasedTask', $result); $this->assertInstanceOf('DbConfigAliasedTask', $this->Tasks->DbConfig); $result = $this->Tasks->loaded(); - $this->assertEquals(array('DbConfig'), $result, 'loaded() results are wrong.'); + $this->assertEquals(['DbConfig'], $result, 'loaded() results are wrong.'); - $result = $this->Tasks->load('SomeTask', array('className' => 'TestPlugin.OtherTask')); + $result = $this->Tasks->load('SomeTask', ['className' => 'TestPlugin.OtherTask']); $this->assertInstanceOf('OtherTaskTask', $result); $this->assertInstanceOf('OtherTaskTask', $this->Tasks->SomeTask); $result = $this->Tasks->loaded(); - $this->assertEquals(array('DbConfig', 'SomeTask'), $result, 'loaded() results are wrong.'); + $this->assertEquals(['DbConfig', 'SomeTask'], $result, 'loaded() results are wrong.'); } } diff --git a/lib/Cake/Test/Case/Controller/ApplicationControllerTest.php b/lib/Cake/Test/Case/Controller/ApplicationControllerTest.php index 6c658b6d08..ca0968ca31 100644 --- a/lib/Cake/Test/Case/Controller/ApplicationControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ApplicationControllerTest.php @@ -30,13 +30,13 @@ public function __construct($request = null, $response = null) { public function next() { $sessionName = session_name(); $sessionId = $this->Session->id(); - return $this->redirect(array( + return $this->redirect([ 'controller' => 'trans_session_id', 'action' => 'next_step', - '?' => array( + '?' => [ $sessionName => $sessionId, - ), - )); + ], + ]); } } @@ -78,12 +78,12 @@ public function tearDown() : void { */ public function testRedirect() { $sessionId = 'o7k64tlhil9pakp89j6d8ovlqk'; - $this->testAction('/trans_session_id/next?CAKEPHP=' . $sessionId); + $this->testAction(); $this->assertStringContainsString('/trans_session_id/next_step?CAKEPHP=' . $sessionId, $this->headers['Location']); - $expectedConfig = array( + $expectedConfig = [ 'cookie' => 'CAKEPHP', 'timeout' => 240, - 'ini' => array( + 'ini' => [ 'session.use_trans_sid' => 1, 'session.cookie_path' => '/', 'session.cookie_lifetime' => 14400, @@ -92,11 +92,11 @@ public function testRedirect() { 'session.cookie_httponly' => 1, 'session.use_cookies' => 0, 'session.use_only_cookies' => 0, - ), + ], 'defaults' => 'php', 'cookieTimeout' => 240, 'cacheLimiter' => 'must-revalidate', - ); + ]; $actualConfig = Configure::read('Session'); $this->assertEquals($expectedConfig, $actualConfig); } diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php index 57d4854087..3621d3c0eb 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php @@ -21,7 +21,7 @@ App::uses('DbAcl', 'Controller/Component/Acl'); App::uses('AclNode', 'Model'); App::uses('Permission', 'Model'); -require_once dirname(dirname(dirname(dirname(__FILE__)))) . DS . 'Model' . DS . 'models.php'; +require_once dirname(__FILE__, 4) . DS . 'Model' . DS . 'models.php'; /** * AclNodeTwoTestBase class @@ -71,7 +71,7 @@ class AroTwoTest extends AclNodeTwoTestBase { * * @var array */ - public $hasAndBelongsToMany = array('AcoTwoTest' => array('with' => 'PermissionTwoTest')); + public $hasAndBelongsToMany = ['AcoTwoTest' => ['with' => 'PermissionTwoTest']]; } /** @@ -100,7 +100,7 @@ class AcoTwoTest extends AclNodeTwoTestBase { * * @var array */ - public $hasAndBelongsToMany = array('AroTwoTest' => array('with' => 'PermissionTwoTest')); + public $hasAndBelongsToMany = ['AroTwoTest' => ['with' => 'PermissionTwoTest']]; } /** @@ -136,7 +136,7 @@ class PermissionTwoTest extends Permission { * * @var array */ - public $belongsTo = array('AroTwoTest' => array('foreignKey' => 'aro_id'), 'AcoTwoTest' => array('foreignKey' => 'aco_id')); + public $belongsTo = ['AroTwoTest' => ['foreignKey' => 'aro_id'], 'AcoTwoTest' => ['foreignKey' => 'aco_id']]; /** * actsAs property @@ -181,7 +181,7 @@ class DbAclTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.aro_two', 'core.aco_two', 'core.aros_aco_two'); + public $fixtures = ['core.aro_two', 'core.aco_two', 'core.aros_aco_two']; /** * setUp method @@ -212,24 +212,24 @@ public function tearDown() : void { * @return void */ public function testCreate() { - $this->Acl->Aro->create(array('alias' => 'Chotchkey')); + $this->Acl->Aro->create(['alias' => 'Chotchkey']); $this->assertTrue((bool)$this->Acl->Aro->save()); $parent = $this->Acl->Aro->id; - $this->Acl->Aro->create(array('parent_id' => $parent, 'alias' => 'Joanna')); + $this->Acl->Aro->create(['parent_id' => $parent, 'alias' => 'Joanna']); $this->assertTrue((bool)$this->Acl->Aro->save()); - $this->Acl->Aro->create(array('parent_id' => $parent, 'alias' => 'Stapler')); + $this->Acl->Aro->create(['parent_id' => $parent, 'alias' => 'Stapler']); $this->assertTrue((bool)$this->Acl->Aro->save()); $root = $this->Acl->Aco->node('ROOT'); $parent = $root[0]['AcoTwoTest']['id']; - $this->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'Drinks')); + $this->Acl->Aco->create(['parent_id' => $parent, 'alias' => 'Drinks']); $this->assertTrue((bool)$this->Acl->Aco->save()); - $this->Acl->Aco->create(array('parent_id' => $parent, 'alias' => 'PiecesOfFlair')); + $this->Acl->Aco->create(['parent_id' => $parent, 'alias' => 'PiecesOfFlair']); $this->assertTrue((bool)$this->Acl->Aco->save()); } @@ -241,12 +241,12 @@ public function testCreate() { public function testCreateWithParent() { $parent = $this->Acl->Aro->findByAlias('Peter', null, null, -1); $this->Acl->Aro->create(); - $this->Acl->Aro->save(array( + $this->Acl->Aro->save([ 'alias' => 'Subordinate', 'model' => 'User', 'foreign_key' => 7, 'parent_id' => $parent['AroTwoTest']['id'] - )); + ]); $result = $this->Acl->Aro->findByAlias('Subordinate', null, null, -1); $this->assertEquals(16, $result['AroTwoTest']['lft']); $this->assertEquals(17, $result['AroTwoTest']['rght']); @@ -259,7 +259,7 @@ public function testCreateWithParent() { */ public function testAllow() { $this->assertFalse($this->Acl->check('Micheal', 'tpsReports', 'read')); - $this->assertTrue($this->Acl->allow('Micheal', 'tpsReports', array('read', 'delete', 'update'))); + $this->assertTrue($this->Acl->allow('Micheal', 'tpsReports', ['read', 'delete', 'update'])); $this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'update')); $this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'read')); $this->assertTrue($this->Acl->check('Micheal', 'tpsReports', 'delete')); @@ -392,7 +392,7 @@ public function testDeny() { $this->assertFalse($this->Acl->check('Samir', 'refill', 'read')); $this->assertFalse($this->Acl->check('Samir', 'refill', 'delete')); - $result = $this->Acl->Aro->Permission->find('all', array('conditions' => array('AroTwoTest.alias' => 'Samir'))); + $result = $this->Acl->Aro->Permission->find('all', ['conditions' => ['AroTwoTest.alias' => 'Samir']]); $expected = '-1'; $this->assertEquals($expected, $result[0]['PermissionTwoTest']['_delete']); @@ -406,20 +406,20 @@ public function testDeny() { */ public function testAclNodeLookup() { $result = $this->Acl->Aro->node('root/users/Samir'); - $expected = array( - array('AroTwoTest' => array('id' => '7', 'parent_id' => '4', 'model' => 'User', 'foreign_key' => 3, 'alias' => 'Samir')), - array('AroTwoTest' => array('id' => '4', 'parent_id' => '1', 'model' => 'Group', 'foreign_key' => 3, 'alias' => 'users')), - array('AroTwoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'root')) - ); + $expected = [ + ['AroTwoTest' => ['id' => '7', 'parent_id' => '4', 'model' => 'User', 'foreign_key' => 3, 'alias' => 'Samir']], + ['AroTwoTest' => ['id' => '4', 'parent_id' => '1', 'model' => 'Group', 'foreign_key' => 3, 'alias' => 'users']], + ['AroTwoTest' => ['id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'root']] + ]; $this->assertEquals($expected, $result); $result = $this->Acl->Aco->node('ROOT/tpsReports/view/current'); - $expected = array( - array('AcoTwoTest' => array('id' => '4', 'parent_id' => '3', 'model' => null, 'foreign_key' => null, 'alias' => 'current')), - array('AcoTwoTest' => array('id' => '3', 'parent_id' => '2', 'model' => null, 'foreign_key' => null, 'alias' => 'view')), - array('AcoTwoTest' => array('id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'tpsReports')), - array('AcoTwoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT')), - ); + $expected = [ + ['AcoTwoTest' => ['id' => '4', 'parent_id' => '3', 'model' => null, 'foreign_key' => null, 'alias' => 'current']], + ['AcoTwoTest' => ['id' => '3', 'parent_id' => '2', 'model' => null, 'foreign_key' => null, 'alias' => 'view']], + ['AcoTwoTest' => ['id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'tpsReports']], + ['AcoTwoTest' => ['id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'ROOT']], + ]; $this->assertEquals($expected, $result); } @@ -446,19 +446,19 @@ public function testInherit() { * @return void */ public function testInheritParentDeny() { - $this->Acl->Aco->create(array('parent_id' => null, 'alias' => 'world')); + $this->Acl->Aco->create(['parent_id' => null, 'alias' => 'world']); $this->Acl->Aco->save(); - $this->Acl->Aco->create(array('parent_id' => $this->Acl->Aco->id, 'alias' => 'town')); + $this->Acl->Aco->create(['parent_id' => $this->Acl->Aco->id, 'alias' => 'town']); $this->Acl->Aco->save(); - $this->Acl->Aco->create(array('parent_id' => null, 'alias' => 'bizzaro_world')); + $this->Acl->Aco->create(['parent_id' => null, 'alias' => 'bizzaro_world']); $this->Acl->Aco->save(); - $this->Acl->Aco->create(array('parent_id' => $this->Acl->Aco->id, 'alias' => 'bizzaro_town')); + $this->Acl->Aco->create(['parent_id' => $this->Acl->Aco->id, 'alias' => 'bizzaro_town']); $this->Acl->Aco->save(); - $this->Acl->Aro->create(array('parent_id' => null, 'alias' => 'Jane')); + $this->Acl->Aro->create(['parent_id' => null, 'alias' => 'Jane']); $this->Acl->Aro->save(); // Setup deny on create for parent @@ -494,7 +494,7 @@ public function testGrant() { $this->assertTrue($this->Acl->check('Samir', 'tpsReports', 'create')); $this->assertFalse($this->Acl->check('Micheal', 'view', 'read')); - $this->Acl->allow('Micheal', 'view', array('read', 'create', 'update')); + $this->Acl->allow('Micheal', 'view', ['read', 'create', 'update']); $this->assertTrue($this->Acl->check('Micheal', 'view', 'read')); $this->assertTrue($this->Acl->check('Micheal', 'view', 'create')); $this->assertTrue($this->Acl->check('Micheal', 'view', 'update')); @@ -535,12 +535,12 @@ public function testRevoke() { protected function _debug($printTreesToo = false) { $this->Acl->Aro->displayField = 'alias'; $this->Acl->Aco->displayField = 'alias'; - $aros = $this->Acl->Aro->find('list', array('order' => 'lft')); - $acos = $this->Acl->Aco->find('list', array('order' => 'lft')); - $rights = array('*', 'create', 'read', 'update', 'delete'); + $aros = $this->Acl->Aro->find('list', ['order' => 'lft']); + $acos = $this->Acl->Aco->find('list', ['order' => 'lft']); + $rights = ['*', 'create', 'read', 'update', 'delete']; $permissions['Aros v Acos >'] = $acos; foreach ($aros as $aro) { - $row = array(); + $row = []; foreach ($acos as $aco) { $perms = ''; foreach ($rights as $right) { @@ -560,13 +560,13 @@ protected function _debug($printTreesToo = false) { } foreach ($permissions as $key => $values) { array_unshift($values, $key); - $values = array_map(array(&$this, '_pad'), $values); + $values = array_map([&$this, '_pad'], $values); $permissions[$key] = implode(' ', $values); } - $permissions = array_map(array(&$this, '_pad'), $permissions); + $permissions = array_map([&$this, '_pad'], $permissions); array_unshift($permissions, 'Current Permissions :'); if ($printTreesToo) { - debug(array('aros' => $this->Acl->Aro->generateTreeList(), 'acos' => $this->Acl->Aco->generateTreeList())); + debug(['aros' => $this->Acl->Aro->generateTreeList(), 'acos' => $this->Acl->Aco->generateTreeList()]); } debug(implode("\r\n", $permissions)); } diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php index 0301b678ab..6c4689288c 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/IniAclTest.php @@ -60,9 +60,9 @@ public function testCheckArray() { $Ini->config = $Ini->readConfigFile($iniFile); $Ini->userPath = 'User.username'; - $user = array( - 'User' => array('username' => 'admin') - ); + $user = [ + 'User' => ['username' => 'admin'] + ]; $this->assertTrue($Ini->check($user, 'posts')); } } diff --git a/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php b/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php index 07bfdc0370..612085cb43 100644 --- a/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Acl/PhpAclTest.php @@ -37,11 +37,11 @@ public function setUp() : void { Configure::write('Acl.classname', 'PhpAcl'); $Collection = new ComponentCollection(); $this->PhpAcl = new PhpAcl(); - $this->Acl = new AclComponent($Collection, array( - 'adapter' => array( + $this->Acl = new AclComponent($Collection, [ + 'adapter' => [ 'config' => CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'acl.php', - ), - )); + ], + ]); } /** @@ -51,14 +51,14 @@ public function setUp() : void { */ public function testRoleInheritance() { $roles = $this->Acl->Aro->roles('User/peter'); - $this->assertEquals(array('Role/accounting'), $roles[0]); - $this->assertEquals(array('User/peter'), $roles[1]); + $this->assertEquals(['Role/accounting'], $roles[0]); + $this->assertEquals(['User/peter'], $roles[1]); $roles = $this->Acl->Aro->roles('hardy'); - $this->assertEquals(array('Role/database_manager', 'Role/data_acquirer'), $roles[0]); - $this->assertEquals(array('Role/accounting', 'Role/data_analyst'), $roles[1]); - $this->assertEquals(array('Role/accounting_manager', 'Role/reports'), $roles[2]); - $this->assertEquals(array('User/hardy'), $roles[3]); + $this->assertEquals(['Role/database_manager', 'Role/data_acquirer'], $roles[0]); + $this->assertEquals(['Role/accounting', 'Role/data_analyst'], $roles[1]); + $this->assertEquals(['Role/accounting_manager', 'Role/reports'], $roles[2]); + $this->assertEquals(['User/hardy'], $roles[3]); } /** @@ -67,9 +67,9 @@ public function testRoleInheritance() { * @return void */ public function testAddRole() { - $this->assertEquals(array(array(PhpAro::DEFAULT_ROLE)), $this->Acl->Aro->roles('foobar')); - $this->Acl->Aro->addRole(array('User/foobar' => 'Role/accounting')); - $this->assertEquals(array(array('Role/accounting'), array('User/foobar')), $this->Acl->Aro->roles('foobar')); + $this->assertEquals([[PhpAro::DEFAULT_ROLE]], $this->Acl->Aro->roles('foobar')); + $this->Acl->Aro->addRole(['User/foobar' => 'Role/accounting']); + $this->assertEquals([['Role/accounting'], ['User/foobar']], $this->Acl->Aro->roles('foobar')); } /** @@ -78,16 +78,16 @@ public function testAddRole() { * @return void */ public function testAroResolve() { - $this->Acl->Aro->map = array( + $this->Acl->Aro->map = [ 'User' => 'FooModel/nickname', 'Role' => 'FooModel/role', - ); + ]; $this->assertEquals('Role/default', $this->Acl->Aro->resolve('Foo.bar')); $this->assertEquals('User/hardy', $this->Acl->Aro->resolve('FooModel/hardy')); $this->assertEquals('User/hardy', $this->Acl->Aro->resolve('hardy')); - $this->assertEquals('User/hardy', $this->Acl->Aro->resolve(array('FooModel' => array('nickname' => 'hardy')))); - $this->assertEquals('Role/admin', $this->Acl->Aro->resolve(array('FooModel' => array('role' => 'admin')))); + $this->assertEquals('User/hardy', $this->Acl->Aro->resolve(['FooModel' => ['nickname' => 'hardy']])); + $this->assertEquals('Role/admin', $this->Acl->Aro->resolve(['FooModel' => ['role' => 'admin']])); $this->assertEquals('Role/admin', $this->Acl->Aro->resolve('Role/admin')); $this->assertEquals('Role/admin', $this->Acl->Aro->resolve('admin')); @@ -95,7 +95,7 @@ public function testAroResolve() { $this->assertEquals('Role/accounting', $this->Acl->Aro->resolve('accounting')); $this->assertEquals(PhpAro::DEFAULT_ROLE, $this->Acl->Aro->resolve('bla')); - $this->assertEquals(PhpAro::DEFAULT_ROLE, $this->Acl->Aro->resolve(array('FooModel' => array('role' => 'hardy')))); + $this->assertEquals(PhpAro::DEFAULT_ROLE, $this->Acl->Aro->resolve(['FooModel' => ['role' => 'hardy']])); } /** @@ -104,22 +104,22 @@ public function testAroResolve() { * @return void */ public function testAroAliases() { - $this->Acl->Aro->map = array( + $this->Acl->Aro->map = [ 'User' => 'User/username', 'Role' => 'User/group_id', - ); + ]; - $this->Acl->Aro->aliases = array( + $this->Acl->Aro->aliases = [ 'Role/1' => 'Role/admin', 'Role/24' => 'Role/accounting', - ); + ]; - $user = array( - 'User' => array( + $user = [ + 'User' => [ 'username' => 'unknown_user', 'group_id' => '1', - ), - ); + ], + ]; // group/1 $this->assertEquals('Role/admin', $this->Acl->Aro->resolve($user)); // group/24 @@ -127,18 +127,18 @@ public function testAroAliases() { $this->assertEquals('Role/accounting', $this->Acl->Aro->resolve('24')); // check department - $user = array( - 'User' => array( + $user = [ + 'User' => [ 'username' => 'foo', 'group_id' => '25', - ), - ); + ], + ]; - $this->Acl->Aro->addRole(array('Role/IT' => null)); - $this->Acl->Aro->addAlias(array('Role/25' => 'Role/IT')); + $this->Acl->Aro->addRole(['Role/IT' => null]); + $this->Acl->Aro->addAlias(['Role/25' => 'Role/IT']); $this->Acl->allow('Role/IT', '/rules/debugging/*'); - $this->assertEquals(array(array('Role/IT')), $this->Acl->Aro->roles($user)); + $this->assertEquals([['Role/IT']], $this->Acl->Aro->roles($user)); $this->assertTrue($this->Acl->check($user, '/rules/debugging/stats/pageload')); $this->assertTrue($this->Acl->check($user, '/rules/debugging/sql/queries')); // Role/default is allowed users dashboard, but not Role/IT @@ -146,7 +146,7 @@ public function testAroAliases() { $this->assertFalse($this->Acl->check($user, '/controllers/invoices/send')); // wee add an more specific entry for user foo to also inherit from Role/accounting - $this->Acl->Aro->addRole(array('User/foo' => 'Role/IT, Role/accounting')); + $this->Acl->Aro->addRole(['User/foo' => 'Role/IT, Role/accounting']); $this->assertTrue($this->Acl->check($user, '/controllers/invoices/send')); } @@ -163,7 +163,7 @@ public function testCheck() { $this->assertTrue($this->Acl->check('jan', 'foo/bar')); $this->assertTrue($this->Acl->check('user/jan', 'foo/bar')); $this->assertTrue($this->Acl->check('Role/admin', 'controllers/bar')); - $this->assertTrue($this->Acl->check(array('User' => array('username' => 'jan')), '/controllers/bar/bll')); + $this->assertTrue($this->Acl->check(['User' => ['username' => 'jan']], '/controllers/bar/bll')); $this->assertTrue($this->Acl->check('Role/database_manager', 'controllers/db/create')); $this->assertTrue($this->Acl->check('User/db_manager_2', 'controllers/db/create')); $this->assertFalse($this->Acl->check('db_manager_2', '/controllers/users/Dashboard')); @@ -285,7 +285,7 @@ public function testDenyRuleIsStrongerThanAllowRule() { public function testInvalidConfigWithAroMissing() { $this->expectException('AclException'); $this->expectExceptionMessage('"roles" section not found in configuration'); - $config = array('aco' => array('allow' => array('foo' => ''))); + $config = ['aco' => ['allow' => ['foo' => '']]]; $this->PhpAcl->build($config); } @@ -293,9 +293,9 @@ public function testInvalidConfigWithAcosMissing() { $this->expectException('AclException'); $this->expectExceptionMessage('Neither "allow" nor "deny" rules were provided in configuration.'); - $config = array( - 'roles' => array('Role/foo' => null), - ); + $config = [ + 'roles' => ['Role/foo' => null], + ]; $this->PhpAcl->build($config); } @@ -306,19 +306,19 @@ public function testInvalidConfigWithAcosMissing() { * @return void */ public function testAcoResolve() { - $this->assertEquals(array('foo', 'bar'), $this->Acl->Aco->resolve('foo/bar')); - $this->assertEquals(array('foo', 'bar'), $this->Acl->Aco->resolve('foo/bar')); - $this->assertEquals(array('foo', 'bar', 'baz'), $this->Acl->Aco->resolve('foo/bar/baz')); - $this->assertEquals(array('foo', '*-bar', '?-baz'), $this->Acl->Aco->resolve('foo/*-bar/?-baz')); + $this->assertEquals(['foo', 'bar'], $this->Acl->Aco->resolve('foo/bar')); + $this->assertEquals(['foo', 'bar'], $this->Acl->Aco->resolve('foo/bar')); + $this->assertEquals(['foo', 'bar', 'baz'], $this->Acl->Aco->resolve('foo/bar/baz')); + $this->assertEquals(['foo', '*-bar', '?-baz'], $this->Acl->Aco->resolve('foo/*-bar/?-baz')); - $this->assertEquals(array('foo', 'bar', '[a-f0-9]{24}', '*_bla', 'bla'), $this->Acl->Aco->resolve('foo/bar/[a-f0-9]{24}/*_bla/bla')); + $this->assertEquals(['foo', 'bar', '[a-f0-9]{24}', '*_bla', 'bla'], $this->Acl->Aco->resolve('foo/bar/[a-f0-9]{24}/*_bla/bla')); // multiple slashes will be squashed to a single, trimmed and then exploded - $this->assertEquals(array('foo', 'bar'), $this->Acl->Aco->resolve('foo//bar')); - $this->assertEquals(array('foo', 'bar'), $this->Acl->Aco->resolve('//foo///bar/')); - $this->assertEquals(array('foo', 'bar'), $this->Acl->Aco->resolve('/foo//bar//')); - $this->assertEquals(array('foo', 'bar'), $this->Acl->Aco->resolve('/foo // bar')); - $this->assertEquals(array(), $this->Acl->Aco->resolve('/////')); + $this->assertEquals(['foo', 'bar'], $this->Acl->Aco->resolve('foo//bar')); + $this->assertEquals(['foo', 'bar'], $this->Acl->Aco->resolve('//foo///bar/')); + $this->assertEquals(['foo', 'bar'], $this->Acl->Aco->resolve('/foo//bar//')); + $this->assertEquals(['foo', 'bar'], $this->Acl->Aco->resolve('/foo // bar')); + $this->assertEquals([], $this->Acl->Aco->resolve('/////')); } /** @@ -327,20 +327,20 @@ public function testAcoResolve() { * @return void */ public function testAroDeclarationContainsCycles() { - $config = array( - 'roles' => array( + $config = [ + 'roles' => [ 'Role/a' => null, 'Role/b' => 'User/b', 'User/a' => 'Role/a, Role/b', 'User/b' => 'User/a', - ), - 'rules' => array( - 'allow' => array( + ], + 'rules' => [ + 'allow' => [ '*' => 'Role/a', - ), - ), - ); + ], + ], + ]; $this->expectError(); $this->expectErrorMessage('cycle detected'); diff --git a/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php index f59ce29309..2b2915a893 100644 --- a/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AclComponentTest.php @@ -34,7 +34,7 @@ class AclComponentTest extends CakeTestCase { public function setUp() : void { parent::setUp(); if (!class_exists('MockAclImplementation', false)) { - $this->getMock('AclInterface', array(), array(), 'MockAclImplementation'); + $this->getMock('AclInterface', [], [], 'MockAclImplementation'); } Configure::write('Acl.classname', 'MockAclImplementation'); $Collection = new ComponentCollection(); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ActionsAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ActionsAuthorizeTest.php index a18a2b9db9..8c2ffd90d6 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ActionsAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ActionsAuthorizeTest.php @@ -36,8 +36,8 @@ class ActionsAuthorizeTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->controller = $this->getMock('Controller', array(), array(), '', false); - $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); + $this->controller = $this->getMock('Controller', [], [], '', false); + $this->Acl = $this->getMock('AclComponent', [], [], '', false); $this->Collection = $this->getMock('ComponentCollection'); $this->auth = new ActionsAuthorize($this->Collection); @@ -62,18 +62,18 @@ protected function _mockAcl() { * @return void */ public function testAuthorizeFailure() { - $user = array( - 'User' => array( + $user = [ + 'User' => [ 'id' => 1, 'user' => 'mariano' - ) - ); + ] + ]; $request = new CakeRequest('/posts/index', false); - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'posts', 'action' => 'index' - )); + ]); $this->_mockAcl(); @@ -91,18 +91,18 @@ public function testAuthorizeFailure() { * @return void */ public function testAuthorizeSuccess() { - $user = array( - 'User' => array( + $user = [ + 'User' => [ 'id' => 1, 'user' => 'mariano' - ) - ); + ] + ]; $request = new CakeRequest('/posts/index', false); - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'posts', 'action' => 'index' - )); + ]); $this->_mockAcl(); @@ -121,21 +121,21 @@ public function testAuthorizeSuccess() { */ public function testAuthorizeSettings() { $request = new CakeRequest('/posts/index', false); - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'posts', 'action' => 'index' - )); + ]); $this->_mockAcl(); $this->auth->settings['userModel'] = 'TestPlugin.TestPluginAuthUser'; - $user = array( + $user = [ 'id' => 1, 'user' => 'mariano' - ); + ]; - $expected = array('TestPlugin.TestPluginAuthUser' => array('id' => 1, 'user' => 'mariano')); + $expected = ['TestPlugin.TestPluginAuthUser' => ['id' => 1, 'user' => 'mariano']]; $this->Acl->expects($this->once()) ->method('check') ->with($expected, 'controllers/Posts/index') @@ -151,11 +151,11 @@ public function testAuthorizeSettings() { */ public function testActionMethod() { $request = new CakeRequest('/posts/index', false); - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'posts', 'action' => 'index' - )); + ]); $result = $this->auth->action($request); $this->assertEquals('controllers/Posts/index', $result); @@ -169,11 +169,11 @@ public function testActionMethod() { public function testActionNoDoubleSlash() { $this->auth->settings['actionPath'] = '/controllers/'; $request = new CakeRequest('/posts/index', false); - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'posts', 'action' => 'index' - )); + ]); $result = $this->auth->action($request); $this->assertEquals('controllers/Posts/index', $result); } @@ -185,11 +185,11 @@ public function testActionNoDoubleSlash() { */ public function testActionWithPlugin() { $request = new CakeRequest('/debug_kit/posts/index', false); - $request->addParams(array( + $request->addParams([ 'plugin' => 'debug_kit', 'controller' => 'posts', 'action' => 'index' - )); + ]); $result = $this->auth->action($request); $this->assertEquals('controllers/DebugKit/Posts/index', $result); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php index 7da3634fa9..da149553f1 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php @@ -34,7 +34,7 @@ class BasicAuthenticateTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.user', 'core.auth_user', 'core.article'); + public $fixtures = ['core.user', 'core.auth_user', 'core.article']; /** * setup @@ -44,16 +44,16 @@ class BasicAuthenticateTest extends CakeTestCase { public function setUp() : void { parent::setUp(); $this->Collection = $this->getMock('ComponentCollection'); - $this->auth = new BasicAuthenticate($this->Collection, array( - 'fields' => array('username' => 'user', 'password' => 'password'), + $this->auth = new BasicAuthenticate($this->Collection, [ + 'fields' => ['username' => 'user', 'password' => 'password'], 'userModel' => 'User', 'realm' => 'localhost', 'recursive' => 0 - )); + ]); $password = Security::hash('password', null, true); $User = ClassRegistry::init('User'); - $User->updateAll(array('password' => $User->getDataSource()->value($password))); + $User->updateAll(['password' => $User->getDataSource()->value($password)]); $this->response = $this->getMock('CakeResponse'); } @@ -63,12 +63,12 @@ public function setUp() : void { * @return void */ public function testConstructor() { - $object = new BasicAuthenticate($this->Collection, array( + $object = new BasicAuthenticate($this->Collection, [ 'userModel' => 'AuthUser', - 'fields' => array('username' => 'user', 'password' => 'password') - )); + 'fields' => ['username' => 'user', 'password' => 'password'] + ]); $this->assertEquals('AuthUser', $object->settings['userModel']); - $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']); + $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->settings['fields']); $this->assertEquals(env('SERVER_NAME'), $object->settings['realm']); } @@ -118,7 +118,7 @@ public function testAuthenticateNoPassword() { */ public function testAuthenticateInjection() { $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_USER'] = '> 1'; $_SERVER['PHP_AUTH_PW'] = "' OR 1 = 1"; @@ -134,22 +134,22 @@ public function testAuthenticateInjection() { */ public function testAuthenticateUsernameZero() { $User = ClassRegistry::init('User'); - $User->updateAll(array('user' => $User->getDataSource()->value('0')), array('user' => 'mariano')); + $User->updateAll(['user' => $User->getDataSource()->value('0')], ['user' => 'mariano']); $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( + $request->data = ['User' => [ 'user' => '0', 'password' => 'password' - )); + ]]; $_SERVER['PHP_AUTH_USER'] = '0'; $_SERVER['PHP_AUTH_PW'] = 'password'; - $expected = array( + $expected = [ 'id' => 1, 'user' => '0', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertEquals($expected, $this->auth->authenticate($request, $this->response)); } @@ -160,7 +160,7 @@ public function testAuthenticateUsernameZero() { */ public function testAuthenticateChallenge() { $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); try { $this->auth->unauthenticated($request, $this->response); @@ -169,7 +169,7 @@ public function testAuthenticateChallenge() { $this->assertNotEmpty($e); - $expected = array('WWW-Authenticate: Basic realm="localhost"'); + $expected = ['WWW-Authenticate: Basic realm="localhost"']; $this->assertEquals($expected, $e->responseHeader()); } @@ -180,18 +180,18 @@ public function testAuthenticateChallenge() { */ public function testAuthenticateSuccess() { $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_USER'] = 'mariano'; $_SERVER['PHP_AUTH_PW'] = 'password'; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertEquals($expected, $result); } @@ -205,15 +205,15 @@ public function testAuthenticateSuccessFromHeaders() { unset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertEquals($expected, $result); } @@ -224,17 +224,17 @@ public function testAuthenticateSuccessFromHeaders() { */ public function testAuthenticateContainSuccess() { $User = ClassRegistry::init('User'); - $User->bindModel(array('hasMany' => array('Article'))); + $User->bindModel(['hasMany' => ['Article']]); $User->Behaviors->load('Containable'); $this->auth->settings['contain'] = 'Article'; $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_USER'] = 'mariano'; $_SERVER['PHP_AUTH_PW'] = 'password'; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', @@ -242,7 +242,7 @@ public function testAuthenticateContainSuccess() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ); + ]; $this->assertEquals($expected, $result['Article'][0]); } @@ -252,18 +252,18 @@ public function testAuthenticateContainSuccess() { * @return void */ public function testAuthenticateUserFieldsSuccess() { - $this->auth->settings['userFields'] = array('id', 'user'); + $this->auth->settings['userFields'] = ['id', 'user']; $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_USER'] = 'mariano'; $_SERVER['PHP_AUTH_PW'] = 'password'; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user' => 'mariano', - ); + ]; $this->assertEquals($expected, $result); } @@ -274,24 +274,24 @@ public function testAuthenticateUserFieldsSuccess() { */ public function testAuthenticateUserFieldsRelatedModelsSuccess() { $User = ClassRegistry::init('User'); - $User->bindModel(array('hasOne' => array( - 'Article' => array( + $User->bindModel(['hasOne' => [ + 'Article' => [ 'order' => 'Article.id ASC' - ) - ))); + ] + ]]); $this->auth->settings['recursive'] = 0; - $this->auth->settings['userFields'] = array('Article.id', 'Article.title'); + $this->auth->settings['userFields'] = ['Article.id', 'Article.title']; $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_USER'] = 'mariano'; $_SERVER['PHP_AUTH_PW'] = 'password'; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'title' => 'First Article', - ); + ]; $this->assertEquals($expected, $result['Article']); } @@ -303,9 +303,9 @@ public function testAuthenticateUserFieldsRelatedModelsSuccess() { public function testAuthenticateFailReChallenge() { $this->expectException(UnauthorizedException::class); $this->expectExceptionCode(401); - $this->auth->settings['scope'] = array('user' => 'nate'); + $this->auth->settings['scope'] = ['user' => 'nate']; $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_USER'] = 'mariano'; $_SERVER['PHP_AUTH_PW'] = 'password'; @@ -320,29 +320,29 @@ public function testAuthenticateFailReChallenge() { */ public function testAuthenticateWithBlowfish() { $hash = Security::hash('password', 'blowfish'); - $this->skipIf(strpos($hash, '$2a$') === false, 'Skipping blowfish tests as hashing is not working'); + $this->skipIf(!str_contains($hash, '$2a$'), 'Skipping blowfish tests as hashing is not working'); $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_USER'] = 'mariano'; $_SERVER['PHP_AUTH_PW'] = 'password'; $User = ClassRegistry::init('User'); $User->updateAll( - array('password' => $User->getDataSource()->value($hash)), - array('User.user' => 'mariano') + ['password' => $User->getDataSource()->value($hash)], + ['User.user' => 'mariano'] ); $this->auth->settings['passwordHasher'] = 'Blowfish'; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php index d62bdee01e..7467ac5a38 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/BlowfishAuthenticateTest.php @@ -32,7 +32,7 @@ */ class BlowfishAuthenticateTest extends CakeTestCase { - public $fixtures = array('core.user', 'core.auth_user'); + public $fixtures = ['core.user', 'core.auth_user']; /** * setup @@ -42,17 +42,17 @@ class BlowfishAuthenticateTest extends CakeTestCase { public function setUp() : void { parent::setUp(); $this->Collection = $this->getMock('ComponentCollection'); - $this->auth = new BlowfishAuthenticate($this->Collection, array( - 'fields' => array('username' => 'user', 'password' => 'password'), + $this->auth = new BlowfishAuthenticate($this->Collection, [ + 'fields' => ['username' => 'user', 'password' => 'password'], 'userModel' => 'User' - )); + ]); $password = Security::hash('password', 'blowfish'); $User = ClassRegistry::init('User'); - $User->updateAll(array('password' => $User->getDataSource()->value($password))); + $User->updateAll(['password' => $User->getDataSource()->value($password)]); $this->response = $this->getMock('CakeResponse'); $hash = Security::hash('password', 'blowfish'); - $this->skipIf(strpos($hash, '$2a$') === false, 'Skipping blowfish tests as hashing is not working'); + $this->skipIf(!str_contains($hash, '$2a$'), 'Skipping blowfish tests as hashing is not working'); } /** @@ -61,12 +61,12 @@ public function setUp() : void { * @return void */ public function testConstructor() { - $Object = new BlowfishAuthenticate($this->Collection, array( + $Object = new BlowfishAuthenticate($this->Collection, [ 'userModel' => 'AuthUser', - 'fields' => array('username' => 'user', 'password' => 'password') - )); + 'fields' => ['username' => 'user', 'password' => 'password'] + ]); $this->assertEquals('AuthUser', $Object->settings['userModel']); - $this->assertEquals(array('username' => 'user', 'password' => 'password'), $Object->settings['fields']); + $this->assertEquals(['username' => 'user', 'password' => 'password'], $Object->settings['fields']); } /** @@ -76,7 +76,7 @@ public function testConstructor() { */ public function testAuthenticateNoData() { $request = new CakeRequest('posts/index', false); - $request->data = array(); + $request->data = []; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -87,7 +87,7 @@ public function testAuthenticateNoData() { */ public function testAuthenticateNoUsername() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array('password' => 'foobar')); + $request->data = ['User' => ['password' => 'foobar']]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -98,7 +98,7 @@ public function testAuthenticateNoUsername() { */ public function testAuthenticateNoPassword() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array('user' => 'mariano')); + $request->data = ['User' => ['user' => 'mariano']]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -109,11 +109,11 @@ public function testAuthenticateNoPassword() { */ public function testAuthenticatePasswordIsFalse() { $request = new CakeRequest('posts/index', false); - $request->data = array( - 'User' => array( + $request->data = [ + 'User' => [ 'user' => 'mariano', 'password' => null - )); + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -124,10 +124,10 @@ public function testAuthenticatePasswordIsFalse() { */ public function testAuthenticateInjection() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( + $request->data = ['User' => [ 'user' => '> 1', 'password' => "' OR 1 = 1" - )); + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -138,17 +138,17 @@ public function testAuthenticateInjection() { */ public function testAuthenticateSuccess() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( + $request->data = ['User' => [ 'user' => 'mariano', 'password' => 'password' - )); + ]]; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - ); + ]; $this->assertEquals($expected, $result); } @@ -158,12 +158,12 @@ public function testAuthenticateSuccess() { * @return void */ public function testAuthenticateScopeFail() { - $this->auth->settings['scope'] = array('user' => 'nate'); + $this->auth->settings['scope'] = ['user' => 'nate']; $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( + $request->data = ['User' => [ 'user' => 'mariano', 'password' => 'password' - )); + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -174,9 +174,9 @@ public function testAuthenticateScopeFail() { */ public function testPluginModel() { Cache::delete('object_map', '_cake_core_'); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $PluginModel = ClassRegistry::init('TestPlugin.TestPluginAuthUser'); @@ -189,17 +189,17 @@ public function testPluginModel() { $this->auth->settings['fields']['username'] = 'username'; $request = new CakeRequest('posts/index', false); - $request->data = array('TestPluginAuthUser' => array( + $request->data = ['TestPluginAuthUser' => [ 'username' => 'gwoo', 'password' => 'password' - )); + ]]; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23' - ); + ]; $this->assertEquals(static::date(), $result['updated']); unset($result['updated']); $this->assertEquals($expected, $result); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php index a06c40fb8e..93560052fa 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/ControllerAuthorizeTest.php @@ -35,7 +35,7 @@ class ControllerAuthorizeTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->controller = $this->getMock('Controller', array('isAuthorized'), array(), '', false); + $this->controller = $this->getMock('Controller', ['isAuthorized'], [], '', false); $this->components = $this->getMock('ComponentCollection'); $this->components->expects($this->any()) ->method('getController') @@ -55,7 +55,7 @@ public function testControllerTypeError() { try { $this->auth->controller(new StdClass()); $this->fail('No exception thrown'); - } catch (TypeError $e) { + } catch (TypeError) { throw new \PHPUnit\Framework\Error('Raised an error', 100); } } @@ -76,7 +76,7 @@ public function testControllerErrorOnMissingMethod() { * @return void */ public function testAuthorizeFailure() { - $user = array(); + $user = []; $request = new CakeRequest('/posts/index', false); $this->assertFalse($this->auth->authorize($user, $request)); } @@ -87,7 +87,7 @@ public function testAuthorizeFailure() { * @return void */ public function testAuthorizeSuccess() { - $user = array('User' => array('username' => 'mark')); + $user = ['User' => ['username' => 'mark']]; $request = new CakeRequest('/posts/index', false); $this->controller->expects($this->once()) diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php index 784909e592..b1c4991b09 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/CrudAuthorizeTest.php @@ -36,10 +36,10 @@ class CrudAuthorizeTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - Configure::write('Routing.prefixes', array()); + Configure::write('Routing.prefixes', []); Router::reload(); - $this->Acl = $this->getMock('AclComponent', array(), array(), '', false); + $this->Acl = $this->getMock('AclComponent', [], [], '', false); $this->Components = $this->getMock('ComponentCollection'); $this->auth = new CrudAuthorize($this->Components); @@ -65,11 +65,11 @@ protected function _mockAcl() { public function testAuthorizeNoMappedAction() { $this->expectWarning(); $request = new CakeRequest('/posts/foobar', false); - $request->addParams(array( + $request->addParams([ 'controller' => 'posts', 'action' => 'foobar' - )); - $user = array('User' => array('user' => 'mark')); + ]); + $user = ['User' => ['user' => 'mark']]; $this->auth->authorize($user, $request); } @@ -81,11 +81,11 @@ public function testAuthorizeNoMappedAction() { */ public function testAuthorizeCheckSuccess() { $request = new CakeRequest('posts/index', false); - $request->addParams(array( + $request->addParams([ 'controller' => 'posts', 'action' => 'index' - )); - $user = array('User' => array('user' => 'mark')); + ]); + $user = ['User' => ['user' => 'mark']]; $this->_mockAcl(); $this->Acl->expects($this->once()) @@ -103,11 +103,11 @@ public function testAuthorizeCheckSuccess() { */ public function testAuthorizeCheckFailure() { $request = new CakeRequest('posts/index', false); - $request->addParams(array( + $request->addParams([ 'controller' => 'posts', 'action' => 'index' - )); - $user = array('User' => array('user' => 'mark')); + ]); + $user = ['User' => ['user' => 'mark']]; $this->_mockAcl(); $this->Acl->expects($this->once()) @@ -125,7 +125,7 @@ public function testAuthorizeCheckFailure() { */ public function testMapActionsGet() { $result = $this->auth->mapActions(); - $expected = array( + $expected = [ 'create' => 'create', 'read' => 'read', 'update' => 'update', @@ -135,7 +135,7 @@ public function testMapActionsGet() { 'edit' => 'update', 'view' => 'read', 'remove' => 'delete' - ); + ]; $this->assertEquals($expected, $result); } @@ -145,17 +145,17 @@ public function testMapActionsGet() { * @return void */ public function testMapActionsSet() { - $map = array( - 'create' => array('generate'), - 'read' => array('listing', 'show'), - 'update' => array('update'), + $map = [ + 'create' => ['generate'], + 'read' => ['listing', 'show'], + 'update' => ['update'], 'random' => 'custom' - ); + ]; $result = $this->auth->mapActions($map); $this->assertNull($result); $result = $this->auth->mapActions(); - $expected = array( + $expected = [ 'add' => 'create', 'create' => 'create', 'read' => 'read', @@ -169,7 +169,7 @@ public function testMapActionsSet() { 'show' => 'read', 'update' => 'update', 'random' => 'custom', - ); + ]; $this->assertEquals($expected, $result); } @@ -179,7 +179,7 @@ public function testMapActionsSet() { * @return void */ public function testAutoPrefixMapActions() { - Configure::write('Routing.prefixes', array('admin', 'manager')); + Configure::write('Routing.prefixes', ['admin', 'manager']); Router::reload(); $auth = new CrudAuthorize($this->Components); diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/DigestAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/DigestAuthenticateTest.php index d7fcd63ac8..f695e59038 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/DigestAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/DigestAuthenticateTest.php @@ -35,7 +35,7 @@ class DigestAuthenticateTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.user', 'core.auth_user'); + public $fixtures = ['core.user', 'core.auth_user']; /** * setup @@ -46,17 +46,17 @@ public function setUp() : void { parent::setUp(); $this->Collection = $this->getMock('ComponentCollection'); $this->server = $_SERVER; - $this->auth = new DigestAuthenticate($this->Collection, array( - 'fields' => array('username' => 'user', 'password' => 'password'), + $this->auth = new DigestAuthenticate($this->Collection, [ + 'fields' => ['username' => 'user', 'password' => 'password'], 'userModel' => 'User', 'realm' => 'localhost', 'nonce' => 123, 'opaque' => '123abc' - )); + ]); $password = DigestAuthenticate::password('mariano', 'cake', 'localhost'); $User = ClassRegistry::init('User'); - $User->updateAll(array('password' => $User->getDataSource()->value($password))); + $User->updateAll(['password' => $User->getDataSource()->value($password)]); $_SERVER['REQUEST_METHOD'] = 'GET'; $this->response = $this->getMock('CakeResponse'); @@ -78,13 +78,13 @@ public function tearDown() : void { * @return void */ public function testConstructor() { - $object = new DigestAuthenticate($this->Collection, array( + $object = new DigestAuthenticate($this->Collection, [ 'userModel' => 'AuthUser', - 'fields' => array('username' => 'user', 'password' => 'password'), + 'fields' => ['username' => 'user', 'password' => 'password'], 'nonce' => 123456 - )); + ]); $this->assertEquals('AuthUser', $object->settings['userModel']); - $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']); + $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->settings['fields']); $this->assertEquals(123456, $object->settings['nonce']); $this->assertEquals(env('SERVER_NAME'), $object->settings['realm']); } @@ -112,7 +112,7 @@ public function testAuthenticateWrongUsername() { $this->expectException(UnauthorizedException::class); $this->expectExceptionCode(401); $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_DIGEST'] = <<addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); try { $this->auth->unauthenticated($request, $this->response); @@ -145,7 +145,7 @@ public function testAuthenticateChallenge() { $this->assertNotEmpty($e); - $expected = array('WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"'); + $expected = ['WWW-Authenticate: Digest realm="localhost",qop="auth",nonce="123",opaque="123abc"']; $this->assertEquals($expected, $e->responseHeader()); } @@ -156,7 +156,7 @@ public function testAuthenticateChallenge() { */ public function testAuthenticateSuccess() { $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_DIGEST'] = <<auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertEquals($expected, $result); } @@ -188,9 +188,9 @@ public function testAuthenticateSuccess() { public function testAuthenticateFailReChallenge() { $this->expectException(UnauthorizedException::class); $this->expectExceptionCode(401); - $this->auth->settings['scope'] = array('user' => 'nate'); + $this->auth->settings['scope'] = ['user' => 'nate']; $request = new CakeRequest('posts/index', false); - $request->addParams(array('pass' => array(), 'named' => array())); + $request->addParams(['pass' => [], 'named' => []]); $_SERVER['PHP_AUTH_DIGEST'] = << 'Mufasa', 'realm' => 'testrealm@host.com', 'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093', @@ -234,7 +234,7 @@ public function testParseAuthData() { 'cnonce' => '0a4f113b', 'response' => '6629fae49393a05397450978507c4ef1', 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41' - ); + ]; $result = $this->auth->parseAuthData($digest); $this->assertSame($expected, $result); @@ -282,7 +282,7 @@ public function testParseAuthEmailAddress() { response="6629fae49393a05397450978507c4ef1", opaque="5ccc069c403ebaf9f0171e9517f40e41" DIGEST; - $expected = array( + $expected = [ 'username' => 'mark@example.com', 'realm' => 'testrealm@host.com', 'nonce' => 'dcd98b7102dd2f0e8b11d0f600bfb0c093', @@ -292,7 +292,7 @@ public function testParseAuthEmailAddress() { 'cnonce' => '0a4f113b', 'response' => '6629fae49393a05397450978507c4ef1', 'opaque' => '5ccc069c403ebaf9f0171e9517f40e41' - ); + ]; $result = $this->auth->parseAuthData($digest); $this->assertSame($expected, $result); } diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php index 6480ed3d85..25872320d7 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/FormAuthenticateTest.php @@ -34,7 +34,7 @@ class FormAuthenticateTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.user', 'core.auth_user'); + public $fixtures = ['core.user', 'core.auth_user']; /** * setup @@ -44,13 +44,13 @@ class FormAuthenticateTest extends CakeTestCase { public function setUp() : void { parent::setUp(); $this->Collection = $this->getMock('ComponentCollection'); - $this->auth = new FormAuthenticate($this->Collection, array( - 'fields' => array('username' => 'user', 'password' => 'password'), + $this->auth = new FormAuthenticate($this->Collection, [ + 'fields' => ['username' => 'user', 'password' => 'password'], 'userModel' => 'User' - )); + ]); $password = Security::hash('password', null, true); $User = ClassRegistry::init('User'); - $User->updateAll(array('password' => $User->getDataSource()->value($password))); + $User->updateAll(['password' => $User->getDataSource()->value($password)]); $this->response = $this->getMock('CakeResponse'); } @@ -60,12 +60,12 @@ public function setUp() : void { * @return void */ public function testConstructor() { - $object = new FormAuthenticate($this->Collection, array( + $object = new FormAuthenticate($this->Collection, [ 'userModel' => 'AuthUser', - 'fields' => array('username' => 'user', 'password' => 'password') - )); + 'fields' => ['username' => 'user', 'password' => 'password'] + ]); $this->assertEquals('AuthUser', $object->settings['userModel']); - $this->assertEquals(array('username' => 'user', 'password' => 'password'), $object->settings['fields']); + $this->assertEquals(['username' => 'user', 'password' => 'password'], $object->settings['fields']); } /** @@ -75,7 +75,7 @@ public function testConstructor() { */ public function testAuthenticateNoData() { $request = new CakeRequest('posts/index', false); - $request->data = array(); + $request->data = []; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -86,7 +86,7 @@ public function testAuthenticateNoData() { */ public function testAuthenticateNoUsername() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array('password' => 'foobar')); + $request->data = ['User' => ['password' => 'foobar']]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -97,7 +97,7 @@ public function testAuthenticateNoUsername() { */ public function testAuthenticateNoPassword() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array('user' => 'mariano')); + $request->data = ['User' => ['user' => 'mariano']]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -108,11 +108,11 @@ public function testAuthenticateNoPassword() { */ public function testAuthenticatePasswordIsFalse() { $request = new CakeRequest('posts/index', false); - $request->data = array( - 'User' => array( + $request->data = [ + 'User' => [ 'user' => 'mariano', 'password' => null - )); + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -124,22 +124,22 @@ public function testAuthenticatePasswordIsFalse() { */ public function testAuthenticatePasswordIsEmptyString() { $request = new CakeRequest('posts/index', false); - $request->data = array( - 'User' => array( + $request->data = [ + 'User' => [ 'user' => 'mariano', 'password' => '' - )); + ]]; $this->auth = $this->getMock( 'FormAuthenticate', - array('_checkFields'), - array( + ['_checkFields'], + [ $this->Collection, - array( - 'fields' => array('username' => 'user', 'password' => 'password'), + [ + 'fields' => ['username' => 'user', 'password' => 'password'], 'userModel' => 'User' - ) - ) + ] + ] ); // Simulate that check for ensuring password is not empty is missing. @@ -157,25 +157,25 @@ public function testAuthenticatePasswordIsEmptyString() { */ public function testAuthenticateFieldsAreNotString() { $request = new CakeRequest('posts/index', false); - $request->data = array( - 'User' => array( - 'user' => array('mariano', 'phpnut'), + $request->data = [ + 'User' => [ + 'user' => ['mariano', 'phpnut'], 'password' => 'my password' - )); + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); - $request->data = array( - 'User' => array( - 'user' => array(), + $request->data = [ + 'User' => [ + 'user' => [], 'password' => 'my password' - )); + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); - $request->data = array( - 'User' => array( + $request->data = [ + 'User' => [ 'user' => 'mariano', - 'password' => array('password1', 'password2') - )); + 'password' => ['password1', 'password2'] + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -186,11 +186,11 @@ public function testAuthenticateFieldsAreNotString() { */ public function testAuthenticateInjection() { $request = new CakeRequest('posts/index', false); - $request->data = array( - 'User' => array( + $request->data = [ + 'User' => [ 'user' => '> 1', 'password' => "' OR 1 = 1" - )); + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -201,17 +201,17 @@ public function testAuthenticateInjection() { */ public function testAuthenticateSuccess() { $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( + $request->data = ['User' => [ 'user' => 'mariano', 'password' => 'password' - )); + ]]; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertEquals($expected, $result); } @@ -221,12 +221,12 @@ public function testAuthenticateSuccess() { * @return void */ public function testAuthenticateScopeFail() { - $this->auth->settings['scope'] = array('user' => 'nate'); + $this->auth->settings['scope'] = ['user' => 'nate']; $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( + $request->data = ['User' => [ 'user' => 'mariano', 'password' => 'password' - )); + ]]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } @@ -238,20 +238,20 @@ public function testAuthenticateScopeFail() { */ public function testAuthenticateUsernameZero() { $User = ClassRegistry::init('User'); - $User->updateAll(array('user' => $User->getDataSource()->value('0')), array('user' => 'mariano')); + $User->updateAll(['user' => $User->getDataSource()->value('0')], ['user' => 'mariano']); $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( + $request->data = ['User' => [ 'user' => '0', 'password' => 'password' - )); + ]]; - $expected = array( + $expected = [ 'id' => 1, 'user' => '0', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertEquals($expected, $this->auth->authenticate($request, $this->response)); } @@ -262,9 +262,9 @@ public function testAuthenticateUsernameZero() { */ public function testPluginModel() { Cache::delete('object_map', '_cake_core_'); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + ], App::RESET); CakePlugin::load('TestPlugin'); $PluginModel = ClassRegistry::init('TestPlugin.TestPluginAuthUser'); @@ -277,17 +277,17 @@ public function testPluginModel() { $this->auth->settings['fields']['username'] = 'username'; $request = new CakeRequest('posts/index', false); - $request->data = array('TestPluginAuthUser' => array( + $request->data = ['TestPluginAuthUser' => [ 'username' => 'gwoo', 'password' => 'cake' - )); + ]]; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'username' => 'gwoo', 'created' => '2007-03-17 01:16:23' - ); + ]; $this->assertEquals(static::date(), $result['updated']); unset($result['updated']); $this->assertEquals($expected, $result); @@ -300,10 +300,10 @@ public function testPluginModel() { * @return void */ public function testPasswordHasherSettings() { - $this->auth->settings['passwordHasher'] = array( + $this->auth->settings['passwordHasher'] = [ 'className' => 'Simple', 'hashType' => 'md5' - ); + ]; $passwordHasher = $this->auth->passwordHasher(); $result = $passwordHasher->config(); @@ -312,33 +312,33 @@ public function testPasswordHasherSettings() { $hash = Security::hash('mypass', 'md5', true); $User = ClassRegistry::init('User'); $User->updateAll( - array('password' => $User->getDataSource()->value($hash)), - array('User.user' => 'mariano') + ['password' => $User->getDataSource()->value($hash)], + ['User.user' => 'mariano'] ); $request = new CakeRequest('posts/index', false); - $request->data = array('User' => array( + $request->data = ['User' => [ 'user' => 'mariano', 'password' => 'mypass' - )); + ]]; $result = $this->auth->authenticate($request, $this->response); - $expected = array( + $expected = [ 'id' => 1, 'user' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertEquals($expected, $result); - $this->auth = new FormAuthenticate($this->Collection, array( - 'fields' => array('username' => 'user', 'password' => 'password'), + $this->auth = new FormAuthenticate($this->Collection, [ + 'fields' => ['username' => 'user', 'password' => 'password'], 'userModel' => 'User' - )); - $this->auth->settings['passwordHasher'] = array( + ]); + $this->auth->settings['passwordHasher'] = [ 'className' => 'Simple', 'hashType' => 'sha1' - ); + ]; $this->assertFalse($this->auth->authenticate($request, $this->response)); } diff --git a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php index 2d6af32cd2..df18d35375 100644 --- a/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/AuthComponentTest.php @@ -37,9 +37,9 @@ class TestBaseAuthenticate extends BaseAuthenticate { * @return array of events => callbacks. */ public function implementedEvents() { - return array( + return [ 'Auth.afterIdentify' => 'afterIdentify' - ); + ]; } public $afterIdentifyCallable = null; @@ -61,10 +61,10 @@ public function afterIdentify($event) { * @return mixed Either false on failure, or an array of user data on success. */ public function authenticate(CakeRequest $request, CakeResponse $response) { - return array( + return [ 'id' => 1, 'username' => 'mark' - ); + ]; } } @@ -102,7 +102,7 @@ public function setAuthenticateObject($index, $object) { */ public function getAuthenticateObject($index) { $this->constructAuthenticate(); - return isset($this->_authenticateObjects[$index]) ? $this->_authenticateObjects[$index] : null; + return $this->_authenticateObjects[$index] ?? null; } /** @@ -127,7 +127,7 @@ protected function _stop($status = 0) { } public static function clearUser() { - static::$_user = array(); + static::$_user = []; } } @@ -160,14 +160,14 @@ class AuthTestController extends Controller { * * @var array */ - public $uses = array('AuthUser'); + public $uses = ['AuthUser']; /** * components property * * @var array */ - public $components = array('Session', 'Flash', 'Auth'); + public $components = ['Session', 'Flash', 'Auth']; /** * testUrl property @@ -272,14 +272,14 @@ class AjaxAuthController extends Controller { * * @var array */ - public $components = array('Session', 'TestAuth'); + public $components = ['Session', 'TestAuth']; /** * uses property * * @var array */ - public $uses = array(); + public $uses = []; /** * testUrl property @@ -332,7 +332,7 @@ public function redirect($url, $status = null, $exit = true) { */ class AuthEventTestListener { - public $callStack = array(); + public $callStack = []; /** * Test function to be used in event dispatching @@ -365,7 +365,7 @@ class AuthComponentTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.auth_user'); + public $fixtures = ['core.auth_user']; /** * initialized property @@ -402,7 +402,7 @@ public function setUp() : void { Router::connect('/:controller/:action/*'); $User = ClassRegistry::init('AuthUser'); - $User->updateAll(array('password' => $User->getDataSource()->value(Security::hash('cake', null, true)))); + $User->updateAll(['password' => $User->getDataSource()->value(Security::hash('cake', null, true))]); } /** @@ -455,27 +455,27 @@ public function testIsErrorOrTests() { * @return void */ public function testLogin() { - $AuthLoginFormAuthenticate = $this->getMock('FormAuthenticate', array(), array(), '', false); - $this->Auth->authenticate = array( - 'AuthLoginForm' => array( + $AuthLoginFormAuthenticate = $this->getMock('FormAuthenticate', [], [], '', false); + $this->Auth->authenticate = [ + 'AuthLoginForm' => [ 'userModel' => 'AuthUser' - ) - ); - $this->Auth->Session = $this->getMock('SessionComponent', array('renew'), array(), '', false); + ] + ]; + $this->Auth->Session = $this->getMock('SessionComponent', ['renew'], [], '', false); $this->Auth->setAuthenticateObject(0, $AuthLoginFormAuthenticate); - $this->Auth->request->data = array( - 'AuthUser' => array( + $this->Auth->request->data = [ + 'AuthUser' => [ 'username' => 'mark', 'password' => Security::hash('cake', null, true) - ) - ); + ] + ]; - $user = array( + $user = [ 'id' => 1, 'username' => 'mark' - ); + ]; $AuthLoginFormAuthenticate->expects($this->once()) ->method('authenticate') @@ -498,19 +498,19 @@ public function testLogin() { * @return void */ public function testLoginAfterIdentify() { - $this->Auth->authenticate = array( + $this->Auth->authenticate = [ 'TestBase', - ); + ]; - $user = array( + $user = [ 'id' => 1, 'username' => 'mark' - ); + ]; $auth = $this->Auth->getAuthenticateObject(0); $listener = $this->getMock('AuthEventTestListener'); - $auth->afterIdentifyCallable = array($listener, 'listenerFunction'); - $event = new CakeEvent('Auth.afterIdentify', $this->Auth, array('user' => $user)); + $auth->afterIdentifyCallable = [$listener, 'listenerFunction']; + $event = new CakeEvent('Auth.afterIdentify', $this->Auth, ['user' => $user]); $listener->expects($this->once())->method('listenerFunction')->with($event); $result = $this->Auth->login(); @@ -530,11 +530,11 @@ public function testRedirectVarClearing() { $this->Controller->here = '/auth_test/admin_add'; $this->assertNull($this->Auth->Session->read('Auth.redirect')); - $this->Auth->authenticate = array('Form'); + $this->Auth->authenticate = ['Form']; $this->Auth->startup($this->Controller); $this->assertEquals('/auth_test/admin_add', $this->Auth->Session->read('Auth.redirect')); - $this->Auth->Session->write('Auth.User', array('username' => 'admad')); + $this->Auth->Session->write('Auth.User', ['username' => 'admad']); $this->Auth->startup($this->Controller); $this->assertNull($this->Auth->Session->read('Auth.redirect')); } @@ -571,7 +571,7 @@ public function testAuthorizeFalse() { public function testIsAuthorizedMissingFile() { $this->expectException(CakeException::class); $this->Controller->Auth->authorize = 'Missing'; - $this->Controller->Auth->isAuthorized(array('User' => array('id' => 1))); + $this->Controller->Auth->isAuthorized(['User' => ['id' => 1]]); } /** @@ -580,9 +580,9 @@ public function testIsAuthorizedMissingFile() { * @return void */ public function testIsAuthorizedDelegation() { - $AuthMockOneAuthorize = $this->getMock('BaseAuthorize', array('authorize'), array(), '', false); - $AuthMockTwoAuthorize = $this->getMock('BaseAuthorize', array('authorize'), array(), '', false); - $AuthMockThreeAuthorize = $this->getMock('BaseAuthorize', array('authorize'), array(), '', false); + $AuthMockOneAuthorize = $this->getMock('BaseAuthorize', ['authorize'], [], '', false); + $AuthMockTwoAuthorize = $this->getMock('BaseAuthorize', ['authorize'], [], '', false); + $AuthMockThreeAuthorize = $this->getMock('BaseAuthorize', ['authorize'], [], '', false); $this->Auth->setAuthorizeObject(0, $AuthMockOneAuthorize); $this->Auth->setAuthorizeObject(1, $AuthMockTwoAuthorize); @@ -591,18 +591,18 @@ public function testIsAuthorizedDelegation() { $AuthMockOneAuthorize->expects($this->once()) ->method('authorize') - ->with(array('User'), $request) + ->with(['User'], $request) ->will($this->returnValue(false)); $AuthMockTwoAuthorize->expects($this->once()) ->method('authorize') - ->with(array('User'), $request) + ->with(['User'], $request) ->will($this->returnValue(true)); $AuthMockThreeAuthorize->expects($this->never()) ->method('authorize'); - $this->assertTrue($this->Auth->isAuthorized(array('User'), $request)); + $this->assertTrue($this->Auth->isAuthorized(['User'], $request)); } /** @@ -611,11 +611,11 @@ public function testIsAuthorizedDelegation() { * @return void */ public function testIsAuthorizedUsingUserInSession() { - $AuthMockFourAuthorize = $this->getMock('BaseAuthorize', array('authorize'), array(), '', false); - $this->Auth->authorize = array('AuthMockFour'); + $AuthMockFourAuthorize = $this->getMock('BaseAuthorize', ['authorize'], [], '', false); + $this->Auth->authorize = ['AuthMockFour']; $this->Auth->setAuthorizeObject(0, $AuthMockFourAuthorize); - $user = array('user' => 'mark'); + $user = ['user' => 'mark']; $this->Auth->Session->write('Auth.User', $user); $request = $this->Controller->request; @@ -633,9 +633,9 @@ public function testIsAuthorizedUsingUserInSession() { * @return void */ public function testLoadAuthorizeResets() { - $this->Controller->Auth->authorize = array( + $this->Controller->Auth->authorize = [ 'Controller' - ); + ]; $result = $this->Controller->Auth->constructAuthorize(); $this->assertEquals(1, count($result)); @@ -658,10 +658,10 @@ public function testLoadAuthenticateNoFile() { * @return void */ public function testAllConfigWithAuthorize() { - $this->Controller->Auth->authorize = array( - AuthComponent::ALL => array('actionPath' => 'controllers/'), + $this->Controller->Auth->authorize = [ + AuthComponent::ALL => ['actionPath' => 'controllers/'], 'Actions' - ); + ]; $objects = $this->Controller->Auth->constructAuthorize(); $result = $objects[0]; $this->assertEquals('controllers/', $result->settings['actionPath']); @@ -673,9 +673,9 @@ public function testAllConfigWithAuthorize() { * @return void */ public function testLoadAuthenticateResets() { - $this->Controller->Auth->authenticate = array( + $this->Controller->Auth->authenticate = [ 'Form' - ); + ]; $result = $this->Controller->Auth->constructAuthenticate(); $this->assertEquals(1, count($result)); @@ -689,10 +689,10 @@ public function testLoadAuthenticateResets() { * @return void */ public function testAllConfigWithAuthenticate() { - $this->Controller->Auth->authenticate = array( - AuthComponent::ALL => array('userModel' => 'AuthUser'), + $this->Controller->Auth->authenticate = [ + AuthComponent::ALL => ['userModel' => 'AuthUser'], 'Form' - ); + ]; $objects = $this->Controller->Auth->constructAuthenticate(); $result = $objects[0]; $this->assertEquals('AuthUser', $result->settings['userModel']); @@ -704,10 +704,10 @@ public function testAllConfigWithAuthenticate() { * @return void */ public function testSameAuthenticateWithDifferentHashers() { - $this->Controller->Auth->authenticate = array( - 'FormSimple' => array('className' => 'Form', 'passwordHasher' => 'Simple'), - 'FormBlowfish' => array('className' => 'Form', 'passwordHasher' => 'Blowfish'), - ); + $this->Controller->Auth->authenticate = [ + 'FormSimple' => ['className' => 'Form', 'passwordHasher' => 'Simple'], + 'FormBlowfish' => ['className' => 'Form', 'passwordHasher' => 'Blowfish'], + ]; $objects = $this->Controller->Auth->constructAuthenticate(); $this->assertEquals(2, count($objects)); @@ -740,7 +740,7 @@ public function testAllowDenyAll() { $this->assertFalse($this->Controller->Auth->startup($this->Controller)); $this->Controller->Auth->allow(); - $this->Controller->Auth->deny(array('add', 'camelCase')); + $this->Controller->Auth->deny(['add', 'camelCase']); $this->Controller->request['action'] = 'delete'; $this->assertTrue($this->Controller->Auth->startup($this->Controller)); @@ -811,7 +811,7 @@ public function testAllowedActionsWithCamelCaseMethods() { $this->Controller->request->addParams(Router::parse($url)); $this->Controller->request->query['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Controller->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; $this->Controller->Auth->userModel = 'AuthUser'; $this->Controller->Auth->allow(); $result = $this->Controller->Auth->startup($this->Controller); @@ -821,13 +821,13 @@ public function testAllowedActionsWithCamelCaseMethods() { $this->Controller->request->addParams(Router::parse($url)); $this->Controller->request->query['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Controller->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->allowedActions = array('delete', 'camelCase', 'add'); + $this->Controller->Auth->allowedActions = ['delete', 'camelCase', 'add']; $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); - $this->Controller->Auth->allowedActions = array('delete', 'add'); + $this->Controller->Auth->allowedActions = ['delete', 'add']; $result = $this->Controller->Auth->startup($this->Controller); $this->assertFalse($result, 'startup() should return false, as action is not allowed. %s'); @@ -835,10 +835,10 @@ public function testAllowedActionsWithCamelCaseMethods() { $this->Controller->request->addParams(Router::parse($url)); $this->Controller->request->query['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); - $this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Controller->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; $this->Controller->Auth->userModel = 'AuthUser'; - $this->Controller->Auth->allow(array('delete', 'add')); + $this->Controller->Auth->allow(['delete', 'add']); $result = $this->Controller->Auth->startup($this->Controller); $this->assertTrue($result, 'startup() should return true, as action is allowed. %s'); } @@ -849,7 +849,7 @@ public function testAllowedActionsSetWithAllowMethod() { $this->Controller->request->query['url'] = Router::normalize($url); $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->allow('action_name', 'anotherAction'); - $this->assertEquals(array('action_name', 'anotherAction'), $this->Controller->Auth->allowedActions); + $this->assertEquals(['action_name', 'anotherAction'], $this->Controller->Auth->allowedActions); } /** @@ -862,17 +862,17 @@ public function testLoginRedirect() { $_ENV['HTTP_REFERER'] = false; putenv('HTTP_REFERER='); - $this->Auth->Session->write('Auth', array( - 'AuthUser' => array('id' => '1', 'username' => 'nate') - )); + $this->Auth->Session->write('Auth', [ + 'AuthUser' => ['id' => '1', 'username' => 'nate'] + ]); $this->Auth->request->addParams(Router::parse('users/login')); $this->Auth->request->url = 'users/login'; $this->Auth->initialize($this->Controller); - $this->Auth->loginRedirect = array( + $this->Auth->loginRedirect = [ 'controller' => 'pages', 'action' => 'display', 'welcome' - ); + ]; $this->Auth->startup($this->Controller); $expected = Router::normalize($this->Auth->loginRedirect); $this->assertEquals($expected, $this->Auth->redirectUrl()); @@ -885,8 +885,8 @@ public function testLoginRedirect() { putenv('HTTP_REFERER='); $url = '/posts/view/1'; - $this->Auth->Session->write('Auth', array( - 'AuthUser' => array('id' => '1', 'username' => 'nate')) + $this->Auth->Session->write('Auth', [ + 'AuthUser' => ['id' => '1', 'username' => 'nate']] ); $this->Controller->testUrl = null; $this->Auth->request->addParams(Router::parse($url)); @@ -895,18 +895,18 @@ public function testLoginRedirect() { $this->Auth->initialize($this->Controller); $this->Auth->authorize = 'controller'; - $this->Auth->loginAction = array( + $this->Auth->loginAction = [ 'controller' => 'AuthTest', 'action' => 'login' - ); + ]; $this->Auth->startup($this->Controller); $expected = Router::normalize('/AuthTest/login'); $this->assertEquals($expected, $this->Controller->testUrl); $this->Auth->Session->delete('Auth'); $_SERVER['HTTP_REFERER'] = $_ENV['HTTP_REFERER'] = Router::url('/admin', true); - $this->Auth->Session->write('Auth', array( - 'AuthUser' => array('id' => '1', 'username' => 'nate') - )); + $this->Auth->Session->write('Auth', [ + 'AuthUser' => ['id' => '1', 'username' => 'nate'] + ]); $this->Auth->request->params['action'] = 'login'; $this->Auth->request->url = 'auth_test/login'; $this->Auth->initialize($this->Controller); @@ -924,7 +924,7 @@ public function testLoginRedirect() { $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->url = $this->Auth->request->here = Router::normalize($url); $this->Auth->initialize($this->Controller); - $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/year:2008/month:feb'); $this->assertEquals($expected, $this->Auth->Session->read('Auth.redirect')); @@ -935,17 +935,17 @@ public function testLoginRedirect() { $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->url = $this->Auth->request->here = Router::normalize($url); $this->Auth->initialize($this->Controller); - $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/view/1'); $this->assertEquals($expected, $this->Auth->Session->read('Auth.redirect')); // QueryString parameters $_back = $_GET; - $_GET = array( + $_GET = [ 'print' => 'true', 'refer' => 'menu' - ); + ]; $this->Auth->Session->delete('Auth'); $url = '/posts/index/29'; $this->Auth->request->addParams(Router::parse($url)); @@ -953,7 +953,7 @@ public function testLoginRedirect() { $this->Auth->request->query = $_GET; $this->Auth->initialize($this->Controller); - $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; $this->Auth->startup($this->Controller); $expected = Router::normalize('posts/index/29?print=true&refer=menu'); $this->assertEquals($expected, $this->Auth->Session->read('Auth.redirect')); @@ -961,14 +961,14 @@ public function testLoginRedirect() { // Different base urls. $appConfig = Configure::read('App'); - $_GET = array(); + $_GET = []; - Configure::write('App', array( + Configure::write('App', [ 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'base' => false, 'baseUrl' => '/cake/index.php' - )); + ]); $this->Auth->Session->delete('Auth'); @@ -978,7 +978,7 @@ public function testLoginRedirect() { $this->Auth->request->url = Router::normalize($url); $this->Auth->initialize($this->Controller); - $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); + $this->Auth->loginAction = ['controller' => 'users', 'action' => 'login']; $this->Auth->startup($this->Controller); $expected = Router::normalize('/posts/add'); $this->assertEquals($expected, $this->Auth->Session->read('Auth.redirect')); @@ -993,12 +993,12 @@ public function testLoginRedirect() { $this->Auth->Session->delete('Auth'); $url = '/posts/edit/1'; $request = new CakeRequest($url); - $request->query = array(); + $request->query = []; $this->Auth->request = $this->Controller->request = $request; $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->url = $this->Auth->request->here = Router::normalize($url); $this->Auth->initialize($this->Controller); - $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; $this->Auth->startup($this->Controller); $expected = Router::normalize('/posts/edit/1'); $this->assertEquals($expected, $this->Auth->Session->read('Auth.redirect')); @@ -1011,7 +1011,7 @@ public function testLoginRedirect() { $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->url = Router::normalize($url); $this->Auth->initialize($this->Controller); - $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); + $this->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; $this->Auth->startup($this->Controller); $expected = Router::normalize('/'); $this->assertEquals($expected, $this->Auth->Session->read('Auth.redirect')); @@ -1031,10 +1031,10 @@ public function testNoLoginRedirectForAuthenticatedUser() { $this->Auth->request->url = 'auth_test/login'; $this->Auth->Session->write('Auth.User.id', '1'); - $this->Auth->authenticate = array('Form'); - $this->getMock('BaseAuthorize', array('authorize'), array(), 'NoLoginRedirectMockAuthorize', false); - $this->Auth->authorize = array('NoLoginRedirectMockAuthorize'); - $this->Auth->loginAction = array('controller' => 'auth_test', 'action' => 'login'); + $this->Auth->authenticate = ['Form']; + $this->getMock('BaseAuthorize', ['authorize'], [], 'NoLoginRedirectMockAuthorize', false); + $this->Auth->authorize = ['NoLoginRedirectMockAuthorize']; + $this->Auth->loginAction = ['controller' => 'auth_test', 'action' => 'login']; $return = $this->Auth->startup($this->Controller); $this->assertTrue($return); @@ -1054,17 +1054,17 @@ public function testDefaultToLoginRedirect() { $url = '/party/on'; $this->Auth->request = $CakeRequest = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->authorize = array('Controller'); - $this->Auth->login(array('username' => 'mariano', 'password' => 'cake')); - $this->Auth->loginRedirect = array( + $this->Auth->authorize = ['Controller']; + $this->Auth->login(['username' => 'mariano', 'password' => 'cake']); + $this->Auth->loginRedirect = [ 'controller' => 'something', 'action' => 'else', - ); + ]; $CakeResponse = new CakeResponse(); $Controller = $this->getMock( 'Controller', - array('on', 'redirect'), - array($CakeRequest, $CakeResponse) + ['on', 'redirect'], + [$CakeRequest, $CakeResponse] ); $expected = Router::url($this->Auth->loginRedirect); @@ -1083,27 +1083,27 @@ public function testRedirectToUnauthorizedRedirect() { $url = '/party/on'; $this->Auth->request = $CakeRequest = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->authorize = array('Controller'); - $this->Auth->login(array('username' => 'admad', 'password' => 'cake')); - $this->Auth->unauthorizedRedirect = array( + $this->Auth->authorize = ['Controller']; + $this->Auth->login(['username' => 'admad', 'password' => 'cake']); + $this->Auth->unauthorizedRedirect = [ 'controller' => 'no_can_do', 'action' => 'jack' - ); + ]; $CakeResponse = new CakeResponse(); $Controller = $this->getMock( 'Controller', - array('on', 'redirect'), - array($CakeRequest, $CakeResponse) + ['on', 'redirect'], + [$CakeRequest, $CakeResponse] ); $this->Auth->Flash = $this->getMock( 'FlashComponent', - array('set'), - array($Controller->Components) + ['set'], + [$Controller->Components] ); - $expected = array( + $expected = [ 'controller' => 'no_can_do', 'action' => 'jack' - ); + ]; $Controller->expects($this->once()) ->method('redirect') ->with($this->equalTo($expected)); @@ -1121,28 +1121,28 @@ public function testRedirectToUnauthorizedRedirectSuppressedAuthError() { $url = '/party/on'; $this->Auth->request = $CakeRequest = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->authorize = array('Controller'); - $this->Auth->login(array('username' => 'admad', 'password' => 'cake')); - $this->Auth->unauthorizedRedirect = array( + $this->Auth->authorize = ['Controller']; + $this->Auth->login(['username' => 'admad', 'password' => 'cake']); + $this->Auth->unauthorizedRedirect = [ 'controller' => 'no_can_do', 'action' => 'jack' - ); + ]; $this->Auth->authError = false; $CakeResponse = new CakeResponse(); $Controller = $this->getMock( 'Controller', - array('on', 'redirect'), - array($CakeRequest, $CakeResponse) + ['on', 'redirect'], + [$CakeRequest, $CakeResponse] ); $this->Auth->Flash = $this->getMock( 'FlashComponent', - array('set'), - array($Controller->Components) + ['set'], + [$Controller->Components] ); - $expected = array( + $expected = [ 'controller' => 'no_can_do', 'action' => 'jack' - ); + ]; $Controller->expects($this->once()) ->method('redirect') ->with($this->equalTo($expected)); @@ -1161,16 +1161,16 @@ public function testForbiddenException() { $url = '/party/on'; $this->Auth->request = $CakeRequest = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->authorize = array('Controller'); - $this->Auth->authorize = array('Controller'); + $this->Auth->authorize = ['Controller']; + $this->Auth->authorize = ['Controller']; $this->Auth->unauthorizedRedirect = false; - $this->Auth->login(array('username' => 'baker', 'password' => 'cake')); + $this->Auth->login(['username' => 'baker', 'password' => 'cake']); $CakeResponse = new CakeResponse(); $Controller = $this->getMock( 'Controller', - array('on', 'redirect'), - array($CakeRequest, $CakeResponse) + ['on', 'redirect'], + [$CakeRequest, $CakeResponse] ); $this->Auth->startup($Controller); @@ -1183,13 +1183,13 @@ public function testForbiddenException() { */ public function testNoRedirectOnLoginAction() { $controller = $this->getMock('Controller'); - $controller->methods = array('login'); + $controller->methods = ['login']; $url = '/AuthTest/login'; $this->Auth->request = $controller->request = new CakeRequest($url); $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login'); - $this->Auth->authorize = array('Controller'); + $this->Auth->loginAction = ['controller' => 'AuthTest', 'action' => 'login']; + $this->Auth->authorize = ['Controller']; $controller->expects($this->never()) ->method('redirect'); @@ -1218,7 +1218,7 @@ public function testNoRedirectOn404() { */ public function testAdminRoute() { $pref = Configure::read('Routing.prefixes'); - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; @@ -1230,9 +1230,9 @@ public function testAdminRoute() { Router::setRequestInfo($this->Auth->request); $this->Auth->initialize($this->Controller); - $this->Auth->loginAction = array( + $this->Auth->loginAction = [ 'admin' => true, 'controller' => 'auth_test', 'action' => 'login' - ); + ]; $this->Auth->startup($this->Controller); $this->assertEquals('/admin/auth_test/login', $this->Controller->testUrl); @@ -1246,9 +1246,9 @@ public function testAdminRoute() { * @return void */ public function testAjaxLogin() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; App::uses('Dispatcher', 'Routing'); @@ -1256,7 +1256,7 @@ public function testAjaxLogin() { $Response = new CakeResponse(); ob_start(); $Dispatcher = new Dispatcher(); - $Dispatcher->dispatch(new CakeRequest('/ajax_auth/add'), $Response, array('return' => 1)); + $Dispatcher->dispatch(new CakeRequest('/ajax_auth/add'), $Response, ['return' => 1]); $result = ob_get_clean(); $this->assertEquals(403, $Response->statusCode()); @@ -1270,9 +1270,9 @@ public function testAjaxLogin() { * @return void */ public function testAjaxLoginResponseCode() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $url = '/ajax_auth/add'; @@ -1283,7 +1283,7 @@ public function testAjaxLoginResponseCode() { Router::setRequestInfo($this->Auth->request); - $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response = $this->getMock('CakeResponse', ['_sendHeader']); $this->Controller->response->expects($this->at(0)) ->method('_sendHeader') ->with('HTTP/1.1 403 Forbidden', null); @@ -1316,7 +1316,7 @@ public function testAjaxLoginResponseCodeNoElement() { Router::setRequestInfo($this->Auth->request); - $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response = $this->getMock('CakeResponse', ['_sendHeader']); $this->Controller->response->expects($this->at(0)) ->method('_sendHeader') ->with('HTTP/1.1 403 Forbidden', null); @@ -1336,26 +1336,26 @@ public function testAjaxLoginResponseCodeNoElement() { */ public function testLoginActionRedirect() { $admin = Configure::read('Routing.prefixes'); - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; $url = '/admin/auth_test/login'; $this->Auth->request->addParams(Router::parse($url)); $this->Auth->request->url = ltrim($url, '/'); - Router::setRequestInfo(array( - array( - 'pass' => array(), 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test', + Router::setRequestInfo([ + [ + 'pass' => [], 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test', 'admin' => true, - ), - array( + ], + [ 'base' => null, 'here' => $url, - 'webroot' => '/', 'passedArgs' => array(), - ) - )); + 'webroot' => '/', 'passedArgs' => [], + ] + ]); $this->Auth->initialize($this->Controller); - $this->Auth->loginAction = array('admin' => true, 'controller' => 'auth_test', 'action' => 'login'); + $this->Auth->loginAction = ['admin' => true, 'controller' => 'auth_test', 'action' => 'login']; $this->Auth->startup($this->Controller); $this->assertNull($this->Controller->testUrl); @@ -1375,9 +1375,9 @@ public function testStatelessAuthWorksWithUser() { $url = '/auth_test/add'; $this->Auth->request->addParams(Router::parse($url)); - $this->Auth->authenticate = array( - 'Basic' => array('userModel' => 'AuthUser') - ); + $this->Auth->authenticate = [ + 'Basic' => ['userModel' => 'AuthUser'] + ]; $this->Auth->startup($this->Controller); $result = $this->Auth->user(); @@ -1396,21 +1396,21 @@ public function testComponentSettings() { $request = new CakeRequest(null, false); $this->Controller = new AuthTestController($request, $this->getMock('CakeResponse')); - $this->Controller->components = array( - 'Auth' => array( - 'loginAction' => array('controller' => 'people', 'action' => 'login'), - 'logoutRedirect' => array('controller' => 'people', 'action' => 'login'), - ), + $this->Controller->components = [ + 'Auth' => [ + 'loginAction' => ['controller' => 'people', 'action' => 'login'], + 'logoutRedirect' => ['controller' => 'people', 'action' => 'login'], + ], 'Session' - ); + ]; $this->Controller->Components->init($this->Controller); - $this->Controller->Components->trigger('initialize', array(&$this->Controller)); + $this->Controller->Components->trigger('initialize', [&$this->Controller]); Router::reload(); - $expected = array( - 'loginAction' => array('controller' => 'people', 'action' => 'login'), - 'logoutRedirect' => array('controller' => 'people', 'action' => 'login'), - ); + $expected = [ + 'loginAction' => ['controller' => 'people', 'action' => 'login'], + 'logoutRedirect' => ['controller' => 'people', 'action' => 'login'], + ]; $this->assertEquals($expected['loginAction'], $this->Controller->Auth->loginAction); $this->assertEquals($expected['logoutRedirect'], $this->Controller->Auth->logoutRedirect); } @@ -1439,7 +1439,7 @@ public function testLogout() { public function testLogoutRemoveUser() { $oldKey = AuthComponent::$sessionKey; AuthComponent::$sessionKey = false; - $this->Auth->login(array('id' => 1, 'username' => 'mariano')); + $this->Auth->login(['id' => 1, 'username' => 'mariano']); $this->assertSame('mariano', $this->Auth->user('username')); $this->Auth->logout(); @@ -1454,9 +1454,9 @@ public function testLogoutRemoveUser() { * @return void */ public function testLogoutTrigger() { - $LogoutTriggerMockAuthenticate = $this->getMock('BaseAuthenticate', array('authenticate', 'logout'), array(), '', false); + $LogoutTriggerMockAuthenticate = $this->getMock('BaseAuthenticate', ['authenticate', 'logout'], [], '', false); - $this->Auth->authenticate = array('LogoutTriggerMock'); + $this->Auth->authenticate = ['LogoutTriggerMock']; $this->Auth->setAuthenticateObject(0, $LogoutTriggerMockAuthenticate); $LogoutTriggerMockAuthenticate->expects($this->once()) ->method('logout'); @@ -1472,20 +1472,20 @@ public function testLogoutTrigger() { public function testMapActions() { $MapActionMockAuthorize = $this->getMock( 'BaseAuthorize', - array('authorize'), - array(), + ['authorize'], + [], '', false ); - $this->Auth->authorize = array('MapActionAuthorize'); + $this->Auth->authorize = ['MapActionAuthorize']; $this->Auth->setAuthorizeObject(0, $MapActionMockAuthorize); - $actions = array('my_action' => 'create'); + $actions = ['my_action' => 'create']; $this->Auth->mapActions($actions); - $actions = array( - 'create' => array('my_other_action'), - 'update' => array('updater') - ); + $actions = [ + 'create' => ['my_other_action'], + 'update' => ['updater'] + ]; $this->Auth->mapActions($actions); $actions = $this->Auth->mapActions(); @@ -1509,15 +1509,15 @@ public function testMapActions() { * @return void */ public function testMapActionsDelegation() { - $MapActionMockAuthorize = $this->getMock('BaseAuthorize', array('authorize', 'mapActions'), array(), '', false); + $MapActionMockAuthorize = $this->getMock('BaseAuthorize', ['authorize', 'mapActions'], [], '', false); - $this->Auth->authorize = array('MapActionMock'); + $this->Auth->authorize = ['MapActionMock']; $this->Auth->setAuthorizeObject(0, $MapActionMockAuthorize); $MapActionMockAuthorize->expects($this->once()) ->method('mapActions') - ->with(array('create' => array('my_action'))); + ->with(['create' => ['my_action']]); - $this->Auth->mapActions(array('create' => array('my_action'))); + $this->Auth->mapActions(['create' => ['my_action']]); } /** @@ -1526,12 +1526,12 @@ public function testMapActionsDelegation() { * @return void */ public function testLoginWithRequestData() { - $RequestLoginMockAuthenticate = $this->getMock('FormAuthenticate', array(), array(), '', false); + $RequestLoginMockAuthenticate = $this->getMock('FormAuthenticate', [], [], '', false); $request = new CakeRequest('users/login', false); - $user = array('username' => 'mark', 'role' => 'admin'); + $user = ['username' => 'mark', 'role' => 'admin']; $this->Auth->request = $request; - $this->Auth->authenticate = array('RequestLoginMock'); + $this->Auth->authenticate = ['RequestLoginMock']; $this->Auth->setAuthenticateObject(0, $RequestLoginMockAuthenticate); $RequestLoginMockAuthenticate->expects($this->once()) ->method('authenticate') @@ -1550,12 +1550,12 @@ public function testLoginWithRequestData() { public function testLoginWithUserData() { $this->assertFalse($this->Auth->loggedIn()); - $user = array( + $user = [ 'username' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ); + ]; $this->assertTrue($this->Auth->login($user)); $this->assertTrue($this->Auth->loggedIn()); $this->assertEquals($user['username'], $this->Auth->user('username')); @@ -1567,16 +1567,16 @@ public function testLoginWithUserData() { * @return void */ public function testFlashSettings() { - $this->Auth->Flash = $this->getMock('FlashComponent', array(), array(), '', false); + $this->Auth->Flash = $this->getMock('FlashComponent', [], [], '', false); $this->Auth->Flash->expects($this->once()) ->method('set') - ->with('Auth failure', array('element' => 'custom', 'params' => array(1), 'key' => 'auth-key')); + ->with('Auth failure', ['element' => 'custom', 'params' => [1], 'key' => 'auth-key']); - $this->Auth->flash = array( + $this->Auth->flash = [ 'element' => 'custom', - 'params' => array(1), + 'params' => [1], 'key' => 'auth-key' - ); + ]; $this->Auth->flash('Auth failure'); } @@ -1586,7 +1586,7 @@ public function testFlashSettings() { * @return void */ public function testRedirectSet() { - $value = array('controller' => 'users', 'action' => 'home'); + $value = ['controller' => 'users', 'action' => 'home']; $result = $this->Auth->redirectUrl($value); $this->assertEquals('/users/home', $result); $this->assertEquals($value, $this->Auth->Session->read('Auth.redirect')); @@ -1598,7 +1598,7 @@ public function testRedirectSet() { * @return void */ public function testRedirectSessionRead() { - $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); + $this->Auth->loginAction = ['controller' => 'users', 'action' => 'login']; $this->Auth->Session->write('Auth.redirect', '/users/home'); $result = $this->Auth->redirectUrl(); @@ -1630,9 +1630,9 @@ public function testRedirectSessionReadDuplicateBase() { * @return void */ public function testRedirectSessionReadEqualToLoginAction() { - $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); - $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'home'); - $this->Auth->Session->write('Auth.redirect', array('controller' => 'users', 'action' => 'login')); + $this->Auth->loginAction = ['controller' => 'users', 'action' => 'login']; + $this->Auth->loginRedirect = ['controller' => 'users', 'action' => 'home']; + $this->Auth->Session->write('Auth.redirect', ['controller' => 'users', 'action' => 'login']); $result = $this->Auth->redirectUrl(); $this->assertEquals('/users/home', $result); @@ -1647,12 +1647,12 @@ public function testRedirectSessionReadEqualToLoginAction() { public function testRedirectUrlWithBaseSet() { $App = Configure::read('App'); - Configure::write('App', array( + Configure::write('App', [ 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'base' => false, 'baseUrl' => '/cake/index.php' - )); + ]); $url = '/users/login'; $this->Auth->request = $this->Controller->request = new CakeRequest($url); @@ -1661,8 +1661,8 @@ public function testRedirectUrlWithBaseSet() { Router::setRequestInfo($this->Auth->request); - $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login'); - $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'home'); + $this->Auth->loginAction = ['controller' => 'users', 'action' => 'login']; + $this->Auth->loginRedirect = ['controller' => 'users', 'action' => 'home']; $result = $this->Auth->redirectUrl(); $this->assertEquals('/users/home', $result); @@ -1703,17 +1703,17 @@ public function testPassword() { * @return void */ public function testUser() { - $data = array( - 'User' => array( + $data = [ + 'User' => [ 'id' => '2', 'username' => 'mark', 'group_id' => 1, - 'Group' => array( + 'Group' => [ 'id' => '1', 'name' => 'Members' - ), + ], 'is_admin' => false, - )); + ]]; $this->Auth->Session->write('Auth', $data); $result = $this->Auth->user(); @@ -1750,7 +1750,7 @@ public function testStatelessAuthNoRedirect() { $_SESSION = null; AuthComponent::$sessionKey = false; - $this->Auth->authenticate = array('Basic'); + $this->Auth->authenticate = ['Basic']; $this->Controller->request['action'] = 'admin_add'; $this->Auth->startup($this->Controller); @@ -1762,10 +1762,10 @@ public function testStatelessAuthNoRedirect() { * @return void */ public function testStatelessLoginSetUserNoSessionStart() { - $user = array( + $user = [ 'id' => 1, 'username' => 'mark' - ); + ]; AuthComponent::$sessionKey = false; $result = $this->Auth->login($user); @@ -1793,9 +1793,9 @@ public function testStatelessAuthNoSessionStart() { $_SERVER['PHP_AUTH_PW'] = 'cake'; AuthComponent::$sessionKey = false; - $this->Auth->authenticate = array( - 'Basic' => array('userModel' => 'AuthUser') - ); + $this->Auth->authenticate = [ + 'Basic' => ['userModel' => 'AuthUser'] + ]; $this->Controller->request['action'] = 'admin_add'; $result = $this->Auth->startup($this->Controller); @@ -1810,7 +1810,7 @@ public function testStatelessAuthNoSessionStart() { * @return void */ public function testStatelessFollowedByStatefulAuth() { - $this->Auth->authenticate = array('Basic', 'Form'); + $this->Auth->authenticate = ['Basic', 'Form']; $this->Controller->request['action'] = 'admin_add'; $this->Auth->response->expects($this->never())->method('statusCode'); @@ -1838,20 +1838,20 @@ public function testStatelessAuthAllowedActionsRetrieveUser() { $_SERVER['PHP_AUTH_PW'] = 'cake'; AuthComponent::$sessionKey = false; - $this->Controller->Auth->authenticate = array( - 'Basic' => array('userModel' => 'AuthUser') - ); + $this->Controller->Auth->authenticate = [ + 'Basic' => ['userModel' => 'AuthUser'] + ]; $this->Controller->request['action'] = 'add'; $this->Controller->Auth->initialize($this->Controller); $this->Controller->Auth->allow(); $this->Controller->Auth->startup($this->Controller); - $expectedUser = array( + $expectedUser = [ 'id' => '1', 'username' => 'mariano', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - ); + ]; $this->assertEquals($expectedUser, $this->Controller->Auth->user()); } diff --git a/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php b/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php index 99fc97b30f..22d7f0f610 100644 --- a/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php @@ -32,7 +32,7 @@ class CookieComponentTestController extends Controller { * * @var array */ - public $components = array('Cookie'); + public $components = ['Cookie']; /** * beforeFilter method @@ -71,7 +71,7 @@ class CookieComponentTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $_COOKIE = array(); + $_COOKIE = []; $this->Controller = new CookieComponentTestController(new CakeRequest(), new CakeResponse()); $this->Controller->constructClasses(); $this->Cookie = $this->Controller->Cookie; @@ -102,15 +102,15 @@ public function tearDown() : void { * @return void */ protected function _setCookieData() { - $this->Cookie->write(array('Encrytped_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'))); - $this->Cookie->write(array('Encrytped_multi_cookies.name' => 'CakePHP')); - $this->Cookie->write(array('Encrytped_multi_cookies.version' => '1.2.0.x')); - $this->Cookie->write(array('Encrytped_multi_cookies.tag' => 'CakePHP Rocks!')); + $this->Cookie->write(['Encrytped_array' => ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']]); + $this->Cookie->write(['Encrytped_multi_cookies.name' => 'CakePHP']); + $this->Cookie->write(['Encrytped_multi_cookies.version' => '1.2.0.x']); + $this->Cookie->write(['Encrytped_multi_cookies.tag' => 'CakePHP Rocks!']); - $this->Cookie->write(array('Plain_array' => array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')), null, false); - $this->Cookie->write(array('Plain_multi_cookies.name' => 'CakePHP'), null, false); - $this->Cookie->write(array('Plain_multi_cookies.version' => '1.2.0.x'), null, false); - $this->Cookie->write(array('Plain_multi_cookies.tag' => 'CakePHP Rocks!'), null, false); + $this->Cookie->write(['Plain_array' => ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']], null, false); + $this->Cookie->write(['Plain_multi_cookies.name' => 'CakePHP'], null, false); + $this->Cookie->write(['Plain_multi_cookies.version' => '1.2.0.x'], null, false); + $this->Cookie->write(['Plain_multi_cookies.tag' => 'CakePHP Rocks!'], null, false); } /** @@ -119,10 +119,10 @@ protected function _setCookieData() { * @return void */ public function testSettings() { - $settings = array( + $settings = [ 'time' => '5 days', 'path' => '/' - ); + ]; $Cookie = new CookieComponent(new ComponentCollection(), $settings); $this->assertEquals($Cookie->time, $settings['time']); $this->assertEquals($Cookie->path, $settings['path']); @@ -145,11 +145,11 @@ public function testCookieName() { public function testReadEncryptedCookieData() { $this->_setCookieData(); $data = $this->Cookie->read('Encrytped_array'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $data = $this->Cookie->read('Encrytped_multi_cookies'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); } @@ -162,11 +162,11 @@ public function testReadCorruptedCookieData() { $this->Cookie->type('aes'); $this->Cookie->key = sha1('some bad key'); - $data = $this->_implode(array('name' => 'jill', 'age' => 24)); + $data = $this->_implode(['name' => 'jill', 'age' => 24]); // Corrupt the cookie data by slicing some bytes off. - $_COOKIE['CakeTestCookie'] = array( + $_COOKIE['CakeTestCookie'] = [ 'BadData' => substr(Security::encrypt($data, $this->Cookie->key), 0, -5) - ); + ]; $this->assertFalse($this->Cookie->check('BadData.name'), 'Key does not exist'); $this->assertNull($this->Cookie->read('BadData.name'), 'Key does not exist'); } @@ -179,11 +179,11 @@ public function testReadCorruptedCookieData() { public function testReadPlainCookieData() { $this->_setCookieData(); $data = $this->Cookie->read('Plain_array'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $data = $this->Cookie->read('Plain_multi_cookies'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); } @@ -193,9 +193,9 @@ public function testReadPlainCookieData() { * @return void */ public function testReadNestedDataFromStrings() { - $_COOKIE['CakeTestCookie'] = array( + $_COOKIE['CakeTestCookie'] = [ 'User' => 'bad data' - ); + ]; $this->assertFalse($this->Cookie->check('User.name'), 'No key'); $this->assertNull($this->Cookie->read('User.name'), 'No key'); } @@ -206,14 +206,14 @@ public function testReadNestedDataFromStrings() { * @return void */ public function testReadWithNameSwitch() { - $_COOKIE = array( - 'CakeTestCookie' => array( + $_COOKIE = [ + 'CakeTestCookie' => [ 'key' => 'value' - ), - 'OtherTestCookie' => array( + ], + 'OtherTestCookie' => [ 'key' => 'other value' - ) - ); + ] + ]; $this->assertEquals('value', $this->Cookie->read('key')); $this->Cookie->name = 'OtherTestCookie'; @@ -295,16 +295,16 @@ public function testWriteFarFuture() { $future = new DateTime('now'); $future->modify('+90 years'); - $expected = array( + $expected = [ 'name' => $this->Cookie->name . '[Testing]', 'value' => 'value', 'path' => '/', 'domain' => '', 'secure' => false, - 'httpOnly' => false); + 'httpOnly' => false]; $result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]'); - $this->assertEquals($future->format('U'), $result['expire'], '', 3); + $this->assertEquals($future->format('U'), $result['expire'], ''); unset($result['expire']); $this->assertEquals($expected, $result); @@ -319,14 +319,14 @@ public function testWriteHttpOnly() { $this->Cookie->httpOnly = true; $this->Cookie->secure = false; $this->Cookie->write('Testing', 'value', false); - $expected = array( + $expected = [ 'name' => $this->Cookie->name . '[Testing]', 'value' => 'value', 'expire' => time() + 10, 'path' => '/', 'domain' => '', 'secure' => false, - 'httpOnly' => true); + 'httpOnly' => true]; $result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]'); $this->assertEquals($expected, $result); } @@ -340,14 +340,14 @@ public function testDeleteHttpOnly() { $this->Cookie->httpOnly = true; $this->Cookie->secure = false; $this->Cookie->delete('Testing', false); - $expected = array( + $expected = [ 'name' => $this->Cookie->name . '[Testing]', 'value' => '', 'expire' => time() - 42000, 'path' => '/', 'domain' => '', 'secure' => false, - 'httpOnly' => true); + 'httpOnly' => true]; $result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]'); $this->assertEquals($expected, $result); } @@ -358,7 +358,7 @@ public function testDeleteHttpOnly() { * @return void */ public function testWritePlainCookieArray() { - $this->Cookie->write(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'), null, false); + $this->Cookie->write(['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'], null, false); $this->assertEquals('CakePHP', $this->Cookie->read('name')); $this->assertEquals('1.2.0.x', $this->Cookie->read('version')); @@ -376,14 +376,14 @@ public function testWritePlainCookieArray() { */ public function testWriteArrayValues() { $this->Cookie->secure = false; - $this->Cookie->write('Testing', array(1, 2, 3), false); - $expected = array( + $this->Cookie->write('Testing', [1, 2, 3], false); + $expected = [ 'name' => $this->Cookie->name . '[Testing]', 'value' => '[1,2,3]', 'path' => '/', 'domain' => '', 'secure' => false, - 'httpOnly' => false); + 'httpOnly' => false]; $result = $this->Controller->response->cookie($this->Cookie->name . '[Testing]'); $this->assertWithinMargin($result['expire'], time() + 10, 1); @@ -398,31 +398,31 @@ public function testWriteArrayValues() { */ public function testWriteMixedArray() { $this->Cookie->encrypt = false; - $this->Cookie->write('User', array('name' => 'mark'), false); + $this->Cookie->write('User', ['name' => 'mark'], false); $this->Cookie->write('User.email', 'mark@example.com', false); - $expected = array( + $expected = [ 'name' => $this->Cookie->name . '[User]', 'value' => '{"name":"mark","email":"mark@example.com"}', 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false - ); + ]; $result = $this->Controller->response->cookie($this->Cookie->name . '[User]'); unset($result['expire']); $this->assertEquals($expected, $result); $this->Cookie->write('User.email', 'mark@example.com', false); - $this->Cookie->write('User', array('name' => 'mark'), false); - $expected = array( + $this->Cookie->write('User', ['name' => 'mark'], false); + $expected = [ 'name' => $this->Cookie->name . '[User]', 'value' => '{"name":"mark"}', 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false - ); + ]; $result = $this->Controller->response->cookie($this->Cookie->name . '[User]'); unset($result['expire']); @@ -439,11 +439,11 @@ public function testReplaceScalarWithArray() { $this->Cookie->write('foo.bar', 2); $data = $this->Cookie->read(); - $expected = array( - 'foo' => array( + $expected = [ + 'foo' => [ 'bar' => 2 - ) - ); + ] + ]; $this->assertEquals($expected, $data); } @@ -455,23 +455,23 @@ public function testReplaceScalarWithArray() { public function testReadingCookieValue() { $this->_setCookieData(); $data = $this->Cookie->read(); - $expected = array( - 'Encrytped_array' => array( + $expected = [ + 'Encrytped_array' => [ 'name' => 'CakePHP', 'version' => '1.2.0.x', - 'tag' => 'CakePHP Rocks!'), - 'Encrytped_multi_cookies' => array( + 'tag' => 'CakePHP Rocks!'], + 'Encrytped_multi_cookies' => [ 'name' => 'CakePHP', 'version' => '1.2.0.x', - 'tag' => 'CakePHP Rocks!'), - 'Plain_array' => array( + 'tag' => 'CakePHP Rocks!'], + 'Plain_array' => [ 'name' => 'CakePHP', 'version' => '1.2.0.x', - 'tag' => 'CakePHP Rocks!'), - 'Plain_multi_cookies' => array( + 'tag' => 'CakePHP Rocks!'], + 'Plain_multi_cookies' => [ 'name' => 'CakePHP', 'version' => '1.2.0.x', - 'tag' => 'CakePHP Rocks!')); + 'tag' => 'CakePHP Rocks!']]; $this->assertEquals($expected, $data); } @@ -484,7 +484,7 @@ public function testDeleteCookieValue() { $this->_setCookieData(); $this->Cookie->delete('Encrytped_multi_cookies.name'); $data = $this->Cookie->read('Encrytped_multi_cookies'); - $expected = array('version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $this->Cookie->delete('Encrytped_array'); @@ -493,7 +493,7 @@ public function testDeleteCookieValue() { $this->Cookie->delete('Plain_multi_cookies.name'); $data = $this->Cookie->read('Plain_multi_cookies'); - $expected = array('version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $this->Cookie->delete('Plain_array'); @@ -510,11 +510,11 @@ public function testDeleteCorruptedCookieData() { $this->Cookie->type('aes'); $this->Cookie->key = sha1('some bad key'); - $data = $this->_implode(array('name' => 'jill', 'age' => 24)); + $data = $this->_implode(['name' => 'jill', 'age' => 24]); // Corrupt the cookie data by slicing some bytes off. - $_COOKIE['CakeTestCookie'] = array( + $_COOKIE['CakeTestCookie'] = [ 'BadData' => substr(Security::encrypt($data, $this->Cookie->key), 0, -5) - ); + ]; $this->assertNull($this->Cookie->delete('BadData.name')); $this->assertNull($this->Cookie->read('BadData.name')); @@ -595,34 +595,34 @@ public function testReadingCookieDataOnStartup() { $data = $this->Cookie->read('Plain_multi_cookies'); $this->assertNull($data); - $_COOKIE['CakeTestCookie'] = array( - 'Encrytped_array' => $this->_encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')), - 'Encrytped_multi_cookies' => array( + $_COOKIE['CakeTestCookie'] = [ + 'Encrytped_array' => $this->_encrypt(['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']), + 'Encrytped_multi_cookies' => [ 'name' => $this->_encrypt('CakePHP'), 'version' => $this->_encrypt('1.2.0.x'), - 'tag' => $this->_encrypt('CakePHP Rocks!')), + 'tag' => $this->_encrypt('CakePHP Rocks!')], 'Plain_array' => '{"name":"CakePHP","version":"1.2.0.x","tag":"CakePHP Rocks!"}', - 'Plain_multi_cookies' => array( + 'Plain_multi_cookies' => [ 'name' => 'CakePHP', 'version' => '1.2.0.x', - 'tag' => 'CakePHP Rocks!')); + 'tag' => 'CakePHP Rocks!']]; $this->Cookie->startup(new CookieComponentTestController()); $data = $this->Cookie->read('Encrytped_array'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $data = $this->Cookie->read('Encrytped_multi_cookies'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $data = $this->Cookie->read('Plain_array'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $data = $this->Cookie->read('Plain_multi_cookies'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $this->Cookie->destroy(); unset($_COOKIE['CakeTestCookie']); @@ -650,32 +650,32 @@ public function testReadingCookieDataWithoutStartup() { $expected = null; $this->assertEquals($expected, $data); - $_COOKIE['CakeTestCookie'] = array( - 'Encrytped_array' => $this->_encrypt(array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!')), - 'Encrytped_multi_cookies' => array( + $_COOKIE['CakeTestCookie'] = [ + 'Encrytped_array' => $this->_encrypt(['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']), + 'Encrytped_multi_cookies' => [ 'name' => $this->_encrypt('CakePHP'), 'version' => $this->_encrypt('1.2.0.x'), - 'tag' => $this->_encrypt('CakePHP Rocks!')), + 'tag' => $this->_encrypt('CakePHP Rocks!')], 'Plain_array' => '{"name":"CakePHP","version":"1.2.0.x","tag":"CakePHP Rocks!"}', - 'Plain_multi_cookies' => array( + 'Plain_multi_cookies' => [ 'name' => 'CakePHP', 'version' => '1.2.0.x', - 'tag' => 'CakePHP Rocks!')); + 'tag' => 'CakePHP Rocks!']]; $data = $this->Cookie->read('Encrytped_array'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $data = $this->Cookie->read('Encrytped_multi_cookies'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $data = $this->Cookie->read('Plain_array'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $data = $this->Cookie->read('Plain_multi_cookies'); - $expected = array('name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!'); + $expected = ['name' => 'CakePHP', 'version' => '1.2.0.x', 'tag' => 'CakePHP Rocks!']; $this->assertEquals($expected, $data); $this->Cookie->destroy(); unset($_COOKIE['CakeTestCookie']); @@ -687,11 +687,11 @@ public function testReadingCookieDataWithoutStartup() { * @return void */ public function testReadLegacyCookieValue() { - $_COOKIE['CakeTestCookie'] = array( - 'Legacy' => array('value' => $this->_oldImplode(array(1, 2, 3))) - ); + $_COOKIE['CakeTestCookie'] = [ + 'Legacy' => ['value' => $this->_oldImplode([1, 2, 3])] + ]; $result = $this->Cookie->read('Legacy.value'); - $expected = array(1, 2, 3); + $expected = [1, 2, 3]; $this->assertEquals($expected, $result); } @@ -701,17 +701,17 @@ public function testReadLegacyCookieValue() { * @return void */ public function testReadEmpty() { - $_COOKIE['CakeTestCookie'] = array( + $_COOKIE['CakeTestCookie'] = [ 'JSON' => '{"name":"value"}', 'Empty' => '', 'String' => '{"somewhat:"broken"}', 'Array' => '{}' - ); - $this->assertEquals(array('name' => 'value'), $this->Cookie->read('JSON')); + ]; + $this->assertEquals(['name' => 'value'], $this->Cookie->read('JSON')); $this->assertEquals('value', $this->Cookie->read('JSON.name')); $this->assertEquals('', $this->Cookie->read('Empty')); $this->assertEquals('{"somewhat:"broken"}', $this->Cookie->read('String')); - $this->assertEquals(array(), $this->Cookie->read('Array')); + $this->assertEquals([], $this->Cookie->read('Array')); } /** @@ -720,10 +720,10 @@ public function testReadEmpty() { * @return void */ public function testReadEmptyKey() { - $_COOKIE['CakeTestCookie'] = array( + $_COOKIE['CakeTestCookie'] = [ '0' => '{"name":"value"}', - 'foo' => array('bar'), - ); + 'foo' => ['bar'], + ]; $this->assertEquals('value', $this->Cookie->read('0.name')); $this->assertEquals('bar', $this->Cookie->read('foo.0')); } @@ -800,10 +800,10 @@ public function testCheckEmpty() { * @return void */ public function testDeleteRemovesChildren() { - $_COOKIE['CakeTestCookie'] = array( - 'User' => array('email' => 'example@example.com', 'name' => 'mark'), + $_COOKIE['CakeTestCookie'] = [ + 'User' => ['email' => 'example@example.com', 'name' => 'mark'], 'other' => 'value' - ); + ]; $this->assertEquals('mark', $this->Cookie->read('User.name')); $this->Cookie->delete('User'); @@ -827,29 +827,29 @@ public function testDeleteChildrenNotExist() { * @return void */ public function testDeleteDeepChildren() { - $_COOKIE = array( - 'CakeTestCookie' => array( - 'foo' => $this->_encrypt(array( - 'bar' => array( + $_COOKIE = [ + 'CakeTestCookie' => [ + 'foo' => $this->_encrypt([ + 'bar' => [ 'baz' => 'value', - ), - )), - ), - ); + ], + ]), + ], + ]; $this->Cookie->delete('foo.bar.baz'); $cookies = $this->Controller->response->cookie(); - $expected = array( - 'CakeTestCookie[foo]' => array( + $expected = [ + 'CakeTestCookie[foo]' => [ 'name' => 'CakeTestCookie[foo]', 'value' => '{"bar":[]}', 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false - ), - ); + ], + ]; $expires = Hash::combine($cookies, '{*}.name', '{*}.expire'); $cookies = Hash::remove($cookies, '{*}.expire'); @@ -864,38 +864,38 @@ public function testDeleteDeepChildren() { * @return void */ public function testDestroy() { - $_COOKIE = array( - 'CakeTestCookie' => array( - 'foo' => $this->_encrypt(array( - 'bar' => array( + $_COOKIE = [ + 'CakeTestCookie' => [ + 'foo' => $this->_encrypt([ + 'bar' => [ 'baz' => 'value', - ), - )), + ], + ]), 'other' => 'value', - ), - ); + ], + ]; $this->Cookie->destroy(); $cookies = $this->Controller->response->cookie(); - $expected = array( - 'CakeTestCookie[foo]' => array( + $expected = [ + 'CakeTestCookie[foo]' => [ 'name' => 'CakeTestCookie[foo]', 'value' => '', 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false - ), - 'CakeTestCookie[other]' => array( + ], + 'CakeTestCookie[other]' => [ 'name' => 'CakeTestCookie[other]', 'value' => '', 'path' => '/', 'domain' => '', 'secure' => false, 'httpOnly' => false - ), - ); + ], + ]; $expires = Hash::combine($cookies, '{*}.name', '{*}.expire'); $cookies = Hash::remove($cookies, '{*}.expire'); diff --git a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php index 107cba0908..3ebb3e8280 100644 --- a/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/EmailComponentTest.php @@ -61,8 +61,8 @@ class DebugCompTransport extends AbstractTransport { * @return bool */ public function send(CakeEmail $email) { - $email->addHeaders(array('Date' => EmailComponentTest::$sentDate)); - $headers = $email->getHeaders(array_fill_keys(array('from', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'), true)); + $email->addHeaders(['Date' => EmailComponentTest::$sentDate]); + $headers = $email->getHeaders(array_fill_keys(['from', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'], true)); $to = $headers['To']; $subject = $headers['Subject']; unset($headers['To'], $headers['Subject']); @@ -103,7 +103,7 @@ class EmailTestController extends Controller { * * @var array */ - public $components = array('Session', 'EmailTest'); + public $components = ['Session', 'EmailTest']; } @@ -147,13 +147,13 @@ public function setUp() : void { $this->Controller = new EmailTestController(); $this->Controller->Components->init($this->Controller); - $this->Controller->EmailTest->initialize($this->Controller, array()); + $this->Controller->EmailTest->initialize($this->Controller, []); static::$sentDate = date(DATE_RFC2822); - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); } /** @@ -331,7 +331,7 @@ public function testTemplateNestedElements() { $this->Controller->EmailTest->layout = 'default'; $this->Controller->EmailTest->template = 'nested_element'; $this->Controller->EmailTest->sendAs = 'html'; - $this->Controller->helpers = array('Html'); + $this->Controller->helpers = ['Html']; $this->Controller->EmailTest->send(); $result = DebugCompTransport::$lastEmail; @@ -432,9 +432,9 @@ public function testSendDebugWithNoSessions() { * @return void */ public function testMessageRetrievalWithoutTemplate() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $this->Controller->EmailTest->to = 'postmaster@example.com'; $this->Controller->EmailTest->from = 'noreply@example.com'; @@ -469,9 +469,9 @@ public function testMessageRetrievalWithoutTemplate() { * @return void */ public function testMessageRetrievalWithTemplate() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $this->Controller->set('value', 22091985); $this->Controller->set('title_for_layout', 'EmailTest'); @@ -529,14 +529,14 @@ public function testMessageRetrievalWithTemplate() { * @return void */ public function testMessageRetrievalWithHelper() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $timestamp = time(); $this->Controller->set('time', $timestamp); $this->Controller->set('title_for_layout', 'EmailTest'); - $this->Controller->helpers = array('Time'); + $this->Controller->helpers = ['Time']; $this->Controller->EmailTest->to = 'postmaster@example.com'; $this->Controller->EmailTest->from = 'noreply@example.com'; @@ -564,7 +564,7 @@ public function testSendContentArray() { $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'DebugComp'; - $content = array('First line', 'Second line', 'Third line'); + $content = ['First line', 'Second line', 'Third line']; $this->assertTrue($this->Controller->EmailTest->send($content)); $result = DebugCompTransport::$lastEmail; @@ -700,10 +700,10 @@ public function testSendWithAttachments() { $this->Controller->EmailTest->replyTo = 'noreply@example.com'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'DebugComp'; - $this->Controller->EmailTest->attachments = array( + $this->Controller->EmailTest->attachments = [ __FILE__, 'some-name.php' => __FILE__ - ); + ]; $body = '

This is the body of the message

'; $this->Controller->EmailTest->sendAs = 'text'; @@ -725,7 +725,7 @@ public function testSendAsIsNotIgnoredIfAttachmentsPresent() { $this->Controller->EmailTest->replyTo = 'noreply@example.com'; $this->Controller->EmailTest->template = null; $this->Controller->EmailTest->delivery = 'DebugComp'; - $this->Controller->EmailTest->attachments = array(__FILE__); + $this->Controller->EmailTest->attachments = [__FILE__]; $body = '

This is the body of the message

'; $this->Controller->EmailTest->sendAs = 'html'; @@ -782,15 +782,15 @@ public function testReset() { $this->Controller->EmailTest->from = 'test.sender@example.com'; $this->Controller->EmailTest->replyTo = 'test.replyto@example.com'; $this->Controller->EmailTest->return = 'test.return@example.com'; - $this->Controller->EmailTest->cc = array('cc1@example.com', 'cc2@example.com'); - $this->Controller->EmailTest->bcc = array('bcc1@example.com', 'bcc2@example.com'); + $this->Controller->EmailTest->cc = ['cc1@example.com', 'cc2@example.com']; + $this->Controller->EmailTest->bcc = ['bcc1@example.com', 'bcc2@example.com']; $this->Controller->EmailTest->date = 'Today!'; $this->Controller->EmailTest->subject = 'Test subject'; $this->Controller->EmailTest->additionalParams = 'X-additional-header'; $this->Controller->EmailTest->delivery = 'smtp'; $this->Controller->EmailTest->smtpOptions['host'] = 'blah'; $this->Controller->EmailTest->smtpOptions['timeout'] = 0.2; - $this->Controller->EmailTest->attachments = array('attachment1', 'attachment2'); + $this->Controller->EmailTest->attachments = ['attachment1', 'attachment2']; $this->Controller->EmailTest->textMessage = 'This is the body of the message'; $this->Controller->EmailTest->htmlMessage = 'This is the body of the message'; $this->Controller->EmailTest->messageId = false; @@ -798,34 +798,34 @@ public function testReset() { try { $this->Controller->EmailTest->send('Should not work'); $this->fail('No exception'); - } catch (SocketException $e) { + } catch (SocketException) { $this->assertTrue(true, 'SocketException raised'); } $this->Controller->EmailTest->reset(); $this->assertNull($this->Controller->EmailTest->template); - $this->assertSame($this->Controller->EmailTest->to, array()); + $this->assertSame($this->Controller->EmailTest->to, []); $this->assertNull($this->Controller->EmailTest->from); $this->assertNull($this->Controller->EmailTest->replyTo); $this->assertNull($this->Controller->EmailTest->return); - $this->assertSame($this->Controller->EmailTest->cc, array()); - $this->assertSame($this->Controller->EmailTest->bcc, array()); + $this->assertSame($this->Controller->EmailTest->cc, []); + $this->assertSame($this->Controller->EmailTest->bcc, []); $this->assertNull($this->Controller->EmailTest->date); $this->assertNull($this->Controller->EmailTest->subject); $this->assertNull($this->Controller->EmailTest->additionalParams); $this->assertNull($this->Controller->EmailTest->smtpError); - $this->assertSame($this->Controller->EmailTest->attachments, array()); + $this->assertSame($this->Controller->EmailTest->attachments, []); $this->assertNull($this->Controller->EmailTest->textMessage); $this->assertTrue($this->Controller->EmailTest->messageId); $this->assertEquals('mail', $this->Controller->EmailTest->delivery); } public function testPluginCustomViewClass() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $this->Controller->view = 'TestPlugin.Email'; @@ -866,7 +866,7 @@ public function testMessageId() { $this->assertTrue($this->Controller->EmailTest->send('This is the body of the message')); $result = DebugCompTransport::$lastEmail; - $host = env('HTTP_HOST') ? env('HTTP_HOST') : php_uname('n'); + $host = env('HTTP_HOST') ?: php_uname('n'); $this->assertMatchesRegularExpression('/Message-ID: \<[a-f0-9]{8}[a-f0-9]{4}[a-f0-9]{4}[a-f0-9]{4}[a-f0-9]{12}@' . $host . '\>\n/', $result); $this->Controller->EmailTest->messageId = '<22091985.998877@example.com>'; diff --git a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php index d56d29fdfe..de293931a3 100644 --- a/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/FlashComponentTest.php @@ -58,90 +58,90 @@ public function testSet() { $this->assertNull(CakeSession::read('Message.flash')); $this->Flash->set('This is a test message'); - $expected = array( - array( + $expected = [ + [ 'message' => 'This is a test message', 'key' => 'flash', 'element' => 'Flash/default', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); $this->Flash->set('This is the first message'); $this->Flash->set('This is the second message'); - $expected = array( - array( + $expected = [ + [ 'message' => 'This is the first message', 'key' => 'flash', 'element' => 'Flash/default', - 'params' => array() - ), - array( + 'params' => [] + ], + [ 'message' => 'This is the second message', 'key' => 'flash', 'element' => 'Flash/default', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); - $this->Flash->set('This is a test message', array( + $this->Flash->set('This is a test message', [ 'element' => 'test', - 'params' => array('foo' => 'bar') - )); - $expected = array( - array( + 'params' => ['foo' => 'bar'] + ]); + $expected = [ + [ 'message' => 'This is a test message', 'key' => 'flash', 'element' => 'Flash/test', - 'params' => array('foo' => 'bar') - ) - ); + 'params' => ['foo' => 'bar'] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); - $this->Flash->set('This is a test message', array('element' => 'MyPlugin.alert')); - $expected = array( - array( + $this->Flash->set('This is a test message', ['element' => 'MyPlugin.alert']); + $expected = [ + [ 'message' => 'This is a test message', 'key' => 'flash', 'element' => 'MyPlugin.Flash/alert', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); - $this->Flash->set('This is a test message', array('key' => 'foobar')); - $expected = array( - array( + $this->Flash->set('This is a test message', ['key' => 'foobar']); + $expected = [ + [ 'message' => 'This is a test message', 'key' => 'foobar', 'element' => 'Flash/default', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.foobar'); $this->assertEquals($expected, $result); CakeSession::delete('Message.foobar'); $this->Flash->set('This is the first message'); - $this->Flash->set('This is the second message', array('clear' => true)); - $expected = array( - array( + $this->Flash->set('This is the second message', ['clear' => true]); + $expected = [ + [ 'message' => 'This is the second message', 'key' => 'flash', 'element' => 'Flash/default', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); @@ -156,14 +156,14 @@ public function testSetWithException() { $this->assertNull(CakeSession::read('Message.flash')); $this->Flash->set(new Exception('This is a test message', 404)); - $expected = array( - array( + $expected = [ + [ 'message' => 'This is a test message', 'key' => 'flash', 'element' => 'Flash/default', - 'params' => array('code' => 404) - ) - ); + 'params' => ['code' => 404] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); @@ -177,16 +177,16 @@ public function testSetWithException() { public function testSetWithComponentConfiguration() { $this->assertNull(CakeSession::read('Message.flash')); - $FlashWithSettings = $this->Components->load('Flash', array('element' => 'test')); + $FlashWithSettings = $this->Components->load('Flash', ['element' => 'test']); $FlashWithSettings->set('This is a test message'); - $expected = array( - array( + $expected = [ + [ 'message' => 'This is a test message', 'key' => 'flash', 'element' => 'Flash/test', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); @@ -201,40 +201,40 @@ public function testCall() { $this->assertNull(CakeSession::read('Message.flash')); $this->Flash->success('It worked'); - $expected = array( - array( + $expected = [ + [ 'message' => 'It worked', 'key' => 'flash', 'element' => 'Flash/success', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); - $this->Flash->alert('It worked', array('plugin' => 'MyPlugin')); - $expected = array( - array( + $this->Flash->alert('It worked', ['plugin' => 'MyPlugin']); + $expected = [ + [ 'message' => 'It worked', 'key' => 'flash', 'element' => 'MyPlugin.Flash/alert', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result); CakeSession::delete('Message.flash'); - $this->Flash->error('It did not work', array('element' => 'error_thing')); - $expected = array( - array( + $this->Flash->error('It did not work', ['element' => 'error_thing']); + $expected = [ + [ 'message' => 'It did not work', 'key' => 'flash', 'element' => 'Flash/error', - 'params' => array() - ) - ); + 'params' => [] + ] + ]; $result = CakeSession::read('Message.flash'); $this->assertEquals($expected, $result, 'Element is ignored in magic call.'); CakeSession::delete('Message.flash'); diff --git a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php index b20bf6b46f..e4ee74a38c 100644 --- a/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/PaginatorComponentTest.php @@ -23,7 +23,7 @@ App::uses('CakeRequest', 'Network'); App::uses('CakeResponse', 'Network'); -require_once dirname(dirname(dirname(__FILE__))) . DS . 'Model' . DS . 'models.php'; +require_once dirname(__FILE__, 3) . DS . 'Model' . DS . 'models.php'; /** * PaginatorTestController class @@ -37,7 +37,7 @@ class PaginatorTestController extends Controller { * * @var array */ - public $components = array('Paginator'); + public $components = ['Paginator']; } /** @@ -59,21 +59,21 @@ class PaginatorControllerPost extends CakeTestModel { * * @var array */ - public $invalidFields = array('name' => 'error_msg'); + public $invalidFields = ['name' => 'error_msg']; /** * lastQueries property * * @var array */ - public $lastQueries = array(); + public $lastQueries = []; /** * belongsTo property * * @var array */ - public $belongsTo = array('PaginatorAuthor' => array('foreignKey' => 'author_id')); + public $belongsTo = ['PaginatorAuthor' => ['foreignKey' => 'author_id']]; /** * beforeFind method @@ -92,9 +92,9 @@ public function beforeFind($query) { * @param array $options * @return void */ - public function find($conditions = null, $fields = array(), $order = null, $recursive = null) { + public function find($conditions = null, $fields = [], $order = null, $recursive = null) { if ($conditions === 'popular') { - $conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1'); + $conditions = [$this->name . '.' . $this->primaryKey . ' > ' => '1']; $options = Hash::merge($fields, compact('conditions')); return parent::find('all', $options); } @@ -124,7 +124,7 @@ class ControllerPaginateModel extends CakeTestModel { */ public function paginate($conditions, $fields, $order, $limit, $page, $recursive, $extra) { $this->extra = $extra; - return array(true); + return [true]; } /** @@ -186,9 +186,9 @@ class PaginatorAuthor extends CakeTestModel { * * @var string */ - public $virtualFields = array( + public $virtualFields = [ 'joined_offset' => 'PaginatorAuthor.id + 1' - ); + ]; } @@ -211,25 +211,25 @@ class PaginatorCustomPost extends CakeTestModel { * * @var string */ - public $belongsTo = array('Author'); + public $belongsTo = ['Author']; /** * findMethods property * * @var array */ - public $findMethods = array( + public $findMethods = [ 'published' => true, 'totals' => true, 'totalsOperation' => true - ); + ]; /** * _findPublished custom find * * @return array */ - protected function _findPublished($state, $query, $results = array()) { + protected function _findPublished($state, $query, $results = []) { if ($state === 'before') { $query['conditions']['published'] = 'Y'; return $query; @@ -242,16 +242,16 @@ protected function _findPublished($state, $query, $results = array()) { * * @return array */ - protected function _findTotals($state, $query, $results = array()) { + protected function _findTotals($state, $query, $results = []) { if ($state === 'before') { - $query['fields'] = array('author_id'); + $query['fields'] = ['author_id']; $this->virtualFields['total_posts'] = "COUNT({$this->alias}.id)"; $query['fields'][] = 'total_posts'; - $query['group'] = array('author_id'); - $query['order'] = array('author_id' => 'ASC'); + $query['group'] = ['author_id']; + $query['order'] = ['author_id' => 'ASC']; return $query; } - $this->virtualFields = array(); + $this->virtualFields = []; return $results; } @@ -260,24 +260,24 @@ protected function _findTotals($state, $query, $results = array()) { * * @return array */ - protected function _findTotalsOperation($state, $query, $results = array()) { + protected function _findTotalsOperation($state, $query, $results = []) { if ($state === 'before') { if (!empty($query['operation']) && $query['operation'] === 'count') { unset($query['limit']); $query['recursive'] = -1; - $query['fields'] = array('COUNT(DISTINCT author_id) AS count'); + $query['fields'] = ['COUNT(DISTINCT author_id) AS count']; return $query; } $query['recursive'] = 0; $query['callbacks'] = 'before'; - $query['fields'] = array('author_id', 'Author.user'); + $query['fields'] = ['author_id', 'Author.user']; $this->virtualFields['total_posts'] = "COUNT({$this->alias}.id)"; $query['fields'][] = 'total_posts'; - $query['group'] = array('author_id', 'Author.user'); - $query['order'] = array('author_id' => 'ASC'); + $query['group'] = ['author_id', 'Author.user']; + $query['order'] = ['author_id' => 'ASC']; return $query; } - $this->virtualFields = array(); + $this->virtualFields = []; return $results; } @@ -290,8 +290,8 @@ class PaginatorComponentTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.post', 'core.comment', 'core.author', - 'core.translated_article', 'core.translate_article', 'core.user'); + public $fixtures = ['core.post', 'core.comment', 'core.author', + 'core.translated_article', 'core.translate_article', 'core.user']; /** * setup @@ -301,9 +301,9 @@ class PaginatorComponentTest extends CakeTestCase { public function setUp() : void { parent::setUp(); $this->request = new CakeRequest('controller_posts/index'); - $this->request->params['pass'] = $this->request->params['named'] = array(); + $this->request->params['pass'] = $this->request->params['named'] = []; $this->Controller = new Controller($this->request); - $this->Paginator = new PaginatorComponent($this->getMock('ComponentCollection'), array()); + $this->Paginator = new PaginatorComponent($this->getMock('ComponentCollection'), []); $this->Paginator->Controller = $this->Controller; $this->Controller->Post = $this->getMock('Model'); $this->Controller->Post->alias = 'Post'; @@ -316,87 +316,87 @@ public function setUp() : void { */ public function testPaginate() { $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); - $Controller->request->params['pass'] = array('1'); - $Controller->request->query = array(); + $Controller->uses = ['PaginatorControllerPost', 'PaginatorControllerComment']; + $Controller->request->params['pass'] = ['1']; + $Controller->request->query = []; $Controller->constructClasses(); $Controller->PaginatorControllerPost->order = null; - $Controller->Paginator->settings = array( - 'order' => array('PaginatorControllerComment.id' => 'ASC') - ); + $Controller->Paginator->settings = [ + 'order' => ['PaginatorControllerComment.id' => 'ASC'] + ]; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id'); - $this->assertEquals(array(1, 2, 3, 4, 5, 6), $results); + $this->assertEquals([1, 2, 3, 4, 5, 6], $results); - $Controller->Paginator->settings = array( - 'order' => array('PaginatorControllerComment.id DESC') - ); + $Controller->Paginator->settings = [ + 'order' => ['PaginatorControllerComment.id DESC'] + ]; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id'); - $this->assertEquals(array(6, 5, 4, 3, 2, 1), $results); + $this->assertEquals([6, 5, 4, 3, 2, 1], $results); - $Controller->Paginator->settings = array( - 'order' => array('PaginatorControllerPost.id' => 'ASC') - ); + $Controller->Paginator->settings = [ + 'order' => ['PaginatorControllerPost.id' => 'ASC'] + ]; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); - $this->assertEquals(array(1, 2, 3), $results); + $this->assertEquals([1, 2, 3], $results); $Controller->modelClass = null; $Controller->uses[0] = 'Plugin.PaginatorControllerPost'; $results = Hash::extract($Controller->Paginator->paginate(), '{n}.PaginatorControllerPost.id'); - $this->assertEquals(array(1, 2, 3), $results); + $this->assertEquals([1, 2, 3], $results); - $Controller->request->params['named'] = array('page' => '-1'); + $Controller->request->params['named'] = ['page' => '-1']; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(1, 2, 3), $results); + $this->assertEquals([1, 2, 3], $results); - $Controller->request->params['named'] = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'asc'); + $Controller->request->params['named'] = ['sort' => 'PaginatorControllerPost.id', 'direction' => 'asc']; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(1, 2, 3), $results); + $this->assertEquals([1, 2, 3], $results); - $Controller->request->params['named'] = array('sort' => 'PaginatorControllerPost.id', 'direction' => 'desc'); + $Controller->request->params['named'] = ['sort' => 'PaginatorControllerPost.id', 'direction' => 'desc']; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(3, 2, 1), $results); + $this->assertEquals([3, 2, 1], $results); - $Controller->request->params['named'] = array('sort' => 'id', 'direction' => 'desc'); + $Controller->request->params['named'] = ['sort' => 'id', 'direction' => 'desc']; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(3, 2, 1), $results); + $this->assertEquals([3, 2, 1], $results); - $Controller->request->params['named'] = array('sort' => 'NotExisting.field', 'direction' => 'desc', 'limit' => 2); + $Controller->request->params['named'] = ['sort' => 'NotExisting.field', 'direction' => 'desc', 'limit' => 2]; $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(), $Controller->PaginatorControllerPost->lastQueries[1]['order'], 'no order should be set.'); + $this->assertEquals([], $Controller->PaginatorControllerPost->lastQueries[1]['order'], 'no order should be set.'); - $Controller->request->params['named'] = array( + $Controller->request->params['named'] = [ 'sort' => 'PaginatorControllerPost.author_id', 'direction' => 'allYourBase' - ); + ]; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); - $this->assertEquals(array('PaginatorControllerPost.author_id' => 'asc'), $Controller->PaginatorControllerPost->lastQueries[0]['order']); - $this->assertEquals(array(1, 3, 2), $results); + $this->assertEquals(['PaginatorControllerPost.author_id' => 'asc'], $Controller->PaginatorControllerPost->lastQueries[0]['order']); + $this->assertEquals([1, 3, 2], $results); - $Controller->request->params['named'] = array(); - $Controller->Paginator->settings = array('limit' => 0, 'maxLimit' => 10, 'paramType' => 'named'); + $Controller->request->params['named'] = []; + $Controller->Paginator->settings = ['limit' => 0, 'maxLimit' => 10, 'paramType' => 'named']; $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertSame(1, $Controller->params['paging']['PaginatorControllerPost']['page']); $this->assertSame($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); $this->assertFalse($Controller->params['paging']['PaginatorControllerPost']['prevPage']); $this->assertTrue($Controller->params['paging']['PaginatorControllerPost']['nextPage']); - $Controller->request->params['named'] = array(); - $Controller->Paginator->settings = array('limit' => 'garbage!', 'maxLimit' => 10, 'paramType' => 'named'); + $Controller->request->params['named'] = []; + $Controller->Paginator->settings = ['limit' => 'garbage!', 'maxLimit' => 10, 'paramType' => 'named']; $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertSame(1, $Controller->params['paging']['PaginatorControllerPost']['page']); $this->assertSame($Controller->params['paging']['PaginatorControllerPost']['pageCount'], 3); $this->assertFalse($Controller->params['paging']['PaginatorControllerPost']['prevPage']); $this->assertTrue($Controller->params['paging']['PaginatorControllerPost']['nextPage']); - $Controller->request->params['named'] = array(); - $Controller->Paginator->settings = array('limit' => '-1', 'maxLimit' => 10, 'paramType' => 'named'); + $Controller->request->params['named'] = []; + $Controller->Paginator->settings = ['limit' => '-1', 'maxLimit' => 10, 'paramType' => 'named']; $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertSame($Controller->params['paging']['PaginatorControllerPost']['limit'], 1); @@ -405,7 +405,7 @@ public function testPaginate() { $this->assertFalse($Controller->params['paging']['PaginatorControllerPost']['prevPage']); $this->assertTrue($Controller->params['paging']['PaginatorControllerPost']['nextPage']); - $Controller->Paginator->settings = array('conditions' => array('PaginatorAuthor.user' => 'mariano')); + $Controller->Paginator->settings = ['conditions' => ['PaginatorAuthor.user' => 'mariano']]; $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertSame(2, $Controller->params['paging']['PaginatorControllerPost']['count']); @@ -413,15 +413,15 @@ public function testPaginate() { public function testPaginateNotCondition() { $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); - $Controller->request->params['pass'] = array('1'); - $Controller->request->query = array(); + $Controller->uses = ['PaginatorControllerPost', 'PaginatorControllerComment']; + $Controller->request->params['pass'] = ['1']; + $Controller->request->query = []; $Controller->constructClasses(); - $Controller->Paginator->settings = array( - 'conditions' => array( - 'NOT' => array('PaginatorAuthor.user' => 'mariano'), - ), - ); + $Controller->Paginator->settings = [ + 'conditions' => [ + 'NOT' => ['PaginatorAuthor.user' => 'mariano'], + ], + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals('larry', $result[0]['PaginatorAuthor']['user']); $this->assertCount(1, $result); @@ -430,15 +430,15 @@ public function testPaginateNotCondition() { public function testPaginateI18nConditionUser() { $Request = new CakeRequest('articles/index'); $Controller = new PaginatorTestController($Request); - $Controller->uses = array('TranslatedArticle'); + $Controller->uses = ['TranslatedArticle']; $Controller->constructClasses(); $Controller->TranslatedArticle->locale = 'eng'; - $Controller->Paginator->settings = array( + $Controller->Paginator->settings = [ 'recursive' => 0, - 'conditions' => array( + 'conditions' => [ 'User.user' => 'mariano', - ), - ); + ], + ]; $result = $Controller->Paginator->paginate('TranslatedArticle'); $this->assertEquals('Title (eng) #1', $result[0]['TranslatedArticle']['title']); $this->assertEquals('mariano', $result[0]['User']['user']); @@ -450,15 +450,15 @@ public function testPaginateI18nConditionUser() { public function testPaginateI18nConditionTitle() { $Request = new CakeRequest('articles/index'); $Controller = new PaginatorTestController($Request); - $Controller->uses = array('TranslatedArticle'); + $Controller->uses = ['TranslatedArticle']; $Controller->constructClasses(); $Controller->TranslatedArticle->locale = 'eng'; - $Controller->Paginator->settings = array( + $Controller->Paginator->settings = [ 'recursive' => 0, - 'conditions' => array( + 'conditions' => [ 'I18n__title.content' => 'Title (eng) #3', - ), - ); + ], + ]; $result = $Controller->Paginator->paginate('TranslatedArticle'); $this->assertEquals('Title (eng) #3', $result[0]['TranslatedArticle']['title']); $this->assertCount(1, $result); @@ -467,15 +467,15 @@ public function testPaginateI18nConditionTitle() { public function testPaginateI18nConditionNotTitle() { $Request = new CakeRequest('articles/index'); $Controller = new PaginatorTestController($Request); - $Controller->uses = array('TranslatedArticle'); + $Controller->uses = ['TranslatedArticle']; $Controller->constructClasses(); $Controller->TranslatedArticle->locale = 'eng'; - $Controller->Paginator->settings = array( + $Controller->Paginator->settings = [ 'recursive' => 0, - 'conditions' => array( + 'conditions' => [ 'I18n__title.content !=' => '', - ), - ); + ], + ]; $result = $Controller->Paginator->paginate('TranslatedArticle'); $this->assertEquals('Title (eng) #1', $result[0]['TranslatedArticle']['title']); $this->assertEquals('Title (eng) #2', $result[1]['TranslatedArticle']['title']); @@ -486,15 +486,15 @@ public function testPaginateI18nConditionNotTitle() { public function testPaginateI18nConditionNotTitleArraySyntax() { $Request = new CakeRequest('articles/index'); $Controller = new PaginatorTestController($Request); - $Controller->uses = array('TranslatedArticle'); + $Controller->uses = ['TranslatedArticle']; $Controller->constructClasses(); $Controller->TranslatedArticle->locale = 'eng'; - $Controller->Paginator->settings = array( + $Controller->Paginator->settings = [ 'recursive' => 0, - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), - ); + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], + ]; $result = $Controller->Paginator->paginate('TranslatedArticle'); $this->assertEquals('Title (eng) #1', $result[0]['TranslatedArticle']['title']); $this->assertEquals('Title (eng) #2', $result[1]['TranslatedArticle']['title']); @@ -505,16 +505,16 @@ public function testPaginateI18nConditionNotTitleArraySyntax() { public function testPaginateI18nConditionNotTitleWithLimit() { $Request = new CakeRequest('articles/index'); $Controller = new PaginatorTestController($Request); - $Controller->uses = array('TranslatedArticle'); + $Controller->uses = ['TranslatedArticle']; $Controller->constructClasses(); $Controller->TranslatedArticle->locale = 'eng'; - $Controller->Paginator->settings = array( + $Controller->Paginator->settings = [ 'recursive' => 0, - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'limit' => 2, - ); + ]; $result = $Controller->Paginator->paginate('TranslatedArticle'); $this->assertEquals('Title (eng) #1', $result[0]['TranslatedArticle']['title']); $this->assertEquals('Title (eng) #2', $result[1]['TranslatedArticle']['title']); @@ -534,7 +534,7 @@ public function testPageParamCasting() { $this->Controller->Post->expects($this->at(1)) ->method('find') - ->will($this->returnValue(array('stuff'))); + ->will($this->returnValue(['stuff'])); $this->Controller->Post->expects($this->at(2)) ->method('hasMethod') @@ -545,8 +545,8 @@ public function testPageParamCasting() { ->method('find') ->will($this->returnValue(2)); - $this->request->params['named'] = array('page' => '1 " onclick="alert(\'xss\');">'); - $this->Paginator->settings = array('limit' => 1, 'maxLimit' => 10, 'paramType' => 'named'); + $this->request->params['named'] = ['page' => '1 " onclick="alert(\'xss\');">']; + $this->Paginator->settings = ['limit' => 1, 'maxLimit' => 10, 'paramType' => 'named']; $this->Paginator->paginate('Post'); $this->assertSame(1, $this->request->params['paging']['Post']['page'], 'XSS exploit opened'); } @@ -559,52 +559,52 @@ public function testPageParamCasting() { public function testPaginateExtraParams() { $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); - $Controller->request->params['pass'] = array('1'); - $Controller->params['url'] = array(); + $Controller->uses = ['PaginatorControllerPost', 'PaginatorControllerComment']; + $Controller->request->params['pass'] = ['1']; + $Controller->params['url'] = []; $Controller->constructClasses(); - $Controller->request->params['named'] = array('page' => '-1', 'contain' => array('PaginatorControllerComment')); - $Controller->Paginator->settings = array( - 'order' => array('PaginatorControllerPost.id' => 'ASC') - ); + $Controller->request->params['named'] = ['page' => '-1', 'contain' => ['PaginatorControllerComment']]; + $Controller->Paginator->settings = [ + 'order' => ['PaginatorControllerPost.id' => 'ASC'] + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id')); + $this->assertEquals([1, 2, 3], Hash::extract($result, '{n}.PaginatorControllerPost.id')); $this->assertTrue(!isset($Controller->PaginatorControllerPost->lastQueries[1]['contain'])); - $Controller->Paginator->settings = array( - 'order' => array('PaginatorControllerPost.author_id') - ); + $Controller->Paginator->settings = [ + 'order' => ['PaginatorControllerPost.author_id'] + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(1, 3, 2), Hash::extract($result, '{n}.PaginatorControllerPost.id')); + $this->assertEquals([1, 3, 2], Hash::extract($result, '{n}.PaginatorControllerPost.id')); - $Controller->request->params['named'] = array('page' => '-1'); - $Controller->Paginator->settings = array( - 'PaginatorControllerPost' => array( - 'contain' => array('PaginatorControllerComment'), + $Controller->request->params['named'] = ['page' => '-1']; + $Controller->Paginator->settings = [ + 'PaginatorControllerPost' => [ + 'contain' => ['PaginatorControllerComment'], 'maxLimit' => 10, 'paramType' => 'named', - 'order' => array('PaginatorControllerPost.id' => 'ASC') - ), - ); + 'order' => ['PaginatorControllerPost.id' => 'ASC'] + ], + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); $this->assertEquals(1, $Controller->params['paging']['PaginatorControllerPost']['page']); - $this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id')); + $this->assertEquals([1, 2, 3], Hash::extract($result, '{n}.PaginatorControllerPost.id')); $this->assertTrue(isset($Controller->PaginatorControllerPost->lastQueries[0]['contain'])); - $Controller->Paginator->settings = array( - 'PaginatorControllerPost' => array( - 'popular', 'fields' => array('id', 'title'), 'maxLimit' => 10, 'paramType' => 'named' - ), - ); + $Controller->Paginator->settings = [ + 'PaginatorControllerPost' => [ + 'popular', 'fields' => ['id', 'title'], 'maxLimit' => 10, 'paramType' => 'named' + ], + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertEquals(array(2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id')); - $this->assertEquals(array('PaginatorControllerPost.id > ' => '1'), $Controller->PaginatorControllerPost->lastQueries[0]['conditions']); + $this->assertEquals([2, 3], Hash::extract($result, '{n}.PaginatorControllerPost.id')); + $this->assertEquals(['PaginatorControllerPost.id > ' => '1'], $Controller->PaginatorControllerPost->lastQueries[0]['conditions']); - $Controller->request->params['named'] = array('limit' => 12); - $Controller->Paginator->settings = array('limit' => 30, 'maxLimit' => 100, 'paramType' => 'named'); + $Controller->request->params['named'] = ['limit' => 12]; + $Controller->Paginator->settings = ['limit' => 30, 'maxLimit' => 100, 'paramType' => 'named']; $Controller->Paginator->paginate('PaginatorControllerPost'); $paging = $Controller->params['paging']['PaginatorControllerPost']; @@ -612,46 +612,46 @@ public function testPaginateExtraParams() { $this->assertEquals(12, $paging['options']['limit']); $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('ControllerPaginateModel'); - $Controller->request->query = array(); + $Controller->uses = ['ControllerPaginateModel']; + $Controller->request->query = []; $Controller->constructClasses(); - $Controller->Paginator->settings = array( - 'ControllerPaginateModel' => array( - 'contain' => array('ControllerPaginateModel'), + $Controller->Paginator->settings = [ + 'ControllerPaginateModel' => [ + 'contain' => ['ControllerPaginateModel'], 'group' => 'Comment.author_id', 'maxLimit' => 10, 'paramType' => 'named' - ) - ); + ] + ]; $Controller->Paginator->paginate('ControllerPaginateModel'); - $expected = array( - 'contain' => array('ControllerPaginateModel'), + $expected = [ + 'contain' => ['ControllerPaginateModel'], 'group' => 'Comment.author_id', 'maxLimit' => 10, 'paramType' => 'named', 'queryScope' => null - ); + ]; $this->assertEquals($expected, $Controller->ControllerPaginateModel->extra); $this->assertEquals($expected, $Controller->ControllerPaginateModel->extraCount); - $Controller->Paginator->settings = array( - 'ControllerPaginateModel' => array( - 'foo', 'contain' => array('ControllerPaginateModel'), + $Controller->Paginator->settings = [ + 'ControllerPaginateModel' => [ + 'foo', 'contain' => ['ControllerPaginateModel'], 'group' => 'Comment.author_id', 'maxLimit' => 10, 'paramType' => 'named', 'queryScope' => null - ) - ); + ] + ]; $Controller->Paginator->paginate('ControllerPaginateModel'); - $expected = array( - 'contain' => array('ControllerPaginateModel'), + $expected = [ + 'contain' => ['ControllerPaginateModel'], 'group' => 'Comment.author_id', 'type' => 'foo', 'maxLimit' => 10, 'paramType' => 'named', 'queryScope' => null - ); + ]; $this->assertEquals($expected, $Controller->ControllerPaginateModel->extra); $this->assertEquals($expected, $Controller->ControllerPaginateModel->extraCount); } @@ -663,25 +663,25 @@ public function testPaginateExtraParams() { */ public function testPaginateSpecialType() { $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); + $Controller->uses = ['PaginatorControllerPost', 'PaginatorControllerComment']; $Controller->request->params['pass'][] = '1'; - $Controller->params['url'] = array(); + $Controller->params['url'] = []; $Controller->constructClasses(); - $Controller->Paginator->settings = array( - 'PaginatorControllerPost' => array( + $Controller->Paginator->settings = [ + 'PaginatorControllerPost' => [ 'popular', - 'fields' => array('id', 'title'), + 'fields' => ['id', 'title'], 'maxLimit' => 10, 'paramType' => 'named' - ) - ); + ] + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertEquals(array(2, 3), Hash::extract($result, '{n}.PaginatorControllerPost.id')); + $this->assertEquals([2, 3], Hash::extract($result, '{n}.PaginatorControllerPost.id')); $this->assertEquals( $Controller->PaginatorControllerPost->lastQueries[0]['conditions'], - array('PaginatorControllerPost.id > ' => '1') + ['PaginatorControllerPost.id > ' => '1'] ); $this->assertFalse(isset($Controller->params['paging']['PaginatorControllerPost']['options'][0])); } @@ -694,16 +694,16 @@ public function testPaginateSpecialType() { public function testDefaultPaginateParams() { $Controller = new PaginatorTestController($this->request); $Controller->modelClass = 'PaginatorControllerPost'; - $Controller->params['url'] = array(); + $Controller->params['url'] = []; $Controller->constructClasses(); - $Controller->Paginator->settings = array( + $Controller->Paginator->settings = [ 'order' => 'PaginatorControllerPost.id DESC', 'maxLimit' => 10, 'paramType' => 'named' - ); + ]; $results = Hash::extract($Controller->Paginator->paginate('PaginatorControllerPost'), '{n}.PaginatorControllerPost.id'); $this->assertEquals('PaginatorControllerPost.id DESC', $Controller->params['paging']['PaginatorControllerPost']['order']); - $this->assertEquals(array(3, 2, 1), $results); + $this->assertEquals([3, 2, 1], $results); } /** @@ -713,54 +713,54 @@ public function testDefaultPaginateParams() { */ public function testPaginateOrderModelDefault() { $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost'); - $Controller->params['url'] = array(); + $Controller->uses = ['PaginatorControllerPost']; + $Controller->params['url'] = []; $Controller->constructClasses(); - $Controller->PaginatorControllerPost->order = array( + $Controller->PaginatorControllerPost->order = [ $Controller->PaginatorControllerPost->alias . '.created' => 'desc' - ); + ]; - $Controller->Paginator->settings = array( - 'fields' => array('id', 'title', 'created'), + $Controller->Paginator->settings = [ + 'fields' => ['id', 'title', 'created'], 'maxLimit' => 10, 'paramType' => 'named' - ); + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); - $expected = array('2007-03-18 10:43:23', '2007-03-18 10:41:23', '2007-03-18 10:39:23'); + $expected = ['2007-03-18 10:43:23', '2007-03-18 10:41:23', '2007-03-18 10:39:23']; $this->assertEquals($expected, Hash::extract($result, '{n}.PaginatorControllerPost.created')); $this->assertEquals( $Controller->PaginatorControllerPost->order, $Controller->request->paging['PaginatorControllerPost']['options']['order'] ); - $Controller->PaginatorControllerPost->order = array('PaginatorControllerPost.id'); - $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); - $this->assertEquals(array('PaginatorControllerPost.id' => 'asc'), $result['order']); + $Controller->PaginatorControllerPost->order = ['PaginatorControllerPost.id']; + $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, []); + $this->assertEquals(['PaginatorControllerPost.id' => 'asc'], $result['order']); $Controller->PaginatorControllerPost->order = 'PaginatorControllerPost.id'; - $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); + $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, []); $this->assertArrayNotHasKey('order', $result); - $Controller->PaginatorControllerPost->order = array( + $Controller->PaginatorControllerPost->order = [ 'PaginatorControllerPost.id', 'PaginatorControllerPost.created' => 'asc' - ); - $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); - $expected = array( + ]; + $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, []); + $expected = [ 'PaginatorControllerPost.id' => 'asc', 'PaginatorControllerPost.created' => 'asc' - ); + ]; $this->assertEquals($expected, $result['order']); - $Controller->PaginatorControllerPost->order = array( + $Controller->PaginatorControllerPost->order = [ 'PaginatorControllerPost.id ASC', 'PaginatorControllerPost.created DESC' - ); - $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, array()); - $expected = array( + ]; + $result = $Controller->Paginator->validateSort($Controller->PaginatorControllerPost, []); + $expected = [ 'PaginatorControllerPost.id' => 'ASC', 'PaginatorControllerPost.created' => 'DESC' - ); + ]; $this->assertEquals($expected, $result['order']); } @@ -771,25 +771,25 @@ public function testPaginateOrderModelDefault() { */ public function testPaginateOrderVirtualField() { $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); - $Controller->params['url'] = array(); + $Controller->uses = ['PaginatorControllerPost', 'PaginatorControllerComment']; + $Controller->params['url'] = []; $Controller->constructClasses(); - $Controller->PaginatorControllerPost->virtualFields = array( + $Controller->PaginatorControllerPost->virtualFields = [ 'offset_test' => 'PaginatorControllerPost.id + 1' - ); + ]; - $Controller->Paginator->settings = array( - 'fields' => array('id', 'title', 'offset_test'), - 'order' => array('offset_test' => 'DESC'), + $Controller->Paginator->settings = [ + 'fields' => ['id', 'title', 'offset_test'], + 'order' => ['offset_test' => 'DESC'], 'maxLimit' => 10, 'paramType' => 'named' - ); + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertEquals(array(4, 3, 2), Hash::extract($result, '{n}.PaginatorControllerPost.offset_test')); + $this->assertEquals([4, 3, 2], Hash::extract($result, '{n}.PaginatorControllerPost.offset_test')); - $Controller->request->params['named'] = array('sort' => 'offset_test', 'direction' => 'asc'); + $Controller->request->params['named'] = ['sort' => 'offset_test', 'direction' => 'asc']; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertEquals(array(2, 3, 4), Hash::extract($result, '{n}.PaginatorControllerPost.offset_test')); + $this->assertEquals([2, 3, 4], Hash::extract($result, '{n}.PaginatorControllerPost.offset_test')); } /** @@ -799,21 +799,21 @@ public function testPaginateOrderVirtualField() { */ public function testPaginateOrderVirtualFieldJoinedModel() { $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost'); - $Controller->params['url'] = array(); + $Controller->uses = ['PaginatorControllerPost']; + $Controller->params['url'] = []; $Controller->constructClasses(); $Controller->PaginatorControllerPost->recursive = 0; - $Controller->Paginator->settings = array( - 'order' => array('PaginatorAuthor.joined_offset' => 'DESC'), + $Controller->Paginator->settings = [ + 'order' => ['PaginatorAuthor.joined_offset' => 'DESC'], 'maxLimit' => 10, 'paramType' => 'named' - ); + ]; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertEquals(array(4, 2, 2), Hash::extract($result, '{n}.PaginatorAuthor.joined_offset')); + $this->assertEquals([4, 2, 2], Hash::extract($result, '{n}.PaginatorAuthor.joined_offset')); - $Controller->request->params['named'] = array('sort' => 'PaginatorAuthor.joined_offset', 'direction' => 'asc'); + $Controller->request->params['named'] = ['sort' => 'PaginatorAuthor.joined_offset', 'direction' => 'asc']; $result = $Controller->Paginator->paginate('PaginatorControllerPost'); - $this->assertEquals(array(2, 2, 4), Hash::extract($result, '{n}.PaginatorAuthor.joined_offset')); + $this->assertEquals([2, 2, 4], Hash::extract($result, '{n}.PaginatorAuthor.joined_offset')); } /** @@ -834,24 +834,24 @@ public function testPaginateMissingModel() { * @return void */ public function testMergeOptionsModelSpecific() { - $this->Paginator->settings = array( + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null, - 'Post' => array( + 'Post' => [ 'page' => 1, 'limit' => 10, 'maxLimit' => 50, 'paramType' => 'named', - ) - ); + ] + ]; $result = $this->Paginator->mergeOptions('Silly'); $this->assertEquals($this->Paginator->settings, $result); $result = $this->Paginator->mergeOptions('Post'); - $expected = array('page' => 1, 'limit' => 10, 'paramType' => 'named', 'maxLimit' => 50, 'queryScope' => null); + $expected = ['page' => 1, 'limit' => 10, 'paramType' => 'named', 'maxLimit' => 50, 'queryScope' => null]; $this->assertEquals($expected, $result); } @@ -861,18 +861,18 @@ public function testMergeOptionsModelSpecific() { * @return void */ public function testMergeOptionsNamedParams() { - $this->request->params['named'] = array( + $this->request->params['named'] = [ 'page' => 10, 'limit' => 10 - ); - $this->Paginator->settings = array( + ]; + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array('page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null); + $expected = ['page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null]; $this->assertEquals($expected, $result); } @@ -882,65 +882,65 @@ public function testMergeOptionsNamedParams() { * @return void */ public function testMergeOptionsCustomScope() { - $this->request->params['named'] = array( + $this->request->params['named'] = [ 'page' => 10, 'limit' => 10, - 'scope' => array( + 'scope' => [ 'page' => 2, 'limit' => 5, - ) - ); - $this->Paginator->settings = array( + ] + ]; + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'findType' => 'myCustomFind', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array( + $expected = [ 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'findType' => 'myCustomFind', 'paramType' => 'named', 'queryScope' => null - ); + ]; $this->assertEquals($expected, $result); - $this->Paginator->settings = array( + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'findType' => 'myCustomFind', 'queryScope' => 'non-existent', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array( + $expected = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'findType' => 'myCustomFind', 'paramType' => 'named', 'queryScope' => 'non-existent', - ); + ]; $this->assertEquals($expected, $result); - $this->Paginator->settings = array( + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'findType' => 'myCustomFind', 'queryScope' => 'scope', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array( + $expected = [ 'page' => 2, 'limit' => 5, 'maxLimit' => 100, 'findType' => 'myCustomFind', 'paramType' => 'named', 'queryScope' => 'scope', - ); + ]; $this->assertEquals($expected, $result); } @@ -950,26 +950,26 @@ public function testMergeOptionsCustomScope() { * @return void */ public function testMergeOptionsCustomFindKey() { - $this->request->params['named'] = array( + $this->request->params['named'] = [ 'page' => 10, 'limit' => 10 - ); - $this->Paginator->settings = array( + ]; + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', 'findType' => 'myCustomFind' - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array( + $expected = [ 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'findType' => 'myCustomFind', 'queryScope' => null - ); + ]; $this->assertEquals($expected, $result); } @@ -979,28 +979,28 @@ public function testMergeOptionsCustomFindKey() { * @return void */ public function testMergeOptionsQueryString() { - $this->request->params['named'] = array( + $this->request->params['named'] = [ 'page' => 10, 'limit' => 10 - ); - $this->request->query = array( + ]; + $this->request->query = [ 'page' => 99, 'limit' => 75 - ); - $this->Paginator->settings = array( + ]; + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'querystring', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array( + $expected = [ 'page' => 99, 'limit' => 75, 'maxLimit' => 100, 'paramType' => 'querystring', 'queryScope' => null - ); + ]; $this->assertEquals($expected, $result); } @@ -1010,22 +1010,22 @@ public function testMergeOptionsQueryString() { * @return void */ public function testMergeOptionsDefaultWhiteList() { - $this->request->params['named'] = array( + $this->request->params['named'] = [ 'page' => 10, 'limit' => 10, - 'fields' => array('bad.stuff'), + 'fields' => ['bad.stuff'], 'recursive' => 1000, - 'conditions' => array('bad.stuff'), - 'contain' => array('bad') - ); - $this->Paginator->settings = array( + 'conditions' => ['bad.stuff'], + 'contain' => ['bad'] + ]; + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array('page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null); + $expected = ['page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null]; $this->assertEquals($expected, $result); } @@ -1035,30 +1035,30 @@ public function testMergeOptionsDefaultWhiteList() { * @return void */ public function testMergeOptionsExtraWhitelist() { - $this->request->params['named'] = array( + $this->request->params['named'] = [ 'page' => 10, 'limit' => 10, - 'fields' => array('bad.stuff'), + 'fields' => ['bad.stuff'], 'recursive' => 1000, - 'conditions' => array('bad.stuff'), - 'contain' => array('bad') - ); - $this->Paginator->settings = array( + 'conditions' => ['bad.stuff'], + 'contain' => ['bad'] + ]; + $this->Paginator->settings = [ 'page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', - ); + ]; $this->Paginator->whitelist[] = 'fields'; $result = $this->Paginator->mergeOptions('Post'); - $expected = array( + $expected = [ 'page' => 10, 'limit' => 10, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null, - 'fields' => array('bad.stuff') - ); + 'fields' => ['bad.stuff'] + ]; $this->assertEquals($expected, $result); } @@ -1068,31 +1068,31 @@ public function testMergeOptionsExtraWhitelist() { * @return void */ public function testMergeOptionsMaxLimit() { - $this->Paginator->settings = array( + $this->Paginator->settings = [ 'limit' => 200, 'paramType' => 'named', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array('page' => 1, 'limit' => 200, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null); + $expected = ['page' => 1, 'limit' => 200, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null]; $this->assertEquals($expected, $result); - $this->Paginator->settings = array( + $this->Paginator->settings = [ 'maxLimit' => 10, 'paramType' => 'named', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array('page' => 1, 'limit' => 20, 'maxLimit' => 10, 'paramType' => 'named', 'queryScope' => null); + $expected = ['page' => 1, 'limit' => 20, 'maxLimit' => 10, 'paramType' => 'named', 'queryScope' => null]; $this->assertEquals($expected, $result); - $this->request->params['named'] = array( + $this->request->params['named'] = [ 'limit' => 500 - ); - $this->Paginator->settings = array( + ]; + $this->Paginator->settings = [ 'limit' => 150, 'paramType' => 'named', - ); + ]; $result = $this->Paginator->mergeOptions('Post'); - $expected = array('page' => 1, 'limit' => 500, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null); + $expected = ['page' => 1, 'limit' => 500, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null]; $this->assertEquals($expected, $result); } @@ -1106,7 +1106,7 @@ public function testValidateSortInvalidDirection() { $model->alias = 'model'; $model->expects($this->any())->method('hasField')->will($this->returnValue(true)); - $options = array('sort' => 'something', 'direction' => 'boogers'); + $options = ['sort' => 'something', 'direction' => 'boogers']; $result = $this->Paginator->validateSort($model, $options); $this->assertEquals('asc', $result['order']['model.something']); @@ -1120,10 +1120,10 @@ public function testValidateSortInvalidDirection() { public function testOutOfRangePageNumberGetsClamped() { $this->expectException(NotFoundException::class); $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost'); - $Controller->params['named'] = array( + $Controller->uses = ['PaginatorControllerPost']; + $Controller->params['named'] = [ 'page' => 3000, - ); + ]; $Controller->constructClasses(); $Controller->PaginatorControllerPost->recursive = 0; $Controller->Paginator->paginate('PaginatorControllerPost'); @@ -1137,10 +1137,10 @@ public function testOutOfRangePageNumberGetsClamped() { public function testOutOfVeryBigPageNumberGetsClamped() { $this->expectException(NotFoundException::class); $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost'); - $Controller->params['named'] = array( + $Controller->uses = ['PaginatorControllerPost']; + $Controller->params['named'] = [ 'page' => '3000000000000000000000000', - ); + ]; $Controller->constructClasses(); $Controller->PaginatorControllerPost->recursive = 0; $Controller->Paginator->paginate('PaginatorControllerPost'); @@ -1153,20 +1153,20 @@ public function testOutOfVeryBigPageNumberGetsClamped() { */ public function testOutOfRangePageNumberAndPageCountZero() { $Controller = new PaginatorTestController($this->request); - $Controller->uses = array('PaginatorControllerPost'); - $Controller->params['named'] = array( + $Controller->uses = ['PaginatorControllerPost']; + $Controller->params['named'] = [ 'page' => '3000', - ); + ]; $Controller->constructClasses(); $Controller->PaginatorControllerPost->recursive = 0; - $Controller->paginate = array( - 'conditions' => array('PaginatorControllerPost.id >' => 100) - ); + $Controller->paginate = [ + 'conditions' => ['PaginatorControllerPost.id >' => 100] + ]; try { $Controller->Paginator->paginate('PaginatorControllerPost'); $this->fail(); - } catch (NotFoundException $e) { + } catch (NotFoundException) { $this->assertEquals( 1, $Controller->request->params['paging']['PaginatorControllerPost']['page'], @@ -1185,8 +1185,8 @@ public function testValidateSortWhitelistFailure() { $model->alias = 'model'; $model->expects($this->any())->method('hasField')->will($this->returnValue(true)); - $options = array('sort' => 'body', 'direction' => 'asc'); - $result = $this->Paginator->validateSort($model, $options, array('title', 'id')); + $options = ['sort' => 'body', 'direction' => 'asc']; + $result = $this->Paginator->validateSort($model, $options, ['title', 'id']); $this->assertNull($result['order']); } @@ -1201,10 +1201,10 @@ public function testValidateSortWhitelistTrusted() { $model->alias = 'model'; $model->expects($this->never())->method('hasField'); - $options = array('sort' => 'body', 'direction' => 'asc'); - $result = $this->Paginator->validateSort($model, $options, array('body')); + $options = ['sort' => 'body', 'direction' => 'asc']; + $result = $this->Paginator->validateSort($model, $options, ['body']); - $expected = array('body' => 'asc'); + $expected = ['body' => 'asc']; $this->assertEquals($expected, $result['order']); } @@ -1227,7 +1227,7 @@ public function testValidateSortVirtualField() { ->with('something', true) ->will($this->returnValue(true)); - $options = array('sort' => 'something', 'direction' => 'desc'); + $options = ['sort' => 'something', 'direction' => 'desc']; $result = $this->Paginator->validateSort($model, $options); $this->assertEquals('desc', $result['order']['something']); @@ -1252,7 +1252,7 @@ public function testValidateSortSharedFields() { ->with('something') ->will($this->returnValue(true)); - $options = array('sort' => 'Child.something', 'direction' => 'desc'); + $options = ['sort' => 'Child.something', 'direction' => 'desc']; $result = $this->Paginator->validateSort($model, $options); $this->assertEquals('desc', $result['order']['Child.something']); @@ -1267,17 +1267,17 @@ public function testValidateSortMultiple() { $model->alias = 'model'; $model->expects($this->any())->method('hasField')->will($this->returnValue(true)); - $options = array( - 'order' => array( + $options = [ + 'order' => [ 'author_id' => 'asc', 'title' => 'asc' - ) - ); + ] + ]; $result = $this->Paginator->validateSort($model, $options); - $expected = array( + $expected = [ 'model.author_id' => 'asc', 'model.title' => 'asc' - ); + ]; $this->assertEquals($expected, $result['order']); } @@ -1292,12 +1292,12 @@ public function testValidateSortNoSort() { $model->alias = 'model'; $model->expects($this->any())->method('hasField')->will($this->returnValue(true)); - $options = array('direction' => 'asc'); - $result = $this->Paginator->validateSort($model, $options, array('title', 'id')); + $options = ['direction' => 'asc']; + $result = $this->Paginator->validateSort($model, $options, ['title', 'id']); $this->assertFalse(isset($result['order'])); - $options = array('order' => 'invalid desc'); - $result = $this->Paginator->validateSort($model, $options, array('title', 'id')); + $options = ['order' => 'invalid desc']; + $result = $this->Paginator->validateSort($model, $options, ['title', 'id']); $this->assertEquals($options['order'], $result['order']); } @@ -1312,9 +1312,9 @@ public function testValidateSortInvalidAlias() { $model->alias = 'Model'; $model->expects($this->any())->method('hasField')->will($this->returnValue(true)); - $options = array('sort' => 'Derp.id'); + $options = ['sort' => 'Derp.id']; $result = $this->Paginator->validateSort($model, $options); - $this->assertEquals(array(), $result['order']); + $this->assertEquals([], $result['order']); } /** @@ -1323,19 +1323,19 @@ public function testValidateSortInvalidAlias() { * @return void */ public function testCheckLimit() { - $result = $this->Paginator->checkLimit(array('limit' => 1000000, 'maxLimit' => 100)); + $result = $this->Paginator->checkLimit(['limit' => 1000000, 'maxLimit' => 100]); $this->assertEquals(100, $result['limit']); - $result = $this->Paginator->checkLimit(array('limit' => 'sheep!', 'maxLimit' => 100)); + $result = $this->Paginator->checkLimit(['limit' => 'sheep!', 'maxLimit' => 100]); $this->assertEquals(1, $result['limit']); - $result = $this->Paginator->checkLimit(array('limit' => '-1', 'maxLimit' => 100)); + $result = $this->Paginator->checkLimit(['limit' => '-1', 'maxLimit' => 100]); $this->assertEquals(1, $result['limit']); - $result = $this->Paginator->checkLimit(array('limit' => null, 'maxLimit' => 100)); + $result = $this->Paginator->checkLimit(['limit' => null, 'maxLimit' => 100]); $this->assertEquals(1, $result['limit']); - $result = $this->Paginator->checkLimit(array('limit' => 0, 'maxLimit' => 100)); + $result = $this->Paginator->checkLimit(['limit' => 0, 'maxLimit' => 100]); $this->assertEquals(1, $result['limit']); } @@ -1347,32 +1347,32 @@ public function testCheckLimit() { public function testPaginateMaxLimit() { $Controller = new Controller($this->request); - $Controller->uses = array('PaginatorControllerPost', 'ControllerComment'); + $Controller->uses = ['PaginatorControllerPost', 'ControllerComment']; $Controller->request->params['pass'][] = '1'; $Controller->constructClasses(); - $Controller->request->params['named'] = array( - 'contain' => array('ControllerComment'), 'limit' => '1000' - ); + $Controller->request->params['named'] = [ + 'contain' => ['ControllerComment'], 'limit' => '1000' + ]; $Controller->paginate('PaginatorControllerPost'); $this->assertEquals(100, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']); - $Controller->request->params['named'] = array( - 'contain' => array('ControllerComment'), 'limit' => '1000', 'maxLimit' => 1000 - ); + $Controller->request->params['named'] = [ + 'contain' => ['ControllerComment'], 'limit' => '1000', 'maxLimit' => 1000 + ]; $Controller->paginate('PaginatorControllerPost'); $this->assertEquals(100, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']); - $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '10'); + $Controller->request->params['named'] = ['contain' => ['ControllerComment'], 'limit' => '10']; $Controller->paginate('PaginatorControllerPost'); $this->assertEquals(10, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']); - $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '1000'); - $Controller->paginate = array('maxLimit' => 2000, 'paramType' => 'named'); + $Controller->request->params['named'] = ['contain' => ['ControllerComment'], 'limit' => '1000']; + $Controller->paginate = ['maxLimit' => 2000, 'paramType' => 'named']; $Controller->paginate('PaginatorControllerPost'); $this->assertEquals(1000, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']); - $Controller->request->params['named'] = array('contain' => array('ControllerComment'), 'limit' => '5000'); + $Controller->request->params['named'] = ['contain' => ['ControllerComment'], 'limit' => '5000']; $Controller->paginate('PaginatorControllerPost'); $this->assertEquals(2000, $Controller->params['paging']['PaginatorControllerPost']['options']['limit']); } @@ -1384,41 +1384,41 @@ public function testPaginateMaxLimit() { */ public function testPaginateOrderVirtualFieldSharedWithRealField() { $Controller = new Controller($this->request); - $Controller->uses = array('PaginatorControllerPost', 'PaginatorControllerComment'); + $Controller->uses = ['PaginatorControllerPost', 'PaginatorControllerComment']; $Controller->constructClasses(); - $Controller->PaginatorControllerComment->virtualFields = array( + $Controller->PaginatorControllerComment->virtualFields = [ 'title' => 'PaginatorControllerComment.comment' - ); - $Controller->PaginatorControllerComment->bindModel(array( - 'belongsTo' => array( - 'PaginatorControllerPost' => array( + ]; + $Controller->PaginatorControllerComment->bindModel([ + 'belongsTo' => [ + 'PaginatorControllerPost' => [ 'className' => 'PaginatorControllerPost', 'foreignKey' => 'article_id' - ) - ) - ), false); + ] + ] + ], false); - $Controller->paginate = array( - 'fields' => array( + $Controller->paginate = [ + 'fields' => [ 'PaginatorControllerComment.id', 'title', 'PaginatorControllerPost.title' - ), - ); - $Controller->request->params['named'] = array( + ], + ]; + $Controller->request->params['named'] = [ 'sort' => 'PaginatorControllerPost.title', 'direction' => 'desc' - ); + ]; $result = Hash::extract( $Controller->paginate('PaginatorControllerComment'), '{n}.PaginatorControllerComment.id' ); $result1 = array_splice($result, 0, 2); sort($result1); - $this->assertEquals(array(5, 6), $result1); + $this->assertEquals([5, 6], $result1); sort($result); - $this->assertEquals(array(1, 2, 3, 4), $result); + $this->assertEquals([1, 2, 3, 4], $result); } /** @@ -1428,31 +1428,31 @@ public function testPaginateOrderVirtualFieldSharedWithRealField() { */ public function testPaginateCustomFind() { $Controller = new Controller($this->request); - $Controller->uses = array('PaginatorCustomPost'); + $Controller->uses = ['PaginatorCustomPost']; $Controller->constructClasses(); - $data = array('author_id' => 3, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N'); + $data = ['author_id' => 3, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N']; $Controller->PaginatorCustomPost->create($data); $result = $Controller->PaginatorCustomPost->save(); $this->assertTrue(!empty($result)); $result = $Controller->paginate(); - $this->assertEquals(array(1, 2, 3, 4), Hash::extract($result, '{n}.PaginatorCustomPost.id')); + $this->assertEquals([1, 2, 3, 4], Hash::extract($result, '{n}.PaginatorCustomPost.id')); $result = $Controller->params['paging']['PaginatorCustomPost']; $this->assertEquals(4, $result['current']); $this->assertEquals(4, $result['count']); - $Controller->paginate = array('published'); + $Controller->paginate = ['published']; $result = $Controller->paginate(); - $this->assertEquals(array(1, 2, 3), Hash::extract($result, '{n}.PaginatorCustomPost.id')); + $this->assertEquals([1, 2, 3], Hash::extract($result, '{n}.PaginatorCustomPost.id')); $result = $Controller->params['paging']['PaginatorCustomPost']; $this->assertEquals(3, $result['current']); $this->assertEquals(3, $result['count']); - $Controller->paginate = array('published', 'limit' => 2); + $Controller->paginate = ['published', 'limit' => 2]; $result = $Controller->paginate(); - $this->assertEquals(array(1, 2), Hash::extract($result, '{n}.PaginatorCustomPost.id')); + $this->assertEquals([1, 2], Hash::extract($result, '{n}.PaginatorCustomPost.id')); $result = $Controller->params['paging']['PaginatorCustomPost']; $this->assertEquals(2, $result['current']); @@ -1468,23 +1468,23 @@ public function testPaginateCustomFind() { */ public function testPaginateCustomFindFieldsArray() { $Controller = new Controller($this->request); - $Controller->uses = array('PaginatorCustomPost'); + $Controller->uses = ['PaginatorCustomPost']; $Controller->constructClasses(); - $data = array('author_id' => 3, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N'); + $data = ['author_id' => 3, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N']; $Controller->PaginatorCustomPost->create($data); $result = $Controller->PaginatorCustomPost->save(); $this->assertTrue(!empty($result)); - $Controller->paginate = array( + $Controller->paginate = [ 'list', - 'conditions' => array('PaginatorCustomPost.published' => 'Y'), + 'conditions' => ['PaginatorCustomPost.published' => 'Y'], 'limit' => 2 - ); + ]; $result = $Controller->paginate(); - $expected = array( + $expected = [ 1 => 'First Post', 2 => 'Second Post', - ); + ]; $this->assertEquals($expected, $result); $result = $Controller->params['paging']['PaginatorCustomPost']; $this->assertEquals(2, $result['current']); @@ -1500,23 +1500,23 @@ public function testPaginateCustomFindFieldsArray() { */ public function testPaginateCustomFindWithCustomFindKey() { $Controller = new Controller($this->request); - $Controller->uses = array('PaginatorCustomPost'); + $Controller->uses = ['PaginatorCustomPost']; $Controller->constructClasses(); - $data = array('author_id' => 3, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N'); + $data = ['author_id' => 3, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N']; $Controller->PaginatorCustomPost->create($data); $result = $Controller->PaginatorCustomPost->save(); $this->assertTrue(!empty($result)); - $Controller->paginate = array( - 'conditions' => array('PaginatorCustomPost.published' => 'Y'), + $Controller->paginate = [ + 'conditions' => ['PaginatorCustomPost.published' => 'Y'], 'findType' => 'list', 'limit' => 2 - ); + ]; $result = $Controller->paginate(); - $expected = array( + $expected = [ 1 => 'First Post', 2 => 'Second Post', - ); + ]; $this->assertEquals($expected, $result); $result = $Controller->params['paging']['PaginatorCustomPost']; $this->assertEquals(2, $result['current']); @@ -1533,32 +1533,32 @@ public function testPaginateCustomFindWithCustomFindKey() { */ public function testPaginateCustomFindGroupBy() { $Controller = new Controller($this->request); - $Controller->uses = array('PaginatorCustomPost'); + $Controller->uses = ['PaginatorCustomPost']; $Controller->constructClasses(); - $data = array('author_id' => 2, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N'); + $data = ['author_id' => 2, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N']; $Controller->PaginatorCustomPost->create($data); $result = $Controller->PaginatorCustomPost->save(); $this->assertTrue(!empty($result)); - $Controller->paginate = array( + $Controller->paginate = [ 'totals', 'limit' => 2 - ); + ]; $result = $Controller->paginate(); - $expected = array( - array( - 'PaginatorCustomPost' => array( + $expected = [ + [ + 'PaginatorCustomPost' => [ 'author_id' => '1', 'total_posts' => '2' - ) - ), - array( - 'PaginatorCustomPost' => array( + ] + ], + [ + 'PaginatorCustomPost' => [ 'author_id' => '2', 'total_posts' => '1' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $result = $Controller->params['paging']['PaginatorCustomPost']; $this->assertEquals(2, $result['current']); @@ -1567,20 +1567,20 @@ public function testPaginateCustomFindGroupBy() { $this->assertTrue($result['nextPage']); $this->assertFalse($result['prevPage']); - $Controller->paginate = array( + $Controller->paginate = [ 'totals', 'limit' => 2, 'page' => 2 - ); + ]; $result = $Controller->paginate(); - $expected = array( - array( - 'PaginatorCustomPost' => array( + $expected = [ + [ + 'PaginatorCustomPost' => [ 'author_id' => '3', 'total_posts' => '1' - ) - ), - ); + ] + ], + ]; $this->assertEquals($expected, $result); $result = $Controller->params['paging']['PaginatorCustomPost']; $this->assertEquals(1, $result['current']); @@ -1598,38 +1598,38 @@ public function testPaginateCustomFindGroupBy() { */ public function testPaginateCustomFindCount() { $Controller = new Controller($this->request); - $Controller->uses = array('PaginatorCustomPost'); + $Controller->uses = ['PaginatorCustomPost']; $Controller->constructClasses(); - $data = array('author_id' => 2, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N'); + $data = ['author_id' => 2, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N']; $Controller->PaginatorCustomPost->create($data); $result = $Controller->PaginatorCustomPost->save(); $this->assertTrue(!empty($result)); - $Controller->paginate = array( + $Controller->paginate = [ 'totalsOperation', 'limit' => 2 - ); + ]; $result = $Controller->paginate(); - $expected = array( - array( - 'PaginatorCustomPost' => array( + $expected = [ + [ + 'PaginatorCustomPost' => [ 'author_id' => '1', 'total_posts' => '2' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'mariano', - ) - ), - array( - 'PaginatorCustomPost' => array( + ] + ], + [ + 'PaginatorCustomPost' => [ 'author_id' => '2', 'total_posts' => '1' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'nate' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $result = $Controller->params['paging']['PaginatorCustomPost']; $this->assertEquals(2, $result['current']); diff --git a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php index c79e5bd1ee..b0db15c355 100644 --- a/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php @@ -145,15 +145,15 @@ public function tearDown() : void { * @return void */ public function testConstructorSettings() { - $settings = array( + $settings = [ 'ajaxLayout' => 'test_ajax', - 'viewClassMap' => array('json' => 'MyPlugin.MyJson') - ); + 'viewClassMap' => ['json' => 'MyPlugin.MyJson'] + ]; $Collection = new ComponentCollection(); $Collection->init($this->Controller); $RequestHandler = new RequestHandlerComponent($Collection, $settings); $this->assertEquals('test_ajax', $RequestHandler->ajaxLayout); - $this->assertEquals(array('json' => 'MyPlugin.MyJson'), $RequestHandler->settings['viewClassMap']); + $this->assertEquals(['json' => 'MyPlugin.MyJson'], $RequestHandler->settings['viewClassMap']); } /** @@ -257,7 +257,7 @@ public function testInitializeNoContentTypeWithMultipleAcceptedTypes() { $this->assertEquals('xml', $this->RequestHandler->ext); $this->RequestHandler->ext = null; - Router::setExtensions(array('json', 'xml'), false); + Router::setExtensions(['json', 'xml'], false); $this->RequestHandler->initialize($this->Controller); $this->assertEquals('json', $this->RequestHandler->ext); @@ -317,12 +317,12 @@ public function testInitializeContentTypeAndExtensionMismatch() { $this->Controller->request = $this->getMock('CakeRequest'); $this->Controller->request->expects($this->any()) ->method('accepts') - ->will($this->returnValue(array('application/json'))); + ->will($this->returnValue(['application/json'])); $this->RequestHandler->initialize($this->Controller); $this->assertNull($this->RequestHandler->ext); - call_user_func_array(array('Router', 'parseExtensions'), $extensions); + call_user_func_array(['Router', 'parseExtensions'], $extensions); } /** @@ -331,21 +331,21 @@ public function testInitializeContentTypeAndExtensionMismatch() { * @return void */ public function testViewClassMap() { - $this->RequestHandler->settings = array('viewClassMap' => array('json' => 'CustomJson')); + $this->RequestHandler->settings = ['viewClassMap' => ['json' => 'CustomJson']]; $this->RequestHandler->initialize($this->Controller); $result = $this->RequestHandler->viewClassMap(); - $expected = array( + $expected = [ 'json' => 'CustomJson', 'xml' => 'Xml' - ); + ]; $this->assertEquals($expected, $result); $result = $this->RequestHandler->viewClassMap('xls', 'Excel.Excel'); - $expected = array( + $expected = [ 'json' => 'CustomJson', 'xml' => 'Xml', 'xls' => 'Excel.Excel' - ); + ]; $this->assertEquals($expected, $result); $this->RequestHandler->renderAs($this->Controller, 'json'); @@ -393,7 +393,7 @@ public function testAutoAjaxLayout() { public function testStartupCallback() { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/xml'; - $this->Controller->request = $this->getMock('CakeRequest', array('_readInput')); + $this->Controller->request = $this->getMock('CakeRequest', ['_readInput']); $this->RequestHandler->startup($this->Controller); $this->assertTrue(is_array($this->Controller->data)); $this->assertFalse(is_object($this->Controller->data)); @@ -407,7 +407,7 @@ public function testStartupCallback() { public function testStartupCallbackJson() { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/json'; - $this->Controller->request = $this->getMock('CakeRequest', array('_readInput')); + $this->Controller->request = $this->getMock('CakeRequest', ['_readInput']); $this->RequestHandler->startup($this->Controller); $this->assertTrue(is_array($this->Controller->data)); $this->assertFalse(is_object($this->Controller->data)); @@ -421,7 +421,7 @@ public function testStartupCallbackJson() { public function testStartupCallbackCharset() { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/xml; charset=UTF-8'; - $this->Controller->request = $this->getMock('CakeRequest', array('_readInput')); + $this->Controller->request = $this->getMock('CakeRequest', ['_readInput']); $this->RequestHandler->startup($this->Controller); $this->assertTrue(is_array($this->Controller->data)); $this->assertFalse(is_object($this->Controller->data)); @@ -438,15 +438,15 @@ public function testStartupCustomTypeProcess() { } $_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['CONTENT_TYPE'] = 'text/csv'; - $this->Controller->request = $this->getMock('CakeRequest', array('_readInput')); + $this->Controller->request = $this->getMock('CakeRequest', ['_readInput']); $this->Controller->request->expects($this->once()) ->method('_readInput') ->will($this->returnValue('"A","csv","string"')); - $this->RequestHandler->addInputType('csv', array('str_getcsv')); + $this->RequestHandler->addInputType('csv', ['str_getcsv']); $this->RequestHandler->startup($this->Controller); - $expected = array( + $expected = [ 'A', 'csv', 'string' - ); + ]; $this->assertEquals($expected, $this->Controller->request->data); } @@ -502,9 +502,9 @@ public function testRenderAsWithAttachment() { $this->RequestHandler->request = $this->getMock('CakeRequest'); $this->RequestHandler->request->expects($this->any()) ->method('parseAccept') - ->will($this->returnValue(array('1.0' => array('application/xml')))); + ->will($this->returnValue(['1.0' => ['application/xml']])); - $this->RequestHandler->response = $this->getMock('CakeResponse', array('type', 'download', 'charset')); + $this->RequestHandler->response = $this->getMock('CakeResponse', ['type', 'download', 'charset']); $this->RequestHandler->response->expects($this->at(0)) ->method('type') ->with('application/xml'); @@ -515,7 +515,7 @@ public function testRenderAsWithAttachment() { ->method('download') ->with('myfile.xml'); - $this->RequestHandler->renderAs($this->Controller, 'xml', array('attachment' => 'myfile.xml')); + $this->RequestHandler->renderAs($this->Controller, 'xml', ['attachment' => 'myfile.xml']); $this->assertEquals('Xml', $this->Controller->viewClass); } @@ -526,7 +526,7 @@ public function testRenderAsWithAttachment() { * @return void */ public function testRespondAs() { - $this->RequestHandler->response = $this->getMock('CakeResponse', array('type')); + $this->RequestHandler->response = $this->getMock('CakeResponse', ['type']); $this->RequestHandler->response->expects($this->at(0))->method('type') ->with('application/json'); $this->RequestHandler->response->expects($this->at(1))->method('type') @@ -546,22 +546,22 @@ public function testRespondAs() { public function testRespondAsWithAttachment() { $this->RequestHandler = $this->getMock( 'RequestHandlerComponent', - array('_header'), - array(&$this->Controller->Components) + ['_header'], + [&$this->Controller->Components] ); - $this->RequestHandler->response = $this->getMock('CakeResponse', array('type', 'download')); + $this->RequestHandler->response = $this->getMock('CakeResponse', ['type', 'download']); $this->RequestHandler->request = $this->getMock('CakeRequest'); $this->RequestHandler->request->expects($this->once()) ->method('parseAccept') - ->will($this->returnValue(array('1.0' => array('application/xml')))); + ->will($this->returnValue(['1.0' => ['application/xml']])); $this->RequestHandler->response->expects($this->once())->method('download') ->with('myfile.xml'); $this->RequestHandler->response->expects($this->once())->method('type') ->with('application/xml'); - $result = $this->RequestHandler->respondAs('xml', array('attachment' => 'myfile.xml')); + $result = $this->RequestHandler->respondAs('xml', ['attachment' => 'myfile.xml']); $this->assertTrue($result); } @@ -623,10 +623,10 @@ public function testRequestContentTypes() { $_SERVER['CONTENT_TYPE'] = 'application/json'; $this->assertEquals('json', $this->RequestHandler->requestedWith()); - $result = $this->RequestHandler->requestedWith(array('json', 'xml')); + $result = $this->RequestHandler->requestedWith(['json', 'xml']); $this->assertEquals('json', $result); - $result = $this->RequestHandler->requestedWith(array('rss', 'atom')); + $result = $this->RequestHandler->requestedWith(['rss', 'atom']); $this->assertFalse($result); $_SERVER['REQUEST_METHOD'] = 'DELETE'; @@ -639,10 +639,10 @@ public function testRequestContentTypes() { unset($_SERVER['CONTENT_TYPE']); $_SERVER['HTTP_CONTENT_TYPE'] = 'application/json'; - $result = $this->RequestHandler->requestedWith(array('json', 'xml')); + $result = $this->RequestHandler->requestedWith(['json', 'xml']); $this->assertEquals('json', $result); - $result = $this->RequestHandler->requestedWith(array('rss', 'atom')); + $result = $this->RequestHandler->requestedWith(['rss', 'atom']); $this->assertFalse($result); $_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*'; @@ -751,8 +751,8 @@ public function testMapAlias() { $result = $this->RequestHandler->mapAlias('wap'); $this->assertEquals('text/vnd.wap.wml', $result); - $result = $this->RequestHandler->mapAlias(array('xml', 'js', 'json')); - $expected = array('application/xml', 'application/javascript', 'application/json'); + $result = $this->RequestHandler->mapAlias(['xml', 'js', 'json']); + $expected = ['application/xml', 'application/javascript', 'application/json']; $this->assertEquals($expected, $result); } @@ -763,8 +763,8 @@ public function testMapAlias() { */ public function testAccepts() { $_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'; - $this->assertTrue($this->RequestHandler->accepts(array('js', 'xml', 'html'))); - $this->assertFalse($this->RequestHandler->accepts(array('gif', 'jpeg', 'foo'))); + $this->assertTrue($this->RequestHandler->accepts(['js', 'xml', 'html'])); + $this->assertFalse($this->RequestHandler->accepts(['gif', 'jpeg', 'foo'])); $_SERVER['HTTP_ACCEPT'] = '*/*;q=0.5'; $this->assertFalse($this->RequestHandler->accepts('rss')); @@ -781,11 +781,11 @@ public function testPrefers() { $this->RequestHandler->ext = 'rss'; $this->assertEquals('rss', $this->RequestHandler->prefers()); $this->assertFalse($this->RequestHandler->prefers('xml')); - $this->assertEquals('xml', $this->RequestHandler->prefers(array('js', 'xml', 'xhtml'))); - $this->assertFalse($this->RequestHandler->prefers(array('red', 'blue'))); - $this->assertEquals('xhtml', $this->RequestHandler->prefers(array('js', 'json', 'xhtml'))); - $this->assertTrue($this->RequestHandler->prefers(array('rss')), 'Should return true if input matches ext.'); - $this->assertFalse($this->RequestHandler->prefers(array('html')), 'No match with ext, return false.'); + $this->assertEquals('xml', $this->RequestHandler->prefers(['js', 'xml', 'xhtml'])); + $this->assertFalse($this->RequestHandler->prefers(['red', 'blue'])); + $this->assertEquals('xhtml', $this->RequestHandler->prefers(['js', 'json', 'xhtml'])); + $this->assertTrue($this->RequestHandler->prefers(['rss']), 'Should return true if input matches ext.'); + $this->assertFalse($this->RequestHandler->prefers(['html']), 'No match with ext, return false.'); $_SERVER['HTTP_ACCEPT'] = 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5'; $this->_init(); @@ -830,13 +830,13 @@ public function testClientProperties() { * @return void */ public function testAjaxRedirectAsRequestAction() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); - $this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); + $this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', ['_stop'], [&$this->Controller->Components]); $this->Controller->request = $this->getMock('CakeRequest'); - $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response = $this->getMock('CakeResponse', ['_sendHeader']); $this->Controller->RequestHandler->request = $this->Controller->request; $this->Controller->RequestHandler->response = $this->Controller->response; $this->Controller->request->expects($this->any())->method('is')->will($this->returnValue(true)); @@ -844,7 +844,7 @@ public function testAjaxRedirectAsRequestAction() { ob_start(); $this->Controller->RequestHandler->beforeRedirect( - $this->Controller, array('controller' => 'request_handler_test', 'action' => 'destination') + $this->Controller, ['controller' => 'request_handler_test', 'action' => 'destination'] ); $result = ob_get_clean(); $this->assertMatchesRegularExpression('/posts index/', $result, 'RequestAction redirect failed.'); @@ -859,13 +859,13 @@ public function testAjaxRedirectAsRequestAction() { * @return void */ public function testAjaxRedirectAsRequestActionStillRenderingLayout() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); - $this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); + $this->Controller->RequestHandler = $this->getMock('RequestHandlerComponent', ['_stop'], [&$this->Controller->Components]); $this->Controller->request = $this->getMock('CakeRequest'); - $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response = $this->getMock('CakeResponse', ['_sendHeader']); $this->Controller->RequestHandler->request = $this->Controller->request; $this->Controller->RequestHandler->response = $this->Controller->response; $this->Controller->request->expects($this->any())->method('is')->will($this->returnValue(true)); @@ -873,7 +873,7 @@ public function testAjaxRedirectAsRequestActionStillRenderingLayout() { ob_start(); $this->Controller->RequestHandler->beforeRedirect( - $this->Controller, array('controller' => 'request_handler_test', 'action' => 'ajax2_layout') + $this->Controller, ['controller' => 'request_handler_test', 'action' => 'ajax2_layout'] ); $result = ob_get_clean(); $this->assertMatchesRegularExpression('/posts index/', $result, 'RequestAction redirect failed.'); @@ -892,20 +892,20 @@ public function testAjaxRedirectAsRequestActionStillRenderingLayout() { public function testBeforeRedirectCallbackWithArrayUrl() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; - Router::setRequestInfo(array( - array('plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => array(), 'named' => array(), 'form' => array(), 'url' => array('url' => 'accounts/')), - array('base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/') - )); + Router::setRequestInfo([ + ['plugin' => null, 'controller' => 'accounts', 'action' => 'index', 'pass' => [], 'named' => [], 'form' => [], 'url' => ['url' => 'accounts/']], + ['base' => '/officespace', 'here' => '/officespace/accounts/', 'webroot' => '/officespace/'] + ]); - $RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); - $RequestHandler->response = $this->getMock('CakeResponse', array('_sendHeader')); + $RequestHandler = $this->getMock('RequestHandlerComponent', ['_stop'], [&$this->Controller->Components]); + $RequestHandler->response = $this->getMock('CakeResponse', ['_sendHeader']); $RequestHandler->request = new CakeRequest('posts/index'); - $RequestHandler->response = $this->getMock('CakeResponse', array('_sendHeader')); + $RequestHandler->response = $this->getMock('CakeResponse', ['_sendHeader']); ob_start(); $RequestHandler->beforeRedirect( $this->Controller, - array('controller' => 'request_handler_test', 'action' => 'param_method', 'first', 'second') + ['controller' => 'request_handler_test', 'action' => 'param_method', 'first', 'second'] ); $result = ob_get_clean(); $this->assertEquals('one: first two: second', $result); @@ -919,9 +919,9 @@ public function testBeforeRedirectCallbackWithArrayUrl() { public function testBeforeRedirectCallingHeader() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; - $controller = $this->getMock('Controller', array('header')); - $RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); - $RequestHandler->response = $this->getMock('CakeResponse', array('_sendHeader', 'statusCode')); + $controller = $this->getMock('Controller', ['header']); + $RequestHandler = $this->getMock('RequestHandlerComponent', ['_stop'], [&$this->Controller->Components]); + $RequestHandler->response = $this->getMock('CakeResponse', ['_sendHeader', 'statusCode']); $RequestHandler->request = $this->getMock('CakeRequest'); $RequestHandler->request->expects($this->once())->method('is') ->with('ajax') @@ -939,7 +939,7 @@ public function testBeforeRedirectCallingHeader() { */ public function testAddInputTypeException() { $this->expectException(CakeException::class); - $this->RequestHandler->addInputType('csv', array('I am not callable')); + $this->RequestHandler->addInputType('csv', ['I am not callable']); } /** @@ -949,8 +949,8 @@ public function testAddInputTypeException() { */ public function testCheckNotModifiedByEtagStar() { $_SERVER['HTTP_IF_NONE_MATCH'] = '*'; - $RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); - $RequestHandler->response = $this->getMock('CakeResponse', array('notModified')); + $RequestHandler = $this->getMock('RequestHandlerComponent', ['_stop'], [&$this->Controller->Components]); + $RequestHandler->response = $this->getMock('CakeResponse', ['notModified']); $RequestHandler->response->etag('something'); $RequestHandler->response->expects($this->once())->method('notModified'); $this->assertFalse($RequestHandler->beforeRender($this->Controller)); @@ -963,8 +963,8 @@ public function testCheckNotModifiedByEtagStar() { */ public function testCheckNotModifiedByEtagExact() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; - $RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); - $RequestHandler->response = $this->getMock('CakeResponse', array('notModified')); + $RequestHandler = $this->getMock('RequestHandlerComponent', ['_stop'], [&$this->Controller->Components]); + $RequestHandler->response = $this->getMock('CakeResponse', ['notModified']); $RequestHandler->response->etag('something', true); $RequestHandler->response->expects($this->once())->method('notModified'); $this->assertFalse($RequestHandler->beforeRender($this->Controller)); @@ -978,8 +978,8 @@ public function testCheckNotModifiedByEtagExact() { public function testCheckNotModifiedByEtagAndTime() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); - $RequestHandler->response = $this->getMock('CakeResponse', array('notModified')); + $RequestHandler = $this->getMock('RequestHandlerComponent', ['_stop'], [&$this->Controller->Components]); + $RequestHandler->response = $this->getMock('CakeResponse', ['notModified']); $RequestHandler->response->etag('something', true); $RequestHandler->response->modified('2012-01-01 00:00:00'); $RequestHandler->response->expects($this->once())->method('notModified'); @@ -992,8 +992,8 @@ public function testCheckNotModifiedByEtagAndTime() { * @return void */ public function testCheckNotModifiedNoInfo() { - $RequestHandler = $this->getMock('RequestHandlerComponent', array('_stop'), array(&$this->Controller->Components)); - $RequestHandler->response = $this->getMock('CakeResponse', array('notModified')); + $RequestHandler = $this->getMock('RequestHandlerComponent', ['_stop'], [&$this->Controller->Components]); + $RequestHandler->response = $this->getMock('CakeResponse', ['notModified']); $RequestHandler->response->expects($this->never())->method('notModified'); $this->assertNull($RequestHandler->beforeRender($this->Controller)); } diff --git a/lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php b/lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php index e49e65c0a1..15bd4993c5 100644 --- a/lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php @@ -71,7 +71,7 @@ class SecurityTestController extends Controller { * * @var array */ - public $components = array('Session', 'TestSecurity'); + public $components = ['Session', 'TestSecurity']; /** * failed property @@ -85,7 +85,7 @@ class SecurityTestController extends Controller { * * @var array */ - public $testHeaders = array(); + public $testHeaders = []; /** * fail method @@ -124,7 +124,7 @@ class BrokenCallbackController extends Controller { public $name = 'UncallableCallback'; - public $components = array('Session', 'TestSecurity'); + public $components = ['Session', 'TestSecurity']; public function index() { } @@ -164,8 +164,8 @@ public function setUp() : void { parent::setUp(); $_SERVER['REQUEST_METHOD'] = 'GET'; - $request = $this->getMock('CakeRequest', array('here'), array('posts/index', false)); - $request->addParams(array('controller' => 'posts', 'action' => 'index')); + $request = $this->getMock('CakeRequest', ['here'], ['posts/index', false]); + $request->addParams(['controller' => 'posts', 'action' => 'index']); $request->expects($this->any()) ->method('here') ->will($this->returnValue('/posts/index')); @@ -214,8 +214,8 @@ public function validatePost($expectedException = null, $expectedExceptionMessag public function testBlackholeWithBrokenCallback() { $this->expectException(BadRequestException::class); $request = new CakeRequest('posts/index', false); - $request->addParams(array( - 'controller' => 'posts', 'action' => 'index') + $request->addParams([ + 'controller' => 'posts', 'action' => 'index'] ); $this->Controller = new BrokenCallbackController($request); $this->Controller->Components->init($this->Controller); @@ -232,10 +232,10 @@ public function testBlackholeWithBrokenCallback() { * @return void */ public function testExceptionWhenActionIsBlackholeCallback() { - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'posts', 'action' => 'fail' - )); + ]); $this->assertFalse($this->Controller->failed); $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed, 'Request was blackholed.'); @@ -247,14 +247,14 @@ public function testExceptionWhenActionIsBlackholeCallback() { * @return void */ public function testConstructorSettingProperties() { - $settings = array( - 'requirePost' => array('edit', 'update'), - 'requireSecure' => array('update_account'), - 'requireGet' => array('index'), + $settings = [ + 'requirePost' => ['edit', 'update'], + 'requireSecure' => ['update_account'], + 'requireGet' => ['index'], 'validatePost' => false, - ); + ]; $Security = new SecurityComponent($this->Controller->Components, $settings); - $this->Controller->Security->initialize($this->Controller, $settings); + $this->Controller->Security->initialize($this->Controller); $this->assertEquals($Security->requirePost, $settings['requirePost']); $this->assertEquals($Security->requireSecure, $settings['requireSecure']); $this->assertEquals($Security->requireGet, $settings['requireGet']); @@ -281,7 +281,7 @@ public function testStartup() { public function testRequirePostFail() { $_SERVER['REQUEST_METHOD'] = 'GET'; $this->Controller->request['action'] = 'posted'; - $this->Controller->Security->requirePost(array('posted')); + $this->Controller->Security->requirePost(['posted']); $this->Controller->Security->validatePost = false; $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed); @@ -310,7 +310,7 @@ public function testRequireSecureFail() { $_SERVER['HTTPS'] = 'off'; $_SERVER['REQUEST_METHOD'] = 'POST'; $this->Controller->request['action'] = 'posted'; - $this->Controller->Security->requireSecure(array('posted')); + $this->Controller->Security->requireSecure(['posted']); $this->Controller->Security->validatePost = false; $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed); @@ -338,22 +338,22 @@ public function testRequireSecureSucceed() { public function testRequireAuthFail() { $_SERVER['REQUEST_METHOD'] = 'AUTH'; $this->Controller->request['action'] = 'posted'; - $this->Controller->request->data = array('username' => 'willy', 'password' => 'somePass'); - $this->Controller->Security->requireAuth(array('posted')); + $this->Controller->request->data = ['username' => 'willy', 'password' => 'somePass']; + $this->Controller->Security->requireAuth(['posted']); $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed); - $this->Controller->Session->write('_Token', array('allowedControllers' => array())); - $this->Controller->request->data = array('username' => 'willy', 'password' => 'somePass'); + $this->Controller->Session->write('_Token', ['allowedControllers' => []]); + $this->Controller->request->data = ['username' => 'willy', 'password' => 'somePass']; $this->Controller->request['action'] = 'posted'; $this->Controller->Security->requireAuth('posted'); $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed); - $this->Controller->Session->write('_Token', array( - 'allowedControllers' => array('SecurityTest'), 'allowedActions' => array('posted2') - )); - $this->Controller->request->data = array('username' => 'willy', 'password' => 'somePass'); + $this->Controller->Session->write('_Token', [ + 'allowedControllers' => ['SecurityTest'], 'allowedActions' => ['posted2'] + ]); + $this->Controller->request->data = ['username' => 'willy', 'password' => 'somePass']; $this->Controller->request['action'] = 'posted'; $this->Controller->Security->requireAuth('posted'); $this->Controller->Security->startup($this->Controller); @@ -367,24 +367,24 @@ public function testRequireAuthFail() { */ public function testRequireAuthSucceed() { $_SERVER['REQUEST_METHOD'] = 'AUTH'; - $this->Controller->Security->unlockedActions = array('posted'); + $this->Controller->Security->unlockedActions = ['posted']; $this->Controller->request['action'] = 'posted'; $this->Controller->Security->requireAuth('posted'); $this->Controller->Security->startup($this->Controller); $this->assertFalse($this->Controller->failed); - $this->Controller->Security->Session->write('_Token', array( - 'allowedControllers' => array('SecurityTest'), - 'allowedActions' => array('posted') - )); + $this->Controller->Security->Session->write('_Token', [ + 'allowedControllers' => ['SecurityTest'], + 'allowedActions' => ['posted'] + ]); $this->Controller->request['controller'] = 'SecurityTest'; $this->Controller->request['action'] = 'posted'; - $this->Controller->request->data = array( + $this->Controller->request->data = [ 'username' => 'willy', 'password' => 'somePass', '_Token' => '' - ); + ]; $this->Controller->action = 'posted'; $this->Controller->Security->requireAuth('posted'); $this->Controller->Security->startup($this->Controller); @@ -413,7 +413,7 @@ public function testRequirePostSucceedWrongMethod() { public function testRequireGetFail() { $_SERVER['REQUEST_METHOD'] = 'POST'; $this->Controller->request['action'] = 'getted'; - $this->Controller->Security->requireGet(array('getted')); + $this->Controller->Security->requireGet(['getted']); $this->Controller->Security->validatePost = false; $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed); @@ -455,7 +455,7 @@ public function testRequireGetSucceedWrongMethod() { public function testRequirePutFail() { $_SERVER['REQUEST_METHOD'] = 'POST'; $this->Controller->request['action'] = 'putted'; - $this->Controller->Security->requirePut(array('putted')); + $this->Controller->Security->requirePut(['putted']); $this->Controller->Security->validatePost = false; $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed); @@ -497,7 +497,7 @@ public function testRequirePutSucceedWrongMethod() { public function testRequireDeleteFail() { $_SERVER['REQUEST_METHOD'] = 'POST'; $this->Controller->request['action'] = 'deleted'; - $this->Controller->Security->requireDelete(array('deleted', 'other_method')); + $this->Controller->Security->requireDelete(['deleted', 'other_method']); $this->Controller->Security->validatePost = false; $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed); @@ -544,16 +544,16 @@ public function testValidatePostOnGetWithData() { $fields = 'an-invalid-token'; $unlocked = ''; $unlocked = ''; - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ 'some-action', - array(), - array() - ))); + [], + [] + ])); - $this->Controller->request->data = array( - 'Model' => array('username' => 'nate', 'password' => 'foo', 'valid' => '0'), + $this->Controller->request->data = [ + 'Model' => ['username' => 'nate', 'password' => 'foo', 'valid' => '0'], '_Token' => compact('fields', 'unlocked', 'debug') - ); + ]; $this->assertFalse($this->Controller->failed, 'Should not be failed yet'); $this->Controller->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed, 'Should fail because of validatePost.'); @@ -572,10 +572,10 @@ public function testValidatePost() { $unlocked = ''; $debug = ''; - $this->Controller->request->data = array( - 'Model' => array('username' => 'nate', 'password' => 'foo', 'valid' => '0'), + $this->Controller->request->data = [ + 'Model' => ['username' => 'nate', 'password' => 'foo', 'valid' => '0'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $this->assertTrue($this->validatePost($this->Controller)); } @@ -588,19 +588,19 @@ public function testValidatePostNoSession() { $this->Controller->Security->startup($this->Controller); $this->Controller->Session->delete('_Token'); $unlocked = ''; - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ '/posts/index', - array(), - array() - ))); + [], + [] + ])); $key = $this->Controller->params['_Token']['key']; $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid'; - $this->Controller->data = array( - 'Model' => array('username' => 'nate', 'password' => 'foo', 'valid' => '0'), + $this->Controller->data = [ + 'Model' => ['username' => 'nate', 'password' => 'foo', 'valid' => '0'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $this->assertFalse($this->validatePost('AuthSecurityException', 'Unexpected field \'Model.password\' in POST data, Unexpected field \'Model.username\' in POST data')); } @@ -614,10 +614,10 @@ public function testValidatePostFormHacking() { $key = $this->Controller->params['_Token']['key']; $unlocked = ''; - $this->Controller->request->data = array( - 'Model' => array('username' => 'nate', 'password' => 'foo', 'valid' => '0'), + $this->Controller->request->data = [ + 'Model' => ['username' => 'nate', 'password' => 'foo', 'valid' => '0'], '_Token' => compact('key', 'unlocked') - ); + ]; $result = $this->validatePost('AuthSecurityException', '\'_Token.fields\' was not found in request data.'); $this->assertFalse($result, 'validatePost passed when fields were missing. %s'); } @@ -631,7 +631,7 @@ public function testValidatePostFormHacking() { */ public function testValidatePostEmptyForm() { $_SERVER['REQUEST_METHOD'] = 'POST'; - $this->Controller->request->data = array(); + $this->Controller->request->data = []; $this->Controller->Security->startup($this->Controller); $result = $this->validatePost('AuthSecurityException', '\'_Token\' was not found in request data.'); $this->assertFalse($result, 'validatePost passed when empty form is submitted'); @@ -648,20 +648,20 @@ public function testValidatePostObjectDeserialize() { $key = $this->Controller->request->params['_Token']['key']; $fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877'; $unlocked = ''; - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ '/posts/index', - array('Model.password', 'Model.username', 'Model.valid'), - array() - ))); + ['Model.password', 'Model.username', 'Model.valid'], + [] + ])); // a corrupted serialized object, so we can see if it ever gets to deserialize $attack = 'O:3:"App":1:{s:5:"__map";a:1:{s:3:"foo";s:7:"Hacked!";s:1:"fail"}}'; $fields .= urlencode(':' . str_rot13($attack)); - $this->Controller->request->data = array( - 'Model' => array('username' => 'mark', 'password' => 'foo', 'valid' => '0'), + $this->Controller->request->data = [ + 'Model' => ['username' => 'mark', 'password' => 'foo', 'valid' => '0'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost('SecurityException', 'Bad Request'); $this->assertFalse($result, 'validatePost passed when key was missing. %s'); } @@ -677,16 +677,16 @@ public function testValidatePostArray() { $key = $this->Controller->request->params['_Token']['key']; $fields = '38504e4a341d4e6eadb437217efd91270e558d55%3A'; $unlocked = ''; - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ 'some-action', - array(), - array() - ))); + [], + [] + ])); - $this->Controller->request->data = array( - 'Model' => array('multi_field' => array('1', '3')), + $this->Controller->request->data = [ + 'Model' => ['multi_field' => ['1', '3']], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $this->assertTrue($this->validatePost()); } @@ -703,10 +703,10 @@ public function testValidatePostNoModel() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( + $this->Controller->request->data = [ 'anything' => 'some_data', '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); @@ -725,10 +725,10 @@ public function testValidatePostSimple() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Model' => array('username' => '', 'password' => ''), + $this->Controller->request->data = [ + 'Model' => ['username' => '', 'password' => ''], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); @@ -747,19 +747,19 @@ public function testValidatePostComplex() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Addresses' => array( - '0' => array( + $this->Controller->request->data = [ + 'Addresses' => [ + '0' => [ 'id' => '123456', 'title' => '', 'first_name' => '', 'last_name' => '', 'address' => '', 'city' => '', 'phone' => '', 'primary' => '' - ), - '1' => array( + ], + '1' => [ 'id' => '654321', 'title' => '', 'first_name' => '', 'last_name' => '', 'address' => '', 'city' => '', 'phone' => '', 'primary' => '' - ) - ), + ] + ], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); } @@ -777,33 +777,33 @@ public function testValidatePostMultipleSelect() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Tag' => array('Tag' => array(1, 2)), + $this->Controller->request->data = [ + 'Tag' => ['Tag' => [1, 2]], '_Token' => compact('key', 'fields', 'unlocked', 'debug'), - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); - $this->Controller->request->data = array( - 'Tag' => array('Tag' => array(1, 2, 3)), + $this->Controller->request->data = [ + 'Tag' => ['Tag' => [1, 2, 3]], '_Token' => compact('key', 'fields', 'unlocked', 'debug'), - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); - $this->Controller->request->data = array( - 'Tag' => array('Tag' => array(1, 2, 3, 4)), + $this->Controller->request->data = [ + 'Tag' => ['Tag' => [1, 2, 3, 4]], '_Token' => compact('key', 'fields', 'unlocked', 'debug'), - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); $fields = '722de3615e63fdff899e86e85e6498b11c50bb66%3A'; - $this->Controller->request->data = array( + $this->Controller->request->data = [ 'User.password' => 'bar', 'User.name' => 'foo', 'User.is_valid' => '1', - 'Tag' => array('Tag' => array(1)), + 'Tag' => ['Tag' => [1]], '_Token' => compact('key', 'fields', 'unlocked', 'debug'), - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); } @@ -823,32 +823,32 @@ public function testValidatePostCheckbox() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Model' => array('username' => '', 'password' => '', 'valid' => '0'), + $this->Controller->request->data = [ + 'Model' => ['username' => '', 'password' => '', 'valid' => '0'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); $fields = 'efbcf463a2c31e97c85d95eedc41dff9e9c6a026%3A'; - $this->Controller->request->data = array( - 'Model' => array('username' => '', 'password' => '', 'valid' => '0'), + $this->Controller->request->data = [ + 'Model' => ['username' => '', 'password' => '', 'valid' => '0'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); - $this->Controller->request->data = array(); + $this->Controller->request->data = []; $this->Controller->Security->startup($this->Controller); $key = $this->Controller->request->params['_Token']['key']; - $this->Controller->request->data = array( - 'Model' => array('username' => '', 'password' => '', 'valid' => '0'), + $this->Controller->request->data = [ + 'Model' => ['username' => '', 'password' => '', 'valid' => '0'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); @@ -866,13 +866,13 @@ public function testValidatePostHidden() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'username' => '', 'password' => '', 'hidden' => '0', 'other_hidden' => 'some hidden value' - ), + ], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); } @@ -883,19 +883,19 @@ public function testValidatePostHidden() { * @return void */ public function testValidatePostWithDisabledFields() { - $this->Controller->Security->disabledFields = array('Model.username', 'Model.password'); + $this->Controller->Security->disabledFields = ['Model.username', 'Model.password']; $this->Controller->Security->startup($this->Controller); $key = $this->Controller->request->params['_Token']['key']; $fields = 'aa7f254ebd8bf2ef118bc5ca1e191d1ae96857f5%3AModel.hidden'; $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'username' => '', 'password' => '', 'hidden' => '0' - ), + ], '_Token' => compact('fields', 'key', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); @@ -910,7 +910,7 @@ public function testValidatePostDisabledFieldsInData() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->request->params['_Token']['key']; $unlocked = 'Model.username'; - $fields = array('Model.hidden', 'Model.password'); + $fields = ['Model.hidden', 'Model.password']; $fields = urlencode(Security::hash( '/posts/index' . serialize($fields) . @@ -919,14 +919,14 @@ public function testValidatePostDisabledFieldsInData() { ); $debug = 'not used'; - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'username' => 'mark', 'password' => 'sekret', 'hidden' => '0' - ), + ], '_Token' => compact('fields', 'key', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); @@ -940,17 +940,17 @@ public function testValidatePostDisabledFieldsInData() { public function testValidatePostFailNoDisabled() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->request->params['_Token']['key']; - $fields = array('Model.hidden', 'Model.password', 'Model.username'); + $fields = ['Model.hidden', 'Model.password', 'Model.username']; $fields = urlencode(Security::hash(serialize($fields) . Configure::read('Security.salt'))); - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'username' => 'mark', 'password' => 'sekret', 'hidden' => '0' - ), + ], '_Token' => compact('fields', 'key') - ); + ]; $result = $this->validatePost('SecurityException', '\'_Token.unlocked\' was not found in request data.'); $this->assertFalse($result); @@ -963,18 +963,18 @@ public function testValidatePostFailNoDisabled() { */ public function testValidatePostFailNoDebug() { $this->Controller->Security->startup($this->Controller); - $fields = array('Model.hidden', 'Model.password', 'Model.username'); + $fields = ['Model.hidden', 'Model.password', 'Model.username']; $fields = urlencode(Security::hash(serialize($fields) . Configure::read('Security.salt'))); $unlocked = ''; - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'username' => 'mark', 'password' => 'sekret', 'hidden' => '0' - ), + ], '_Token' => compact('fields', 'unlocked') - ); + ]; $result = $this->validatePost('SecurityException', '\'_Token.debug\' was not found in request data.'); $this->assertFalse($result); @@ -987,18 +987,18 @@ public function testValidatePostFailNoDebug() { */ public function testValidatePostFailNoDebugMode() { $this->Controller->Security->startup($this->Controller); - $fields = array('Model.hidden', 'Model.password', 'Model.username'); + $fields = ['Model.hidden', 'Model.password', 'Model.username']; $fields = urlencode(Security::hash(serialize($fields) . Configure::read('Security.salt'))); $unlocked = ''; - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'username' => 'mark', 'password' => 'sekret', 'hidden' => '0' - ), + ], '_Token' => compact('fields', 'unlocked') - ); + ]; Configure::write('debug', false); $result = $this->validatePost('SecurityException', 'The request has been black-holed'); } @@ -1012,25 +1012,25 @@ public function testValidatePostFailDisabledFieldTampering() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->request->params['_Token']['key']; $unlocked = 'Model.username'; - $fields = array('Model.hidden', 'Model.password'); + $fields = ['Model.hidden', 'Model.password']; $fields = urlencode(Security::hash(serialize($fields) . $unlocked . Configure::read('Security.salt'))); - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ '/posts/index', - array('Model.hidden', 'Model.password'), - array('Model.username') - ))); + ['Model.hidden', 'Model.password'], + ['Model.username'] + ])); // Tamper the values. $unlocked = 'Model.username|Model.password'; - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'username' => 'mark', 'password' => 'sekret', 'hidden' => '0' - ), + ], '_Token' => compact('fields', 'key', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost('SecurityException', 'Missing field \'Model.password\' in POST data, Unexpected unlocked field \'Model.password\' in POST data'); $this->assertFalse($result); @@ -1048,12 +1048,12 @@ public function testValidateHiddenMultipleModel() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Model' => array('username' => '', 'password' => '', 'valid' => '0'), - 'Model2' => array('valid' => '0'), - 'Model3' => array('valid' => '0'), + $this->Controller->request->data = [ + 'Model' => ['username' => '', 'password' => '', 'valid' => '0'], + 'Model2' => ['valid' => '0'], + 'Model3' => ['valid' => '0'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); } @@ -1071,19 +1071,19 @@ public function testValidateHasManyModel() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Model' => array( - array( + $this->Controller->request->data = [ + 'Model' => [ + [ 'username' => 'username', 'password' => 'password', 'hidden' => 'value', 'valid' => '0' - ), - array( + ], + [ 'username' => 'username', 'password' => 'password', 'hidden' => 'value', 'valid' => '0' - ) - ), + ] + ], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); @@ -1102,9 +1102,9 @@ public function testValidateHasManyRecordsPass() { $unlocked = ''; $debug = 'not used'; - $this->Controller->request->data = array( - 'Address' => array( - 0 => array( + $this->Controller->request->data = [ + 'Address' => [ + 0 => [ 'id' => '123', 'title' => 'home', 'first_name' => 'Bilbo', @@ -1113,8 +1113,8 @@ public function testValidateHasManyRecordsPass() { 'city' => 'the shire', 'phone' => 'N/A', 'primary' => '1', - ), - 1 => array( + ], + 1 => [ 'id' => '124', 'title' => 'home', 'first_name' => 'Frodo', @@ -1123,10 +1123,10 @@ public function testValidateHasManyRecordsPass() { 'city' => 'the shire', 'phone' => 'N/A', 'primary' => '1' - ) - ), + ] + ], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); @@ -1141,7 +1141,7 @@ public function testValidateNestedNumericSets() { $this->Controller->Security->startup($this->Controller); $key = $this->Controller->request->params['_Token']['key']; $unlocked = ''; - $hashFields = array('TaxonomyData'); + $hashFields = ['TaxonomyData']; $fields = urlencode( Security::hash( '/posts/index' . @@ -1151,13 +1151,13 @@ public function testValidateNestedNumericSets() { ); $debug = 'not used'; - $this->Controller->request->data = array( - 'TaxonomyData' => array( - 1 => array(array(2)), - 2 => array(array(3)) - ), + $this->Controller->request->data = [ + 'TaxonomyData' => [ + 1 => [[2]], + 2 => [[3]] + ], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); } @@ -1175,9 +1175,9 @@ public function testValidateHasManyRecordsFail() { $fields = '7a203edb3d345bbf38fe0dccae960da8842e11d7%3AAddress.0.id%7CAddress.0.primary%7C'; $fields .= 'Address.1.id%7CAddress.1.primary'; $unlocked = ''; - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ '/posts/index', - array( + [ 'Address.0.address', 'Address.0.city', 'Address.0.first_name', @@ -1194,13 +1194,13 @@ public function testValidateHasManyRecordsFail() { 'Address.0.primary' => '5', 'Address.1.id' => '124', 'Address.1.primary' => '1' - ), - array() - ))); + ], + [] + ])); - $this->Controller->request->data = array( - 'Address' => array( - 0 => array( + $this->Controller->request->data = [ + 'Address' => [ + 0 => [ 'id' => '123', 'title' => 'home', 'first_name' => 'Bilbo', @@ -1209,8 +1209,8 @@ public function testValidateHasManyRecordsFail() { 'city' => 'the shire', 'phone' => 'N/A', 'primary' => '5', - ), - 1 => array( + ], + 1 => [ 'id' => '124', 'title' => 'home', 'first_name' => 'Frodo', @@ -1219,10 +1219,10 @@ public function testValidateHasManyRecordsFail() { 'city' => 'the shire', 'phone' => 'N/A', 'primary' => '1' - ) - ), + ] + ], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost('SecurityException', 'Bad Request'); $this->assertFalse($result); @@ -1238,27 +1238,27 @@ public function testFormDisabledFields() { $key = $this->Controller->request->params['_Token']['key']; $fields = '216ee717efd1a251a6d6e9efbb96005a9d09f1eb%3An%3A0%3A%7B%7D'; $unlocked = ''; - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ '/posts/index', - array(), - array() - ))); + [], + [] + ])); - $this->Controller->request->data = array( - 'MyModel' => array('name' => 'some data'), + $this->Controller->request->data = [ + 'MyModel' => ['name' => 'some data'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost('SecurityException', 'Unexpected field \'MyModel.name\' in POST data'); $this->assertFalse($result); $this->Controller->Security->startup($this->Controller); - $this->Controller->Security->disabledFields = array('MyModel.name'); + $this->Controller->Security->disabledFields = ['MyModel.name']; $key = $this->Controller->request->params['_Token']['key']; - $this->Controller->request->data = array( - 'MyModel' => array('name' => 'some data'), + $this->Controller->request->data = [ + 'MyModel' => ['name' => 'some data'], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost(); $this->assertTrue($result); @@ -1274,36 +1274,36 @@ public function testValidatePostRadio() { $key = $this->Controller->request->params['_Token']['key']; $fields = '3be63770e7953c6d2119f5377a9303372040f66f%3An%3A0%3A%7B%7D'; $unlocked = ''; - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ '/posts/index', - array(), - array() - ))); + [], + [] + ])); - $this->Controller->request->data = array( + $this->Controller->request->data = [ '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost('SecurityException', 'Bad Request'); $this->assertFalse($result); - $this->Controller->request->data = array( + $this->Controller->request->data = [ '_Token' => compact('key', 'fields', 'unlocked', 'debug'), - 'Test' => array('test' => '') - ); + 'Test' => ['test' => ''] + ]; $result = $this->validatePost(); $this->assertTrue($result); - $this->Controller->request->data = array( + $this->Controller->request->data = [ '_Token' => compact('key', 'fields', 'unlocked', 'debug'), - 'Test' => array('test' => '1') - ); + 'Test' => ['test' => '1'] + ]; $result = $this->validatePost(); $this->assertTrue($result); - $this->Controller->request->data = array( + $this->Controller->request->data = [ '_Token' => compact('key', 'fields', 'unlocked', 'debug'), - 'Test' => array('test' => '2') - ); + 'Test' => ['test' => '2'] + ]; $result = $this->validatePost(); $this->assertTrue($result); } @@ -1319,19 +1319,19 @@ public function testValidatePostUrlAsHashInput() { $key = $this->Controller->request->params['_Token']['key']; $fields = '5415d31b4483c1e09ddb58d2a91ba9650b12aa83%3A'; $unlocked = ''; - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ 'another-url', - array('Model.username', 'Model.password'), - array() - ))); + ['Model.username', 'Model.password'], + [] + ])); - $this->Controller->request->data = array( - 'Model' => array('username' => '', 'password' => ''), + $this->Controller->request->data = [ + 'Model' => ['username' => '', 'password' => ''], '_Token' => compact('key', 'fields', 'unlocked', 'debug') - ); + ]; $this->assertTrue($this->validatePost()); - $request = $this->getMock('CakeRequest', array('here'), array('articles/edit/1', false)); + $request = $this->getMock('CakeRequest', ['here'], ['articles/edit/1', false]); $request->expects($this->at(0)) ->method('here') ->will($this->returnValue('/posts/index?page=1')); @@ -1406,7 +1406,7 @@ public function testCsrfSettings() { $token = $this->Security->Session->read('_Token'); $this->assertEquals(1, count($token['csrfTokens']), 'Missing the csrf token.'); $this->assertEquals(strtotime('+10 minutes'), current($token['csrfTokens']), 'Token expiry does not match'); - $this->assertEquals(array('key', 'unlockedFields'), array_keys($this->Controller->request->params['_Token']), 'Keys don not match'); + $this->assertEquals(['key', 'unlockedFields'], array_keys($this->Controller->request->params['_Token']), 'Keys don not match'); } /** @@ -1439,17 +1439,17 @@ public function testCsrfNonceConsumption() { $this->Security->csrfCheck = true; $this->Security->csrfExpires = '+10 minutes'; - $this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('+10 minutes'))); + $this->Security->Session->write('_Token.csrfTokens', ['nonce1' => strtotime('+10 minutes')]); $this->Controller->request->params['action'] = 'index'; - $this->Controller->request->data = array( - '_Token' => array( + $this->Controller->request->data = [ + '_Token' => [ 'key' => 'nonce1' - ), - 'Post' => array( + ], + 'Post' => [ 'title' => 'Woot' - ) - ); + ] + ]; $this->Security->startup($this->Controller); $token = $this->Security->Session->read('_Token'); $this->assertFalse(isset($token['csrfTokens']['nonce1']), 'Token was not consumed'); @@ -1465,7 +1465,7 @@ public function testCsrfReusableTokenRenewal() { $csrfExpires = '+10 minutes'; $this->Security->csrfExpires = $csrfExpires; - $this->Security->Session->write('_Token.csrfTokens', array('token' => strtotime('+1 minutes'))); + $this->Security->Session->write('_Token.csrfTokens', ['token' => strtotime('+1 minutes')]); $this->Security->startup($this->Controller); $tokens = $this->Security->Session->read('_Token.csrfTokens'); @@ -1482,11 +1482,11 @@ public function testCsrfNonceVacuum() { $this->Security->csrfCheck = true; $this->Security->csrfExpires = '+10 minutes'; - $this->Security->Session->write('_Token.csrfTokens', array( + $this->Security->Session->write('_Token.csrfTokens', [ 'valid' => strtotime('+30 minutes'), 'poof' => strtotime('-11 minutes'), 'dust' => strtotime('-20 minutes') - )); + ]); $this->Security->startup($this->Controller); $tokens = $this->Security->Session->read('_Token.csrfTokens'); $this->assertEquals(2, count($tokens), 'Too many tokens left behind'); @@ -1506,11 +1506,11 @@ public function testCsrfExceptionOnMissingKey() { $this->Security->blackHoleCallback = ''; $this->Controller->request->params['action'] = 'index'; - $this->Controller->request->data = array( - 'Post' => array( + $this->Controller->request->data = [ + 'Post' => [ 'title' => 'Woot' - ) - ); + ] + ]; $this->Security->startup($this->Controller); } @@ -1524,17 +1524,17 @@ public function testCsrfBlackHoleOnKeyMismatch() { $this->Security->csrfCheck = true; $this->Security->csrfExpires = '+10 minutes'; - $this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('+10 minutes'))); + $this->Security->Session->write('_Token.csrfTokens', ['nonce1' => strtotime('+10 minutes')]); $this->Controller->request->params['action'] = 'index'; - $this->Controller->request->data = array( - '_Token' => array( + $this->Controller->request->data = [ + '_Token' => [ 'key' => 'not the right value' - ), - 'Post' => array( + ], + 'Post' => [ 'title' => 'Woot' - ) - ); + ] + ]; $this->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed, 'fail() was not called.'); } @@ -1552,17 +1552,17 @@ public function testCsrfExceptionOnKeyMismatch() { $this->Security->csrfExpires = '+10 minutes'; $this->Security->blackHoleCallback = ''; - $this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('+10 minutes'))); + $this->Security->Session->write('_Token.csrfTokens', ['nonce1' => strtotime('+10 minutes')]); $this->Controller->request->params['action'] = 'index'; - $this->Controller->request->data = array( - '_Token' => array( + $this->Controller->request->data = [ + '_Token' => [ 'key' => 'not the right value' - ), - 'Post' => array( + ], + 'Post' => [ 'title' => 'Woot' - ) - ); + ] + ]; $this->Security->startup($this->Controller); } @@ -1576,17 +1576,17 @@ public function testCsrfBlackHoleOnExpiredKey() { $this->Security->csrfCheck = true; $this->Security->csrfExpires = '+10 minutes'; - $this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('-5 minutes'))); + $this->Security->Session->write('_Token.csrfTokens', ['nonce1' => strtotime('-5 minutes')]); $this->Controller->request->params['action'] = 'index'; - $this->Controller->request->data = array( - '_Token' => array( + $this->Controller->request->data = [ + '_Token' => [ 'key' => 'nonce1' - ), - 'Post' => array( + ], + 'Post' => [ 'title' => 'Woot' - ) - ); + ] + ]; $this->Security->startup($this->Controller); $this->assertTrue($this->Controller->failed, 'fail() was not called.'); } @@ -1604,17 +1604,17 @@ public function testCsrfExceptionOnExpiredKey() { $this->Security->csrfExpires = '+10 minutes'; $this->Security->blackHoleCallback = ''; - $this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('-5 minutes'))); + $this->Security->Session->write('_Token.csrfTokens', ['nonce1' => strtotime('-5 minutes')]); $this->Controller->request->params['action'] = 'index'; - $this->Controller->request->data = array( - '_Token' => array( + $this->Controller->request->data = [ + '_Token' => [ 'key' => 'nonce1' - ), - 'Post' => array( + ], + 'Post' => [ 'title' => 'Woot' - ) - ); + ] + ]; $this->Security->startup($this->Controller); } @@ -1640,7 +1640,7 @@ public function testCsrfNotUseOnce() { $this->assertEquals($token, $tokenTwo, 'Tokens should not be different.'); $key = $this->Controller->request->params['_Token']['key']; - $this->assertEquals(array($key), array_keys($token), '_Token.key and csrfToken do not match request will blackhole.'); + $this->assertEquals([$key], array_keys($token), '_Token.key and csrfToken do not match request will blackhole.'); } /** @@ -1654,18 +1654,18 @@ public function testCsrfNotUseOnceValidationLeavingToken() { $this->Security->csrfUseOnce = false; $this->Security->csrfExpires = '+10 minutes'; - $this->Security->Session->write('_Token.csrfTokens', array('nonce1' => strtotime('+10 minutes'))); + $this->Security->Session->write('_Token.csrfTokens', ['nonce1' => strtotime('+10 minutes')]); - $this->Controller->request = $this->getMock('CakeRequest', array('is')); + $this->Controller->request = $this->getMock('CakeRequest', ['is']); $this->Controller->request->params['action'] = 'index'; - $this->Controller->request->data = array( - '_Token' => array( + $this->Controller->request->data = [ + '_Token' => [ 'key' => 'nonce1' - ), - 'Post' => array( + ], + 'Post' => [ 'title' => 'Woot' - ) - ); + ] + ]; $this->Security->startup($this->Controller); $token = $this->Security->Session->read('_Token'); $this->assertTrue(isset($token['csrfTokens']['nonce1']), 'Token was consumed'); @@ -1693,14 +1693,14 @@ public function testGenerateToken() { public function testCsrfLimit() { $this->Security->csrfLimit = 3; $time = strtotime('+10 minutes'); - $tokens = array( + $tokens = [ '1' => $time, '2' => $time, '3' => $time, '4' => $time, '5' => $time, - ); - $this->Security->Session->write('_Token', array('csrfTokens' => $tokens)); + ]; + $this->Security->Session->write('_Token', ['csrfTokens' => $tokens]); $this->Security->generateToken($this->Controller->request); $result = $this->Security->Session->read('_Token.csrfTokens'); @@ -1718,7 +1718,7 @@ public function testCsrfLimit() { */ public function testUnlockedActions() { $_SERVER['REQUEST_METHOD'] = 'POST'; - $this->Controller->request->data = array('data'); + $this->Controller->request->data = ['data']; $this->Controller->Security->unlockedActions = 'index'; $this->Controller->Security->blackHoleCallback = null; $result = $this->Controller->Security->startup($this->Controller); @@ -1733,23 +1733,23 @@ public function testUnlockedActions() { public function testValidatePostDebugFormat() { $this->Controller->Security->startup($this->Controller); $unlocked = 'Model.username'; - $fields = array('Model.hidden', 'Model.password'); + $fields = ['Model.hidden', 'Model.password']; $fields = urlencode(Security::hash(serialize($fields) . $unlocked . Configure::read('Security.salt'))); - $debug = urlencode(json_encode(array( + $debug = urlencode(json_encode([ '/posts/index', - array('Model.hidden', 'Model.password'), - array('Model.username'), - array('not expected') - ))); + ['Model.hidden', 'Model.password'], + ['Model.username'], + ['not expected'] + ])); - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'username' => 'mark', 'password' => 'sekret', 'hidden' => '0' - ), + ], '_Token' => compact('fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost('SecurityException', 'Invalid security debug token.'); $this->assertFalse($result); @@ -1799,21 +1799,21 @@ public function testBlackholeThrowsBadRequest() { public function testValidatePostFailTampering() { $this->Controller->Security->startup($this->Controller); $unlocked = ''; - $fields = array('Model.hidden' => 'value', 'Model.id' => '1'); - $debug = urlencode(json_encode(array( + $fields = ['Model.hidden' => 'value', 'Model.id' => '1']; + $debug = urlencode(json_encode([ '/posts/index', $fields, - array() - ))); + [] + ])); $fields = urlencode(Security::hash(serialize($fields) . $unlocked . Configure::read('Security.salt'))); $fields .= urlencode(':Model.hidden|Model.id'); - $this->Controller->request->data = array( - 'Model' => array( + $this->Controller->request->data = [ + 'Model' => [ 'hidden' => 'tampered', 'id' => '1', - ), + ], '_Token' => compact('fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost('SecurityException', 'Tampered field \'Model.hidden\' in POST data (expected value \'value\' but found \'tampered\')'); $this->assertFalse($result); @@ -1827,21 +1827,21 @@ public function testValidatePostFailTampering() { public function testValidatePostFailTamperingMutatedIntoArray() { $this->Controller->Security->startup($this->Controller); $unlocked = ''; - $fields = array('Model.hidden' => 'value', 'Model.id' => '1'); - $debug = urlencode(json_encode(array( + $fields = ['Model.hidden' => 'value', 'Model.id' => '1']; + $debug = urlencode(json_encode([ '/posts/index', $fields, - array() - ))); + [] + ])); $fields = urlencode(Security::hash(serialize($fields) . $unlocked . Configure::read('Security.salt'))); $fields .= urlencode(':Model.hidden|Model.id'); - $this->Controller->request->data = array( - 'Model' => array( - 'hidden' => array('some-key' => 'some-value'), + $this->Controller->request->data = [ + 'Model' => [ + 'hidden' => ['some-key' => 'some-value'], 'id' => '1', - ), + ], '_Token' => compact('fields', 'unlocked', 'debug') - ); + ]; $result = $this->validatePost('SecurityException', 'Unexpected field \'Model.hidden.some-key\' in POST data, Missing field \'Model.hidden\' in POST data'); $this->assertFalse($result); @@ -1855,21 +1855,21 @@ public function testValidatePostFailTamperingMutatedIntoArray() { public function testValidatePostUnexpectedDebugToken() { $this->Controller->Security->startup($this->Controller); $unlocked = ''; - $fields = array('Model.hidden' => 'value', 'Model.id' => '1'); - $debug = urlencode(json_encode(array( + $fields = ['Model.hidden' => 'value', 'Model.id' => '1']; + $debug = urlencode(json_encode([ '/posts/index', $fields, - array() - ))); + [] + ])); $fields = urlencode(Security::hash(serialize($fields) . $unlocked . Configure::read('Security.salt'))); $fields .= urlencode(':Model.hidden|Model.id'); - $this->Controller->request->data = array( - 'Model' => array( - 'hidden' => array('some-key' => 'some-value'), + $this->Controller->request->data = [ + 'Model' => [ + 'hidden' => ['some-key' => 'some-value'], 'id' => '1', - ), + ], '_Token' => compact('fields', 'unlocked', 'debug') - ); + ]; Configure::write('debug', false); $result = $this->validatePost('SecurityException', 'Unexpected \'_Token.debug\' found in request data'); $this->assertFalse($result); @@ -1883,9 +1883,9 @@ public function testValidatePostUnexpectedDebugToken() { public function testAuthRequiredThrowsExceptionTokenNotFoundPost() { $this->expectException(AuthSecurityException::class); $this->expectExceptionMessage("'_Token' was not found in request data."); - $this->Controller->Security->requireAuth = array('protected'); + $this->Controller->Security->requireAuth = ['protected']; $this->Controller->request->params['action'] = 'protected'; - $this->Controller->request->data = array('some-key' => 'some-value'); + $this->Controller->request->data = ['some-key' => 'some-value']; $this->Controller->Security->authRequired($this->Controller); } @@ -1897,9 +1897,9 @@ public function testAuthRequiredThrowsExceptionTokenNotFoundPost() { public function testAuthRequiredThrowsExceptionTokenNotFoundSession() { $this->expectException(AuthSecurityException::class); $this->expectExceptionMessage("'_Token' was not found in session."); - $this->Controller->Security->requireAuth = array('protected'); + $this->Controller->Security->requireAuth = ['protected']; $this->Controller->request->params['action'] = 'protected'; - $this->Controller->request->data = array('_Token' => 'not empty'); + $this->Controller->request->data = ['_Token' => 'not empty']; $this->Controller->Security->authRequired($this->Controller); } @@ -1911,13 +1911,13 @@ public function testAuthRequiredThrowsExceptionTokenNotFoundSession() { public function testAuthRequiredThrowsExceptionControllerNotAllowed() { $this->expectException(AuthSecurityException::class); $this->expectExceptionMessage("Controller 'NotAllowed' was not found in allowed controllers: 'Allowed, AnotherAllowed'."); - $this->Controller->Security->requireAuth = array('protected'); + $this->Controller->Security->requireAuth = ['protected']; $this->Controller->request->params['controller'] = 'NotAllowed'; $this->Controller->request->params['action'] = 'protected'; - $this->Controller->request->data = array('_Token' => 'not empty'); - $this->Controller->Session->write('_Token', array( - 'allowedControllers' => array('Allowed', 'AnotherAllowed') - )); + $this->Controller->request->data = ['_Token' => 'not empty']; + $this->Controller->Session->write('_Token', [ + 'allowedControllers' => ['Allowed', 'AnotherAllowed'] + ]); $this->Controller->Security->authRequired($this->Controller); } @@ -1929,13 +1929,13 @@ public function testAuthRequiredThrowsExceptionControllerNotAllowed() { public function testAuthRequiredThrowsExceptionActionNotAllowed() { $this->expectException(AuthSecurityException::class); $this->expectExceptionMessage("Action 'NotAllowed::protected' was not found in allowed actions: 'index, view'."); - $this->Controller->Security->requireAuth = array('protected'); + $this->Controller->Security->requireAuth = ['protected']; $this->Controller->request->params['controller'] = 'NotAllowed'; $this->Controller->request->params['action'] = 'protected'; - $this->Controller->request->data = array('_Token' => 'not empty'); - $this->Controller->Session->write('_Token', array( - 'allowedActions' => array('index', 'view') - )); + $this->Controller->request->data = ['_Token' => 'not empty']; + $this->Controller->Session->write('_Token', [ + 'allowedActions' => ['index', 'view'] + ]); $this->Controller->Security->authRequired($this->Controller); } @@ -1945,14 +1945,14 @@ public function testAuthRequiredThrowsExceptionActionNotAllowed() { * @return void */ public function testAuthRequired() { - $this->Controller->Security->requireAuth = array('protected'); + $this->Controller->Security->requireAuth = ['protected']; $this->Controller->request->params['controller'] = 'Allowed'; $this->Controller->request->params['action'] = 'protected'; - $this->Controller->request->data = array('_Token' => 'not empty'); - $this->Controller->Session->write('_Token', array( - 'allowedActions' => array('protected'), - 'allowedControllers' => array('Allowed'), - )); + $this->Controller->request->data = ['_Token' => 'not empty']; + $this->Controller->Session->write('_Token', [ + 'allowedActions' => ['protected'], + 'allowedControllers' => ['Allowed'], + ]); $this->assertTrue($this->Controller->Security->authRequired($this->Controller)); } @@ -1965,7 +1965,7 @@ public function testMethodsRequiredThrowsExceptionMethodNotAllowed() { $this->expectException(SecurityException::class); $this->expectExceptionMessage("The request method must be POST"); $_SERVER['REQUEST_METHOD'] = 'GET'; - $this->Controller->Security->requirePost = array('delete'); + $this->Controller->Security->requirePost = ['delete']; $this->Controller->request->params['controller'] = 'Test'; $this->Controller->request->params['action'] = 'delete'; $this->Controller->Security->startup($this->Controller); @@ -1979,7 +1979,7 @@ public function testMethodsRequiredThrowsExceptionMethodNotAllowed() { */ public function testMethodsRequired() { $_SERVER['REQUEST_METHOD'] = 'POST'; - $this->Controller->Security->requirePost = array('delete'); + $this->Controller->Security->requirePost = ['delete']; $this->Controller->request->params['controller'] = 'Test'; $this->Controller->request->params['action'] = 'delete'; $this->Controller->Security->startup($this->Controller); diff --git a/lib/Cake/Test/Case/Controller/Component/SessionComponentTest.php b/lib/Cake/Test/Case/Controller/Component/SessionComponentTest.php index ef587da278..476760a3b9 100644 --- a/lib/Cake/Test/Case/Controller/Component/SessionComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/SessionComponentTest.php @@ -31,7 +31,7 @@ class SessionTestController extends Controller { * * @var array */ - public $uses = array(); + public $uses = []; /** * sessionId method @@ -56,7 +56,7 @@ class OrangeSessionTestController extends Controller { * * @var array */ - public $uses = array(); + public $uses = []; /** * sessionId method @@ -83,7 +83,7 @@ class SessionComponentTest extends CakeTestCase { * * @var string */ - public $fixtures = array('core.session'); + public $fixtures = ['core.session']; /** * test case startup @@ -92,11 +92,11 @@ class SessionComponentTest extends CakeTestCase { */ public static function setupBeforeClass() : void { static::$_sessionBackup = Configure::read('Session'); - Configure::write('Session', array( + Configure::write('Session', [ 'defaults' => 'php', 'timeout' => 100, 'cookie' => 'test' - )); + ]); } /** @@ -192,17 +192,17 @@ public function testSessionReadWrite() { $this->assertTrue($Session->write('Test.key.path', 'some value')); $this->assertEquals('some value', $Session->read('Test.key.path')); - $this->assertEquals(array('path' => 'some value'), $Session->read('Test.key')); + $this->assertEquals(['path' => 'some value'], $Session->read('Test.key')); $this->assertTrue($Session->write('Test.key.path2', 'another value')); - $this->assertEquals(array('path' => 'some value', 'path2' => 'another value'), $Session->read('Test.key')); + $this->assertEquals(['path' => 'some value', 'path2' => 'another value'], $Session->read('Test.key')); $Session->delete('Test'); - $array = array('key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'); + $array = ['key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3']; $this->assertTrue($Session->write('Test', $array)); $this->assertEquals($Session->read('Test'), $array); $Session->delete('Test'); - $this->assertTrue($Session->write(array('Test' => 'some value'))); + $this->assertTrue($Session->write(['Test' => 'some value'])); $this->assertEquals('some value', $Session->read('Test')); $Session->delete('Test'); } @@ -247,13 +247,13 @@ public function testSessionFlash() { $this->assertNull($Session->read('Message.flash')); $Session->setFlash('This is a test message'); - $this->assertEquals(array('message' => 'This is a test message', 'element' => 'default', 'params' => array()), $Session->read('Message.flash.0')); + $this->assertEquals(['message' => 'This is a test message', 'element' => 'default', 'params' => []], $Session->read('Message.flash.0')); - $Session->setFlash('This is a test message', 'test', array('name' => 'Joel Moss')); - $this->assertEquals(array('message' => 'This is a test message', 'element' => 'test', 'params' => array('name' => 'Joel Moss')), $Session->read('Message.flash.1')); + $Session->setFlash('This is a test message', 'test', ['name' => 'Joel Moss']); + $this->assertEquals(['message' => 'This is a test message', 'element' => 'test', 'params' => ['name' => 'Joel Moss']], $Session->read('Message.flash.1')); - $Session->setFlash('This is a test message', 'default', array(), 'myFlash'); - $this->assertEquals(array('message' => 'This is a test message', 'element' => 'default', 'params' => array()), $Session->read('Message.myFlash.0')); + $Session->setFlash('This is a test message', 'default', [], 'myFlash'); + $this->assertEquals(['message' => 'This is a test message', 'element' => 'default', 'params' => []], $Session->read('Message.myFlash.0')); $Session->delete('Message'); } @@ -280,7 +280,7 @@ public function testSessionDestroy() { $Session->write('Test', 'some value'); $this->assertEquals('some value', $Session->read('Test')); - $Session->destroy('Test'); + $Session->destroy(); $this->assertNull($Session->read('Test')); } diff --git a/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php b/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php index 8c66526cab..180e15854d 100644 --- a/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php +++ b/lib/Cake/Test/Case/Controller/ComponentCollectionTest.php @@ -60,7 +60,7 @@ public function testLoad() { $this->assertInstanceOf('CookieComponent', $this->Components->Cookie); $result = $this->Components->loaded(); - $this->assertEquals(array('Cookie'), $result, 'loaded() results are wrong.'); + $this->assertEquals(['Cookie'], $result, 'loaded() results are wrong.'); $this->assertTrue($this->Components->enabled('Cookie')); @@ -74,27 +74,27 @@ public function testLoad() { * @return void */ public function testLoadWithAlias() { - $result = $this->Components->load('Cookie', array('className' => 'CookieAlias', 'somesetting' => true)); + $result = $this->Components->load('Cookie', ['className' => 'CookieAlias', 'somesetting' => true]); $this->assertInstanceOf('CookieAliasComponent', $result); $this->assertInstanceOf('CookieAliasComponent', $this->Components->Cookie); $this->assertTrue($this->Components->Cookie->settings['somesetting']); $result = $this->Components->loaded(); - $this->assertEquals(array('Cookie'), $result, 'loaded() results are wrong.'); + $this->assertEquals(['Cookie'], $result, 'loaded() results are wrong.'); $this->assertTrue($this->Components->enabled('Cookie')); $result = $this->Components->load('Cookie'); $this->assertInstanceOf('CookieAliasComponent', $result); - App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS))); + App::build(['Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS]]); CakePlugin::load('TestPlugin'); - $result = $this->Components->load('SomeOther', array('className' => 'TestPlugin.Other')); + $result = $this->Components->load('SomeOther', ['className' => 'TestPlugin.Other']); $this->assertInstanceOf('OtherComponent', $result); $this->assertInstanceOf('OtherComponent', $this->Components->SomeOther); $result = $this->Components->loaded(); - $this->assertEquals(array('Cookie', 'SomeOther'), $result, 'loaded() results are wrong.'); + $this->assertEquals(['Cookie', 'SomeOther'], $result, 'loaded() results are wrong.'); App::build(); CakePlugin::unload(); } @@ -105,7 +105,7 @@ public function testLoadWithAlias() { * @return void */ public function testLoadWithEnableFalse() { - $result = $this->Components->load('Cookie', array('enabled' => false)); + $result = $this->Components->load('Cookie', ['enabled' => false]); $this->assertInstanceOf('CookieComponent', $result); $this->assertInstanceOf('CookieComponent', $this->Components->Cookie); @@ -128,9 +128,9 @@ public function testLoadMissingComponent() { * @return void */ public function testLoadPluginComponent() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + ]); CakePlugin::load('TestPlugin'); $result = $this->Components->load('TestPlugin.Other'); $this->assertInstanceOf('OtherComponent', $result, 'Component class is wrong.'); @@ -149,17 +149,17 @@ public function testUnload() { $this->Components->load('Security'); $result = $this->Components->loaded(); - $this->assertEquals(array('Cookie', 'Security'), $result, 'loaded components is wrong'); + $this->assertEquals(['Cookie', 'Security'], $result, 'loaded components is wrong'); $this->Components->unload('Cookie'); $this->assertFalse(isset($this->Components->Cookie)); $this->assertTrue(isset($this->Components->Security)); $result = $this->Components->loaded(); - $this->assertEquals(array('Security'), $result, 'loaded components is wrong'); + $this->assertEquals(['Security'], $result, 'loaded components is wrong'); $result = $this->Components->enabled(); - $this->assertEquals(array('Security'), $result, 'enabled components is wrong'); + $this->assertEquals(['Security'], $result, 'enabled components is wrong'); } /** @@ -169,7 +169,7 @@ public function testUnload() { */ public function testGetController() { $controller = $this->getMock('Controller'); - $controller->components = array('Security'); + $controller->components = ['Security']; $this->Components->init($controller); $result = $this->Components->getController(); diff --git a/lib/Cake/Test/Case/Controller/ComponentTest.php b/lib/Cake/Test/Case/Controller/ComponentTest.php index 0686ac335f..924b83727e 100644 --- a/lib/Cake/Test/Case/Controller/ComponentTest.php +++ b/lib/Cake/Test/Case/Controller/ComponentTest.php @@ -31,10 +31,10 @@ class ParamTestComponent extends Component { * * @var array */ - public $components = array( - 'Apple' => array('enabled' => true), - 'Banana' => array('config' => 'value'), - ); + public $components = [ + 'Apple' => ['enabled' => true], + 'Banana' => ['config' => 'value'], + ]; } /** @@ -49,7 +49,7 @@ class ComponentTestController extends Controller { * * @var array */ - public $uses = array(); + public $uses = []; } @@ -65,7 +65,7 @@ class AppleComponent extends Component { * * @var array */ - public $components = array('Orange'); + public $components = ['Orange']; /** * testName property @@ -98,7 +98,7 @@ class OrangeComponent extends Component { * * @var array */ - public $components = array('Banana'); + public $components = ['Banana']; /** * initialize method @@ -161,7 +161,7 @@ class MutuallyReferencingOneComponent extends Component { * * @var array */ - public $components = array('MutuallyReferencingTwo'); + public $components = ['MutuallyReferencingTwo']; } /** @@ -176,7 +176,7 @@ class MutuallyReferencingTwoComponent extends Component { * * @var array */ - public $components = array('MutuallyReferencingOne'); + public $components = ['MutuallyReferencingOne']; } /** @@ -191,7 +191,7 @@ class SomethingWithEmailComponent extends Component { * * @var array */ - public $components = array('Email'); + public $components = ['Email']; } /** @@ -209,9 +209,9 @@ class ComponentTest extends CakeTestCase { public function setUp() : void { parent::setUp(); $this->_pluginPaths = App::path('plugins'); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); } /** @@ -252,7 +252,7 @@ public function testInnerComponentsAreNotEnabled() { $this->assertInstanceOf('OrangeComponent', $Apple->Orange, 'class is wrong'); $result = $Collection->enabled(); - $this->assertEquals(array('Apple'), $result, 'Too many components enabled.'); + $this->assertEquals(['Apple'], $result, 'Too many components enabled.'); } /** @@ -278,12 +278,12 @@ public function testMultipleComponentInitialize() { */ public function testSomethingReferencingEmailComponent() { $Controller = new ComponentTestController(); - $Controller->components = array('SomethingWithEmail'); + $Controller->components = ['SomethingWithEmail']; $Controller->uses = false; $Controller->constructClasses(); - $Controller->Components->trigger('initialize', array(&$Controller)); + $Controller->Components->trigger('initialize', [&$Controller]); $Controller->beforeFilter(); - $Controller->Components->trigger('startup', array(&$Controller)); + $Controller->Components->trigger('startup', [&$Controller]); $this->assertInstanceOf('SomethingWithEmailComponent', $Controller->SomethingWithEmail); $this->assertInstanceOf('EmailComponent', $Controller->SomethingWithEmail->Email); diff --git a/lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php b/lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php index 554a1f96ee..8a13e8e508 100644 --- a/lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerMergeVarsTest.php @@ -32,14 +32,14 @@ class MergeVarsAppController extends Controller { * * @var array */ - public $components = array('MergeVar' => array('flag', 'otherFlag', 'redirect' => false)); + public $components = ['MergeVar' => ['flag', 'otherFlag', 'redirect' => false]]; /** * helpers * * @var array */ - public $helpers = array('MergeVar' => array('format' => 'html', 'terse')); + public $helpers = ['MergeVar' => ['format' => 'html', 'terse']]; } /** @@ -63,7 +63,7 @@ class MergeVariablesController extends MergeVarsAppController { * * @var arrays */ - public $uses = array(); + public $uses = []; /** * parent for mergeVars @@ -85,14 +85,14 @@ class MergeVarPluginAppController extends MergeVarsAppController { * * @var array */ - public $components = array('Auth' => array('setting' => 'val', 'otherVal')); + public $components = ['Auth' => ['setting' => 'val', 'otherVal']]; /** * helpers * * @var array */ - public $helpers = array('Js'); + public $helpers = ['Js']; /** * parent for mergeVars @@ -114,7 +114,7 @@ class MergePostsController extends MergeVarPluginAppController { * * @var array */ - public $uses = array(); + public $uses = []; } /** @@ -133,7 +133,7 @@ public function testComponentParamMergingNoDuplication() { $Controller = new MergeVariablesController(); $Controller->constructClasses(); - $expected = array('MergeVar' => array('flag', 'otherFlag', 'redirect' => false)); + $expected = ['MergeVar' => ['flag', 'otherFlag', 'redirect' => false]]; $this->assertEquals($expected, $Controller->components, 'Duplication of settings occurred. %s'); } @@ -144,10 +144,10 @@ public function testComponentParamMergingNoDuplication() { */ public function testComponentMergingWithRedeclarations() { $Controller = new MergeVariablesController(); - $Controller->components['MergeVar'] = array('remote', 'redirect' => true); + $Controller->components['MergeVar'] = ['remote', 'redirect' => true]; $Controller->constructClasses(); - $expected = array('MergeVar' => array('flag', 'otherFlag', 'redirect' => true, 'remote')); + $expected = ['MergeVar' => ['flag', 'otherFlag', 'redirect' => true, 'remote']]; $this->assertEquals($expected, $Controller->components, 'Merging of settings is wrong. %s'); } @@ -160,7 +160,7 @@ public function testHelperSettingMergingNoDuplication() { $Controller = new MergeVariablesController(); $Controller->constructClasses(); - $expected = array('MergeVar' => array('format' => 'html', 'terse')); + $expected = ['MergeVar' => ['format' => 'html', 'terse']]; $this->assertEquals($expected, $Controller->helpers, 'Duplication of settings occurred. %s'); } @@ -172,14 +172,14 @@ public function testHelperSettingMergingNoDuplication() { */ public function testHelperOrderPrecedence() { $Controller = new MergeVariablesController(); - $Controller->helpers = array('Custom', 'Foo' => array('something')); + $Controller->helpers = ['Custom', 'Foo' => ['something']]; $Controller->constructClasses(); - $expected = array( - 'MergeVar' => array('format' => 'html', 'terse'), + $expected = [ + 'MergeVar' => ['format' => 'html', 'terse'], 'Custom' => null, - 'Foo' => array('something') - ); + 'Foo' => ['something'] + ]; $this->assertSame($expected, $Controller->helpers, 'Order is incorrect.'); } @@ -190,32 +190,32 @@ public function testHelperOrderPrecedence() { */ public function testMergeVarsWithPlugin() { $Controller = new MergePostsController(); - $Controller->components = array('Email' => array('ports' => 'open')); + $Controller->components = ['Email' => ['ports' => 'open']]; $Controller->plugin = 'MergeVarPlugin'; $Controller->constructClasses(); - $expected = array( - 'MergeVar' => array('flag', 'otherFlag', 'redirect' => false), - 'Auth' => array('setting' => 'val', 'otherVal'), - 'Email' => array('ports' => 'open') - ); + $expected = [ + 'MergeVar' => ['flag', 'otherFlag', 'redirect' => false], + 'Auth' => ['setting' => 'val', 'otherVal'], + 'Email' => ['ports' => 'open'] + ]; $this->assertEquals($expected, $Controller->components, 'Components are unexpected.'); - $expected = array( - 'MergeVar' => array('format' => 'html', 'terse'), + $expected = [ + 'MergeVar' => ['format' => 'html', 'terse'], 'Js' => null - ); + ]; $this->assertEquals($expected, $Controller->helpers, 'Helpers are unexpected.'); $Controller = new MergePostsController(); - $Controller->components = array(); + $Controller->components = []; $Controller->plugin = 'MergeVarPlugin'; $Controller->constructClasses(); - $expected = array( - 'MergeVar' => array('flag', 'otherFlag', 'redirect' => false), - 'Auth' => array('setting' => 'val', 'otherVal'), - ); + $expected = [ + 'MergeVar' => ['flag', 'otherFlag', 'redirect' => false], + 'Auth' => ['setting' => 'val', 'otherVal'], + ]; $this->assertEquals($expected, $Controller->components, 'Components are unexpected.'); } @@ -227,8 +227,8 @@ public function testMergeVarsWithPlugin() { */ public function testMergeVarsNotGreedy() { $Controller = new Controller(); - $Controller->components = array(); - $Controller->uses = array(); + $Controller->components = []; + $Controller->uses = []; $Controller->constructClasses(); $this->assertFalse(isset($Controller->Session)); @@ -242,7 +242,7 @@ public function testMergeVarsNotGreedy() { */ public function testMergeVarsModelClass() { $Controller = new MergeVariablescontroller(); - $Controller->uses = array('Test', 'TestAlias'); + $Controller->uses = ['Test', 'TestAlias']; $Controller->constructClasses(); $this->assertEquals($Controller->uses[0], $Controller->modelClass); } diff --git a/lib/Cake/Test/Case/Controller/ControllerTest.php b/lib/Cake/Test/Case/Controller/ControllerTest.php index 1f1a8cdb7d..a12b057a18 100644 --- a/lib/Cake/Test/Case/Controller/ControllerTest.php +++ b/lib/Cake/Test/Case/Controller/ControllerTest.php @@ -33,21 +33,21 @@ class ControllerTestAppController extends Controller { * * @var array */ - public $helpers = array('Html'); + public $helpers = ['Html']; /** * uses property * * @var array */ - public $uses = array('ControllerPost'); + public $uses = ['ControllerPost']; /** * components property * * @var array */ - public $components = array('Cookie'); + public $components = ['Cookie']; } /** @@ -69,7 +69,7 @@ class ControllerPost extends CakeTestModel { * * @var array */ - public $invalidFields = array('name' => 'error_msg'); + public $invalidFields = ['name' => 'error_msg']; /** * lastQuery property @@ -95,9 +95,9 @@ public function beforeFind($query) { * @param array $options * @return void */ - public function find($type = 'first', $options = array()) { + public function find($type = 'first', $options = []) { if ($type === 'popular') { - $conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1'); + $conditions = [$this->name . '.' . $this->primaryKey . ' > ' => '1']; $options = Hash::merge($options, compact('conditions')); return parent::find('all', $options); } @@ -142,7 +142,7 @@ class ControllerComment extends CakeTestModel { * * @var array */ - public $data = array('name' => 'Some Name'); + public $data = ['name' => 'Some Name']; /** * alias property @@ -213,21 +213,21 @@ class TestController extends ControllerTestAppController { * * @var array */ - public $helpers = array('Session'); + public $helpers = ['Session']; /** * components property * * @var array */ - public $components = array('Security'); + public $components = ['Security']; /** * uses property * * @var array */ - public $uses = array('ControllerComment', 'ControllerAlias'); + public $uses = ['ControllerComment', 'ControllerAlias']; protected $_mergeParent = 'ControllerTestAppController'; @@ -239,10 +239,10 @@ class TestController extends ControllerTestAppController { * @return void */ public function index($testId, $testTwoId) { - $this->data = array( + $this->data = [ 'testId' => $testId, 'test2Id' => $testTwoId - ); + ]; } /** @@ -253,10 +253,10 @@ public function index($testId, $testTwoId) { * @return void */ public function view($testId, $testTwoId) { - $this->data = array( + $this->data = [ 'testId' => $testId, 'test2Id' => $testTwoId - ); + ]; } public function returner() { @@ -380,10 +380,10 @@ class ControllerTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.post', 'core.comment' - ); + ]; /** * reset environment. @@ -447,11 +447,11 @@ public function testLoadModelUsesTrue() { * @return void */ public function testLoadModelInPlugins() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Controller' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS), - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Controller' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS], + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS] + ]); CakePlugin::load('TestPlugin'); App::uses('TestPluginAppController', 'TestPlugin.Controller'); App::uses('TestPluginController', 'TestPlugin.Controller'); @@ -480,7 +480,7 @@ public function testConstructClasses() { $request = new CakeRequest('controller_posts/index'); $Controller = new Controller($request); - $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->uses = ['ControllerPost', 'ControllerComment']; $Controller->constructClasses(); $this->assertInstanceOf('ControllerPost', $Controller->ControllerPost); $this->assertInstanceOf('ControllerComment', $Controller->ControllerComment); @@ -489,11 +489,11 @@ public function testConstructClasses() { unset($Controller); - App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS))); + App::build(['Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS]]); CakePlugin::load('TestPlugin'); $Controller = new Controller($request); - $Controller->uses = array('TestPlugin.TestPluginPost'); + $Controller->uses = ['TestPlugin.TestPluginPost']; $Controller->constructClasses(); $this->assertTrue(isset($Controller->TestPluginPost)); @@ -507,7 +507,7 @@ public function testConstructClasses() { */ public function testConstructClassesWithComponents() { $Controller = new TestPluginController(new CakeRequest(), new CakeResponse()); - $Controller->uses = array('NameTest'); + $Controller->uses = ['NameTest']; $Controller->components[] = 'Test2'; $Controller->constructClasses(); @@ -524,7 +524,7 @@ public function testConstructClassesWithComponents() { public function testAliasName() { $request = new CakeRequest('controller_posts/index'); $Controller = new Controller($request); - $Controller->uses = array('NameTest'); + $Controller->uses = ['NameTest']; $Controller->constructClasses(); $this->assertEquals('Name', $Controller->NameTest->name); @@ -543,7 +543,7 @@ public function testFlash() { $request->webroot = '/'; $request->base = '/'; - $Controller = new Controller($request, $this->getMock('CakeResponse', array('_sendHeader'))); + $Controller = new Controller($request, $this->getMock('CakeResponse', ['_sendHeader'])); $Controller->flash('this should work', '/flash'); $result = $Controller->response->body(); @@ -562,15 +562,15 @@ public function testFlash() {

this should work

'; - $result = str_replace(array("\t", "\r\n", "\n"), "", $result); - $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected); + $result = str_replace(["\t", "\r\n", "\n"], "", $result); + $expected = str_replace(["\t", "\r\n", "\n"], "", $expected); $this->assertEquals($expected, $result); - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $Controller = new Controller($request); - $Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $Controller->response = $this->getMock('CakeResponse', ['_sendHeader']); $Controller->flash('this should work', '/flash', 1, 'ajax2'); $result = $Controller->response->body(); $this->assertMatchesRegularExpression('/Ajax!/', $result); @@ -589,32 +589,32 @@ public function testControllerSet() { $Controller->set('variable_with_underscores', null); $this->assertTrue(array_key_exists('variable_with_underscores', $Controller->viewVars)); - $Controller->viewVars = array(); - $viewVars = array('ModelName' => array('id' => 1, 'name' => 'value')); + $Controller->viewVars = []; + $viewVars = ['ModelName' => ['id' => 1, 'name' => 'value']]; $Controller->set($viewVars); $this->assertTrue(array_key_exists('ModelName', $Controller->viewVars)); - $Controller->viewVars = array(); + $Controller->viewVars = []; $Controller->set('variable_with_underscores', 'value'); $this->assertTrue(array_key_exists('variable_with_underscores', $Controller->viewVars)); - $Controller->viewVars = array(); - $viewVars = array('ModelName' => 'name'); + $Controller->viewVars = []; + $viewVars = ['ModelName' => 'name']; $Controller->set($viewVars); $this->assertTrue(array_key_exists('ModelName', $Controller->viewVars)); $Controller->set('title', 'someTitle'); $this->assertSame($Controller->viewVars['title'], 'someTitle'); - $Controller->viewVars = array(); - $expected = array('ModelName' => 'name', 'ModelName2' => 'name2'); - $Controller->set(array('ModelName', 'ModelName2'), array('name', 'name2')); + $Controller->viewVars = []; + $expected = ['ModelName' => 'name', 'ModelName2' => 'name2']; + $Controller->set(['ModelName', 'ModelName2'], ['name', 'name2']); $this->assertSame($expected, $Controller->viewVars); - $Controller->viewVars = array(); - $Controller->set(array(3 => 'three', 4 => 'four')); - $Controller->set(array(1 => 'one', 2 => 'two')); - $expected = array(3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two'); + $Controller->viewVars = []; + $Controller->set([3 => 'three', 4 => 'four']); + $Controller->set([1 => 'one', 2 => 'two']); + $expected = [3 => 'three', 4 => 'four', 1 => 'one', 2 => 'two']; $this->assertEquals($expected, $Controller->viewVars); } @@ -624,9 +624,9 @@ public function testControllerSet() { * @return void */ public function testRender() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); ClassRegistry::flush(); $request = new CakeRequest('controller_posts/index'); $request->params['action'] = 'index'; @@ -646,10 +646,10 @@ public function testRender() { $Controller->view = null; $Controller = new TestController($request, new CakeResponse()); - $Controller->uses = array('ControllerAlias', 'TestPlugin.ControllerComment', 'ControllerPost'); - $Controller->helpers = array('Html'); + $Controller->uses = ['ControllerAlias', 'TestPlugin.ControllerComment', 'ControllerPost']; + $Controller->helpers = ['Html']; $Controller->constructClasses(); - $Controller->ControllerComment->validationErrors = array('title' => 'tooShort'); + $Controller->ControllerComment->validationErrors = ['title' => 'tooShort']; $expected = $Controller->ControllerComment->validationErrors; $Controller->viewPath = 'Posts'; @@ -658,11 +658,11 @@ public function testRender() { $this->assertTrue(isset($View->validationErrors['ControllerComment'])); $this->assertEquals($expected, $View->validationErrors['ControllerComment']); - $expectedModels = array( - 'ControllerAlias' => array('plugin' => null, 'className' => 'ControllerAlias'), - 'ControllerComment' => array('plugin' => 'TestPlugin', 'className' => 'ControllerComment'), - 'ControllerPost' => array('plugin' => null, 'className' => 'ControllerPost') - ); + $expectedModels = [ + 'ControllerAlias' => ['plugin' => null, 'className' => 'ControllerAlias'], + 'ControllerComment' => ['plugin' => 'TestPlugin', 'className' => 'ControllerComment'], + 'ControllerPost' => ['plugin' => null, 'className' => 'ControllerPost'] + ]; $this->assertEquals($expectedModels, $Controller->request->params['models']); ClassRegistry::flush(); @@ -675,14 +675,14 @@ public function testRender() { * @return void */ public function testComponentBeforeRenderChangingViewClass() { - App::build(array( - 'View' => array( + App::build([ + 'View' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS - ) - ), true); + ] + ], true); $Controller = new Controller($this->getMock('CakeRequest'), new CakeResponse()); - $Controller->uses = array(); - $Controller->components = array('Test'); + $Controller->uses = []; + $Controller->components = ['Test']; $Controller->constructClasses(); $Controller->Test->viewclass = 'Theme'; $Controller->viewPath = 'Posts'; @@ -699,8 +699,8 @@ public function testComponentBeforeRenderChangingViewClass() { */ public function testComponentCancelRender() { $Controller = new Controller($this->getMock('CakeRequest'), new CakeResponse()); - $Controller->uses = array(); - $Controller->components = array('Test2'); + $Controller->uses = []; + $Controller->components = ['Test2']; $Controller->constructClasses(); $result = $Controller->render('index'); $this->assertInstanceOf('CakeResponse', $result); @@ -727,16 +727,16 @@ public function testToBeInheritedGuardmethods() { * @return void */ public static function statusCodeProvider() { - return array( - array(300, "Multiple Choices"), - array(301, "Moved Permanently"), - array(302, "Found"), - array(303, "See Other"), - array(304, "Not Modified"), - array(305, "Use Proxy"), - array(307, "Temporary Redirect"), - array(403, "Forbidden"), - ); + return [ + [300, "Multiple Choices"], + [301, "Moved Permanently"], + [302, "Found"], + [303, "See Other"], + [304, "Not Modified"], + [305, "Use Proxy"], + [307, "Temporary Redirect"], + [403, "Forbidden"], + ]; } /** @@ -747,9 +747,9 @@ public static function statusCodeProvider() { */ public function testRedirectByCode($code, $msg) { $Controller = new Controller(null); - $Controller->response = $this->getMock('CakeResponse', array('header', 'statusCode')); + $Controller->response = $this->getMock('CakeResponse', ['header', 'statusCode']); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); $Controller->response->expects($this->once())->method('statusCode') ->with($code); @@ -768,9 +768,9 @@ public function testRedirectByCode($code, $msg) { */ public function testRedirectByMessage($code, $msg) { $Controller = new Controller(null); - $Controller->response = $this->getMock('CakeResponse', array('header', 'statusCode')); + $Controller->response = $this->getMock('CakeResponse', ['header', 'statusCode']); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); $Controller->response->expects($this->once())->method('statusCode') ->with($code); @@ -789,8 +789,8 @@ public function testRedirectByMessage($code, $msg) { */ public function testRedirectTriggeringComponentsReturnNull() { $Controller = new Controller(null); - $Controller->response = $this->getMock('CakeResponse', array('header', 'statusCode')); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller->response = $this->getMock('CakeResponse', ['header', 'statusCode']); + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); $Controller->Components->expects($this->once())->method('trigger') ->will($this->returnValue(null)); @@ -811,11 +811,11 @@ public function testRedirectTriggeringComponentsReturnNull() { */ public function testRedirectBeforeRedirectModifyingParams() { $Controller = new Controller(null); - $Controller->response = $this->getMock('CakeResponse', array('header', 'statusCode')); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller->response = $this->getMock('CakeResponse', ['header', 'statusCode']); + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); $Controller->Components->expects($this->once())->method('trigger') - ->will($this->returnValue(array('https://book.cakephp.org'))); + ->will($this->returnValue(['https://book.cakephp.org'])); $Controller->response->expects($this->once())->method('statusCode') ->with(301); @@ -832,20 +832,20 @@ public function testRedirectBeforeRedirectModifyingParams() { * @return void */ public function testRedirectBeforeRedirectModifyingParamsArrayReturn() { - $Controller = $this->getMock('Controller', array('header', '_stop')); + $Controller = $this->getMock('Controller', ['header', '_stop']); $Controller->response = $this->getMock('CakeResponse'); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); - $return = array( - array( + $return = [ + [ 'url' => 'http://example.com/test/1', 'exit' => false, 'status' => 302 - ), - array( + ], + [ 'url' => 'http://example.com/test/2', - ), - ); + ], + ]; $Controller->Components->expects($this->once())->method('trigger') ->will($this->returnValue($return)); @@ -865,9 +865,9 @@ public function testRedirectBeforeRedirectModifyingParamsArrayReturn() { * @return void */ public function testRedirectBeforeRedirectInController() { - $Controller = $this->getMock('Controller', array('_stop', 'beforeRedirect')); - $Controller->response = $this->getMock('CakeResponse', array('header')); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller = $this->getMock('Controller', ['_stop', 'beforeRedirect']); + $Controller->response = $this->getMock('CakeResponse', ['header']); + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); $Controller->expects($this->once())->method('beforeRedirect') ->with('https://cakephp.org') @@ -883,18 +883,18 @@ public function testRedirectBeforeRedirectInController() { * @return void */ public function testRedirectBeforeRedirectInControllerWithArray() { - $Controller = $this->getMock('Controller', array('_stop', 'beforeRedirect')); - $Controller->response = $this->getMock('CakeResponse', array('header')); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller = $this->getMock('Controller', ['_stop', 'beforeRedirect']); + $Controller->response = $this->getMock('CakeResponse', ['header']); + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); $Controller->expects($this->once()) ->method('beforeRedirect') ->with('https://cakephp.org', null, true) - ->will($this->returnValue(array( + ->will($this->returnValue([ 'url' => 'http://example.org', 'status' => 302, 'exit' => true - ))); + ])); $Controller->response->expects($this->at(0)) ->method('header') @@ -935,7 +935,7 @@ public function testMergeVars() { $this->assertEquals(0, count(array_diff($TestController->uses, $uses))); $this->assertEquals(count(array_diff_assoc(Hash::normalize($TestController->components), Hash::normalize($components))), 0); - $expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost'); + $expected = ['ControllerComment', 'ControllerAlias', 'ControllerPost']; $this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, ControllerTestAppController models should be last.'); $TestController = new AnotherTestController($request); @@ -956,7 +956,7 @@ public function testMergeVars() { $testVars = get_class_vars('ControllerCommentsController'); $this->assertTrue(in_array('ControllerPost', $appVars['uses'])); - $this->assertEquals(array('ControllerPost'), $testVars['uses']); + $this->assertEquals(['ControllerPost'], $testVars['uses']); $this->assertTrue(isset($TestController->ControllerPost)); $this->assertTrue(isset($TestController->ControllerComment)); @@ -972,8 +972,8 @@ public function testChildComponentOptionsSupercedeParents() { $TestController = new TestController($request); - $expected = array('foo'); - $TestController->components = array('Cookie' => $expected); + $expected = ['foo']; + $TestController->components = ['Cookie' => $expected]; $TestController->constructClasses(); $this->assertEquals($expected, $TestController->components['Cookie']); } @@ -988,8 +988,8 @@ public function testMergeVarsNotGreedy() { $request = new CakeRequest('controller_posts/index'); $Controller = new Controller($request); - $Controller->components = array(); - $Controller->uses = array(); + $Controller->components = []; + $Controller->uses = []; $Controller->constructClasses(); $this->assertFalse(isset($Controller->Session)); @@ -1013,8 +1013,8 @@ public function testReferer() { $this->assertEquals('/posts/index', $result); $Controller = new Controller($request); - $request->setReturnValue('referer', '/', array(true)); - $result = $Controller->referer(array('controller' => 'posts', 'action' => 'index'), true); + $request->setReturnValue('referer', '/', [true]); + $result = $Controller->referer(['controller' => 'posts', 'action' => 'index'], true); $this->assertEquals('/posts/index', $result); $request = $this->getMock('CakeRequest'); @@ -1040,7 +1040,7 @@ public function testReferer() { * @return void */ public function testRefererSlash() { - $request = $this->getMock('CakeRequest', array('referer')); + $request = $this->getMock('CakeRequest', ['referer']); $request->base = '/base'; $request->expects($this->any()) ->method('referer') @@ -1066,7 +1066,7 @@ public function testSetAction() { $TestController = new TestController($request); $TestController->setAction('view', 1, 2); - $expected = array('testId' => 1, 'test2Id' => 2); + $expected = ['testId' => 1, 'test2Id' => 2]; $this->assertSame($expected, $TestController->request->data); $this->assertSame('view', $TestController->request->params['action']); $this->assertSame('view', $TestController->view); @@ -1092,7 +1092,7 @@ public function testValidateErrors() { $comment = new ControllerComment($request); $comment->set('someVar', 'data'); $result = $TestController->validateErrors($comment); - $expected = array('some_field' => array('error_message'), 'some_field2' => array('error_message2')); + $expected = ['some_field' => ['error_message'], 'some_field2' => ['error_message2']]; $this->assertSame($expected, $result); $this->assertEquals(2, $TestController->validate($comment)); } @@ -1107,11 +1107,11 @@ public function testValidateErrorsOnArbitraryModels() { $TestController = new TestController(); $Post = new ControllerPost(); - $Post->validate = array('title' => 'notBlank'); + $Post->validate = ['title' => 'notBlank']; $Post->set('title', ''); $result = $TestController->validateErrors($Post); - $expected = array('title' => array('This field cannot be left blank')); + $expected = ['title' => ['This field cannot be left blank']]; $this->assertEquals($expected, $result); } @@ -1125,54 +1125,54 @@ public function testPostConditions() { $Controller = new Controller($request); - $data = array( - 'Model1' => array('field1' => '23'), - 'Model2' => array('field2' => 'string'), - 'Model3' => array('field3' => '23'), - ); - $expected = array( + $data = [ + 'Model1' => ['field1' => '23'], + 'Model2' => ['field2' => 'string'], + 'Model3' => ['field3' => '23'], + ]; + $expected = [ 'Model1.field1' => '23', 'Model2.field2' => 'string', 'Model3.field3' => '23', - ); + ]; $result = $Controller->postConditions($data); $this->assertSame($expected, $result); - $data = array(); - $Controller->data = array( - 'Model1' => array('field1' => '23'), - 'Model2' => array('field2' => 'string'), - 'Model3' => array('field3' => '23'), - ); - $expected = array( + $data = []; + $Controller->data = [ + 'Model1' => ['field1' => '23'], + 'Model2' => ['field2' => 'string'], + 'Model3' => ['field3' => '23'], + ]; + $expected = [ 'Model1.field1' => '23', 'Model2.field2' => 'string', 'Model3.field3' => '23', - ); + ]; $result = $Controller->postConditions($data); $this->assertSame($expected, $result); - $data = array(); - $Controller->data = array(); + $data = []; + $Controller->data = []; $result = $Controller->postConditions($data); $this->assertNull($result); - $data = array(); - $Controller->data = array( - 'Model1' => array('field1' => '23'), - 'Model2' => array('field2' => 'string'), - 'Model3' => array('field3' => '23'), - ); - $ops = array( + $data = []; + $Controller->data = [ + 'Model1' => ['field1' => '23'], + 'Model2' => ['field2' => 'string'], + 'Model3' => ['field3' => '23'], + ]; + $ops = [ 'Model1.field1' => '>', 'Model2.field2' => 'LIKE', 'Model3.field3' => '<=', - ); - $expected = array( + ]; + $expected = [ 'Model1.field1 >' => '23', 'Model2.field2 LIKE' => "%string%", 'Model3.field3 <=' => '23', - ); + ]; $result = $Controller->postConditions($data, $ops); $this->assertSame($expected, $result); } @@ -1183,26 +1183,26 @@ public function testPostConditions() { * @return array */ public function dangerousPostConditionsProvider() { - return array( - array( - array('Model' => array('field !=' => 1)) - ), - array( - array('Model' => array('field AND 1=1 OR' => 'thing')) - ), - array( - array('Model' => array('field >' => 1)) - ), - array( - array('Model' => array('field OR RAND()' => 1)) - ), - array( - array('Posts' => array('id IS NULL union all select posts.* from posts where id; --' => 1)) - ), - array( - array('Post.id IS NULL; --' => array('id' => 1)) - ), - ); + return [ + [ + ['Model' => ['field !=' => 1]] + ], + [ + ['Model' => ['field AND 1=1 OR' => 'thing']] + ], + [ + ['Model' => ['field >' => 1]] + ], + [ + ['Model' => ['field OR RAND()' => 1]] + ], + [ + ['Posts' => ['id IS NULL union all select posts.* from posts where id; --' => 1]] + ], + [ + ['Post.id IS NULL; --' => ['id' => 1]] + ], + ]; } /** @@ -1225,7 +1225,7 @@ public function testPostConditionsDangerous($data) { * @return void */ public function testControllerHttpCodes() { - $response = $this->getMock('CakeResponse', array('httpCodes')); + $response = $this->getMock('CakeResponse', ['httpCodes']); $Controller = new Controller(null, $response); $Controller->response->expects($this->at(0))->method('httpCodes')->with(null); $Controller->response->expects($this->at(1))->method('httpCodes')->with(100); @@ -1239,31 +1239,23 @@ public function testControllerHttpCodes() { * @return void */ public function testStartupProcess() { - $Controller = $this->getMock('Controller', array('getEventManager')); + $Controller = $this->getMock('Controller', ['getEventManager']); $eventManager = $this->getMock('CakeEventManager'); $eventManager->expects($this->at(0))->method('dispatch') ->with( $this->logicalAnd( $this->isInstanceOf('CakeEvent'), - $this->callback(function (CakeEvent $event) { - return $event->name() === 'Controller.initialize'; - }), - $this->callback(function (CakeEvent $event) use ($Controller) { - return $event->subject() === $Controller; - }), + $this->callback(fn(CakeEvent $event) => $event->name() === 'Controller.initialize'), + $this->callback(fn(CakeEvent $event) => $event->subject() === $Controller), ) ); $eventManager->expects($this->at(1))->method('dispatch') ->with( $this->logicalAnd( $this->isInstanceOf('CakeEvent'), - $this->callback(function (CakeEvent $event) { - return $event->name() === 'Controller.startup'; - }), - $this->callback(function (CakeEvent $event) use ($Controller) { - return $event->subject() === $Controller; - }), + $this->callback(fn(CakeEvent $event) => $event->name() === 'Controller.startup'), + $this->callback(fn(CakeEvent $event) => $event->subject() === $Controller), ) ); $Controller->expects($this->exactly(2))->method('getEventManager') @@ -1277,10 +1269,10 @@ public function testStartupProcess() { * @return void */ public function testStartupProcessIndirect() { - $Controller = $this->getMock('Controller', array('beforeFilter')); + $Controller = $this->getMock('Controller', ['beforeFilter']); - $Controller->components = array('MockShutdown'); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller->components = ['MockShutdown']; + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); $Controller->expects($this->once())->method('beforeFilter'); $Controller->Components->expects($this->exactly(2))->method('trigger')->with($this->isInstanceOf('CakeEvent')); @@ -1294,19 +1286,15 @@ public function testStartupProcessIndirect() { * @return void */ public function testShutdownProcess() { - $Controller = $this->getMock('Controller', array('getEventManager')); + $Controller = $this->getMock('Controller', ['getEventManager']); $eventManager = $this->getMock('CakeEventManager'); $eventManager->expects($this->once())->method('dispatch') ->with( $this->logicalAnd( $this->isInstanceOf('CakeEvent'), - $this->callback(function (CakeEvent $event) { - return $event->name() === 'Controller.shutdown'; - }), - $this->callback(function (CakeEvent $event) use ($Controller) { - return $event->subject() === $Controller; - }), + $this->callback(fn(CakeEvent $event) => $event->name() === 'Controller.shutdown'), + $this->callback(fn(CakeEvent $event) => $event->subject() === $Controller), ) ); $Controller->expects($this->once())->method('getEventManager') @@ -1320,10 +1308,10 @@ public function testShutdownProcess() { * @return void */ public function testShutdownProcessIndirect() { - $Controller = $this->getMock('Controller', array('afterFilter')); + $Controller = $this->getMock('Controller', ['afterFilter']); - $Controller->components = array('MockShutdown'); - $Controller->Components = $this->getMock('ComponentCollection', array('trigger')); + $Controller->components = ['MockShutdown']; + $Controller->Components = $this->getMock('ComponentCollection', ['trigger']); $Controller->expects($this->once())->method('afterFilter'); $Controller->Components->expects($this->exactly(1))->method('trigger')->with($this->isInstanceOf('CakeEvent')); @@ -1338,8 +1326,8 @@ public function testShutdownProcessIndirect() { */ public function testPropertyBackwardsCompatibility() { $request = new CakeRequest('posts/index', false); - $request->addParams(array('controller' => 'posts', 'action' => 'index')); - $request->data = array('Post' => array('id' => 1)); + $request->addParams(['controller' => 'posts', 'action' => 'index']); + $request->data = ['Post' => ['id' => 1]]; $request->here = '/posts/index'; $request->webroot = '/'; @@ -1379,28 +1367,28 @@ public function testPropertyCompatibilityAndModelsComponents() { */ public function testPaginateBackwardsCompatibility() { $request = new CakeRequest('controller_posts/index'); - $request->params['pass'] = $request->params['named'] = array(); - $response = $this->getMock('CakeResponse', array('httpCodes')); + $request->params['pass'] = $request->params['named'] = []; + $response = $this->getMock('CakeResponse', ['httpCodes']); $Controller = new Controller($request, $response); - $Controller->uses = array('ControllerPost', 'ControllerComment'); + $Controller->uses = ['ControllerPost', 'ControllerComment']; $Controller->passedArgs[] = '1'; - $Controller->params['url'] = array(); - $Controller->params['named'] = array( - 'posts' => array( + $Controller->params['url'] = []; + $Controller->params['named'] = [ + 'posts' => [ 'page' => 2, 'limit' => 2, - ), - ); + ], + ]; $Controller->constructClasses(); - $expected = array('page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null); + $expected = ['page' => 1, 'limit' => 20, 'maxLimit' => 100, 'paramType' => 'named', 'queryScope' => null]; $this->assertEquals($expected, $Controller->paginate); $results = Hash::extract($Controller->paginate('ControllerPost'), '{n}.ControllerPost.id'); - $this->assertEquals(array(1, 2, 3), $results); + $this->assertEquals([1, 2, 3], $results); - $Controller->passedArgs = array(); - $Controller->paginate = array('limit' => '1'); - $this->assertEquals(array('limit' => '1'), $Controller->paginate); + $Controller->passedArgs = []; + $Controller->paginate = ['limit' => '1']; + $this->assertEquals(['limit' => '1'], $Controller->paginate); $Controller->paginate('ControllerPost'); $this->assertSame($Controller->params['paging']['ControllerPost']['page'], 1); $this->assertSame($Controller->params['paging']['ControllerPost']['pageCount'], 3); @@ -1408,7 +1396,7 @@ public function testPaginateBackwardsCompatibility() { $this->assertTrue($Controller->params['paging']['ControllerPost']['nextPage']); $this->assertNull($Controller->params['paging']['ControllerPost']['queryScope']); - $Controller->paginate = array('queryScope' => 'posts'); + $Controller->paginate = ['queryScope' => 'posts']; $Controller->paginate('ControllerPost'); $this->assertSame($Controller->params['paging']['ControllerPost']['page'], 2); $this->assertSame($Controller->params['paging']['ControllerPost']['pageCount'], 2); @@ -1424,7 +1412,7 @@ public function testInvokeActionMissingAction() { $this->expectException(MissingActionException::class); $this->expectExceptionMessage("Action TestController::missing() could not be found."); $url = new CakeRequest('test/missing'); - $url->addParams(array('controller' => 'test_controller', 'action' => 'missing')); + $url->addParams(['controller' => 'test_controller', 'action' => 'missing']); $response = $this->getMock('CakeResponse'); $Controller = new TestController($url, $response); @@ -1440,7 +1428,7 @@ public function testInvokeActionPrivate() { $this->expectException(PrivateActionException::class); $this->expectExceptionMessage("Private Action TestController::private_m() is not directly accessible."); $url = new CakeRequest('test/private_m/'); - $url->addParams(array('controller' => 'test_controller', 'action' => 'private_m')); + $url->addParams(['controller' => 'test_controller', 'action' => 'private_m']); $response = $this->getMock('CakeResponse'); $Controller = new TestController($url, $response); @@ -1456,7 +1444,7 @@ public function testInvokeActionProtected() { $this->expectException(PrivateActionException::class); $this->expectExceptionMessage("Private Action TestController::protected_m() is not directly accessible."); $url = new CakeRequest('test/protected_m/'); - $url->addParams(array('controller' => 'test_controller', 'action' => 'protected_m')); + $url->addParams(['controller' => 'test_controller', 'action' => 'protected_m']); $response = $this->getMock('CakeResponse'); $Controller = new TestController($url, $response); @@ -1472,7 +1460,7 @@ public function testInvokeActionHidden() { $this->expectException(PrivateActionException::class); $this->expectExceptionMessage("Private Action TestController::_hidden() is not directly accessible."); $url = new CakeRequest('test/_hidden/'); - $url->addParams(array('controller' => 'test_controller', 'action' => '_hidden')); + $url->addParams(['controller' => 'test_controller', 'action' => '_hidden']); $response = $this->getMock('CakeResponse'); $Controller = new TestController($url, $response); @@ -1488,7 +1476,7 @@ public function testInvokeActionBaseMethods() { $this->expectException(PrivateActionException::class); $this->expectExceptionMessage("Private Action TestController::redirect() is not directly accessible."); $url = new CakeRequest('test/redirect/'); - $url->addParams(array('controller' => 'test_controller', 'action' => 'redirect')); + $url->addParams(['controller' => 'test_controller', 'action' => 'redirect']); $response = $this->getMock('CakeResponse'); $Controller = new TestController($url, $response); @@ -1504,10 +1492,10 @@ public function testInvokeActionPrefixProtection() { $this->expectException(PrivateActionException::class); $this->expectExceptionMessage("Private Action TestController::admin_add() is not directly accessible."); Router::reload(); - Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin')); + Router::connect('/admin/:controller/:action/*', ['prefix' => 'admin']); $url = new CakeRequest('test/admin_add/'); - $url->addParams(array('controller' => 'test_controller', 'action' => 'admin_add')); + $url->addParams(['controller' => 'test_controller', 'action' => 'admin_add']); $response = $this->getMock('CakeResponse'); $Controller = new TestController($url, $response); @@ -1523,10 +1511,10 @@ public function testInvokeActionPrefixProtectionCasing() { $this->expectException(PrivateActionException::class); $this->expectExceptionMessage("Private Action TestController::Admin_add() is not directly accessible."); Router::reload(); - Router::connect('/admin/:controller/:action/*', array('prefix' => 'admin')); + Router::connect('/admin/:controller/:action/*', ['prefix' => 'admin']); $url = new CakeRequest('test/Admin_add/'); - $url->addParams(array('controller' => 'test_controller', 'action' => 'Admin_add')); + $url->addParams(['controller' => 'test_controller', 'action' => 'Admin_add']); $response = $this->getMock('CakeResponse'); $Controller = new TestController($url, $response); @@ -1540,11 +1528,11 @@ public function testInvokeActionPrefixProtectionCasing() { */ public function testInvokeActionReturnValue() { $url = new CakeRequest('test/returner/'); - $url->addParams(array( + $url->addParams([ 'controller' => 'test_controller', 'action' => 'returner', - 'pass' => array() - )); + 'pass' => [] + ]); $response = $this->getMock('CakeResponse'); $Controller = new TestController($url, $response); diff --git a/lib/Cake/Test/Case/Controller/PagesControllerTest.php b/lib/Cake/Test/Case/Controller/PagesControllerTest.php index e3fdb92120..9e72bf7d19 100644 --- a/lib/Cake/Test/Case/Controller/PagesControllerTest.php +++ b/lib/Cake/Test/Case/Controller/PagesControllerTest.php @@ -32,11 +32,11 @@ class PagesControllerTest extends CakeTestCase { * @return void */ public function testDisplay() { - App::build(array( - 'View' => array( + App::build([ + 'View' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS - ) - )); + ] + ]); $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse()); $Pages->viewPath = 'Posts'; @@ -85,11 +85,11 @@ public function testMissingViewInDebug() { public function testDirectoryTraversalProtection() { $this->expectException(ForbiddenException::class); $this->expectExceptionCode(403); - App::build(array( - 'View' => array( + App::build([ + 'View' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS - ) - )); + ] + ]); $Pages = new PagesController(new CakeRequest(null, false), new CakeResponse()); $Pages->display('..', 'Posts', 'index'); } diff --git a/lib/Cake/Test/Case/Controller/ScaffoldTest.php b/lib/Cake/Test/Case/Controller/ScaffoldTest.php index cbad1a32e8..cbec7e4919 100644 --- a/lib/Cake/Test/Case/Controller/ScaffoldTest.php +++ b/lib/Cake/Test/Case/Controller/ScaffoldTest.php @@ -23,7 +23,7 @@ App::uses('ScaffoldView', 'View'); App::uses('AppModel', 'Model'); -require_once dirname(dirname(__FILE__)) . DS . 'Model' . DS . 'models.php'; +require_once dirname(__FILE__, 2) . DS . 'Model' . DS . 'models.php'; /** * ScaffoldMockController class @@ -68,7 +68,7 @@ class ScaffoldMockControllerWithFields extends Controller { * @return bool true */ public function beforeScaffold($method) { - $this->set('scaffoldFields', array('title')); + $this->set('scaffoldFields', ['title']); return true; } @@ -154,7 +154,7 @@ class ScaffoldTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag'); + public $fixtures = ['core.article', 'core.user', 'core.comment', 'core.join_thing', 'core.tag']; /** * setUp method @@ -166,7 +166,7 @@ public function setUp() : void { Configure::write('Config.language', 'eng'); $request = new CakeRequest(null, false); $this->Controller = new ScaffoldMockController($request); - $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response = $this->getMock('CakeResponse', ['_sendHeader']); } /** @@ -187,16 +187,16 @@ public function tearDown() : void { * @return void */ public function testScaffoldParams() { - $params = array( + $params = [ 'plugin' => null, - 'pass' => array(), - 'form' => array(), - 'named' => array(), - 'url' => array('url' => 'admin/scaffold_mock/edit'), + 'pass' => [], + 'form' => [], + 'named' => [], + 'url' => ['url' => 'admin/scaffold_mock/edit'], 'controller' => 'scaffold_mock', 'action' => 'admin_edit', 'admin' => true, - ); + ]; $this->Controller->request->base = ''; $this->Controller->request->webroot = '/'; $this->Controller->request->here = '/admin/scaffold_mock/edit'; @@ -217,16 +217,16 @@ public function testScaffoldParams() { * @return void */ public function testScaffoldVariableSetting() { - $params = array( + $params = [ 'plugin' => null, - 'pass' => array(), - 'form' => array(), - 'named' => array(), - 'url' => array('url' => 'admin/scaffold_mock/edit'), + 'pass' => [], + 'form' => [], + 'named' => [], + 'url' => ['url' => 'admin/scaffold_mock/edit'], 'controller' => 'scaffold_mock', 'action' => 'admin_edit', 'admin' => true, - ); + ]; $this->Controller->request->base = ''; $this->Controller->request->webroot = '/'; $this->Controller->request->here = '/admin/scaffold_mock/edit'; @@ -247,7 +247,7 @@ public function testScaffoldVariableSetting() { $this->assertEquals('title', $result['displayField']); $this->assertEquals('scaffoldMock', $result['singularVar']); $this->assertEquals('scaffoldMock', $result['pluralVar']); - $this->assertEquals(array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated'), $result['scaffoldFields']); + $this->assertEquals(['id', 'user_id', 'title', 'body', 'published', 'created', 'updated'], $result['scaffoldFields']); $this->assertArrayHasKey('plugin', $result['associations']['belongsTo']['User']); } @@ -272,15 +272,15 @@ public function testScaffoldChangingViewProperty() { * @return void */ public function testScaffoldFlashMessages() { - $params = array( + $params = [ 'plugin' => null, - 'pass' => array(1), - 'form' => array(), - 'named' => array(), - 'url' => array('url' => 'scaffold_mock'), + 'pass' => [1], + 'form' => [], + 'named' => [], + 'url' => ['url' => 'scaffold_mock'], 'controller' => 'scaffold_mock', 'action' => 'edit', - ); + ]; $this->Controller->request->base = ''; $this->Controller->request->webroot = '/'; $this->Controller->request->here = '/scaffold_mock/edit'; @@ -289,13 +289,13 @@ public function testScaffoldFlashMessages() { //set router. Router::reload(); Router::setRequestInfo($this->Controller->request); - $this->Controller->request->data = array( - 'ScaffoldMock' => array( + $this->Controller->request->data = [ + 'ScaffoldMock' => [ 'id' => 1, 'title' => 'New title', 'body' => 'new body' - ) - ); + ] + ]; $this->Controller->constructClasses(); unset($this->Controller->Session); @@ -313,15 +313,15 @@ public function testScaffoldFlashMessages() { */ public function testHabtmFieldAdditionWithScaffoldForm() { CakePlugin::unload(); - $params = array( + $params = [ 'plugin' => null, - 'pass' => array(1), - 'form' => array(), - 'named' => array(), - 'url' => array('url' => 'scaffold_mock'), + 'pass' => [1], + 'form' => [], + 'named' => [], + 'url' => ['url' => 'scaffold_mock'], 'controller' => 'scaffold_mock', 'action' => 'edit', - ); + ]; $this->Controller->request->base = ''; $this->Controller->request->webroot = '/'; $this->Controller->request->here = '/scaffold_mock/edit'; @@ -339,7 +339,7 @@ public function testHabtmFieldAdditionWithScaffoldForm() { $this->assertMatchesRegularExpression('/name="data\[ScaffoldTag\]\[ScaffoldTag\]"/', $result); $result = $Scaffold->controller->viewVars; - $this->assertEquals(array('id', 'user_id', 'title', 'body', 'published', 'created', 'updated', 'ScaffoldTag'), $result['scaffoldFields']); + $this->assertEquals(['id', 'user_id', 'title', 'body', 'published', 'created', 'updated', 'ScaffoldTag'], $result['scaffoldFields']); } /** @@ -350,17 +350,17 @@ public function testHabtmFieldAdditionWithScaffoldForm() { public function testEditScaffoldWithScaffoldFields() { $request = new CakeRequest(null, false); $this->Controller = new ScaffoldMockControllerWithFields($request); - $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response = $this->getMock('CakeResponse', ['_sendHeader']); - $params = array( + $params = [ 'plugin' => null, - 'pass' => array(1), - 'form' => array(), - 'named' => array(), - 'url' => array('url' => 'scaffold_mock/edit'), + 'pass' => [1], + 'form' => [], + 'named' => [], + 'url' => ['url' => 'scaffold_mock/edit'], 'controller' => 'scaffold_mock', 'action' => 'edit', - ); + ]; $this->Controller->request->base = ''; $this->Controller->request->webroot = '/'; $this->Controller->request->here = '/scaffold_mock/edit'; @@ -387,17 +387,17 @@ public function testEditScaffoldWithScaffoldFields() { public function testScaffoldError() { $request = new CakeRequest(null, false); $this->Controller = new ScaffoldMockControllerWithError($request); - $this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $this->Controller->response = $this->getMock('CakeResponse', ['_sendHeader']); - $params = array( + $params = [ 'plugin' => null, - 'pass' => array(1), - 'form' => array(), - 'named' => array(), - 'url' => array('url' => 'scaffold_mock/edit'), + 'pass' => [1], + 'form' => [], + 'named' => [], + 'url' => ['url' => 'scaffold_mock/edit'], 'controller' => 'scaffold_mock', 'action' => 'edit', - ); + ]; $this->Controller->request->base = ''; $this->Controller->request->webroot = '/'; $this->Controller->request->here = '/scaffold_mock/edit'; diff --git a/lib/Cake/Test/Case/Core/AppTest.php b/lib/Cake/Test/Case/Core/AppTest.php index 57c0fbda4d..e06f621c60 100644 --- a/lib/Cake/Test/Case/Core/AppTest.php +++ b/lib/Cake/Test/Case/Core/AppTest.php @@ -40,53 +40,53 @@ public function tearDown() : void { */ public function testBuild() { $old = App::path('Model'); - $expected = array( + $expected = [ APP . 'Model' . DS - ); + ]; $this->assertEquals($expected, $old); - App::build(array('Model' => array('/path/to/models/'))); + App::build(['Model' => ['/path/to/models/']]); $new = App::path('Model'); - $expected = array( + $expected = [ '/path/to/models/', APP . 'Model' . DS - ); + ]; $this->assertEquals($expected, $new); App::build(); - App::build(array('Model' => array('/path/to/models/')), App::PREPEND); + App::build(['Model' => ['/path/to/models/']], App::PREPEND); $new = App::path('Model'); - $expected = array( + $expected = [ '/path/to/models/', APP . 'Model' . DS - ); + ]; $this->assertEquals($expected, $new); App::build(); - App::build(array('Model' => array('/path/to/models/')), App::APPEND); + App::build(['Model' => ['/path/to/models/']], App::APPEND); $new = App::path('Model'); - $expected = array( + $expected = [ APP . 'Model' . DS, '/path/to/models/' - ); + ]; $this->assertEquals($expected, $new); App::build(); - App::build(array( - 'Model' => array('/path/to/models/'), - 'Controller' => array('/path/to/controllers/'), - ), App::APPEND); + App::build([ + 'Model' => ['/path/to/models/'], + 'Controller' => ['/path/to/controllers/'], + ], App::APPEND); $new = App::path('Model'); - $expected = array( + $expected = [ APP . 'Model' . DS, '/path/to/models/' - ); + ]; $this->assertEquals($expected, $new); $new = App::path('Controller'); - $expected = array( + $expected = [ APP . 'Controller' . DS, '/path/to/controllers/' - ); + ]; $this->assertEquals($expected, $new); App::build(); //reset defaults @@ -101,81 +101,81 @@ public function testBuild() { */ public function testCompatibleBuild() { $old = App::path('models'); - $expected = array( + $expected = [ APP . 'Model' . DS - ); + ]; $this->assertEquals($expected, $old); - App::build(array('models' => array('/path/to/models/'))); + App::build(['models' => ['/path/to/models/']]); $new = App::path('models'); - $expected = array( + $expected = [ '/path/to/models/', APP . 'Model' . DS - ); + ]; $this->assertEquals($expected, $new); $this->assertEquals($expected, App::path('Model')); - App::build(array('datasources' => array('/path/to/datasources/'))); - $expected = array( + App::build(['datasources' => ['/path/to/datasources/']]); + $expected = [ '/path/to/datasources/', APP . 'Model' . DS . 'Datasource' . DS - ); + ]; $result = App::path('datasources'); $this->assertEquals($expected, $result); $this->assertEquals($expected, App::path('Model/Datasource')); - App::build(array('behaviors' => array('/path/to/behaviors/'))); - $expected = array( + App::build(['behaviors' => ['/path/to/behaviors/']]); + $expected = [ '/path/to/behaviors/', APP . 'Model' . DS . 'Behavior' . DS - ); + ]; $result = App::path('behaviors'); $this->assertEquals($expected, $result); $this->assertEquals($expected, App::path('Model/Behavior')); - App::build(array('controllers' => array('/path/to/controllers/'))); - $expected = array( + App::build(['controllers' => ['/path/to/controllers/']]); + $expected = [ '/path/to/controllers/', APP . 'Controller' . DS - ); + ]; $result = App::path('controllers'); $this->assertEquals($expected, $result); $this->assertEquals($expected, App::path('Controller')); - App::build(array('components' => array('/path/to/components/'))); - $expected = array( + App::build(['components' => ['/path/to/components/']]); + $expected = [ '/path/to/components/', APP . 'Controller' . DS . 'Component' . DS - ); + ]; $result = App::path('components'); $this->assertEquals($expected, $result); $this->assertEquals($expected, App::path('Controller/Component')); - App::build(array('views' => array('/path/to/views/'))); - $expected = array( + App::build(['views' => ['/path/to/views/']]); + $expected = [ '/path/to/views/', APP . 'View' . DS - ); + ]; $result = App::path('views'); $this->assertEquals($expected, $result); $this->assertEquals($expected, App::path('View')); - App::build(array('helpers' => array('/path/to/helpers/'))); - $expected = array( + App::build(['helpers' => ['/path/to/helpers/']]); + $expected = [ '/path/to/helpers/', APP . 'View' . DS . 'Helper' . DS - ); + ]; $result = App::path('helpers'); $this->assertEquals($expected, $result); $this->assertEquals($expected, App::path('View/Helper')); - App::build(array('shells' => array('/path/to/shells/'))); - $expected = array( + App::build(['shells' => ['/path/to/shells/']]); + $expected = [ '/path/to/shells/', APP . 'Console' . DS . 'Command' . DS - ); + ]; $result = App::path('shells'); $this->assertEquals($expected, $result); $this->assertEquals($expected, App::path('Console/Command')); @@ -191,31 +191,31 @@ public function testCompatibleBuild() { * @return void */ public function testBuildPackage() { - $pluginPaths = array( + $pluginPaths = [ '/foo/bar', APP . 'Plugin' . DS, - dirname(dirname(CAKE)) . DS . 'plugins' . DS - ); - App::build(array( - 'Plugin' => array( + dirname(CAKE, 2) . DS . 'plugins' . DS + ]; + App::build([ + 'Plugin' => [ '/foo/bar' - ) - )); + ] + ]); $result = App::path('Plugin'); $this->assertEquals($pluginPaths, $result); $paths = App::path('Service'); - $this->assertEquals(array(), $paths); + $this->assertEquals([], $paths); - App::build(array( - 'Service' => array( + App::build([ + 'Service' => [ '%s' . 'Service' . DS, - ), - ), App::REGISTER); + ], + ], App::REGISTER); - $expected = array( + $expected = [ APP . 'Service' . DS, - ); + ]; $result = App::path('Service'); $this->assertEquals($expected, $result); @@ -225,7 +225,7 @@ public function testBuildPackage() { App::build(); $paths = App::path('Service'); - $this->assertEquals(array(), $paths); + $this->assertEquals([], $paths); } /** @@ -235,9 +235,9 @@ public function testBuildPackage() { */ public function testPathWithPlugins() { $basepath = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS; - App::build(array( - 'Plugin' => array($basepath), - )); + App::build([ + 'Plugin' => [$basepath], + ]); CakePlugin::load('TestPlugin'); $result = App::path('Vendor', 'TestPlugin'); @@ -251,18 +251,18 @@ public function testPathWithPlugins() { */ public function testBuildWithReset() { $old = App::path('Model'); - $expected = array( + $expected = [ APP . 'Model' . DS - ); + ]; $this->assertEquals($expected, $old); - App::build(array('Model' => array('/path/to/models/')), App::RESET); + App::build(['Model' => ['/path/to/models/']], App::RESET); $new = App::path('Model'); - $expected = array( + $expected = [ '/path/to/models/' - ); + ]; $this->assertEquals($expected, $new); App::build(); //reset defaults @@ -277,22 +277,22 @@ public function testBuildWithReset() { */ public function testCore() { $model = App::core('Model'); - $this->assertEquals(array(CAKE . 'Model' . DS), $model); + $this->assertEquals([CAKE . 'Model' . DS], $model); $view = App::core('View'); - $this->assertEquals(array(CAKE . 'View' . DS), $view); + $this->assertEquals([CAKE . 'View' . DS], $view); $controller = App::core('Controller'); - $this->assertEquals(array(CAKE . 'Controller' . DS), $controller); + $this->assertEquals([CAKE . 'Controller' . DS], $controller); $component = App::core('Controller/Component'); - $this->assertEquals(array(CAKE . 'Controller' . DS . 'Component' . DS), str_replace('/', DS, $component)); + $this->assertEquals([CAKE . 'Controller' . DS . 'Component' . DS], str_replace('/', DS, $component)); $auth = App::core('Controller/Component/Auth'); - $this->assertEquals(array(CAKE . 'Controller' . DS . 'Component' . DS . 'Auth' . DS), str_replace('/', DS, $auth)); + $this->assertEquals([CAKE . 'Controller' . DS . 'Component' . DS . 'Auth' . DS], str_replace('/', DS, $auth)); $datasource = App::core('Model/Datasource'); - $this->assertEquals(array(CAKE . 'Model' . DS . 'Datasource' . DS), str_replace('/', DS, $datasource)); + $this->assertEquals([CAKE . 'Model' . DS . 'Datasource' . DS], str_replace('/', DS, $datasource)); } /** @@ -305,14 +305,14 @@ public function testListObjects() { $this->assertTrue(in_array('Dispatcher', $result)); $this->assertTrue(in_array('Router', $result)); - App::build(array( + App::build([ 'Model/Behavior' => App::core('Model/Behavior'), 'Controller' => App::core('Controller'), 'Controller/Component' => App::core('Controller/Component'), 'View' => App::core('View'), 'Model' => App::core('Model'), 'View/Helper' => App::core('View/Helper'), - ), App::RESET); + ], App::RESET); $result = App::objects('behavior', null, false); $this->assertTrue(in_array('TreeBehavior', $result)); $result = App::objects('Model/Behavior', null, false); @@ -342,17 +342,17 @@ public function testListObjects() { $this->assertFalse($result); $result = App::objects('file', 'non_existing_configure'); - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); $result = App::objects('NonExistingType'); - $this->assertSame(array(), $result); + $this->assertSame([], $result); - App::build(array( - 'plugins' => array( + App::build([ + 'plugins' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS - ) - )); + ] + ]); $result = App::objects('plugin', null, false); $this->assertTrue(in_array('Cache', $result)); $this->assertTrue(in_array('Log', $result)); @@ -370,9 +370,9 @@ public function testListObjectsIgnoreDotDirectories() { $this->skipIf(!is_writable($path), $path . ' is not writable.'); - App::build(array( - 'plugins' => array($path) - ), App::RESET); + App::build([ + 'plugins' => [$path] + ], App::RESET); mkdir($path . '.svn'); $result = App::objects('plugin', null, false); rmdir($path . '.svn'); @@ -386,11 +386,11 @@ public function testListObjectsIgnoreDotDirectories() { * @return void */ public function testListObjectsInPlugin() { - App::build(array( - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS), - 'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS], + 'plugins' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $result = App::objects('TestPlugin.model'); $this->assertTrue(in_array('TestPluginPost', $result)); @@ -403,10 +403,10 @@ public function testListObjectsInPlugin() { $this->assertTrue(in_array('TestPluginPersisterOneBehavior', $result)); $result = App::objects('TestPlugin.helper'); - $expected = array('OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper'); + $expected = ['OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper']; $this->assertEquals($expected, $result); $result = App::objects('TestPlugin.View/Helper'); - $expected = array('OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper'); + $expected = ['OtherHelperHelper', 'PluggedHelperHelper', 'TestPluginAppHelper']; $this->assertEquals($expected, $result); $result = App::objects('TestPlugin.component'); @@ -415,9 +415,9 @@ public function testListObjectsInPlugin() { $this->assertTrue(in_array('OtherComponent', $result)); $result = App::objects('TestPluginTwo.behavior'); - $this->assertSame(array(), $result); + $this->assertSame([], $result); $result = App::objects('TestPluginTwo.Model/Behavior'); - $this->assertSame(array(), $result); + $this->assertSame([], $result); $result = App::objects('model', null, false); $this->assertTrue(in_array('Comment', $result)); @@ -436,9 +436,9 @@ public function testListObjectsInPlugin() { * @return void */ public function testThemePath() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $path = App::themePath('test_theme'); $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'TestTheme' . DS; $this->assertEquals($expected, $path); @@ -483,13 +483,13 @@ public function testClassLoading() { $this->assertTrue($file); $this->assertTrue(class_exists('AppModel')); - $file = App::import('WrongType', null, true, array(), ''); + $file = App::import('WrongType', null, true, [], ''); $this->assertFalse($file); $file = App::import('Model', 'NonExistingPlugin.NonExistingModel', false); $this->assertFalse($file); - $file = App::import('Model', array('NonExistingPlugin.NonExistingModel'), false); + $file = App::import('Model', ['NonExistingPlugin.NonExistingModel'], false); $this->assertFalse($file); if (!class_exists('AppController', false)) { @@ -535,11 +535,11 @@ public function testClassLoading() { * @return void */ public function testPluginImporting() { - App::build(array( - 'Lib' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'Lib' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $result = App::import('Controller', 'TestPlugin.Tests'); $this->assertTrue($result); @@ -579,11 +579,11 @@ public function testPluginImporting() { */ public function testImportingHelpersFromAlternatePaths() { $this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.'); - App::build(array( - 'View/Helper' => array( + App::build([ + 'View/Helper' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Helper' . DS - ) - )); + ] + ]); $this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.'); App::import('Helper', 'Banana'); $this->assertTrue(class_exists('BananaHelper', false), 'BananaHelper was not loaded.'); @@ -597,10 +597,10 @@ public function testImportingHelpersFromAlternatePaths() { * @return void */ public function testFileLoading() { - $file = App::import('File', 'RealFile', false, array(), CAKE . 'Config' . DS . 'config.php'); + $file = App::import('File', 'RealFile', false, [], CAKE . 'Config' . DS . 'config.php'); $this->assertTrue($file); - $file = App::import('File', 'NoFile', false, array(), CAKE . 'Config' . DS . 'cake' . DS . 'config.php'); + $file = App::import('File', 'NoFile', false, [], CAKE . 'Config' . DS . 'cake' . DS . 'config.php'); $this->assertFalse($file); } @@ -610,21 +610,21 @@ public function testFileLoading() { * @return void */ public function testFileLoadingWithArray() { - $type = array( + $type = [ 'type' => 'File', 'name' => 'SomeName', 'parent' => false, 'file' => CAKE . DS . 'Config' . DS . 'config.php' - ); + ]; $file = App::import($type); $this->assertTrue($file); - $type = array( + $type = [ 'type' => 'File', 'name' => 'NoFile', 'parent' => false, 'file' => CAKE . 'Config' . DS . 'cake' . DS . 'config.php' - ); + ]; $file = App::import($type); $this->assertFalse($file); } @@ -635,17 +635,17 @@ public function testFileLoadingWithArray() { * @return void */ public function testFileLoadingReturnValue() { - $file = App::import('File', 'Name', false, array(), CAKE . 'Config' . DS . 'config.php', true); + $file = App::import('File', 'Name', false, [], CAKE . 'Config' . DS . 'config.php', true); $this->assertTrue(!empty($file)); $this->assertTrue(isset($file['Cake.version'])); - $type = array( + $type = [ 'type' => 'File', 'name' => 'OtherName', 'parent' => false, 'file' => CAKE . 'Config' . DS . 'config.php', 'return' => true - ); + ]; $file = App::import($type); $this->assertTrue(!empty($file)); @@ -658,10 +658,10 @@ public function testFileLoadingReturnValue() { * @return void */ public function testLoadingWithSearch() { - $file = App::import('File', 'NewName', false, array(CAKE . 'Config' . DS), 'config.php'); + $file = App::import('File', 'NewName', false, [CAKE . 'Config' . DS], 'config.php'); $this->assertTrue($file); - $file = App::import('File', 'AnotherNewName', false, array(CAKE), 'config.php'); + $file = App::import('File', 'AnotherNewName', false, [CAKE], 'config.php'); $this->assertFalse($file); } @@ -671,23 +671,23 @@ public function testLoadingWithSearch() { * @return void */ public function testLoadingWithSearchArray() { - $type = array( + $type = [ 'type' => 'File', 'name' => 'RandomName', 'parent' => false, 'file' => 'config.php', - 'search' => array(CAKE . 'Config' . DS) - ); + 'search' => [CAKE . 'Config' . DS] + ]; $file = App::import($type); $this->assertTrue($file); - $type = array( + $type = [ 'type' => 'File', 'name' => 'AnotherRandomName', 'parent' => false, 'file' => 'config.php', - 'search' => array(CAKE) - ); + 'search' => [CAKE] + ]; $file = App::import($type); $this->assertFalse($file); } @@ -701,10 +701,10 @@ public function testMultipleLoading() { if (class_exists('PersisterOne', false) || class_exists('PersisterTwo', false)) { $this->markTestSkipped('Cannot test loading of classes that exist.'); } - App::build(array( - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS) - )); - $toLoad = array('PersisterOne', 'PersisterTwo'); + App::build([ + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS] + ]); + $toLoad = ['PersisterOne', 'PersisterTwo']; $load = App::import('Model', $toLoad); $this->assertTrue($load); @@ -713,19 +713,19 @@ public function testMultipleLoading() { $this->assertTrue(isset($classes['PersisterOne'])); $this->assertTrue(isset($classes['PersisterTwo'])); - $load = App::import('Model', array('PersisterOne', 'SomeNotFoundClass', 'PersisterTwo')); + $load = App::import('Model', ['PersisterOne', 'SomeNotFoundClass', 'PersisterTwo']); $this->assertFalse($load); } public function testLoadingVendor() { - App::build(array( - 'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'vendors' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS), - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'plugins' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'vendors' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS], + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); ob_start(); - $result = App::import('Vendor', 'css/TestAsset', array('ext' => 'css')); + $result = App::import('Vendor', 'css/TestAsset', ['ext' => 'css']); $text = ob_get_clean(); $this->assertTrue($result); $this->assertEquals('/* this is the test asset css file */', trim($text)); @@ -739,19 +739,19 @@ public function testLoadingVendor() { $this->assertTrue(class_exists('ConfigureTestVendorSample')); ob_start(); - $result = App::import('Vendor', 'SomeNameInSubfolder', array('file' => 'somename/some.name.php')); + $result = App::import('Vendor', 'SomeNameInSubfolder', ['file' => 'somename/some.name.php']); $text = ob_get_clean(); $this->assertTrue($result); $this->assertEquals('This is a file with dot in file name', $text); ob_start(); - $result = App::import('Vendor', 'TestHello', array('file' => 'Test' . DS . 'hello.php')); + $result = App::import('Vendor', 'TestHello', ['file' => 'Test' . DS . 'hello.php']); $text = ob_get_clean(); $this->assertTrue($result); $this->assertEquals('This is the hello.php file in Test directory', $text); ob_start(); - $result = App::import('Vendor', 'MyTest', array('file' => 'Test' . DS . 'MyTest.php')); + $result = App::import('Vendor', 'MyTest', ['file' => 'Test' . DS . 'MyTest.php']); $text = ob_get_clean(); $this->assertTrue($result); $this->assertEquals('This is the MyTest.php file', $text); @@ -776,11 +776,11 @@ public function testLoadingVendor() { * @return void */ public function testLoadClassInLibs() { - App::build(array( - 'libs' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS), - 'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'libs' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS], + 'plugins' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $this->assertFalse(class_exists('CustomLibClass', false)); App::uses('CustomLibClass', 'TestPlugin.Custom/Package'); @@ -820,10 +820,10 @@ public function testPaths() { * @return void */ public function testPluginLibClasses() { - App::build(array( - 'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'plugins' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $this->assertFalse(class_exists('TestPluginOtherLibrary', false)); App::uses('TestPluginOtherLibrary', 'TestPlugin.Lib'); $this->assertTrue(class_exists('TestPluginOtherLibrary')); @@ -853,11 +853,11 @@ public function testIncreaseMemoryLimit($memoryLimit, $additionalKb, $expected) * @return void */ public function memoryVariationProvider() { - return array( - array('131072K', 100000, '231072K'), - array('256M', 1, '262145K'), - array('1G', 1, '1048577K'), - array('-1', 100000, '-1') - ); + return [ + ['131072K', 100000, '231072K'], + ['256M', 1, '262145K'], + ['1G', 1, '1048577K'], + ['-1', 100000, '-1'] + ]; } } diff --git a/lib/Cake/Test/Case/Core/CakeObjectTest.php b/lib/Cake/Test/Case/Core/CakeObjectTest.php index 5d829da079..dc960502ed 100644 --- a/lib/Cake/Test/Case/Core/CakeObjectTest.php +++ b/lib/Cake/Test/Case/Core/CakeObjectTest.php @@ -49,7 +49,7 @@ class RequestActionController extends Controller { * * @var array */ - public $uses = array('RequestActionPost'); + public $uses = ['RequestActionPost']; /** * test_request_action method @@ -154,7 +154,7 @@ class TestCakeObject extends CakeObject { * * @var array */ - public $methodCalls = array(); + public $methodCalls = []; /** * emptyMethod method @@ -172,7 +172,7 @@ public function emptyMethod() { * @return void */ public function oneParamMethod($param) { - $this->methodCalls[] = array('oneParamMethod' => array($param)); + $this->methodCalls[] = ['oneParamMethod' => [$param]]; } /** @@ -183,7 +183,7 @@ public function oneParamMethod($param) { * @return void */ public function twoParamMethod($param, $paramTwo) { - $this->methodCalls[] = array('twoParamMethod' => array($param, $paramTwo)); + $this->methodCalls[] = ['twoParamMethod' => [$param, $paramTwo]]; } /** @@ -195,7 +195,7 @@ public function twoParamMethod($param, $paramTwo) { * @return void */ public function threeParamMethod($param, $paramTwo, $paramThree) { - $this->methodCalls[] = array('threeParamMethod' => array($param, $paramTwo, $paramThree)); + $this->methodCalls[] = ['threeParamMethod' => [$param, $paramTwo, $paramThree]]; } /** @@ -208,7 +208,7 @@ public function threeParamMethod($param, $paramTwo, $paramThree) { * @return void */ public function fourParamMethod($param, $paramTwo, $paramThree, $paramFour) { - $this->methodCalls[] = array('fourParamMethod' => array($param, $paramTwo, $paramThree, $paramFour)); + $this->methodCalls[] = ['fourParamMethod' => [$param, $paramTwo, $paramThree, $paramFour]]; } /** @@ -222,7 +222,7 @@ public function fourParamMethod($param, $paramTwo, $paramThree, $paramFour) { * @return void */ public function fiveParamMethod($param, $paramTwo, $paramThree, $paramFour, $paramFive) { - $this->methodCalls[] = array('fiveParamMethod' => array($param, $paramTwo, $paramThree, $paramFour, $paramFive)); + $this->methodCalls[] = ['fiveParamMethod' => [$param, $paramTwo, $paramThree, $paramFour, $paramFive]]; } /** @@ -238,7 +238,7 @@ public function fiveParamMethod($param, $paramTwo, $paramThree, $paramFour, $par * @return void */ public function crazyMethod($param, $paramTwo, $paramThree, $paramFour, $paramFive, $paramSix, $paramSeven = null) { - $this->methodCalls[] = array('crazyMethod' => array($param, $paramTwo, $paramThree, $paramFour, $paramFive, $paramSix, $paramSeven)); + $this->methodCalls[] = ['crazyMethod' => [$param, $paramTwo, $paramThree, $paramFour, $paramFive, $paramSix, $paramSeven]]; } /** @@ -248,7 +248,7 @@ public function crazyMethod($param, $paramTwo, $paramThree, $paramFour, $paramFi * @return void */ public function methodWithOptionalParam($param = null) { - $this->methodCalls[] = array('methodWithOptionalParam' => array($param)); + $this->methodCalls[] = ['methodWithOptionalParam' => [$param]]; } /** @@ -257,7 +257,7 @@ public function methodWithOptionalParam($param = null) { * @param array $properties The $properties. * @return void */ - public function set($properties = array()) { + public function set($properties = []) { return parent::_set($properties); } @@ -286,7 +286,7 @@ class ObjectTest extends CakeTestCase { * * @var string */ - public $fixtures = array('core.post', 'core.test_plugin_comment', 'core.comment'); + public $fixtures = ['core.post', 'core.test_plugin_comment', 'core.comment']; /** * setUp method @@ -319,7 +319,7 @@ public function testLog() { unlink(LOGS . 'error.log'); } $this->assertTrue($this->object->log('Test warning 1')); - $this->assertTrue($this->object->log(array('Test' => 'warning 2'))); + $this->assertTrue($this->object->log(['Test' => 'warning 2'])); $result = file(LOGS . 'error.log'); $this->assertMatchesRegularExpression('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Test warning 1$/', $result[0]); $this->assertMatchesRegularExpression('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Array$/', $result[1]); @@ -329,7 +329,7 @@ public function testLog() { unlink(LOGS . 'error.log'); $this->assertTrue($this->object->log('Test warning 1', LOG_WARNING)); - $this->assertTrue($this->object->log(array('Test' => 'warning 2'), LOG_WARNING)); + $this->assertTrue($this->object->log(['Test' => 'warning 2'], LOG_WARNING)); $result = file(LOGS . 'error.log'); $this->assertMatchesRegularExpression('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 1$/', $result[0]); $this->assertMatchesRegularExpression('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Array$/', $result[1]); @@ -348,13 +348,13 @@ public function testSet() { $this->object->set('a string'); $this->assertEquals('Joel', $this->object->firstName); - $this->object->set(array('firstName')); + $this->object->set(['firstName']); $this->assertEquals('Joel', $this->object->firstName); - $this->object->set(array('firstName' => 'Ashley')); + $this->object->set(['firstName' => 'Ashley']); $this->assertEquals('Ashley', $this->object->firstName); - $this->object->set(array('firstName' => 'Joel', 'lastName' => 'Moose')); + $this->object->set(['firstName' => 'Joel', 'lastName' => 'Moose']); $this->assertEquals('Joel', $this->object->firstName); $this->assertEquals('Moose', $this->object->lastName); } @@ -376,62 +376,62 @@ public function testToString() { */ public function testMethodDispatching() { $this->object->emptyMethod(); - $expected = array('emptyMethod'); + $expected = ['emptyMethod']; $this->assertSame($expected, $this->object->methodCalls); $this->object->oneParamMethod('Hello'); - $expected[] = array('oneParamMethod' => array('Hello')); + $expected[] = ['oneParamMethod' => ['Hello']]; $this->assertSame($expected, $this->object->methodCalls); $this->object->twoParamMethod(true, false); - $expected[] = array('twoParamMethod' => array(true, false)); + $expected[] = ['twoParamMethod' => [true, false]]; $this->assertSame($expected, $this->object->methodCalls); $this->object->threeParamMethod(true, false, null); - $expected[] = array('threeParamMethod' => array(true, false, null)); + $expected[] = ['threeParamMethod' => [true, false, null]]; $this->assertSame($expected, $this->object->methodCalls); $this->object->crazyMethod(1, 2, 3, 4, 5, 6, 7); - $expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7)); + $expected[] = ['crazyMethod' => [1, 2, 3, 4, 5, 6, 7]]; $this->assertSame($expected, $this->object->methodCalls); $this->object = new TestCakeObject(); - $this->assertSame($this->object->methodCalls, array()); + $this->assertSame($this->object->methodCalls, []); $this->object->dispatchMethod('emptyMethod'); - $expected = array('emptyMethod'); + $expected = ['emptyMethod']; $this->assertSame($expected, $this->object->methodCalls); - $this->object->dispatchMethod('oneParamMethod', array('Hello')); - $expected[] = array('oneParamMethod' => array('Hello')); + $this->object->dispatchMethod('oneParamMethod', ['Hello']); + $expected[] = ['oneParamMethod' => ['Hello']]; $this->assertSame($expected, $this->object->methodCalls); - $this->object->dispatchMethod('twoParamMethod', array(true, false)); - $expected[] = array('twoParamMethod' => array(true, false)); + $this->object->dispatchMethod('twoParamMethod', [true, false]); + $expected[] = ['twoParamMethod' => [true, false]]; $this->assertSame($expected, $this->object->methodCalls); - $this->object->dispatchMethod('threeParamMethod', array(true, false, null)); - $expected[] = array('threeParamMethod' => array(true, false, null)); + $this->object->dispatchMethod('threeParamMethod', [true, false, null]); + $expected[] = ['threeParamMethod' => [true, false, null]]; $this->assertSame($expected, $this->object->methodCalls); - $this->object->dispatchMethod('fourParamMethod', array(1, 2, 3, 4)); - $expected[] = array('fourParamMethod' => array(1, 2, 3, 4)); + $this->object->dispatchMethod('fourParamMethod', [1, 2, 3, 4]); + $expected[] = ['fourParamMethod' => [1, 2, 3, 4]]; $this->assertSame($expected, $this->object->methodCalls); - $this->object->dispatchMethod('fiveParamMethod', array(1, 2, 3, 4, 5)); - $expected[] = array('fiveParamMethod' => array(1, 2, 3, 4, 5)); + $this->object->dispatchMethod('fiveParamMethod', [1, 2, 3, 4, 5]); + $expected[] = ['fiveParamMethod' => [1, 2, 3, 4, 5]]; $this->assertSame($expected, $this->object->methodCalls); - $this->object->dispatchMethod('crazyMethod', array(1, 2, 3, 4, 5, 6, 7)); - $expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7)); + $this->object->dispatchMethod('crazyMethod', [1, 2, 3, 4, 5, 6, 7]); + $expected[] = ['crazyMethod' => [1, 2, 3, 4, 5, 6, 7]]; $this->assertSame($expected, $this->object->methodCalls); - $this->object->dispatchMethod('methodWithOptionalParam', array('Hello')); - $expected[] = array('methodWithOptionalParam' => array("Hello")); + $this->object->dispatchMethod('methodWithOptionalParam', ['Hello']); + $expected[] = ['methodWithOptionalParam' => ["Hello"]]; $this->assertSame($expected, $this->object->methodCalls); $this->object->dispatchMethod('methodWithOptionalParam'); - $expected[] = array('methodWithOptionalParam' => array(null)); + $expected[] = ['methodWithOptionalParam' => [null]]; $this->assertSame($expected, $this->object->methodCalls); } @@ -441,11 +441,11 @@ public function testMethodDispatching() { * @return void */ public function testRequestAction() { - App::build(array( - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), - 'Controller' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS) - ), App::RESET); + App::build([ + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS], + 'Controller' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS] + ], App::RESET); $this->assertNull(Router::getRequest(), 'request stack should be empty.'); $result = $this->object->requestAction(''); @@ -465,7 +465,7 @@ public function testRequestAction() { $expected = 7; $this->assertEquals($expected, $result); - $result = $this->object->requestAction('/tests_apps/index', array('return')); + $result = $this->object->requestAction('/tests_apps/index', ['return']); $expected = 'This is the TestsAppsController index view '; $this->assertEquals($expected, $result); @@ -500,22 +500,22 @@ public function testRequestActionHere() { * @return void */ public function testRequestActionPlugins() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + ], App::RESET); CakePlugin::load('TestPlugin'); Router::reload(); - $result = $this->object->requestAction('/test_plugin/tests/index', array('return')); + $result = $this->object->requestAction('/test_plugin/tests/index', ['return']); $expected = 'test plugin index'; $this->assertEquals($expected, $result); - $result = $this->object->requestAction('/test_plugin/tests/index/some_param', array('return')); + $result = $this->object->requestAction('/test_plugin/tests/index/some_param', ['return']); $expected = 'test plugin index'; $this->assertEquals($expected, $result); $result = $this->object->requestAction( - array('controller' => 'tests', 'action' => 'index', 'plugin' => 'test_plugin'), array('return') + ['controller' => 'tests', 'action' => 'index', 'plugin' => 'test_plugin'], ['return'] ); $expected = 'test plugin index'; $this->assertEquals($expected, $result); @@ -525,7 +525,7 @@ public function testRequestActionPlugins() { $this->assertEquals($expected, $result); $result = $this->object->requestAction( - array('controller' => 'tests', 'action' => 'some_method', 'plugin' => 'test_plugin') + ['controller' => 'tests', 'action' => 'some_method', 'plugin' => 'test_plugin'] ); $expected = 25; $this->assertEquals($expected, $result); @@ -537,51 +537,51 @@ public function testRequestActionPlugins() { * @return void */ public function testRequestActionArray() { - App::build(array( - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), - 'Controller' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin')); + App::build([ + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS], + 'Controller' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin']); $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'test_request_action') + ['controller' => 'request_action', 'action' => 'test_request_action'] ); $expected = 'This is a test'; $this->assertEquals($expected, $result); $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'another_ra_test'), - array('pass' => array('5', '7')) + ['controller' => 'request_action', 'action' => 'another_ra_test'], + ['pass' => ['5', '7']] ); $expected = 12; $this->assertEquals($expected, $result); $result = $this->object->requestAction( - array('controller' => 'tests_apps', 'action' => 'index'), array('return') + ['controller' => 'tests_apps', 'action' => 'index'], ['return'] ); $expected = 'This is the TestsAppsController index view '; $this->assertEquals($expected, $result); - $result = $this->object->requestAction(array('controller' => 'tests_apps', 'action' => 'some_method')); + $result = $this->object->requestAction(['controller' => 'tests_apps', 'action' => 'some_method']); $expected = 5; $this->assertEquals($expected, $result); $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'normal_request_action') + ['controller' => 'request_action', 'action' => 'normal_request_action'] ); $expected = 'Hello World'; $this->assertEquals($expected, $result); $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'paginate_request_action') + ['controller' => 'request_action', 'action' => 'paginate_request_action'] ); $this->assertTrue($result); $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'paginate_request_action'), - array('pass' => array(5), 'named' => array('param' => 'value')) + ['controller' => 'request_action', 'action' => 'paginate_request_action'], + ['pass' => [5], 'named' => ['param' => 'value']] ); $this->assertTrue($result); } @@ -593,7 +593,7 @@ public function testRequestActionArray() { */ public function testRequestActionRemoveReturnParam() { $result = $this->object->requestAction( - '/request_action/param_check', array('return') + '/request_action/param_check', ['return'] ); $this->assertEquals('', $result, 'Return key was found'); } @@ -611,12 +611,12 @@ public function testRequestActionParamParseAndPass() { $this->assertEquals(null, $result['plugin']); $result = $this->object->requestAction('/request_action/params_pass/sort:desc/limit:5'); - $expected = array('sort' => 'desc', 'limit' => 5); + $expected = ['sort' => 'desc', 'limit' => 5]; $this->assertEquals($expected, $result['named']); $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'params_pass'), - array('named' => array('sort' => 'desc', 'limit' => 5)) + ['controller' => 'request_action', 'action' => 'params_pass'], + ['named' => ['sort' => 'desc', 'limit' => 5]] ); $this->assertEquals($expected, $result['named']); } @@ -633,8 +633,8 @@ public function testRequestActionGetParameters() { $this->assertEquals('value', $result->query['get']); $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'params_pass'), - array('url' => array('get' => 'value', 'limit' => 5)) + ['controller' => 'request_action', 'action' => 'params_pass'], + ['url' => ['get' => 'value', 'limit' => 5]] ); $this->assertEquals('value', $result->query['get']); } @@ -648,15 +648,15 @@ public function testRequestActionGetParameters() { public function testRequestActionNoPostPassing() { $_tmp = $_POST; - $_POST = array('data' => array( + $_POST = ['data' => [ 'item' => 'value' - )); - $result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'post_pass')); + ]]; + $result = $this->object->requestAction(['controller' => 'request_action', 'action' => 'post_pass']); $this->assertEmpty($result); $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'post_pass'), - array('data' => $_POST['data']) + ['controller' => 'request_action', 'action' => 'post_pass'], + ['data' => $_POST['data']] ); $expected = $_POST['data']; $this->assertEquals($expected, $result); @@ -674,18 +674,18 @@ public function testRequestActionNoPostPassing() { * @return void */ public function testRequestActionPostWithData() { - $data = array( - 'Post' => array('id' => 2) - ); + $data = [ + 'Post' => ['id' => 2] + ]; $result = $this->object->requestAction( - array('controller' => 'request_action', 'action' => 'post_pass'), - array('data' => $data) + ['controller' => 'request_action', 'action' => 'post_pass'], + ['data' => $data] ); $this->assertEquals($data, $result); $result = $this->object->requestAction( '/request_action/post_pass', - array('data' => $data) + ['data' => $data] ); $this->assertEquals($data, $result); } diff --git a/lib/Cake/Test/Case/Core/CakePluginTest.php b/lib/Cake/Test/Case/Core/CakePluginTest.php index 86cb13eca1..1fa047b8df 100644 --- a/lib/Cake/Test/Case/Core/CakePluginTest.php +++ b/lib/Cake/Test/Case/Core/CakePluginTest.php @@ -30,9 +30,9 @@ class CakePluginTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); App::objects('plugins', null, false); } @@ -54,7 +54,7 @@ public function tearDown() : void { public function testLoadSingle() { CakePlugin::unload(); CakePlugin::load('TestPlugin'); - $expected = array('TestPlugin'); + $expected = ['TestPlugin']; $this->assertEquals($expected, CakePlugin::loaded()); } @@ -65,14 +65,14 @@ public function testLoadSingle() { */ public function testUnload() { CakePlugin::load('TestPlugin'); - $expected = array('TestPlugin'); + $expected = ['TestPlugin']; $this->assertEquals($expected, CakePlugin::loaded()); CakePlugin::unload('TestPlugin'); - $this->assertEquals(array(), CakePlugin::loaded()); + $this->assertEquals([], CakePlugin::loaded()); CakePlugin::load('TestPlugin'); - $expected = array('TestPlugin'); + $expected = ['TestPlugin']; $this->assertEquals($expected, CakePlugin::loaded()); CakePlugin::unload('TestFakePlugin'); @@ -85,7 +85,7 @@ public function testUnload() { * @return void */ public function testLoadSingleWithBootstrap() { - CakePlugin::load('TestPlugin', array('bootstrap' => true)); + CakePlugin::load('TestPlugin', ['bootstrap' => true]); $this->assertTrue(CakePlugin::loaded('TestPlugin')); $this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap')); } @@ -96,7 +96,7 @@ public function testLoadSingleWithBootstrap() { * @return void */ public function testLoadSingleWithBootstrapAndRoutes() { - CakePlugin::load('TestPlugin', array('bootstrap' => true, 'routes' => true)); + CakePlugin::load('TestPlugin', ['bootstrap' => true, 'routes' => true]); $this->assertTrue(CakePlugin::loaded('TestPlugin')); $this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap')); @@ -110,8 +110,8 @@ public function testLoadSingleWithBootstrapAndRoutes() { * @return void */ public function testLoadMultiple() { - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); - $expected = array('TestPlugin', 'TestPluginTwo'); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); + $expected = ['TestPlugin', 'TestPluginTwo']; $this->assertEquals($expected, CakePlugin::loaded()); } @@ -121,8 +121,8 @@ public function testLoadMultiple() { * @return void */ public function testLoadMultipleWithDefaults() { - CakePlugin::load(array('TestPlugin', 'TestPluginTwo'), array('bootstrap' => true, 'routes' => false)); - $expected = array('TestPlugin', 'TestPluginTwo'); + CakePlugin::load(['TestPlugin', 'TestPluginTwo'], ['bootstrap' => true, 'routes' => false]); + $expected = ['TestPlugin', 'TestPluginTwo']; $this->assertEquals($expected, CakePlugin::loaded()); $this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap')); $this->assertEquals('loaded plugin two bootstrap', Configure::read('CakePluginTest.test_plugin_two.bootstrap')); @@ -135,10 +135,10 @@ public function testLoadMultipleWithDefaults() { */ public function testLoadMultipleWithDefaultsAndOverride() { CakePlugin::load( - array('TestPlugin', 'TestPluginTwo' => array('routes' => false)), - array('bootstrap' => true, 'routes' => true) + ['TestPlugin', 'TestPluginTwo' => ['routes' => false]], + ['bootstrap' => true, 'routes' => true] ); - $expected = array('TestPlugin', 'TestPluginTwo'); + $expected = ['TestPlugin', 'TestPluginTwo']; $this->assertEquals($expected, CakePlugin::loaded()); $this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap')); $this->assertEquals(null, Configure::read('CakePluginTest.test_plugin_two.bootstrap')); @@ -150,7 +150,7 @@ public function testLoadMultipleWithDefaultsAndOverride() { * @return void */ public function testMultipleBootstrapFiles() { - CakePlugin::load('TestPlugin', array('bootstrap' => array('bootstrap', 'custom_config'))); + CakePlugin::load('TestPlugin', ['bootstrap' => ['bootstrap', 'custom_config']]); $this->assertTrue(CakePlugin::loaded('TestPlugin')); $this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap')); } @@ -161,7 +161,7 @@ public function testMultipleBootstrapFiles() { * @return void */ public function testCallbackBootstrap() { - CakePlugin::load('TestPlugin', array('bootstrap' => array($this, 'pluginBootstrap'))); + CakePlugin::load('TestPlugin', ['bootstrap' => [$this, 'pluginBootstrap']]); $this->assertTrue(CakePlugin::loaded('TestPlugin')); $this->assertEquals('called plugin bootstrap callback', Configure::read('CakePluginTest.test_plugin.bootstrap')); } @@ -173,7 +173,7 @@ public function testCallbackBootstrap() { */ public function testLoadMultipleWithDefaultsMissingFile() { $this->expectWarning(); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo'), array('bootstrap' => true, 'routes' => true)); + CakePlugin::load(['TestPlugin', 'TestPluginTwo'], ['bootstrap' => true, 'routes' => true]); CakePlugin::routes(); } @@ -183,11 +183,11 @@ public function testLoadMultipleWithDefaultsMissingFile() { * @return void */ public function testIgnoreMissingFiles() { - CakePlugin::loadAll(array(array( + CakePlugin::loadAll([[ 'bootstrap' => true, 'routes' => true, 'ignoreMissing' => true - ))); + ]]); CakePlugin::routes(); } @@ -207,7 +207,7 @@ public function testLoadNotFound() { * @return void */ public function testPath() { - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $expected = CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'TestPlugin' . DS; $this->assertEquals($expected, CakePlugin::path('TestPlugin')); @@ -232,7 +232,7 @@ public function testPathNotFound() { */ public function testLoadAll() { CakePlugin::loadAll(); - $expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo'); + $expected = ['PluginJs', 'TestPlugin', 'TestPluginTwo']; $this->assertEquals($expected, CakePlugin::loaded()); } @@ -242,9 +242,9 @@ public function testLoadAll() { * @return void */ public function testLoadAllWithDefaults() { - $defaults = array('bootstrap' => true); - CakePlugin::loadAll(array($defaults)); - $expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo'); + $defaults = ['bootstrap' => true]; + CakePlugin::loadAll([$defaults]); + $expected = ['PluginJs', 'TestPlugin', 'TestPluginTwo']; $this->assertEquals($expected, CakePlugin::loaded()); $this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap')); $this->assertEquals('loaded plugin bootstrap', Configure::read('CakePluginTest.test_plugin.bootstrap')); @@ -258,10 +258,10 @@ public function testLoadAllWithDefaults() { * @return void */ public function testLoadAllWithDefaultsAndOverride() { - CakePlugin::loadAll(array(array('bootstrap' => true), 'TestPlugin' => array('routes' => true))); + CakePlugin::loadAll([['bootstrap' => true], 'TestPlugin' => ['routes' => true]]); CakePlugin::routes(); - $expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo'); + $expected = ['PluginJs', 'TestPlugin', 'TestPluginTwo']; $this->assertEquals($expected, CakePlugin::loaded()); $this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap')); $this->assertEquals('loaded plugin routes', Configure::read('CakePluginTest.test_plugin.routes')); @@ -276,10 +276,10 @@ public function testLoadAllWithDefaultsAndOverride() { * @return void */ public function testLoadAllWithDefaultsAndOverrideComplex() { - CakePlugin::loadAll(array(array('bootstrap' => true), 'TestPlugin' => array('routes' => true, 'bootstrap' => false))); + CakePlugin::loadAll([['bootstrap' => true], 'TestPlugin' => ['routes' => true, 'bootstrap' => false]]); CakePlugin::routes(); - $expected = array('PluginJs', 'TestPlugin', 'TestPluginTwo'); + $expected = ['PluginJs', 'TestPlugin', 'TestPluginTwo']; $this->assertEquals($expected, CakePlugin::loaded()); $this->assertEquals('loaded js plugin bootstrap', Configure::read('CakePluginTest.js_plugin.bootstrap')); $this->assertEquals('loaded plugin routes', Configure::read('CakePluginTest.test_plugin.routes')); diff --git a/lib/Cake/Test/Case/Core/ConfigureTest.php b/lib/Cake/Test/Case/Core/ConfigureTest.php index ad4838b2b6..eedd5f29da 100644 --- a/lib/Cake/Test/Case/Core/ConfigureTest.php +++ b/lib/Cake/Test/Case/Core/ConfigureTest.php @@ -79,9 +79,9 @@ public function tearDown() : void { * @return void */ public function testBootstrap() { - $expected = array( + $expected = [ 'foo' => 'bar' - ); + ]; Configure::write('App', $expected); Configure::bootstrap(true); @@ -135,7 +135,7 @@ public function testWrite() { $result = Configure::read('SomeName.someKey'); $this->assertEquals(null, $result); - $expected = array('One' => array('Two' => array('Three' => array('Four' => array('Five' => 'cool'))))); + $expected = ['One' => ['Two' => ['Three' => ['Four' => ['Five' => 'cool']]]]]; $writeResult = Configure::write('Key', $expected); $this->assertTrue($writeResult); @@ -163,7 +163,7 @@ public function testWrite() { */ public function testConsume() { $this->assertNull(Configure::consume('DoesNotExist'), 'Should be null on empty value'); - Configure::write('Test', array('key' => 'value', 'key2' => 'value2')); + Configure::write('Test', ['key' => 'value', 'key2' => 'value2']); $result = Configure::consume('Test.key'); $this->assertEquals('value', $result); @@ -172,7 +172,7 @@ public function testConsume() { $this->assertEquals('value2', $result, 'Other values should remain.'); $result = Configure::consume('Test'); - $expected = array('key2' => 'value2'); + $expected = ['key2' => 'value2']; $this->assertEquals($expected, $result); } @@ -182,7 +182,7 @@ public function testConsume() { * @return void */ public function testConsumeEmpty() { - Configure::write('Test', array('key' => 'value', 'key2' => 'value2')); + Configure::write('Test', ['key' => 'value', 'key2' => 'value2']); $result = Configure::consume(''); $this->assertNull($result); $result = Configure::consume(null); @@ -218,7 +218,7 @@ public function testDelete() { $result = Configure::read('SomeName.someKey'); $this->assertNull($result); - Configure::write('SomeName', array('someKey' => 'myvalue', 'otherKey' => 'otherValue')); + Configure::write('SomeName', ['someKey' => 'myvalue', 'otherKey' => 'otherValue']); $result = Configure::read('SomeName.someKey'); $this->assertEquals('myvalue', $result); @@ -309,7 +309,7 @@ public function testLoadExceptionOnNonExistantFile() { public function testLoadDefaultConfig() { try { Configure::load('non_existing_configuration_file'); - } catch (Exception $e) { + } catch (Exception) { $result = Configure::configured('default'); $this->assertTrue($result); } @@ -365,9 +365,9 @@ public function testLoadNoMerge() { * @return void */ public function testLoadPlugin() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); Configure::config('test', new PhpReader()); CakePlugin::load('TestPlugin'); $result = Configure::load('TestPlugin.load', 'test'); @@ -413,7 +413,7 @@ public function testStoreAndRestoreWithData() { Configure::write('Cache.disable', false); Configure::write('testing', 'value'); - Configure::store('store_test', 'default', array('store_test' => 'one')); + Configure::store('store_test', 'default', ['store_test' => 'one']); Configure::delete('testing'); $this->assertNull(Configure::read('store_test'), 'Calling store with data shouldn\'t modify runtime.'); @@ -465,7 +465,7 @@ public function testReaderExceptionOnIncorrectClass() { try { Configure::config('test', $reader); - } catch (TypeError $e) { + } catch (TypeError) { throw new \PHPUnit\Framework\Error('Raised an error', 100); } } @@ -518,7 +518,7 @@ public function testDump() { public function testDumpPartial() { Configure::config('test_reader', new PhpReader(TMP)); - $result = Configure::dump('config_test.php', 'test_reader', array('Error')); + $result = Configure::dump('config_test.php', 'test_reader', ['Error']); $this->assertTrue($result > 0); $result = file_get_contents(TMP . 'config_test.php'); $this->assertStringContainsString(' array( + App::build([ + 'View' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS - ) - ), App::RESET); + ] + ], App::RESET); Router::reload(); $request = new CakeRequest(null, false); @@ -119,10 +119,10 @@ public function testHandleErrorDebugOn() { * @return void */ public static function errorProvider() { - return array( - array(E_USER_NOTICE, 'Notice'), - array(E_USER_WARNING, 'Warning'), - ); + return [ + [E_USER_NOTICE, 'Notice'], + [E_USER_WARNING, 'Warning'], + ]; } /** @@ -263,7 +263,7 @@ public function testHandleExceptionLogSkipping() { unlink(LOGS . 'error.log'); } Configure::write('Exception.log', true); - Configure::write('Exception.skipLog', array('NotFoundException')); + Configure::write('Exception.skipLog', ['NotFoundException']); $notFound = new NotFoundException('Kaboom!'); $forbidden = new ForbiddenException('Fooled you!'); @@ -288,11 +288,11 @@ public function testHandleExceptionLogSkipping() { * @return void */ public function testLoadPluginHandler() { - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ) - ), App::RESET); + ] + ], App::RESET); CakePlugin::load('TestPlugin'); Configure::write('Exception.renderer', 'TestPlugin.TestPluginExceptionRenderer'); $error = new NotFoundException('Kaboom!'); diff --git a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php index 6309063d13..fc2ff3adb2 100644 --- a/lib/Cake/Test/Case/Error/ExceptionRendererTest.php +++ b/lib/Cake/Test/Case/Error/ExceptionRendererTest.php @@ -74,14 +74,14 @@ class TestErrorController extends Controller { * * @var array */ - public $uses = array(); + public $uses = []; /** * components property * * @return void */ - public $components = array('Blueberry'); + public $components = ['Blueberry']; /** * beforeRender method @@ -147,11 +147,11 @@ class ExceptionRendererTest extends CakeTestCase { public function setUp() : void { parent::setUp(); Configure::write('Config.language', 'eng'); - App::build(array( - 'View' => array( + App::build([ + 'View' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS - ) - ), App::RESET); + ] + ], App::RESET); Router::reload(); $request = new CakeRequest(null, false); @@ -178,7 +178,7 @@ public function tearDown() : void { * @return void */ protected function _mockResponse($error) { - $error->controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $error->controller->response = $this->getMock('CakeResponse', ['_sendHeader']); return $error; } @@ -276,20 +276,20 @@ public function testErrorMethodCoercion() { */ public function testCakeErrorHelpersNotLost() { $testApp = CAKE . 'Test' . DS . 'test_app' . DS; - App::build(array( - 'Controller' => array( + App::build([ + 'Controller' => [ $testApp . 'Controller' . DS - ), - 'View/Helper' => array( + ], + 'View/Helper' => [ $testApp . 'View' . DS . 'Helper' . DS - ), - 'View/Layouts' => array( + ], + 'View/Layouts' => [ $testApp . 'View' . DS . 'Layouts' . DS - ), - 'Error' => array( + ], + 'Error' => [ $testApp . 'Error' . DS - ), - ), App::RESET); + ], + ], App::RESET); App::uses('TestAppsExceptionRenderer', 'Error'); $exception = new SocketException('socket exception'); @@ -309,7 +309,7 @@ public function testCakeErrorHelpersNotLost() { public function testUnknownExceptionTypeWithExceptionThatHasA400Code() { $exception = new MissingWidgetThingException('coding fail.'); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(404); ob_start(); @@ -329,7 +329,7 @@ public function testUnknownExceptionTypeWithExceptionThatHasA400Code() { public function testUnknownExceptionTypeWithNoCodeIsA500() { $exception = new OutOfBoundsException('foul ball.'); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once()) ->method('statusCode') ->with(500); @@ -352,7 +352,7 @@ public function testUnknownExceptionInProduction() { $exception = new OutOfBoundsException('foul ball.'); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once()) ->method('statusCode') ->with(500); @@ -374,7 +374,7 @@ public function testUnknownExceptionInProduction() { public function testUnknownExceptionTypeWithCodeHigherThan500() { $exception = new OutOfBoundsException('foul ball.', 501); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(501); ob_start(); @@ -398,7 +398,7 @@ public function testError400() { $exception = new NotFoundException('Custom message'); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(404); ob_start(); @@ -425,7 +425,7 @@ public function testerror400OnlyChangingCakeException() { $result = ob_get_clean(); $this->assertStringContainsString('Custom message', $result); - $exception = new MissingActionException(array('controller' => 'PostsController', 'action' => 'index')); + $exception = new MissingActionException(['controller' => 'PostsController', 'action' => 'index']); $ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception)); ob_start(); @@ -464,7 +464,7 @@ public function testError400NoInjection() { public function testError500Message() { $exception = new InternalErrorException('An Internal Error Has Occurred'); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(500); ob_start(); @@ -481,12 +481,12 @@ public function testError500Message() { */ public function testExceptionResponseHeader() { $exception = new MethodNotAllowedException('Only allowing POST and DELETE'); - $exception->responseHeader(array('Allow: POST, DELETE')); + $exception->responseHeader(['Allow: POST, DELETE']); $ExceptionRenderer = new ExceptionRenderer($exception); //Replace response object with mocked object add back the original headers which had been set in ExceptionRenderer constructor $headers = $ExceptionRenderer->controller->response->header(); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['_sendHeader']); $ExceptionRenderer->controller->response->header($headers); $ExceptionRenderer->controller->response->expects($this->at(1))->method('_sendHeader')->with('Allow', 'POST, DELETE'); @@ -501,7 +501,7 @@ public function testExceptionResponseHeader() { * @return void */ public function testMissingController() { - $exception = new MissingControllerException(array('class' => 'PostsController')); + $exception = new MissingControllerException(['class' => 'PostsController']); $ExceptionRenderer = $this->_mockResponse(new ExceptionRenderer($exception)); ob_start(); @@ -518,140 +518,140 @@ public function testMissingController() { * @return void */ public static function testProvider() { - return array( - array( - new MissingActionException(array('controller' => 'PostsController', 'action' => 'index')), - array( + return [ + [ + new MissingActionException(['controller' => 'PostsController', 'action' => 'index']), + [ '/

Missing Method in PostsController<\/h2>/', '/PostsController::<\/em>index\(\)<\/em>/' - ), + ], 404 - ), - array( - new PrivateActionException(array('controller' => 'PostsController', 'action' => '_secretSauce')), - array( + ], + [ + new PrivateActionException(['controller' => 'PostsController', 'action' => '_secretSauce']), + [ '/

Private Method in PostsController<\/h2>/', '/PostsController::<\/em>_secretSauce\(\)<\/em>/' - ), + ], 404 - ), - array( - new MissingTableException(array('table' => 'articles', 'class' => 'Article', 'ds' => 'test')), - array( + ], + [ + new MissingTableException(['table' => 'articles', 'class' => 'Article', 'ds' => 'test']), + [ '/

Missing Database Table<\/h2>/', '/Table articles<\/em> for model Article<\/em> was not found in datasource test<\/em>/' - ), + ], 500 - ), - array( - new MissingDatabaseException(array('connection' => 'default')), - array( + ], + [ + new MissingDatabaseException(['connection' => 'default']), + [ '/

Missing Database Connection<\/h2>/', '/Confirm you have created the file/' - ), + ], 500 - ), - array( - new MissingViewException(array('file' => '/posts/about.ctp')), - array( + ], + [ + new MissingViewException(['file' => '/posts/about.ctp']), + [ "/posts\/about.ctp/" - ), + ], 500 - ), - array( - new MissingLayoutException(array('file' => 'layouts/my_layout.ctp')), - array( + ], + [ + new MissingLayoutException(['file' => 'layouts/my_layout.ctp']), + [ "/Missing Layout/", "/layouts\/my_layout.ctp/" - ), + ], 500 - ), - array( - new MissingConnectionException(array('class' => 'Mysql')), - array( + ], + [ + new MissingConnectionException(['class' => 'Mysql']), + [ '/

Missing Database Connection<\/h2>/', '/A Database connection using "Mysql" was missing or unable to connect./', - ), + ], 500 - ), - array( - new MissingConnectionException(array('class' => 'Mysql', 'enabled' => false)), - array( + ], + [ + new MissingConnectionException(['class' => 'Mysql', 'enabled' => false]), + [ '/

Missing Database Connection<\/h2>/', '/A Database connection using "Mysql" was missing or unable to connect./', '/Mysql driver is NOT enabled/' - ), + ], 500 - ), - array( - new MissingDatasourceConfigException(array('config' => 'default')), - array( + ], + [ + new MissingDatasourceConfigException(['config' => 'default']), + [ '/

Missing Datasource Configuration<\/h2>/', '/The datasource configuration default<\/em> was not found in database.php/' - ), + ], 500 - ), - array( - new MissingDatasourceException(array('class' => 'MyDatasource', 'plugin' => 'MyPlugin')), - array( + ], + [ + new MissingDatasourceException(['class' => 'MyDatasource', 'plugin' => 'MyPlugin']), + [ '/

Missing Datasource<\/h2>/', '/Datasource class MyPlugin.MyDatasource<\/em> could not be found/' - ), + ], 500 - ), - array( - new MissingHelperException(array('class' => 'MyCustomHelper')), - array( + ], + [ + new MissingHelperException(['class' => 'MyCustomHelper']), + [ '/

Missing Helper<\/h2>/', '/MyCustomHelper<\/em> could not be found./', '/Create the class MyCustomHelper<\/em> below in file:/', '/(\/|\\\)MyCustomHelper.php/' - ), + ], 500 - ), - array( - new MissingBehaviorException(array('class' => 'MyCustomBehavior')), - array( + ], + [ + new MissingBehaviorException(['class' => 'MyCustomBehavior']), + [ '/

Missing Behavior<\/h2>/', '/Create the class MyCustomBehavior<\/em> below in file:/', '/(\/|\\\)MyCustomBehavior.php/' - ), + ], 500 - ), - array( - new MissingComponentException(array('class' => 'SideboxComponent')), - array( + ], + [ + new MissingComponentException(['class' => 'SideboxComponent']), + [ '/

Missing Component<\/h2>/', '/Create the class SideboxComponent<\/em> below in file:/', '/(\/|\\\)SideboxComponent.php/' - ), + ], 500 - ), - array( + ], + [ new Exception('boom'), - array( + [ '/Internal Error/' - ), + ], 500 - ), - array( + ], + [ new RuntimeException('another boom'), - array( + [ '/Internal Error/' - ), + ], 500 - ), - array( + ], + [ new CakeException('base class'), - array('/Internal Error/'), + ['/Internal Error/'], 500 - ), - array( + ], + [ new ConfigureException('No file'), - array('/Internal Error/'), + ['/Internal Error/'], 500 - ) - ); + ] + ]; } /** @@ -662,7 +662,7 @@ public static function testProvider() { */ public function testCakeExceptionHandling($exception, $patterns, $code) { $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once()) ->method('statusCode') ->with($code); @@ -682,11 +682,11 @@ public function testCakeExceptionHandling($exception, $patterns, $code) { * @return void */ public function testMissingRenderSafe() { - $exception = new MissingHelperException(array('class' => 'Fail')); + $exception = new MissingHelperException(['class' => 'Fail']); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller = $this->getMock('Controller', array('render')); - $ExceptionRenderer->controller->helpers = array('Fail', 'Boom'); + $ExceptionRenderer->controller = $this->getMock('Controller', ['render']); + $ExceptionRenderer->controller->helpers = ['Fail', 'Boom']; $ExceptionRenderer->controller->request = $this->getMock('CakeRequest'); $ExceptionRenderer->controller->expects($this->at(0)) ->method('render') @@ -701,7 +701,7 @@ public function testMissingRenderSafe() { $ExceptionRenderer->controller->response = $response; $ExceptionRenderer->render(); sort($ExceptionRenderer->controller->helpers); - $this->assertEquals(array('Form', 'Html', 'Session'), $ExceptionRenderer->controller->helpers); + $this->assertEquals(['Form', 'Html', 'Session'], $ExceptionRenderer->controller->helpers); } /** @@ -713,7 +713,7 @@ public function testRenderExceptionInBeforeRender() { $exception = new NotFoundException('Not there, sorry'); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller = $this->getMock('Controller', array('beforeRender')); + $ExceptionRenderer->controller = $this->getMock('Controller', ['beforeRender']); $ExceptionRenderer->controller->request = $this->getMock('CakeRequest'); $ExceptionRenderer->controller->expects($this->any()) ->method('beforeRender') @@ -737,8 +737,8 @@ public function testMissingSubdirRenderSafe() { $exception = new NotFoundException(); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller = $this->getMock('Controller', array('render')); - $ExceptionRenderer->controller->helpers = array('Fail', 'Boom'); + $ExceptionRenderer->controller = $this->getMock('Controller', ['render']); + $ExceptionRenderer->controller->helpers = ['Fail', 'Boom']; $ExceptionRenderer->controller->layoutPath = 'json'; $ExceptionRenderer->controller->subDir = 'json'; $ExceptionRenderer->controller->viewClass = 'Json'; @@ -774,11 +774,11 @@ public function testMissingPluginRenderSafe() { $exception = new NotFoundException(); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller = $this->getMock('Controller', array('render')); + $ExceptionRenderer->controller = $this->getMock('Controller', ['render']); $ExceptionRenderer->controller->plugin = 'TestPlugin'; $ExceptionRenderer->controller->request = $this->getMock('CakeRequest'); - $exception = new MissingPluginException(array('plugin' => 'TestPlugin')); + $exception = new MissingPluginException(['plugin' => 'TestPlugin']); $ExceptionRenderer->controller->expects($this->once()) ->method('render') ->with('error400') @@ -802,18 +802,18 @@ public function testMissingPluginRenderSafe() { * @return void */ public function testMissingPluginRenderSafeWithPlugin() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $exception = new NotFoundException(); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller = $this->getMock('Controller', array('render')); + $ExceptionRenderer->controller = $this->getMock('Controller', ['render']); $ExceptionRenderer->controller->plugin = 'TestPlugin'; $ExceptionRenderer->controller->request = $this->getMock('CakeRequest'); - $exception = new MissingPluginException(array('plugin' => 'TestPluginTwo')); + $exception = new MissingPluginException(['plugin' => 'TestPluginTwo']); $ExceptionRenderer->controller->expects($this->once()) ->method('render') ->with('error400') @@ -844,7 +844,7 @@ public function testRenderWithNoRequest() { $exception = new Exception('Terrible'); $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once()) ->method('statusCode') ->with(500); @@ -864,9 +864,9 @@ public function testRenderWithNoRequest() { public function testPDOException() { $exception = new PDOException('There was an error in the SQL query'); $exception->queryString = 'SELECT * from poo_query < 5 and :seven'; - $exception->params = array('seven' => 7); + $exception->params = ['seven' => 7]; $ExceptionRenderer = new ExceptionRenderer($exception); - $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', array('statusCode', '_sendHeader')); + $ExceptionRenderer->controller->response = $this->getMock('CakeResponse', ['statusCode', '_sendHeader']); $ExceptionRenderer->controller->response->expects($this->once())->method('statusCode')->with(500); ob_start(); @@ -885,7 +885,7 @@ public function testPDOException() { * @return void */ public function testRenderShutdownEvents() { - $fired = array(); + $fired = []; $listener = function ($event) use (&$fired) { $fired[] = $event->name(); }; @@ -901,7 +901,7 @@ public function testRenderShutdownEvents() { $ExceptionRenderer->render(); ob_get_clean(); - $expected = array('Controller.shutdown', 'Dispatcher.afterDispatch'); + $expected = ['Controller.shutdown', 'Dispatcher.afterDispatch']; $this->assertEquals($expected, $fired); } } diff --git a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php index c76318ef0a..02339364d4 100644 --- a/lib/Cake/Test/Case/Event/CakeEventManagerTest.php +++ b/lib/Cake/Test/Case/Event/CakeEventManagerTest.php @@ -25,7 +25,7 @@ */ class CakeEventTestListener { - public $callStack = array(); + public $callStack = []; /** * Test function to be used in event dispatching @@ -65,14 +65,14 @@ public function stopListener($event) { class CustomTestEventListener extends CakeEventTestListener implements CakeEventListener { public function implementedEvents() { - return array( + return [ 'fake.event' => 'listenerFunction', - 'another.event' => array('callable' => 'secondListenerFunction', 'passParams' => true), - 'multiple.handlers' => array( - array('callable' => 'listenerFunction'), - array('callable' => 'thirdListenerFunction') - ) - ); + 'another.event' => ['callable' => 'secondListenerFunction', 'passParams' => true], + 'multiple.handlers' => [ + ['callable' => 'listenerFunction'], + ['callable' => 'thirdListenerFunction'] + ] + ]; } /** @@ -99,25 +99,25 @@ class CakeEventManagerTest extends CakeTestCase { public function testAttachListeners() { $manager = new CakeEventManager(); $manager->attach('fakeFunction', 'fake.event'); - $expected = array( - array('callable' => 'fakeFunction', 'passParams' => false) - ); + $expected = [ + ['callable' => 'fakeFunction', 'passParams' => false] + ]; $this->assertEquals($expected, $manager->listeners('fake.event')); $manager->attach('fakeFunction2', 'fake.event'); - $expected[] = array('callable' => 'fakeFunction2', 'passParams' => false); + $expected[] = ['callable' => 'fakeFunction2', 'passParams' => false]; $this->assertEquals($expected, $manager->listeners('fake.event')); - $manager->attach('inQ5', 'fake.event', array('priority' => 5)); - $manager->attach('inQ1', 'fake.event', array('priority' => 1)); - $manager->attach('otherInQ5', 'fake.event', array('priority' => 5)); + $manager->attach('inQ5', 'fake.event', ['priority' => 5]); + $manager->attach('inQ1', 'fake.event', ['priority' => 1]); + $manager->attach('otherInQ5', 'fake.event', ['priority' => 5]); $expected = array_merge( - array( - array('callable' => 'inQ1', 'passParams' => false), - array('callable' => 'inQ5', 'passParams' => false), - array('callable' => 'otherInQ5', 'passParams' => false) - ), + [ + ['callable' => 'inQ1', 'passParams' => false], + ['callable' => 'inQ5', 'passParams' => false], + ['callable' => 'otherInQ5', 'passParams' => false] + ], $expected ); $this->assertEquals($expected, $manager->listeners('fake.event')); @@ -132,16 +132,16 @@ public function testAttachMultipleEventKeys() { $manager = new CakeEventManager(); $manager->attach('fakeFunction', 'fake.event'); $manager->attach('fakeFunction2', 'another.event'); - $manager->attach('fakeFunction3', 'another.event', array('priority' => 1, 'passParams' => true)); - $expected = array( - array('callable' => 'fakeFunction', 'passParams' => false) - ); + $manager->attach('fakeFunction3', 'another.event', ['priority' => 1, 'passParams' => true]); + $expected = [ + ['callable' => 'fakeFunction', 'passParams' => false] + ]; $this->assertEquals($expected, $manager->listeners('fake.event')); - $expected = array( - array('callable' => 'fakeFunction3', 'passParams' => true), - array('callable' => 'fakeFunction2', 'passParams' => false) - ); + $expected = [ + ['callable' => 'fakeFunction3', 'passParams' => true], + ['callable' => 'fakeFunction2', 'passParams' => false] + ]; $this->assertEquals($expected, $manager->listeners('another.event')); } @@ -152,21 +152,21 @@ public function testAttachMultipleEventKeys() { */ public function testDetach() { $manager = new CakeEventManager(); - $manager->attach(array('AClass', 'aMethod'), 'fake.event'); - $manager->attach(array('AClass', 'anotherMethod'), 'another.event'); - $manager->attach('fakeFunction', 'another.event', array('priority' => 1)); + $manager->attach(['AClass', 'aMethod'], 'fake.event'); + $manager->attach(['AClass', 'anotherMethod'], 'another.event'); + $manager->attach('fakeFunction', 'another.event', ['priority' => 1]); - $manager->detach(array('AClass', 'aMethod'), 'fake.event'); - $this->assertEquals(array(), $manager->listeners('fake.event')); + $manager->detach(['AClass', 'aMethod'], 'fake.event'); + $this->assertEquals([], $manager->listeners('fake.event')); - $manager->detach(array('AClass', 'anotherMethod'), 'another.event'); - $expected = array( - array('callable' => 'fakeFunction', 'passParams' => false) - ); + $manager->detach(['AClass', 'anotherMethod'], 'another.event'); + $expected = [ + ['callable' => 'fakeFunction', 'passParams' => false] + ]; $this->assertEquals($expected, $manager->listeners('another.event')); $manager->detach('fakeFunction', 'another.event'); - $this->assertEquals(array(), $manager->listeners('another.event')); + $this->assertEquals([], $manager->listeners('another.event')); } /** @@ -176,16 +176,16 @@ public function testDetach() { */ public function testDetachFromAll() { $manager = new CakeEventManager(); - $manager->attach(array('AClass', 'aMethod'), 'fake.event'); - $manager->attach(array('AClass', 'aMethod'), 'another.event'); - $manager->attach('fakeFunction', 'another.event', array('priority' => 1)); - - $manager->detach(array('AClass', 'aMethod')); - $expected = array( - array('callable' => 'fakeFunction', 'passParams' => false) - ); + $manager->attach(['AClass', 'aMethod'], 'fake.event'); + $manager->attach(['AClass', 'aMethod'], 'another.event'); + $manager->attach('fakeFunction', 'another.event', ['priority' => 1]); + + $manager->detach(['AClass', 'aMethod']); + $expected = [ + ['callable' => 'fakeFunction', 'passParams' => false] + ]; $this->assertEquals($expected, $manager->listeners('another.event')); - $this->assertEquals(array(), $manager->listeners('fake.event')); + $this->assertEquals([], $manager->listeners('fake.event')); } /** @@ -198,8 +198,8 @@ public function testDispatch() { $manager = new CakeEventManager(); $listener = $this->getMock('CakeEventTestListener'); $anotherListener = $this->getMock('CakeEventTestListener'); - $manager->attach(array($listener, 'listenerFunction'), 'fake.event'); - $manager->attach(array($anotherListener, 'listenerFunction'), 'fake.event'); + $manager->attach([$listener, 'listenerFunction'], 'fake.event'); + $manager->attach([$anotherListener, 'listenerFunction'], 'fake.event'); $event = new CakeEvent('fake.event'); $listener->expects($this->once())->method('listenerFunction')->with($event); @@ -215,11 +215,11 @@ public function testDispatch() { public function testDispatchWithKeyName() { $manager = new CakeEventManager(); $listener = new CakeEventTestListener(); - $manager->attach(array($listener, 'listenerFunction'), 'fake.event'); + $manager->attach([$listener, 'listenerFunction'], 'fake.event'); $event = 'fake.event'; $manager->dispatch($event); - $expected = array('listenerFunction'); + $expected = ['listenerFunction']; $this->assertEquals($expected, $listener->callStack); } @@ -233,8 +233,8 @@ public function testDispatchReturnValue() { $manager = new CakeEventManager(); $listener = $this->getMock('CakeEventTestListener'); $anotherListener = $this->getMock('CakeEventTestListener'); - $manager->attach(array($listener, 'listenerFunction'), 'fake.event'); - $manager->attach(array($anotherListener, 'listenerFunction'), 'fake.event'); + $manager->attach([$listener, 'listenerFunction'], 'fake.event'); + $manager->attach([$anotherListener, 'listenerFunction'], 'fake.event'); $event = new CakeEvent('fake.event'); $listener->expects($this->at(0))->method('listenerFunction') @@ -257,8 +257,8 @@ public function testDispatchFalseStopsEvent() { $manager = new CakeEventManager(); $listener = $this->getMock('CakeEventTestListener'); $anotherListener = $this->getMock('CakeEventTestListener'); - $manager->attach(array($listener, 'listenerFunction'), 'fake.event'); - $manager->attach(array($anotherListener, 'listenerFunction'), 'fake.event'); + $manager->attach([$listener, 'listenerFunction'], 'fake.event'); + $manager->attach([$anotherListener, 'listenerFunction'], 'fake.event'); $event = new CakeEvent('fake.event'); $listener->expects($this->at(0))->method('listenerFunction') @@ -279,12 +279,12 @@ public function testDispatchFalseStopsEvent() { public function testDispatchPrioritized() { $manager = new CakeEventManager(); $listener = new CakeEventTestListener(); - $manager->attach(array($listener, 'listenerFunction'), 'fake.event'); - $manager->attach(array($listener, 'secondListenerFunction'), 'fake.event', array('priority' => 5)); + $manager->attach([$listener, 'listenerFunction'], 'fake.event'); + $manager->attach([$listener, 'secondListenerFunction'], 'fake.event', ['priority' => 5]); $event = new CakeEvent('fake.event'); $manager->dispatch($event); - $expected = array('secondListenerFunction', 'listenerFunction'); + $expected = ['secondListenerFunction', 'listenerFunction']; $this->assertEquals($expected, $listener->callStack); } @@ -298,9 +298,9 @@ public function testDispatchPassingParams() { $manager = new CakeEventManager(); $listener = $this->getMock('CakeEventTestListener'); $anotherListener = $this->getMock('CakeEventTestListener'); - $manager->attach(array($listener, 'listenerFunction'), 'fake.event'); - $manager->attach(array($anotherListener, 'secondListenerFunction'), 'fake.event', array('passParams' => true)); - $event = new CakeEvent('fake.event', $this, array('some' => 'data')); + $manager->attach([$listener, 'listenerFunction'], 'fake.event'); + $manager->attach([$anotherListener, 'secondListenerFunction'], 'fake.event', ['passParams' => true]); + $event = new CakeEvent('fake.event', $this, ['some' => 'data']); $listener->expects($this->once())->method('listenerFunction')->with($event); $anotherListener->expects($this->once())->method('secondListenerFunction')->with('data'); @@ -317,21 +317,21 @@ public function testDispatchPassingParams() { */ public function testAttachSubscriber() { $manager = new CakeEventManager(); - $listener = $this->getMock('CustomTestEventListener', array('secondListenerFunction')); + $listener = $this->getMock('CustomTestEventListener', ['secondListenerFunction']); $manager->attach($listener); $event = new CakeEvent('fake.event'); $manager->dispatch($event); - $expected = array('listenerFunction'); + $expected = ['listenerFunction']; $this->assertEquals($expected, $listener->callStack); $listener->expects($this->at(0))->method('secondListenerFunction')->with('data'); - $event = new CakeEvent('another.event', $this, array('some' => 'data')); + $event = new CakeEvent('another.event', $this, ['some' => 'data']); $manager->dispatch($event); $manager = new CakeEventManager(); - $listener = $this->getMock('CustomTestEventListener', array('listenerFunction', 'thirdListenerFunction')); + $listener = $this->getMock('CustomTestEventListener', ['listenerFunction', 'thirdListenerFunction']); $manager->attach($listener); $event = new CakeEvent('multiple.handlers'); $listener->expects($this->once())->method('listenerFunction')->with($event); @@ -346,19 +346,19 @@ public function testAttachSubscriber() { */ public function testDetachSubscriber() { $manager = new CakeEventManager(); - $listener = $this->getMock('CustomTestEventListener', array('secondListenerFunction')); + $listener = $this->getMock('CustomTestEventListener', ['secondListenerFunction']); $manager->attach($listener); - $expected = array( - array('callable' => array($listener, 'secondListenerFunction'), 'passParams' => true) - ); + $expected = [ + ['callable' => [$listener, 'secondListenerFunction'], 'passParams' => true] + ]; $this->assertEquals($expected, $manager->listeners('another.event')); - $expected = array( - array('callable' => array($listener, 'listenerFunction'), 'passParams' => false) - ); + $expected = [ + ['callable' => [$listener, 'listenerFunction'], 'passParams' => false] + ]; $this->assertEquals($expected, $manager->listeners('fake.event')); $manager->detach($listener); - $this->assertEquals(array(), $manager->listeners('fake.event')); - $this->assertEquals(array(), $manager->listeners('another.event')); + $this->assertEquals([], $manager->listeners('fake.event')); + $this->assertEquals([], $manager->listeners('another.event')); } /** @@ -381,7 +381,7 @@ public function testGlobalDispatcherGetter() { * @triggers fake.event */ public function testDispatchWithGlobal() { - $generalManager = $this->getMock('CakeEventManager', array('prioritisedListeners')); + $generalManager = $this->getMock('CakeEventManager', ['prioritisedListeners']); $manager = new CakeEventManager(); $event = new CakeEvent('fake.event'); CakeEventManager::instance($generalManager); @@ -406,15 +406,15 @@ public function testStopPropagation() { $generalManager->expects($this->any()) ->method('prioritisedListeners') ->with('fake.event') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); - $manager->attach(array($listener, 'listenerFunction'), 'fake.event'); - $manager->attach(array($listener, 'stopListener'), 'fake.event', array('priority' => 8)); - $manager->attach(array($listener, 'secondListenerFunction'), 'fake.event', array('priority' => 5)); + $manager->attach([$listener, 'listenerFunction'], 'fake.event'); + $manager->attach([$listener, 'stopListener'], 'fake.event', ['priority' => 8]); + $manager->attach([$listener, 'secondListenerFunction'], 'fake.event', ['priority' => 5]); $event = new CakeEvent('fake.event'); $manager->dispatch($event); - $expected = array('secondListenerFunction'); + $expected = ['secondListenerFunction']; $this->assertEquals($expected, $listener->callStack); CakeEventManager::instance(new CakeEventManager()); } @@ -436,17 +436,17 @@ public function testDispatchPrioritizedWithGlobal() { ->method('prioritisedListeners') ->with('fake.event') ->will($this->returnValue( - array(11 => array( - array('callable' => array($listener, 'secondListenerFunction'), 'passParams' => false) - )) + [11 => [ + ['callable' => [$listener, 'secondListenerFunction'], 'passParams' => false] + ]] )); - $manager->attach(array($listener, 'listenerFunction'), 'fake.event'); - $manager->attach(array($listener, 'thirdListenerFunction'), 'fake.event', array('priority' => 15)); + $manager->attach([$listener, 'listenerFunction'], 'fake.event'); + $manager->attach([$listener, 'thirdListenerFunction'], 'fake.event', ['priority' => 15]); $manager->dispatch($event); - $expected = array('listenerFunction', 'secondListenerFunction', 'thirdListenerFunction'); + $expected = ['listenerFunction', 'secondListenerFunction', 'thirdListenerFunction']; $this->assertEquals($expected, $listener->callStack); CakeEventManager::instance(new CakeEventManager()); } @@ -468,16 +468,16 @@ public function testDispatchGlobalBeforeLocal() { ->method('prioritisedListeners') ->with('fake.event') ->will($this->returnValue( - array(10 => array( - array('callable' => array($listener, 'listenerFunction'), 'passParams' => false) - )) + [10 => [ + ['callable' => [$listener, 'listenerFunction'], 'passParams' => false] + ]] )); - $manager->attach(array($listener, 'secondListenerFunction'), 'fake.event'); + $manager->attach([$listener, 'secondListenerFunction'], 'fake.event'); $manager->dispatch($event); - $expected = array('listenerFunction', 'secondListenerFunction'); + $expected = ['listenerFunction', 'secondListenerFunction']; $this->assertEquals($expected, $listener->callStack); CakeEventManager::instance(new CakeEventManager()); } @@ -495,7 +495,7 @@ public function onMyEvent($event) { * @triggers my_event $manager */ public function testDispatchLocalHandledByGlobal() { - $callback = array($this, 'onMyEvent'); + $callback = [$this, 'onMyEvent']; CakeEventManager::instance()->attach($callback, 'my_event'); $manager = new CakeEventManager(); $event = new CakeEvent('my_event', $manager); @@ -515,11 +515,11 @@ public function testDispatchWithGlobalAndLocalEvents() { CakeEventManager::instance()->attach($listener); $listener2 = new CakeEventTestListener(); $manager = new CakeEventManager(); - $manager->attach(array($listener2, 'listenerFunction'), 'fake.event'); + $manager->attach([$listener2, 'listenerFunction'], 'fake.event'); $manager->dispatch(new CakeEvent('fake.event', $this)); - $this->assertEquals(array('listenerFunction'), $listener->callStack); - $this->assertEquals(array('listenerFunction'), $listener2->callStack); + $this->assertEquals(['listenerFunction'], $listener->callStack); + $this->assertEquals(['listenerFunction'], $listener2->callStack); } } diff --git a/lib/Cake/Test/Case/Event/CakeEventTest.php b/lib/Cake/Test/Case/Event/CakeEventTest.php index 061ee941fc..90afd10ac1 100644 --- a/lib/Cake/Test/Case/Event/CakeEventTest.php +++ b/lib/Cake/Test/Case/Event/CakeEventTest.php @@ -71,8 +71,8 @@ public function testPropagation() { * @triggers fake.event $this, array('some' => 'data') */ public function testEventData() { - $event = new CakeEvent('fake.event', $this, array('some' => 'data')); - $this->assertEquals(array('some' => 'data'), $event->data); + $event = new CakeEvent('fake.event', $this, ['some' => 'data']); + $this->assertEquals(['some' => 'data'], $event->data); } /** diff --git a/lib/Cake/Test/Case/I18n/I18nTest.php b/lib/Cake/Test/Case/I18n/I18nTest.php index 9db69ae0f9..6d07a0b56e 100644 --- a/lib/Cake/Test/Case/I18n/I18nTest.php +++ b/lib/Cake/Test/Case/I18n/I18nTest.php @@ -35,11 +35,11 @@ public function setUp() : void { parent::setUp(); Cache::delete('object_map', '_cake_core_'); - App::build(array( - 'Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin')); + App::build([ + 'Locale' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin']); } /** @@ -1722,9 +1722,9 @@ public function testNoCoreTranslation() { * @return void */ public function testPluginTranslation() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); Configure::write('Config.language', 'po'); $singular = $this->_domainSingular(); @@ -1771,9 +1771,9 @@ public function testPluginTranslationPreferApp() { Configure::write('I18n.preferApp', true); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); Configure::write('Config.language', 'po'); $singular = $this->_domainSingular(); @@ -1956,11 +1956,11 @@ public function testTimeDefinition() { $this->assertEquals($expected, $result); $result = __c('am_pm', 5); - $expected = array('AM', 'PM'); + $expected = ['AM', 'PM']; $this->assertEquals($expected, $result); $result = __c('abmon', 5); - $expected = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); + $expected = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; $this->assertEquals($expected, $result); } @@ -1978,11 +1978,11 @@ public function testTimeDefinitionJapanese() { $this->assertEquals($expected, $result); $result = __c('am_pm', 5); - $expected = array("午前", "午後"); + $expected = ["午前", "午後"]; $this->assertEquals($expected, $result); $result = __c('abmon', 5); - $expected = array(" 1月", " 2月", " 3月", " 4月", " 5月", " 6月", " 7月", " 8月", " 9月", "10月", "11月", "12月"); + $expected = [" 1月", " 2月", " 3月", " 4月", " 5月", " 6月", " 7月", " 8月", " 9月", "10月", "11月", "12月"]; $this->assertEquals($expected, $result); } @@ -2021,7 +2021,7 @@ public function testTranslateEmptyDomain() { public function testLoadLocaleDefinition() { $path = current(App::path('locales')); $result = I18n::loadLocaleDefinition($path . 'nld' . DS . 'LC_TIME'); - $expected = array('zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'); + $expected = ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag']; $this->assertSame($expected, $result['day']); } @@ -2076,7 +2076,7 @@ protected function _domainCategorySingular($domain = 'test_plugin', $category = * @return void */ protected function _domainCategoryPlural($domain = 'test_plugin', $category = 3) { - $plurals = array(); + $plurals = []; for ($number = 0; $number <= 25; $number++) { $plurals[] = sprintf(__dcn($domain, '%d = 1', '%d = 0 or > 1', (float)$number, $category), (float)$number); } @@ -2099,7 +2099,7 @@ protected function _domainSingular($domain = 'test_plugin') { * @return void */ protected function _domainPlural($domain = 'test_plugin') { - $plurals = array(); + $plurals = []; for ($number = 0; $number <= 25; $number++) { $plurals[] = sprintf(__dn($domain, '%d = 1', '%d = 0 or > 1', (float)$number), (float)$number); } @@ -2133,7 +2133,7 @@ protected function _singular() { * @return void */ protected function _plural($upTo = 25) { - $plurals = array(); + $plurals = []; for ($number = 0; $number <= $upTo; $number++) { $plurals[] = sprintf(__n('%d = 1', '%d = 0 or > 1', (float)$number), (float)$number); } @@ -2157,7 +2157,7 @@ protected function _singularFromCore() { * @return void */ protected function _pluralFromCore($upTo = 25) { - $plurals = array(); + $plurals = []; for ($number = 0; $number <= $upTo; $number++) { $plurals[] = sprintf(__n('%d = 1 (from core)', '%d = 0 or > 1 (from core)', (float)$number), (float)$number); } diff --git a/lib/Cake/Test/Case/I18n/L10nTest.php b/lib/Cake/Test/Case/I18n/L10nTest.php index 130f91790c..e09b0e5512 100644 --- a/lib/Cake/Test/Case/I18n/L10nTest.php +++ b/lib/Cake/Test/Case/I18n/L10nTest.php @@ -48,21 +48,21 @@ public function testGet() { $this->assertEquals('en', $lang); $this->assertEquals('English', $localize->language); - $this->assertEquals(array('eng'), $localize->languagePath); + $this->assertEquals(['eng'], $localize->languagePath); $this->assertEquals('eng', $localize->locale); // Map Entry $localize->get('eng'); $this->assertEquals('English', $localize->language); - $this->assertEquals(array('eng'), $localize->languagePath); + $this->assertEquals(['eng'], $localize->languagePath); $this->assertEquals('eng', $localize->locale); // Catalog Entry $localize->get('en-ca'); $this->assertEquals('English (Canadian)', $localize->language); - $this->assertEquals(array('en_ca', 'eng'), $localize->languagePath); + $this->assertEquals(['en_ca', 'eng'], $localize->languagePath); $this->assertEquals('en_ca', $localize->locale); // Default Entry @@ -71,7 +71,7 @@ public function testGet() { $this->assertEquals('en-us', $lang); $this->assertEquals('English (United States)', $localize->language); - $this->assertEquals(array('en_us', 'eng'), $localize->languagePath); + $this->assertEquals(['en_us', 'eng'], $localize->languagePath); $this->assertEquals('en_us', $localize->locale); $localize->get('es'); @@ -93,7 +93,7 @@ public function testGetAutoLanguage() { $this->assertEquals('en-ca', $lang); $this->assertEquals('English (Canadian)', $localize->language); - $this->assertEquals(array('en_ca', 'eng'), $localize->languagePath); + $this->assertEquals(['en_ca', 'eng'], $localize->languagePath); $this->assertEquals('en_ca', $localize->locale); $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx'; @@ -101,19 +101,19 @@ public function testGetAutoLanguage() { $this->assertEquals('es-mx', $lang); $this->assertEquals('Spanish (Mexican)', $localize->language); - $this->assertEquals(array('es_mx', 'spa'), $localize->languagePath); + $this->assertEquals(['es_mx', 'spa'], $localize->languagePath); $this->assertEquals('es_mx', $localize->locale); $localize = new L10n(); $localize->default = 'en-us'; $lang = $localize->get(); - $this->assertEquals(array('es_mx', 'spa', 'eng'), $localize->languagePath); + $this->assertEquals(['es_mx', 'spa', 'eng'], $localize->languagePath); $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en_xy,en_ca'; $localize->get(); $this->assertEquals('English', $localize->language); - $this->assertEquals(array('eng'), $localize->languagePath); + $this->assertEquals(['eng'], $localize->languagePath); $this->assertEquals('eng', $localize->locale); $_SERVER = $serverBackup; @@ -134,7 +134,7 @@ public function testGetWithDeprecatedConstant() { $this->assertEquals('en-us', $lang); $this->assertEquals('English (United States)', $localize->language); - $this->assertEquals(array('en_us', 'eng'), $localize->languagePath); + $this->assertEquals(['en_us', 'eng'], $localize->languagePath); $this->assertEquals('en_us', $localize->locale); $localize = new L10n(); @@ -143,7 +143,7 @@ public function testGetWithDeprecatedConstant() { $this->assertEquals('en-us', $lang); $this->assertEquals('English (United States)', $localize->language); - $this->assertEquals(array('en_us', 'eng'), $localize->languagePath); + $this->assertEquals(['en_us', 'eng'], $localize->languagePath); $this->assertEquals('en_us', $localize->locale); } @@ -155,332 +155,332 @@ public function testGetWithDeprecatedConstant() { public function testMap() { $localize = new L10n(); - $result = $localize->map(array('afr', 'af')); - $expected = array('afr' => 'af', 'af' => 'afr'); + $result = $localize->map(['afr', 'af']); + $expected = ['afr' => 'af', 'af' => 'afr']; $this->assertEquals($expected, $result); - $result = $localize->map(array('sqi', 'sq')); - $expected = array('sqi' => 'sq', 'sq' => 'sqi'); + $result = $localize->map(['sqi', 'sq']); + $expected = ['sqi' => 'sq', 'sq' => 'sqi']; $this->assertEquals($expected, $result); - $result = $localize->map(array('alb', 'sq')); - $expected = array('alb' => 'sq', 'sq' => 'sqi'); + $result = $localize->map(['alb', 'sq']); + $expected = ['alb' => 'sq', 'sq' => 'sqi']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ara', 'ar')); - $expected = array('ara' => 'ar', 'ar' => 'ara'); + $result = $localize->map(['ara', 'ar']); + $expected = ['ara' => 'ar', 'ar' => 'ara']; $this->assertEquals($expected, $result); - $result = $localize->map(array('hye', 'hy')); - $expected = array('hye' => 'hy', 'hy' => 'hye'); + $result = $localize->map(['hye', 'hy']); + $expected = ['hye' => 'hy', 'hy' => 'hye']; $this->assertEquals($expected, $result); - $result = $localize->map(array('eus', 'eu')); - $expected = array('eus' => 'eu', 'eu' => 'eus'); + $result = $localize->map(['eus', 'eu']); + $expected = ['eus' => 'eu', 'eu' => 'eus']; $this->assertEquals($expected, $result); - $result = $localize->map(array('baq', 'eu')); - $expected = array('baq' => 'eu', 'eu' => 'eus'); + $result = $localize->map(['baq', 'eu']); + $expected = ['baq' => 'eu', 'eu' => 'eus']; $this->assertEquals($expected, $result); - $result = $localize->map(array('bos', 'bs')); - $expected = array('bos' => 'bs', 'bs' => 'bos'); + $result = $localize->map(['bos', 'bs']); + $expected = ['bos' => 'bs', 'bs' => 'bos']; $this->assertEquals($expected, $result); - $result = $localize->map(array('bul', 'bg')); - $expected = array('bul' => 'bg', 'bg' => 'bul'); + $result = $localize->map(['bul', 'bg']); + $expected = ['bul' => 'bg', 'bg' => 'bul']; $this->assertEquals($expected, $result); - $result = $localize->map(array('bel', 'be')); - $expected = array('bel' => 'be', 'be' => 'bel'); + $result = $localize->map(['bel', 'be']); + $expected = ['bel' => 'be', 'be' => 'bel']; $this->assertEquals($expected, $result); - $result = $localize->map(array('cat', 'ca')); - $expected = array('cat' => 'ca', 'ca' => 'cat'); + $result = $localize->map(['cat', 'ca']); + $expected = ['cat' => 'ca', 'ca' => 'cat']; $this->assertEquals($expected, $result); - $result = $localize->map(array('chi', 'zh')); - $expected = array('chi' => 'zh', 'zh' => 'zho'); + $result = $localize->map(['chi', 'zh']); + $expected = ['chi' => 'zh', 'zh' => 'zho']; $this->assertEquals($expected, $result); - $result = $localize->map(array('zho', 'zh')); - $expected = array('zho' => 'zh', 'zh' => 'zho'); + $result = $localize->map(['zho', 'zh']); + $expected = ['zho' => 'zh', 'zh' => 'zho']; $this->assertEquals($expected, $result); - $result = $localize->map(array('hrv', 'hr')); - $expected = array('hrv' => 'hr', 'hr' => 'hrv'); + $result = $localize->map(['hrv', 'hr']); + $expected = ['hrv' => 'hr', 'hr' => 'hrv']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ces', 'cs')); - $expected = array('ces' => 'cs', 'cs' => 'ces'); + $result = $localize->map(['ces', 'cs']); + $expected = ['ces' => 'cs', 'cs' => 'ces']; $this->assertEquals($expected, $result); - $result = $localize->map(array('cze', 'cs')); - $expected = array('cze' => 'cs', 'cs' => 'ces'); + $result = $localize->map(['cze', 'cs']); + $expected = ['cze' => 'cs', 'cs' => 'ces']; $this->assertEquals($expected, $result); - $result = $localize->map(array('dan', 'da')); - $expected = array('dan' => 'da', 'da' => 'dan'); + $result = $localize->map(['dan', 'da']); + $expected = ['dan' => 'da', 'da' => 'dan']; $this->assertEquals($expected, $result); - $result = $localize->map(array('dut', 'nl')); - $expected = array('dut' => 'nl', 'nl' => 'nld'); + $result = $localize->map(['dut', 'nl']); + $expected = ['dut' => 'nl', 'nl' => 'nld']; $this->assertEquals($expected, $result); - $result = $localize->map(array('nld', 'nl')); - $expected = array('nld' => 'nl', 'nl' => 'nld'); + $result = $localize->map(['nld', 'nl']); + $expected = ['nld' => 'nl', 'nl' => 'nld']; $this->assertEquals($expected, $result); - $result = $localize->map(array('nld')); - $expected = array('nld' => 'nl'); + $result = $localize->map(['nld']); + $expected = ['nld' => 'nl']; $this->assertEquals($expected, $result); - $result = $localize->map(array('dut')); - $expected = array('dut' => 'nl'); + $result = $localize->map(['dut']); + $expected = ['dut' => 'nl']; $this->assertEquals($expected, $result); - $result = $localize->map(array('eng', 'en')); - $expected = array('eng' => 'en', 'en' => 'eng'); + $result = $localize->map(['eng', 'en']); + $expected = ['eng' => 'en', 'en' => 'eng']; $this->assertEquals($expected, $result); - $result = $localize->map(array('est', 'et')); - $expected = array('est' => 'et', 'et' => 'est'); + $result = $localize->map(['est', 'et']); + $expected = ['est' => 'et', 'et' => 'est']; $this->assertEquals($expected, $result); - $result = $localize->map(array('fao', 'fo')); - $expected = array('fao' => 'fo', 'fo' => 'fao'); + $result = $localize->map(['fao', 'fo']); + $expected = ['fao' => 'fo', 'fo' => 'fao']; $this->assertEquals($expected, $result); - $result = $localize->map(array('fas', 'fa')); - $expected = array('fas' => 'fa', 'fa' => 'fas'); + $result = $localize->map(['fas', 'fa']); + $expected = ['fas' => 'fa', 'fa' => 'fas']; $this->assertEquals($expected, $result); - $result = $localize->map(array('per', 'fa')); - $expected = array('per' => 'fa', 'fa' => 'fas'); + $result = $localize->map(['per', 'fa']); + $expected = ['per' => 'fa', 'fa' => 'fas']; $this->assertEquals($expected, $result); - $result = $localize->map(array('fin', 'fi')); - $expected = array('fin' => 'fi', 'fi' => 'fin'); + $result = $localize->map(['fin', 'fi']); + $expected = ['fin' => 'fi', 'fi' => 'fin']; $this->assertEquals($expected, $result); - $result = $localize->map(array('fra', 'fr')); - $expected = array('fra' => 'fr', 'fr' => 'fra'); + $result = $localize->map(['fra', 'fr']); + $expected = ['fra' => 'fr', 'fr' => 'fra']; $this->assertEquals($expected, $result); - $result = $localize->map(array('fre', 'fr')); - $expected = array('fre' => 'fr', 'fr' => 'fra'); + $result = $localize->map(['fre', 'fr']); + $expected = ['fre' => 'fr', 'fr' => 'fra']; $this->assertEquals($expected, $result); - $result = $localize->map(array('gla', 'gd')); - $expected = array('gla' => 'gd', 'gd' => 'gla'); + $result = $localize->map(['gla', 'gd']); + $expected = ['gla' => 'gd', 'gd' => 'gla']; $this->assertEquals($expected, $result); - $result = $localize->map(array('glg', 'gl')); - $expected = array('glg' => 'gl', 'gl' => 'glg'); + $result = $localize->map(['glg', 'gl']); + $expected = ['glg' => 'gl', 'gl' => 'glg']; $this->assertEquals($expected, $result); - $result = $localize->map(array('deu', 'de')); - $expected = array('deu' => 'de', 'de' => 'deu'); + $result = $localize->map(['deu', 'de']); + $expected = ['deu' => 'de', 'de' => 'deu']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ger', 'de')); - $expected = array('ger' => 'de', 'de' => 'deu'); + $result = $localize->map(['ger', 'de']); + $expected = ['ger' => 'de', 'de' => 'deu']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ell', 'el')); - $expected = array('ell' => 'el', 'el' => 'gre'); + $result = $localize->map(['ell', 'el']); + $expected = ['ell' => 'el', 'el' => 'gre']; $this->assertEquals($expected, $result); - $result = $localize->map(array('gre', 'el')); - $expected = array('gre' => 'el', 'el' => 'gre'); + $result = $localize->map(['gre', 'el']); + $expected = ['gre' => 'el', 'el' => 'gre']; $this->assertEquals($expected, $result); - $result = $localize->map(array('heb', 'he')); - $expected = array('heb' => 'he', 'he' => 'heb'); + $result = $localize->map(['heb', 'he']); + $expected = ['heb' => 'he', 'he' => 'heb']; $this->assertEquals($expected, $result); - $result = $localize->map(array('hin', 'hi')); - $expected = array('hin' => 'hi', 'hi' => 'hin'); + $result = $localize->map(['hin', 'hi']); + $expected = ['hin' => 'hi', 'hi' => 'hin']; $this->assertEquals($expected, $result); - $result = $localize->map(array('hun', 'hu')); - $expected = array('hun' => 'hu', 'hu' => 'hun'); + $result = $localize->map(['hun', 'hu']); + $expected = ['hun' => 'hu', 'hu' => 'hun']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ice', 'is')); - $expected = array('ice' => 'is', 'is' => 'isl'); + $result = $localize->map(['ice', 'is']); + $expected = ['ice' => 'is', 'is' => 'isl']; $this->assertEquals($expected, $result); - $result = $localize->map(array('isl', 'is')); - $expected = array('isl' => 'is', 'is' => 'isl'); + $result = $localize->map(['isl', 'is']); + $expected = ['isl' => 'is', 'is' => 'isl']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ind', 'id')); - $expected = array('ind' => 'id', 'id' => 'ind'); + $result = $localize->map(['ind', 'id']); + $expected = ['ind' => 'id', 'id' => 'ind']; $this->assertEquals($expected, $result); - $result = $localize->map(array('gle', 'ga')); - $expected = array('gle' => 'ga', 'ga' => 'gle'); + $result = $localize->map(['gle', 'ga']); + $expected = ['gle' => 'ga', 'ga' => 'gle']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ita', 'it')); - $expected = array('ita' => 'it', 'it' => 'ita'); + $result = $localize->map(['ita', 'it']); + $expected = ['ita' => 'it', 'it' => 'ita']; $this->assertEquals($expected, $result); - $result = $localize->map(array('jpn', 'ja')); - $expected = array('jpn' => 'ja', 'ja' => 'jpn'); + $result = $localize->map(['jpn', 'ja']); + $expected = ['jpn' => 'ja', 'ja' => 'jpn']; $this->assertEquals($expected, $result); - $result = $localize->map(array('kaz', 'kk')); - $expected = array('kaz' => 'kk', 'kk' => 'kaz'); + $result = $localize->map(['kaz', 'kk']); + $expected = ['kaz' => 'kk', 'kk' => 'kaz']; $this->assertEquals($expected, $result); - $result = $localize->map(array('kor', 'ko')); - $expected = array('kor' => 'ko', 'ko' => 'kor'); + $result = $localize->map(['kor', 'ko']); + $expected = ['kor' => 'ko', 'ko' => 'kor']; $this->assertEquals($expected, $result); - $result = $localize->map(array('lav', 'lv')); - $expected = array('lav' => 'lv', 'lv' => 'lav'); + $result = $localize->map(['lav', 'lv']); + $expected = ['lav' => 'lv', 'lv' => 'lav']; $this->assertEquals($expected, $result); - $result = $localize->map(array('lit', 'lt')); - $expected = array('lit' => 'lt', 'lt' => 'lit'); + $result = $localize->map(['lit', 'lt']); + $expected = ['lit' => 'lt', 'lt' => 'lit']; $this->assertEquals($expected, $result); - $result = $localize->map(array('mac', 'mk')); - $expected = array('mac' => 'mk', 'mk' => 'mkd'); + $result = $localize->map(['mac', 'mk']); + $expected = ['mac' => 'mk', 'mk' => 'mkd']; $this->assertEquals($expected, $result); - $result = $localize->map(array('mkd', 'mk')); - $expected = array('mkd' => 'mk', 'mk' => 'mkd'); + $result = $localize->map(['mkd', 'mk']); + $expected = ['mkd' => 'mk', 'mk' => 'mkd']; $this->assertEquals($expected, $result); - $result = $localize->map(array('may', 'ms')); - $expected = array('may' => 'ms', 'ms' => 'msa'); + $result = $localize->map(['may', 'ms']); + $expected = ['may' => 'ms', 'ms' => 'msa']; $this->assertEquals($expected, $result); - $result = $localize->map(array('msa', 'ms')); - $expected = array('msa' => 'ms', 'ms' => 'msa'); + $result = $localize->map(['msa', 'ms']); + $expected = ['msa' => 'ms', 'ms' => 'msa']; $this->assertEquals($expected, $result); - $result = $localize->map(array('mlt', 'mt')); - $expected = array('mlt' => 'mt', 'mt' => 'mlt'); + $result = $localize->map(['mlt', 'mt']); + $expected = ['mlt' => 'mt', 'mt' => 'mlt']; $this->assertEquals($expected, $result); - $result = $localize->map(array('nor', 'no')); - $expected = array('nor' => 'no', 'no' => 'nor'); + $result = $localize->map(['nor', 'no']); + $expected = ['nor' => 'no', 'no' => 'nor']; $this->assertEquals($expected, $result); - $result = $localize->map(array('nob', 'nb')); - $expected = array('nob' => 'nb', 'nb' => 'nob'); + $result = $localize->map(['nob', 'nb']); + $expected = ['nob' => 'nb', 'nb' => 'nob']; $this->assertEquals($expected, $result); - $result = $localize->map(array('nno', 'nn')); - $expected = array('nno' => 'nn', 'nn' => 'nno'); + $result = $localize->map(['nno', 'nn']); + $expected = ['nno' => 'nn', 'nn' => 'nno']; $this->assertEquals($expected, $result); - $result = $localize->map(array('pol', 'pl')); - $expected = array('pol' => 'pl', 'pl' => 'pol'); + $result = $localize->map(['pol', 'pl']); + $expected = ['pol' => 'pl', 'pl' => 'pol']; $this->assertEquals($expected, $result); - $result = $localize->map(array('por', 'pt')); - $expected = array('por' => 'pt', 'pt' => 'por'); + $result = $localize->map(['por', 'pt']); + $expected = ['por' => 'pt', 'pt' => 'por']; $this->assertEquals($expected, $result); - $result = $localize->map(array('roh', 'rm')); - $expected = array('roh' => 'rm', 'rm' => 'roh'); + $result = $localize->map(['roh', 'rm']); + $expected = ['roh' => 'rm', 'rm' => 'roh']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ron', 'ro')); - $expected = array('ron' => 'ro', 'ro' => 'ron'); + $result = $localize->map(['ron', 'ro']); + $expected = ['ron' => 'ro', 'ro' => 'ron']; $this->assertEquals($expected, $result); - $result = $localize->map(array('rum', 'ro')); - $expected = array('rum' => 'ro', 'ro' => 'ron'); + $result = $localize->map(['rum', 'ro']); + $expected = ['rum' => 'ro', 'ro' => 'ron']; $this->assertEquals($expected, $result); - $result = $localize->map(array('rus', 'ru')); - $expected = array('rus' => 'ru', 'ru' => 'rus'); + $result = $localize->map(['rus', 'ru']); + $expected = ['rus' => 'ru', 'ru' => 'rus']; $this->assertEquals($expected, $result); - $result = $localize->map(array('sme', 'se')); - $expected = array('sme' => 'se', 'se' => 'sme'); + $result = $localize->map(['sme', 'se']); + $expected = ['sme' => 'se', 'se' => 'sme']; $this->assertEquals($expected, $result); - $result = $localize->map(array('srp', 'sr')); - $expected = array('srp' => 'sr', 'sr' => 'srp'); + $result = $localize->map(['srp', 'sr']); + $expected = ['srp' => 'sr', 'sr' => 'srp']; $this->assertEquals($expected, $result); - $result = $localize->map(array('slk', 'sk')); - $expected = array('slk' => 'sk', 'sk' => 'slk'); + $result = $localize->map(['slk', 'sk']); + $expected = ['slk' => 'sk', 'sk' => 'slk']; $this->assertEquals($expected, $result); - $result = $localize->map(array('slo', 'sk')); - $expected = array('slo' => 'sk', 'sk' => 'slk'); + $result = $localize->map(['slo', 'sk']); + $expected = ['slo' => 'sk', 'sk' => 'slk']; $this->assertEquals($expected, $result); - $result = $localize->map(array('slv', 'sl')); - $expected = array('slv' => 'sl', 'sl' => 'slv'); + $result = $localize->map(['slv', 'sl']); + $expected = ['slv' => 'sl', 'sl' => 'slv']; $this->assertEquals($expected, $result); - $result = $localize->map(array('wen', 'sb')); - $expected = array('wen' => 'sb', 'sb' => 'wen'); + $result = $localize->map(['wen', 'sb']); + $expected = ['wen' => 'sb', 'sb' => 'wen']; $this->assertEquals($expected, $result); - $result = $localize->map(array('spa', 'es')); - $expected = array('spa' => 'es', 'es' => 'spa'); + $result = $localize->map(['spa', 'es']); + $expected = ['spa' => 'es', 'es' => 'spa']; $this->assertEquals($expected, $result); - $result = $localize->map(array('swe', 'sv')); - $expected = array('swe' => 'sv', 'sv' => 'swe'); + $result = $localize->map(['swe', 'sv']); + $expected = ['swe' => 'sv', 'sv' => 'swe']; $this->assertEquals($expected, $result); - $result = $localize->map(array('tha', 'th')); - $expected = array('tha' => 'th', 'th' => 'tha'); + $result = $localize->map(['tha', 'th']); + $expected = ['tha' => 'th', 'th' => 'tha']; $this->assertEquals($expected, $result); - $result = $localize->map(array('tso', 'ts')); - $expected = array('tso' => 'ts', 'ts' => 'tso'); + $result = $localize->map(['tso', 'ts']); + $expected = ['tso' => 'ts', 'ts' => 'tso']; $this->assertEquals($expected, $result); - $result = $localize->map(array('tsn', 'tn')); - $expected = array('tsn' => 'tn', 'tn' => 'tsn'); + $result = $localize->map(['tsn', 'tn']); + $expected = ['tsn' => 'tn', 'tn' => 'tsn']; $this->assertEquals($expected, $result); - $result = $localize->map(array('tur', 'tr')); - $expected = array('tur' => 'tr', 'tr' => 'tur'); + $result = $localize->map(['tur', 'tr']); + $expected = ['tur' => 'tr', 'tr' => 'tur']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ukr', 'uk')); - $expected = array('ukr' => 'uk', 'uk' => 'ukr'); + $result = $localize->map(['ukr', 'uk']); + $expected = ['ukr' => 'uk', 'uk' => 'ukr']; $this->assertEquals($expected, $result); - $result = $localize->map(array('urd', 'ur')); - $expected = array('urd' => 'ur', 'ur' => 'urd'); + $result = $localize->map(['urd', 'ur']); + $expected = ['urd' => 'ur', 'ur' => 'urd']; $this->assertEquals($expected, $result); - $result = $localize->map(array('ven', 've')); - $expected = array('ven' => 've', 've' => 'ven'); + $result = $localize->map(['ven', 've']); + $expected = ['ven' => 've', 've' => 'ven']; $this->assertEquals($expected, $result); - $result = $localize->map(array('vie', 'vi')); - $expected = array('vie' => 'vi', 'vi' => 'vie'); + $result = $localize->map(['vie', 'vi']); + $expected = ['vie' => 'vi', 'vi' => 'vie']; $this->assertEquals($expected, $result); - $result = $localize->map(array('xho', 'xh')); - $expected = array('xho' => 'xh', 'xh' => 'xho'); + $result = $localize->map(['xho', 'xh']); + $expected = ['xho' => 'xh', 'xh' => 'xho']; $this->assertEquals($expected, $result); - $result = $localize->map(array('cy', 'cym')); - $expected = array('cym' => 'cy', 'cy' => 'cym'); + $result = $localize->map(['cy', 'cym']); + $expected = ['cym' => 'cy', 'cy' => 'cym']; $this->assertEquals($expected, $result); - $result = $localize->map(array('yid', 'yi')); - $expected = array('yid' => 'yi', 'yi' => 'yid'); + $result = $localize->map(['yid', 'yi']); + $expected = ['yid' => 'yi', 'yi' => 'yid']; $this->assertEquals($expected, $result); - $result = $localize->map(array('zul', 'zu')); - $expected = array('zul' => 'zu', 'zu' => 'zul'); + $result = $localize->map(['zul', 'zu']); + $expected = ['zul' => 'zu', 'zu' => 'zul']; $this->assertEquals($expected, $result); } @@ -492,501 +492,501 @@ public function testMap() { public function testCatalog() { $localize = new L10n(); - $result = $localize->catalog(array('af')); - $expected = array( - 'af' => array('language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('ar', 'ar-ae', 'ar-bh', 'ar-dz', 'ar-eg', 'ar-iq', 'ar-jo', 'ar-kw', 'ar-lb', 'ar-ly', 'ar-ma', - 'ar-om', 'ar-qa', 'ar-sa', 'ar-sy', 'ar-tn', 'ar-ye')); - $expected = array( - 'ar' => array('language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-ae' => array('language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-bh' => array('language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-dz' => array('language' => 'Arabic (Algeria)', 'locale' => 'ar_dz', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-eg' => array('language' => 'Arabic (Egypt)', 'locale' => 'ar_eg', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-iq' => array('language' => 'Arabic (Iraq)', 'locale' => 'ar_iq', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-jo' => array('language' => 'Arabic (Jordan)', 'locale' => 'ar_jo', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-kw' => array('language' => 'Arabic (Kuwait)', 'locale' => 'ar_kw', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-ly' => array('language' => 'Arabic (Libya)', 'locale' => 'ar_ly', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-ma' => array('language' => 'Arabic (Morocco)', 'locale' => 'ar_ma', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-om' => array('language' => 'Arabic (Oman)', 'locale' => 'ar_om', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-qa' => array('language' => 'Arabic (Qatar)', 'locale' => 'ar_qa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-sa' => array('language' => 'Arabic (Saudi Arabia)', 'locale' => 'ar_sa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-sy' => array('language' => 'Arabic (Syria)', 'locale' => 'ar_sy', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-tn' => array('language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'ar-ye' => array('language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('be')); - $expected = array( - 'be' => array('language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('bg')); - $expected = array( - 'bg' => array('language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('bs')); - $expected = array( - 'bs' => array('language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('ca')); - $expected = array( - 'ca' => array('language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('cs')); - $expected = array( - 'cs' => array('language' => 'Czech', 'locale' => 'ces', 'localeFallback' => 'ces', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('da')); - $expected = array( - 'da' => array('language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('de', 'de-at', 'de-ch', 'de-de', 'de-li', 'de-lu')); - $expected = array( - 'de' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-at' => array('language' => 'German (Austria)', 'locale' => 'de_at', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-ch' => array('language' => 'German (Swiss)', 'locale' => 'de_ch', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-de' => array('language' => 'German (Germany)', 'locale' => 'de_de', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-li' => array('language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'de-lu' => array('language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('el')); - $expected = array( - 'el' => array('language' => 'Greek', 'locale' => 'ell', 'localeFallback' => 'ell', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('en', 'en-au', 'en-bz', 'en-ca', 'en-gb', 'en-ie', 'en-jm', 'en-nz', 'en-tt', 'en-us', 'en-za')); - $expected = array( - 'en' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-au' => array('language' => 'English (Australian)', 'locale' => 'en_au', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-bz' => array('language' => 'English (Belize)', 'locale' => 'en_bz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-ca' => array('language' => 'English (Canadian)', 'locale' => 'en_ca', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-gb' => array('language' => 'English (British)', 'locale' => 'en_gb', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-ie' => array('language' => 'English (Ireland)', 'locale' => 'en_ie', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-jm' => array('language' => 'English (Jamaica)', 'locale' => 'en_jm', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-tt' => array('language' => 'English (Trinidad)', 'locale' => 'en_tt', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-us' => array('language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'en-za' => array('language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr') - ); - $this->assertEquals($expected, $result); - - $result = $localize->catalog(array('es', 'es-ar', 'es-bo', 'es-cl', 'es-co', 'es-cr', 'es-do', 'es-ec', 'es-es', 'es-gt', 'es-hn', - 'es-mx', 'es-ni', 'es-pa', 'es-pe', 'es-pr', 'es-py', 'es-sv', 'es-uy', 'es-ve')); - $expected = array( - 'es' => array('language' => 'Spanish (Spain - Traditional)', 'locale' => 'spa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-ar' => array('language' => 'Spanish (Argentina)', 'locale' => 'es_ar', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-bo' => array('language' => 'Spanish (Bolivia)', 'locale' => 'es_bo', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-cl' => array('language' => 'Spanish (Chile)', 'locale' => 'es_cl', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-co' => array('language' => 'Spanish (Colombia)', 'locale' => 'es_co', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-cr' => array('language' => 'Spanish (Costa Rica)', 'locale' => 'es_cr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-ec' => array('language' => 'Spanish (Ecuador)', 'locale' => 'es_ec', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-es' => array('language' => 'Spanish (Spain)', 'locale' => 'es_es', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-gt' => array('language' => 'Spanish (Guatemala)', 'locale' => 'es_gt', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-hn' => array('language' => 'Spanish (Honduras)', 'locale' => 'es_hn', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-mx' => array('language' => 'Spanish (Mexican)', 'locale' => 'es_mx', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-ni' => array('language' => 'Spanish (Nicaragua)', 'locale' => 'es_ni', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-pa' => array('language' => 'Spanish (Panama)', 'locale' => 'es_pa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-pe' => array('language' => 'Spanish (Peru)', 'locale' => 'es_pe', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-pr' => array('language' => 'Spanish (Puerto Rico)', 'locale' => 'es_pr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-py' => array('language' => 'Spanish (Paraguay)', 'locale' => 'es_py', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-sv' => array('language' => 'Spanish (El Salvador)', 'locale' => 'es_sv', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-uy' => array('language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-ve' => array('language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['af']); + $expected = [ + 'af' => ['language' => 'Afrikaans', 'locale' => 'afr', 'localeFallback' => 'afr', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['ar', 'ar-ae', 'ar-bh', 'ar-dz', 'ar-eg', 'ar-iq', 'ar-jo', 'ar-kw', 'ar-lb', 'ar-ly', 'ar-ma', + 'ar-om', 'ar-qa', 'ar-sa', 'ar-sy', 'ar-tn', 'ar-ye']); + $expected = [ + 'ar' => ['language' => 'Arabic', 'locale' => 'ara', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-ae' => ['language' => 'Arabic (U.A.E.)', 'locale' => 'ar_ae', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-bh' => ['language' => 'Arabic (Bahrain)', 'locale' => 'ar_bh', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-dz' => ['language' => 'Arabic (Algeria)', 'locale' => 'ar_dz', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-eg' => ['language' => 'Arabic (Egypt)', 'locale' => 'ar_eg', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-iq' => ['language' => 'Arabic (Iraq)', 'locale' => 'ar_iq', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-jo' => ['language' => 'Arabic (Jordan)', 'locale' => 'ar_jo', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-kw' => ['language' => 'Arabic (Kuwait)', 'locale' => 'ar_kw', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-lb' => ['language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-ly' => ['language' => 'Arabic (Libya)', 'locale' => 'ar_ly', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-ma' => ['language' => 'Arabic (Morocco)', 'locale' => 'ar_ma', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-om' => ['language' => 'Arabic (Oman)', 'locale' => 'ar_om', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-qa' => ['language' => 'Arabic (Qatar)', 'locale' => 'ar_qa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-sa' => ['language' => 'Arabic (Saudi Arabia)', 'locale' => 'ar_sa', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-sy' => ['language' => 'Arabic (Syria)', 'locale' => 'ar_sy', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-tn' => ['language' => 'Arabic (Tunisia)', 'locale' => 'ar_tn', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'ar-ye' => ['language' => 'Arabic (Yemen)', 'locale' => 'ar_ye', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['be']); + $expected = [ + 'be' => ['language' => 'Byelorussian', 'locale' => 'bel', 'localeFallback' => 'bel', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['bg']); + $expected = [ + 'bg' => ['language' => 'Bulgarian', 'locale' => 'bul', 'localeFallback' => 'bul', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['bs']); + $expected = [ + 'bs' => ['language' => 'Bosnian', 'locale' => 'bos', 'localeFallback' => 'bos', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['ca']); + $expected = [ + 'ca' => ['language' => 'Catalan', 'locale' => 'cat', 'localeFallback' => 'cat', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['cs']); + $expected = [ + 'cs' => ['language' => 'Czech', 'locale' => 'ces', 'localeFallback' => 'ces', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['da']); + $expected = [ + 'da' => ['language' => 'Danish', 'locale' => 'dan', 'localeFallback' => 'dan', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['de', 'de-at', 'de-ch', 'de-de', 'de-li', 'de-lu']); + $expected = [ + 'de' => ['language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-at' => ['language' => 'German (Austria)', 'locale' => 'de_at', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-ch' => ['language' => 'German (Swiss)', 'locale' => 'de_ch', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-de' => ['language' => 'German (Germany)', 'locale' => 'de_de', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-li' => ['language' => 'German (Liechtenstein)', 'locale' => 'de_li', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'de-lu' => ['language' => 'German (Luxembourg)', 'locale' => 'de_lu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['el']); + $expected = [ + 'el' => ['language' => 'Greek', 'locale' => 'ell', 'localeFallback' => 'ell', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['en', 'en-au', 'en-bz', 'en-ca', 'en-gb', 'en-ie', 'en-jm', 'en-nz', 'en-tt', 'en-us', 'en-za']); + $expected = [ + 'en' => ['language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-au' => ['language' => 'English (Australian)', 'locale' => 'en_au', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-bz' => ['language' => 'English (Belize)', 'locale' => 'en_bz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-ca' => ['language' => 'English (Canadian)', 'locale' => 'en_ca', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-gb' => ['language' => 'English (British)', 'locale' => 'en_gb', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-ie' => ['language' => 'English (Ireland)', 'locale' => 'en_ie', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-jm' => ['language' => 'English (Jamaica)', 'locale' => 'en_jm', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-nz' => ['language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-tt' => ['language' => 'English (Trinidad)', 'locale' => 'en_tt', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-us' => ['language' => 'English (United States)', 'locale' => 'en_us', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'en-za' => ['language' => 'English (South Africa)', 'locale' => 'en_za', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; + $this->assertEquals($expected, $result); + + $result = $localize->catalog(['es', 'es-ar', 'es-bo', 'es-cl', 'es-co', 'es-cr', 'es-do', 'es-ec', 'es-es', 'es-gt', 'es-hn', + 'es-mx', 'es-ni', 'es-pa', 'es-pe', 'es-pr', 'es-py', 'es-sv', 'es-uy', 'es-ve']); + $expected = [ + 'es' => ['language' => 'Spanish (Spain - Traditional)', 'locale' => 'spa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-ar' => ['language' => 'Spanish (Argentina)', 'locale' => 'es_ar', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-bo' => ['language' => 'Spanish (Bolivia)', 'locale' => 'es_bo', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-cl' => ['language' => 'Spanish (Chile)', 'locale' => 'es_cl', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-co' => ['language' => 'Spanish (Colombia)', 'locale' => 'es_co', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-cr' => ['language' => 'Spanish (Costa Rica)', 'locale' => 'es_cr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-do' => ['language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-ec' => ['language' => 'Spanish (Ecuador)', 'locale' => 'es_ec', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-es' => ['language' => 'Spanish (Spain)', 'locale' => 'es_es', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-gt' => ['language' => 'Spanish (Guatemala)', 'locale' => 'es_gt', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-hn' => ['language' => 'Spanish (Honduras)', 'locale' => 'es_hn', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-mx' => ['language' => 'Spanish (Mexican)', 'locale' => 'es_mx', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-ni' => ['language' => 'Spanish (Nicaragua)', 'locale' => 'es_ni', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-pa' => ['language' => 'Spanish (Panama)', 'locale' => 'es_pa', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-pe' => ['language' => 'Spanish (Peru)', 'locale' => 'es_pe', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-pr' => ['language' => 'Spanish (Puerto Rico)', 'locale' => 'es_pr', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-py' => ['language' => 'Spanish (Paraguay)', 'locale' => 'es_py', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-sv' => ['language' => 'Spanish (El Salvador)', 'locale' => 'es_sv', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-uy' => ['language' => 'Spanish (Uruguay)', 'locale' => 'es_uy', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-ve' => ['language' => 'Spanish (Venezuela)', 'locale' => 'es_ve', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('et')); - $expected = array( - 'et' => array('language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['et']); + $expected = [ + 'et' => ['language' => 'Estonian', 'locale' => 'est', 'localeFallback' => 'est', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('eu')); - $expected = array( - 'eu' => array('language' => 'Basque', 'locale' => 'eus', 'localeFallback' => 'eus', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['eu']); + $expected = [ + 'eu' => ['language' => 'Basque', 'locale' => 'eus', 'localeFallback' => 'eus', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('fa')); - $expected = array( - 'fa' => array('language' => 'Farsi', 'locale' => 'fas', 'localeFallback' => 'fas', 'charset' => 'utf-8', 'direction' => 'rtl') - ); + $result = $localize->catalog(['fa']); + $expected = [ + 'fa' => ['language' => 'Farsi', 'locale' => 'fas', 'localeFallback' => 'fas', 'charset' => 'utf-8', 'direction' => 'rtl'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('fi')); - $expected = array( - 'fi' => array('language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['fi']); + $expected = [ + 'fi' => ['language' => 'Finnish', 'locale' => 'fin', 'localeFallback' => 'fin', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('fo')); - $expected = array( - 'fo' => array('language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['fo']); + $expected = [ + 'fo' => ['language' => 'Faeroese', 'locale' => 'fao', 'localeFallback' => 'fao', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('fr', 'fr-be', 'fr-ca', 'fr-ch', 'fr-fr', 'fr-lu')); - $expected = array( - 'fr' => array('language' => 'French (Standard)', 'locale' => 'fra', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-be' => array('language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-ca' => array('language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-ch' => array('language' => 'French (Swiss)', 'locale' => 'fr_ch', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-fr' => array('language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'fr-lu' => array('language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['fr', 'fr-be', 'fr-ca', 'fr-ch', 'fr-fr', 'fr-lu']); + $expected = [ + 'fr' => ['language' => 'French (Standard)', 'locale' => 'fra', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-be' => ['language' => 'French (Belgium)', 'locale' => 'fr_be', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-ca' => ['language' => 'French (Canadian)', 'locale' => 'fr_ca', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-ch' => ['language' => 'French (Swiss)', 'locale' => 'fr_ch', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-fr' => ['language' => 'French (France)', 'locale' => 'fr_fr', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'fr-lu' => ['language' => 'French (Luxembourg)', 'locale' => 'fr_lu', 'localeFallback' => 'fra', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('ga')); - $expected = array( - 'ga' => array('language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['ga']); + $expected = [ + 'ga' => ['language' => 'Irish', 'locale' => 'gle', 'localeFallback' => 'gle', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('gd', 'gd-ie')); - $expected = array( - 'gd' => array('language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'gd-ie' => array('language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['gd', 'gd-ie']); + $expected = [ + 'gd' => ['language' => 'Gaelic (Scots)', 'locale' => 'gla', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'gd-ie' => ['language' => 'Gaelic (Irish)', 'locale' => 'gd_ie', 'localeFallback' => 'gla', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('gl')); - $expected = array( - 'gl' => array('language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['gl']); + $expected = [ + 'gl' => ['language' => 'Galician', 'locale' => 'glg', 'localeFallback' => 'glg', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('he')); - $expected = array( - 'he' => array('language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8', 'direction' => 'rtl') - ); + $result = $localize->catalog(['he']); + $expected = [ + 'he' => ['language' => 'Hebrew', 'locale' => 'heb', 'localeFallback' => 'heb', 'charset' => 'utf-8', 'direction' => 'rtl'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('hi')); - $expected = array( - 'hi' => array('language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['hi']); + $expected = [ + 'hi' => ['language' => 'Hindi', 'locale' => 'hin', 'localeFallback' => 'hin', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('hr')); - $expected = array( - 'hr' => array('language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['hr']); + $expected = [ + 'hr' => ['language' => 'Croatian', 'locale' => 'hrv', 'localeFallback' => 'hrv', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('hu')); - $expected = array( - 'hu' => array('language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['hu']); + $expected = [ + 'hu' => ['language' => 'Hungarian', 'locale' => 'hun', 'localeFallback' => 'hun', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('hy')); - $expected = array( - 'hy' => array('language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['hy']); + $expected = [ + 'hy' => ['language' => 'Armenian - Armenia', 'locale' => 'hye', 'localeFallback' => 'hye', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('id')); - $expected = array( - 'id' => array('language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'), - ); + $result = $localize->catalog(['id']); + $expected = [ + 'id' => ['language' => 'Indonesian', 'locale' => 'ind', 'localeFallback' => 'ind', 'charset' => 'utf-8', 'direction' => 'ltr'], + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('is')); - $expected = array( - 'is' => array('language' => 'Icelandic', 'locale' => 'isl', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['is']); + $expected = [ + 'is' => ['language' => 'Icelandic', 'locale' => 'isl', 'localeFallback' => 'isl', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('it', 'it-ch')); - $expected = array( - 'it' => array('language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'it-ch' => array('language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['it', 'it-ch']); + $expected = [ + 'it' => ['language' => 'Italian', 'locale' => 'ita', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'it-ch' => ['language' => 'Italian (Swiss) ', 'locale' => 'it_ch', 'localeFallback' => 'ita', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('ja')); - $expected = array( - 'ja' => array('language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['ja']); + $expected = [ + 'ja' => ['language' => 'Japanese', 'locale' => 'jpn', 'localeFallback' => 'jpn', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('kk')); - $expected = array( - 'kk' => array('language' => 'Kazakh', 'locale' => 'kaz', 'localeFallback' => 'kaz', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['kk']); + $expected = [ + 'kk' => ['language' => 'Kazakh', 'locale' => 'kaz', 'localeFallback' => 'kaz', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('ko', 'ko-kp', 'ko-kr')); - $expected = array( - 'ko' => array('language' => 'Korean', 'locale' => 'kor', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), - 'ko-kp' => array('language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'), - 'ko-kr' => array('language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr') - ); + $result = $localize->catalog(['ko', 'ko-kp', 'ko-kr']); + $expected = [ + 'ko' => ['language' => 'Korean', 'locale' => 'kor', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'], + 'ko-kp' => ['language' => 'Korea (North)', 'locale' => 'ko_kp', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'], + 'ko-kr' => ['language' => 'Korea (South)', 'locale' => 'ko_kr', 'localeFallback' => 'kor', 'charset' => 'kr', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('koi8-r', 'ru', 'ru-mo')); - $expected = array( - 'koi8-r' => array('language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r', 'direction' => 'ltr'), - 'ru' => array('language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ru-mo' => array('language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['koi8-r', 'ru', 'ru-mo']); + $expected = [ + 'koi8-r' => ['language' => 'Russian', 'locale' => 'koi8_r', 'localeFallback' => 'rus', 'charset' => 'koi8-r', 'direction' => 'ltr'], + 'ru' => ['language' => 'Russian', 'locale' => 'rus', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ru-mo' => ['language' => 'Russian (Moldavia)', 'locale' => 'ru_mo', 'localeFallback' => 'rus', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('lt')); - $expected = array( - 'lt' => array('language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['lt']); + $expected = [ + 'lt' => ['language' => 'Lithuanian', 'locale' => 'lit', 'localeFallback' => 'lit', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('lv')); - $expected = array( - 'lv' => array('language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['lv']); + $expected = [ + 'lv' => ['language' => 'Latvian', 'locale' => 'lav', 'localeFallback' => 'lav', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('mk', 'mk-mk')); - $expected = array( - 'mk' => array('language' => 'FYRO Macedonian', 'locale' => 'mkd', 'localeFallback' => 'mkd', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'mk-mk' => array('language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mkd', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['mk', 'mk-mk']); + $expected = [ + 'mk' => ['language' => 'FYRO Macedonian', 'locale' => 'mkd', 'localeFallback' => 'mkd', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'mk-mk' => ['language' => 'Macedonian', 'locale' => 'mk_mk', 'localeFallback' => 'mkd', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('ms')); - $expected = array( - 'ms' => array('language' => 'Malaysian', 'locale' => 'msa', 'localeFallback' => 'msa', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['ms']); + $expected = [ + 'ms' => ['language' => 'Malaysian', 'locale' => 'msa', 'localeFallback' => 'msa', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('mt')); - $expected = array( - 'mt' => array('language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['mt']); + $expected = [ + 'mt' => ['language' => 'Maltese', 'locale' => 'mlt', 'localeFallback' => 'mlt', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('nl', 'nl-be')); - $expected = array( - 'nl' => array('language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'nl-be' => array('language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['nl', 'nl-be']); + $expected = [ + 'nl' => ['language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'nl-be' => ['language' => 'Dutch (Belgium)', 'locale' => 'nl_be', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); $result = $localize->catalog('nl'); - $expected = array('language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'); + $expected = ['language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr']; $this->assertEquals($expected, $result); $result = $localize->catalog('nld'); - $expected = array('language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'); + $expected = ['language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr']; $this->assertEquals($expected, $result); $result = $localize->catalog('dut'); - $expected = array('language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr'); + $expected = ['language' => 'Dutch (Standard)', 'locale' => 'nld', 'localeFallback' => 'nld', 'charset' => 'utf-8', 'direction' => 'ltr']; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('nb')); - $expected = array( - 'nb' => array('language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['nb']); + $expected = [ + 'nb' => ['language' => 'Norwegian Bokmal', 'locale' => 'nob', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('nn', 'no')); - $expected = array( - 'nn' => array('language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'no' => array('language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['nn', 'no']); + $expected = [ + 'nn' => ['language' => 'Norwegian Nynorsk', 'locale' => 'nno', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'no' => ['language' => 'Norwegian', 'locale' => 'nor', 'localeFallback' => 'nor', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('pl')); - $expected = array( - 'pl' => array('language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['pl']); + $expected = [ + 'pl' => ['language' => 'Polish', 'locale' => 'pol', 'localeFallback' => 'pol', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('pt', 'pt-br')); - $expected = array( - 'pt' => array('language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['pt', 'pt-br']); + $expected = [ + 'pt' => ['language' => 'Portuguese (Portugal)', 'locale' => 'por', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'pt-br' => ['language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('rm')); - $expected = array( - 'rm' => array('language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['rm']); + $expected = [ + 'rm' => ['language' => 'Rhaeto-Romanic', 'locale' => 'roh', 'localeFallback' => 'roh', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('ro', 'ro-mo')); - $expected = array( - 'ro' => array('language' => 'Romanian', 'locale' => 'ron', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ro-mo' => array('language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['ro', 'ro-mo']); + $expected = [ + 'ro' => ['language' => 'Romanian', 'locale' => 'ron', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ro-mo' => ['language' => 'Romanian (Moldavia)', 'locale' => 'ro_mo', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('sb')); - $expected = array( - 'sb' => array('language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['sb']); + $expected = [ + 'sb' => ['language' => 'Sorbian', 'locale' => 'wen', 'localeFallback' => 'wen', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('sk')); - $expected = array( - 'sk' => array('language' => 'Slovak', 'locale' => 'slk', 'localeFallback' => 'slk', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['sk']); + $expected = [ + 'sk' => ['language' => 'Slovak', 'locale' => 'slk', 'localeFallback' => 'slk', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('sl')); - $expected = array( - 'sl' => array('language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['sl']); + $expected = [ + 'sl' => ['language' => 'Slovenian', 'locale' => 'slv', 'localeFallback' => 'slv', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('sq')); - $expected = array( - 'sq' => array('language' => 'Albanian', 'locale' => 'sqi', 'localeFallback' => 'sqi', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['sq']); + $expected = [ + 'sq' => ['language' => 'Albanian', 'locale' => 'sqi', 'localeFallback' => 'sqi', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('sr')); - $expected = array( - 'sr' => array('language' => 'Serbian', 'locale' => 'srp', 'localeFallback' => 'srp', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['sr']); + $expected = [ + 'sr' => ['language' => 'Serbian', 'locale' => 'srp', 'localeFallback' => 'srp', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('sv', 'sv-fi')); - $expected = array( - 'sv' => array('language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'sv-fi' => array('language' => 'Swedish (Finland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['sv', 'sv-fi']); + $expected = [ + 'sv' => ['language' => 'Swedish', 'locale' => 'swe', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'sv-fi' => ['language' => 'Swedish (Finland)', 'locale' => 'sv_fi', 'localeFallback' => 'swe', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('se')); - $expected = array( - 'se' => array('language' => 'Sami', 'locale' => 'sme', 'localeFallback' => 'sme', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['se']); + $expected = [ + 'se' => ['language' => 'Sami', 'locale' => 'sme', 'localeFallback' => 'sme', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('th')); - $expected = array( - 'th' => array('language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['th']); + $expected = [ + 'th' => ['language' => 'Thai', 'locale' => 'tha', 'localeFallback' => 'tha', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('tn')); - $expected = array( - 'tn' => array('language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['tn']); + $expected = [ + 'tn' => ['language' => 'Tswana', 'locale' => 'tsn', 'localeFallback' => 'tsn', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('tr')); - $expected = array( - 'tr' => array('language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['tr']); + $expected = [ + 'tr' => ['language' => 'Turkish', 'locale' => 'tur', 'localeFallback' => 'tur', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('ts')); - $expected = array( - 'ts' => array('language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['ts']); + $expected = [ + 'ts' => ['language' => 'Tsonga', 'locale' => 'tso', 'localeFallback' => 'tso', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('uk')); - $expected = array( - 'uk' => array('language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['uk']); + $expected = [ + 'uk' => ['language' => 'Ukrainian', 'locale' => 'ukr', 'localeFallback' => 'ukr', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('ur')); - $expected = array( - 'ur' => array('language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl') - ); + $result = $localize->catalog(['ur']); + $expected = [ + 'ur' => ['language' => 'Urdu', 'locale' => 'urd', 'localeFallback' => 'urd', 'charset' => 'utf-8', 'direction' => 'rtl'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('ve')); - $expected = array( - 've' => array('language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['ve']); + $expected = [ + 've' => ['language' => 'Venda', 'locale' => 'ven', 'localeFallback' => 'ven', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('vi')); - $expected = array( - 'vi' => array('language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['vi']); + $expected = [ + 'vi' => ['language' => 'Vietnamese', 'locale' => 'vie', 'localeFallback' => 'vie', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('cy')); - $expected = array( - 'cy' => array('language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8', - 'direction' => 'ltr') - ); + $result = $localize->catalog(['cy']); + $expected = [ + 'cy' => ['language' => 'Welsh', 'locale' => 'cym', 'localeFallback' => 'cym', 'charset' => 'utf-8', + 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('xh')); - $expected = array( - 'xh' => array('language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['xh']); + $expected = [ + 'xh' => ['language' => 'Xhosa', 'locale' => 'xho', 'localeFallback' => 'xho', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('yi')); - $expected = array( - 'yi' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['yi']); + $expected = [ + 'yi' => ['language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('zh', 'zh-cn', 'zh-hk', 'zh-sg', 'zh-tw')); - $expected = array( - 'zh' => array('language' => 'Chinese', 'locale' => 'zho', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zh-cn' => array('language' => 'Chinese (PRC)', 'locale' => 'zh_cn', 'localeFallback' => 'zho', 'charset' => 'GB2312', 'direction' => 'ltr'), - 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zh-sg' => array('language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zh-tw' => array('language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['zh', 'zh-cn', 'zh-hk', 'zh-sg', 'zh-tw']); + $expected = [ + 'zh' => ['language' => 'Chinese', 'locale' => 'zho', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zh-cn' => ['language' => 'Chinese (PRC)', 'locale' => 'zh_cn', 'localeFallback' => 'zho', 'charset' => 'GB2312', 'direction' => 'ltr'], + 'zh-hk' => ['language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zh-sg' => ['language' => 'Chinese (Singapore)', 'locale' => 'zh_sg', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zh-tw' => ['language' => 'Chinese (Taiwan)', 'locale' => 'zh_tw', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('zu')); - $expected = array( - 'zu' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['zu']); + $expected = [ + 'zu' => ['language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('en-nz', 'es-do', 'ar-lb', 'zh-hk', 'pt-br')); - $expected = array( - 'en-nz' => array('language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'es-do' => array('language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'ar-lb' => array('language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'), - 'zh-hk' => array('language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['en-nz', 'es-do', 'ar-lb', 'zh-hk', 'pt-br']); + $expected = [ + 'en-nz' => ['language' => 'English (New Zealand)', 'locale' => 'en_nz', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'es-do' => ['language' => 'Spanish (Dominican Republic)', 'locale' => 'es_do', 'localeFallback' => 'spa', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'ar-lb' => ['language' => 'Arabic (Lebanon)', 'locale' => 'ar_lb', 'localeFallback' => 'ara', 'charset' => 'utf-8', 'direction' => 'rtl'], + 'zh-hk' => ['language' => 'Chinese (Hong Kong)', 'locale' => 'zh_hk', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'pt-br' => ['language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); - $result = $localize->catalog(array('eng', 'deu', 'zho', 'rum', 'zul', 'yid')); - $expected = array( - 'eng' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'deu' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zho' => array('language' => 'Chinese', 'locale' => 'zho', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'rum' => array('language' => 'Romanian', 'locale' => 'ron', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'zul' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr'), - 'yid' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr') - ); + $result = $localize->catalog(['eng', 'deu', 'zho', 'rum', 'zul', 'yid']); + $expected = [ + 'eng' => ['language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'deu' => ['language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zho' => ['language' => 'Chinese', 'locale' => 'zho', 'localeFallback' => 'zho', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'rum' => ['language' => 'Romanian', 'locale' => 'ron', 'localeFallback' => 'ron', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'zul' => ['language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8', 'direction' => 'ltr'], + 'yid' => ['language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8', 'direction' => 'ltr'] + ]; $this->assertEquals($expected, $result); } } diff --git a/lib/Cake/Test/Case/I18n/MultibyteTest.php b/lib/Cake/Test/Case/I18n/MultibyteTest.php index 48a3fde68d..84c41ab668 100644 --- a/lib/Cake/Test/Case/I18n/MultibyteTest.php +++ b/lib/Cake/Test/Case/I18n/MultibyteTest.php @@ -33,315 +33,315 @@ class MultibyteTest extends CakeTestCase { public function testUtf8() { $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; $result = Multibyte::utf8($string); - $expected = array(33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + $expected = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126); + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126]; $this->assertEquals($expected, $result); $string = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; $result = Multibyte::utf8($string); - $expected = array(161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, - 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200); + $expected = [161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]; $this->assertEquals($expected, $result); $string = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; $result = Multibyte::utf8($string); - $expected = array(201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + $expected = [201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300); + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300]; $this->assertEquals($expected, $result); $string = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; $result = Multibyte::utf8($string); - $expected = array(301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, + $expected = [301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400); + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400]; $this->assertEquals($expected, $result); $string = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; $result = Multibyte::utf8($string); - $expected = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, + $expected = [401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, - 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500); + 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500]; $this->assertEquals($expected, $result); $string = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; $result = Multibyte::utf8($string); - $expected = array(601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, + $expected = [601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, - 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700); + 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700]; $this->assertEquals($expected, $result); $string = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; $result = Multibyte::utf8($string); - $expected = array(1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, - 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051); + $expected = [1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, + 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051]; $this->assertEquals($expected, $result); $string = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; $result = Multibyte::utf8($string); - $expected = array(1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, + $expected = [1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, - 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100); + 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100]; $this->assertEquals($expected, $result); $string = 'չպջռսվտ'; $result = Multibyte::utf8($string); - $expected = array(1401, 1402, 1403, 1404, 1405, 1406, 1407); + $expected = [1401, 1402, 1403, 1404, 1405, 1406, 1407]; $this->assertEquals($expected, $result); $string = 'فقكلمنهوىيًٌٍَُ'; $result = Multibyte::utf8($string); - $expected = array(1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615); + $expected = [1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615]; $this->assertEquals($expected, $result); $string = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; $result = Multibyte::utf8($string); - $expected = array(10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10041, 10042, 10043, 10044, + $expected = [10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10041, 10042, 10043, 10044, 10045, 10046, 10047, 10048, 10049, 10050, 10051, 10052, 10053, 10054, 10055, 10056, 10057, 10058, 10059, 10060, 10061, 10062, 10063, 10064, 10065, 10066, 10067, 10068, 10069, 10070, - 10071, 10072, 10073, 10074, 10075, 10076, 10077, 10078); + 10071, 10072, 10073, 10074, 10075, 10076, 10077, 10078]; $this->assertEquals($expected, $result); $string = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; $result = Multibyte::utf8($string); - $expected = array(11904, 11905, 11906, 11907, 11908, 11909, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, 11918, 11919, + $expected = [11904, 11905, 11906, 11907, 11908, 11909, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, 11918, 11919, 11920, 11921, 11922, 11923, 11924, 11925, 11926, 11927, 11928, 11929, 11931, 11932, 11933, 11934, 11935, 11936, 11937, 11938, 11939, 11940, 11941, 11942, 11943, 11944, 11945, 11946, 11947, 11948, 11949, 11950, 11951, 11952, 11953, 11954, 11955, 11956, 11957, 11958, 11959, 11960, 11961, 11962, 11963, 11964, 11965, 11966, 11967, 11968, 11969, 11970, 11971, 11972, 11973, 11974, 11975, 11976, 11977, 11978, 11979, 11980, 11981, 11982, 11983, 11984, - 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, 11995, 11996, 11997, 11998, 11999, 12000); + 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, 11995, 11996, 11997, 11998, 11999, 12000]; $this->assertEquals($expected, $result); $string = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; $result = Multibyte::utf8($string); - $expected = array(12101, 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, 12112, 12113, 12114, 12115, 12116, + $expected = [12101, 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, 12112, 12113, 12114, 12115, 12116, 12117, 12118, 12119, 12120, 12121, 12122, 12123, 12124, 12125, 12126, 12127, 12128, 12129, 12130, 12131, 12132, 12133, 12134, 12135, 12136, 12137, 12138, 12139, 12140, 12141, 12142, 12143, 12144, 12145, 12146, 12147, 12148, - 12149, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12159); + 12149, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12159]; $this->assertEquals($expected, $result); $string = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; $result = Multibyte::utf8($string); - $expected = array(45601, 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, 45612, 45613, 45614, 45615, 45616, + $expected = [45601, 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, 45612, 45613, 45614, 45615, 45616, 45617, 45618, 45619, 45620, 45621, 45622, 45623, 45624, 45625, 45626, 45627, 45628, 45629, 45630, 45631, 45632, 45633, 45634, 45635, 45636, 45637, 45638, 45639, 45640, 45641, 45642, 45643, 45644, 45645, 45646, 45647, 45648, 45649, 45650, 45651, 45652, 45653, 45654, 45655, 45656, 45657, 45658, 45659, 45660, 45661, 45662, 45663, 45664, 45665, 45666, 45667, 45668, 45669, 45670, 45671, 45672, 45673, 45674, 45675, 45676, 45677, 45678, 45679, 45680, 45681, 45682, 45683, 45684, 45685, 45686, 45687, 45688, 45689, 45690, 45691, 45692, 45693, 45694, 45695, 45696, - 45697, 45698, 45699, 45700); + 45697, 45698, 45699, 45700]; $this->assertEquals($expected, $result); $string = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; $result = Multibyte::utf8($string); - $expected = array(65136, 65137, 65138, 65139, 65140, 65141, 65142, 65143, 65144, 65145, 65146, 65147, 65148, 65149, 65150, 65151, + $expected = [65136, 65137, 65138, 65139, 65140, 65141, 65142, 65143, 65144, 65145, 65146, 65147, 65148, 65149, 65150, 65151, 65152, 65153, 65154, 65155, 65156, 65157, 65158, 65159, 65160, 65161, 65162, 65163, 65164, 65165, 65166, 65167, 65168, 65169, 65170, 65171, 65172, 65173, 65174, 65175, 65176, 65177, 65178, 65179, 65180, 65181, 65182, 65183, 65184, 65185, 65186, 65187, 65188, 65189, 65190, 65191, 65192, 65193, 65194, 65195, 65196, 65197, 65198, 65199, - 65200); + 65200]; $this->assertEquals($expected, $result); $string = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; $result = Multibyte::utf8($string); - $expected = array(65201, 65202, 65203, 65204, 65205, 65206, 65207, 65208, 65209, 65210, 65211, 65212, 65213, 65214, 65215, 65216, + $expected = [65201, 65202, 65203, 65204, 65205, 65206, 65207, 65208, 65209, 65210, 65211, 65212, 65213, 65214, 65215, 65216, 65217, 65218, 65219, 65220, 65221, 65222, 65223, 65224, 65225, 65226, 65227, 65228, 65229, 65230, 65231, 65232, 65233, 65234, 65235, 65236, 65237, 65238, 65239, 65240, 65241, 65242, 65243, 65244, 65245, 65246, 65247, 65248, 65249, 65250, 65251, 65252, 65253, 65254, 65255, 65256, 65257, 65258, 65259, 65260, 65261, 65262, 65263, 65264, - 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276); + 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276]; $this->assertEquals($expected, $result); $string = 'abcdefghijklmnopqrstuvwxyz'; $result = Multibyte::utf8($string); - $expected = array(65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, - 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370); + $expected = [65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, + 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370]; $this->assertEquals($expected, $result); $string = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; $result = Multibyte::utf8($string); - $expected = array(65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392, - 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400); + $expected = [65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392, + 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400]; $this->assertEquals($expected, $result); $string = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; $result = Multibyte::utf8($string); - $expected = array(65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, + $expected = [65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, - 65433, 65434, 65435, 65436, 65437, 65438); + 65433, 65434, 65435, 65436, 65437, 65438]; $this->assertEquals($expected, $result); $string = 'Ĥēĺļŏ, Ŵőřļď!'; $result = Multibyte::utf8($string); - $expected = array(292, 275, 314, 316, 335, 44, 32, 372, 337, 345, 316, 271, 33); + $expected = [292, 275, 314, 316, 335, 44, 32, 372, 337, 345, 316, 271, 33]; $this->assertEquals($expected, $result); $string = 'Hello, World!'; $result = Multibyte::utf8($string); - $expected = array(72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33); + $expected = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]; $this->assertEquals($expected, $result); $string = '¨'; $result = Multibyte::utf8($string); - $expected = array(168); + $expected = [168]; $this->assertEquals($expected, $result); $string = '¿'; $result = Multibyte::utf8($string); - $expected = array(191); + $expected = [191]; $this->assertEquals($expected, $result); $string = 'čini'; $result = Multibyte::utf8($string); - $expected = array(269, 105, 110, 105); + $expected = [269, 105, 110, 105]; $this->assertEquals($expected, $result); $string = 'moći'; $result = Multibyte::utf8($string); - $expected = array(109, 111, 263, 105); + $expected = [109, 111, 263, 105]; $this->assertEquals($expected, $result); $string = 'državni'; $result = Multibyte::utf8($string); - $expected = array(100, 114, 382, 97, 118, 110, 105); + $expected = [100, 114, 382, 97, 118, 110, 105]; $this->assertEquals($expected, $result); $string = '把百度设为首页'; $result = Multibyte::utf8($string); - $expected = array(25226, 30334, 24230, 35774, 20026, 39318, 39029); + $expected = [25226, 30334, 24230, 35774, 20026, 39318, 39029]; $this->assertEquals($expected, $result); $string = '一二三周永龍'; $result = Multibyte::utf8($string); - $expected = array(19968, 20108, 19977, 21608, 27704, 40845); + $expected = [19968, 20108, 19977, 21608, 27704, 40845]; $this->assertEquals($expected, $result); $string = 'ԀԂԄԆԈԊԌԎԐԒ'; $result = Multibyte::utf8($string); - $expected = array(1280, 1282, 1284, 1286, 1288, 1290, 1292, 1294, 1296, 1298); + $expected = [1280, 1282, 1284, 1286, 1288, 1290, 1292, 1294, 1296, 1298]; $this->assertEquals($expected, $result); $string = 'ԁԃԅԇԉԋԍԏԐԒ'; $result = Multibyte::utf8($string); - $expected = array(1281, 1283, 1285, 1287, 1289, 1291, 1293, 1295, 1296, 1298); + $expected = [1281, 1283, 1285, 1287, 1289, 1291, 1293, 1295, 1296, 1298]; $this->assertEquals($expected, $result); $string = 'ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖև'; $result = Multibyte::utf8($string); - $expected = array(1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, + $expected = [1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, - 1365, 1366, 1415); + 1365, 1366, 1415]; $this->assertEquals($expected, $result); $string = 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև'; $result = Multibyte::utf8($string); - $expected = array(1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, + $expected = [1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, - 1413, 1414, 1415); + 1413, 1414, 1415]; $this->assertEquals($expected, $result); $string = 'ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ'; $result = Multibyte::utf8($string); - $expected = array(4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, 4272, 4273, + $expected = [4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, 4272, 4273, 4274, 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4289, 4290, 4291, - 4292, 4293); + 4292, 4293]; $this->assertEquals($expected, $result); $string = 'ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẖẗẘẙẚẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ'; $result = Multibyte::utf8($string); - $expected = array(7680, 7682, 7684, 7686, 7688, 7690, 7692, 7694, 7696, 7698, 7700, 7702, 7704, 7706, 7708, 7710, 7712, 7714, + $expected = [7680, 7682, 7684, 7686, 7688, 7690, 7692, 7694, 7696, 7698, 7700, 7702, 7704, 7706, 7708, 7710, 7712, 7714, 7716, 7718, 7720, 7722, 7724, 7726, 7728, 7730, 7732, 7734, 7736, 7738, 7740, 7742, 7744, 7746, 7748, 7750, 7752, 7754, 7756, 7758, 7760, 7762, 7764, 7766, 7768, 7770, 7772, 7774, 7776, 7778, 7780, 7782, 7784, 7786, 7788, 7790, 7792, 7794, 7796, 7798, 7800, 7802, 7804, 7806, 7808, 7810, 7812, 7814, 7816, 7818, 7820, 7822, 7824, 7826, 7828, 7830, 7831, 7832, 7833, 7834, 7840, 7842, 7844, 7846, 7848, 7850, 7852, 7854, 7856, 7858, 7860, 7862, 7864, 7866, 7868, 7870, 7872, 7874, 7876, 7878, 7880, 7882, 7884, 7886, 7888, 7890, 7892, - 7894, 7896, 7898, 7900, 7902, 7904, 7906, 7908, 7910, 7912, 7914, 7916, 7918, 7920, 7922, 7924, 7926, 7928); + 7894, 7896, 7898, 7900, 7902, 7904, 7906, 7908, 7910, 7912, 7914, 7916, 7918, 7920, 7922, 7924, 7926, 7928]; $this->assertEquals($expected, $result); $string = 'ḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ'; $result = Multibyte::utf8($string); - $expected = array(7681, 7683, 7685, 7687, 7689, 7691, 7693, 7695, 7697, 7699, 7701, 7703, 7705, 7707, 7709, 7711, 7713, 7715, + $expected = [7681, 7683, 7685, 7687, 7689, 7691, 7693, 7695, 7697, 7699, 7701, 7703, 7705, 7707, 7709, 7711, 7713, 7715, 7717, 7719, 7721, 7723, 7725, 7727, 7729, 7731, 7733, 7735, 7737, 7739, 7741, 7743, 7745, 7747, 7749, 7751, 7753, 7755, 7757, 7759, 7761, 7763, 7765, 7767, 7769, 7771, 7773, 7775, 7777, 7779, 7781, 7783, 7785, 7787, 7789, 7791, 7793, 7795, 7797, 7799, 7801, 7803, 7805, 7807, 7809, 7811, 7813, 7815, 7817, 7819, 7821, 7823, 7825, 7827, 7829, 7830, 7831, 7832, 7833, 7834, 7841, 7843, 7845, 7847, 7849, 7851, 7853, 7855, 7857, 7859, 7861, 7863, 7865, 7867, 7869, 7871, 7873, 7875, 7877, 7879, 7881, 7883, 7885, 7887, 7889, 7891, 7893, 7895, - 7897, 7899, 7901, 7903, 7905, 7907, 7909, 7911, 7913, 7915, 7917, 7919, 7921, 7923, 7925, 7927, 7929); + 7897, 7899, 7901, 7903, 7905, 7907, 7909, 7911, 7913, 7915, 7917, 7919, 7921, 7923, 7925, 7927, 7929]; $this->assertEquals($expected, $result); $string = 'ΩKÅℲ'; $result = Multibyte::utf8($string); - $expected = array(8486, 8490, 8491, 8498); + $expected = [8486, 8490, 8491, 8498]; $this->assertEquals($expected, $result); $string = 'ωkåⅎ'; $result = Multibyte::utf8($string); - $expected = array(969, 107, 229, 8526); + $expected = [969, 107, 229, 8526]; $this->assertEquals($expected, $result); $string = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃ'; $result = Multibyte::utf8($string); - $expected = array(8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 8554, 8555, 8556, 8557, 8558, 8559, 8579); + $expected = [8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 8554, 8555, 8556, 8557, 8558, 8559, 8579]; $this->assertEquals($expected, $result); $string = 'ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↄ'; $result = Multibyte::utf8($string); - $expected = array(8560, 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8570, 8571, 8572, 8573, 8574, 8575, 8580); + $expected = [8560, 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8570, 8571, 8572, 8573, 8574, 8575, 8580]; $this->assertEquals($expected, $result); $string = 'ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ'; $result = Multibyte::utf8($string); - $expected = array(9398, 9399, 9400, 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409, 9410, 9411, 9412, 9413, 9414, - 9415, 9416, 9417, 9418, 9419, 9420, 9421, 9422, 9423); + $expected = [9398, 9399, 9400, 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409, 9410, 9411, 9412, 9413, 9414, + 9415, 9416, 9417, 9418, 9419, 9420, 9421, 9422, 9423]; $this->assertEquals($expected, $result); $string = 'ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ'; $result = Multibyte::utf8($string); - $expected = array(9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433, 9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441, - 9442, 9443, 9444, 9445, 9446, 9447, 9448, 9449); + $expected = [9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433, 9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441, + 9442, 9443, 9444, 9445, 9446, 9447, 9448, 9449]; $this->assertEquals($expected, $result); $string = 'ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮ'; $result = Multibyte::utf8($string); - $expected = array(11264, 11265, 11266, 11267, 11268, 11269, 11270, 11271, 11272, 11273, 11274, 11275, 11276, 11277, 11278, + $expected = [11264, 11265, 11266, 11267, 11268, 11269, 11270, 11271, 11272, 11273, 11274, 11275, 11276, 11277, 11278, 11279, 11280, 11281, 11282, 11283, 11284, 11285, 11286, 11287, 11288, 11289, 11290, 11291, 11292, 11293, 11294, 11295, 11296, 11297, 11298, 11299, 11300, 11301, 11302, 11303, 11304, 11305, 11306, 11307, 11308, - 11309, 11310); + 11309, 11310]; $this->assertEquals($expected, $result); $string = 'ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞ'; $result = Multibyte::utf8($string); - $expected = array(11312, 11313, 11314, 11315, 11316, 11317, 11318, 11319, 11320, 11321, 11322, 11323, 11324, 11325, 11326, 11327, + $expected = [11312, 11313, 11314, 11315, 11316, 11317, 11318, 11319, 11320, 11321, 11322, 11323, 11324, 11325, 11326, 11327, 11328, 11329, 11330, 11331, 11332, 11333, 11334, 11335, 11336, 11337, 11338, 11339, 11340, 11341, 11342, 11343, - 11344, 11345, 11346, 11347, 11348, 11349, 11350, 11351, 11352, 11353, 11354, 11355, 11356, 11357, 11358); + 11344, 11345, 11346, 11347, 11348, 11349, 11350, 11351, 11352, 11353, 11354, 11355, 11356, 11357, 11358]; $this->assertEquals($expected, $result); $string = 'ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢ'; $result = Multibyte::utf8($string); - $expected = array(11392, 11394, 11396, 11398, 11400, 11402, 11404, 11406, 11408, 11410, 11412, 11414, 11416, 11418, 11420, + $expected = [11392, 11394, 11396, 11398, 11400, 11402, 11404, 11406, 11408, 11410, 11412, 11414, 11416, 11418, 11420, 11422, 11424, 11426, 11428, 11430, 11432, 11434, 11436, 11438, 11440, 11442, 11444, 11446, 11448, 11450, 11452, 11454, 11456, 11458, 11460, 11462, 11464, 11466, 11468, 11470, 11472, 11474, 11476, 11478, 11480, - 11482, 11484, 11486, 11488, 11490); + 11482, 11484, 11486, 11488, 11490]; $this->assertEquals($expected, $result); $string = 'ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ'; $result = Multibyte::utf8($string); - $expected = array(11393, 11395, 11397, 11399, 11401, 11403, 11405, 11407, 11409, 11411, 11413, 11415, 11417, 11419, 11421, 11423, + $expected = [11393, 11395, 11397, 11399, 11401, 11403, 11405, 11407, 11409, 11411, 11413, 11415, 11417, 11419, 11421, 11423, 11425, 11427, 11429, 11431, 11433, 11435, 11437, 11439, 11441, 11443, 11445, 11447, 11449, 11451, 11453, 11455, 11457, 11459, 11461, 11463, 11465, 11467, 11469, 11471, 11473, 11475, 11477, 11479, 11481, 11483, 11485, 11487, - 11489, 11491); + 11489, 11491]; $this->assertEquals($expected, $result); $string = 'fffiflffifflſtstﬓﬔﬕﬖﬗ'; $result = Multibyte::utf8($string); - $expected = array(64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279); + $expected = [64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279]; $this->assertEquals($expected, $result); } @@ -351,315 +351,315 @@ public function testUtf8() { * @return void */ public function testAscii() { - $input = array(33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + $input = [33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, - 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126); + 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126]; $result = Multibyte::ascii($input); $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; $this->assertEquals($expected, $result); - $input = array(161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, - 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200); + $input = [161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, + 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200]; $result = Multibyte::ascii($input); $expected = '¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈ'; $this->assertEquals($expected, $result); - $input = array(201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + $input = [201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, - 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300); + 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300]; $result = Multibyte::ascii($input); $expected = 'ÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĀāĂ㥹ĆćĈĉĊċČčĎďĐđĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħĨĩĪīĬ'; $this->assertEquals($expected, $result); - $input = array(301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, + $input = [301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, - 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400); + 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400]; $expected = 'ĭĮįİıIJijĴĵĶķĸĹĺĻļĽľĿŀŁłŃńŅņŇňʼnŊŋŌōŎŏŐőŒœŔŕŖŗŘřŚśŜŝŞşŠšŢţŤťŦŧŨũŪūŬŭŮůŰűŲųŴŵŶŷŸŹźŻżŽžſƀƁƂƃƄƅƆƇƈƉƊƋƌƍƎƏƐ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, + $input = [401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, - 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500); + 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500]; $expected = 'ƑƒƓƔƕƖƗƘƙƚƛƜƝƞƟƠơƢƣƤƥƦƧƨƩƪƫƬƭƮƯưƱƲƳƴƵƶƷƸƹƺƻƼƽƾƿǀǁǂǃDŽDždžLJLjljNJNjnjǍǎǏǐǑǒǓǔǕǖǗǘǙǚǛǜǝǞǟǠǡǢǣǤǥǦǧǨǩǪǫǬǭǮǯǰDZDzdzǴ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, + $input = [601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, - 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700); + 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700]; $expected = 'əɚɛɜɝɞɟɠɡɢɣɤɥɦɧɨɩɪɫɬɭɮɯɰɱɲɳɴɵɶɷɸɹɺɻɼɽɾɿʀʁʂʃʄʅʆʇʈʉʊʋʌʍʎʏʐʑʒʓʔʕʖʗʘʙʚʛʜʝʞʟʠʡʢʣʤʥʦʧʨʩʪʫʬʭʮʯʰʱʲʳʴʵʶʷʸʹʺʻʼ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, - 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051); + $input = [1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, + 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051]; $expected = 'ЀЁЂЃЄЅІЇЈЉЊЋЌЍЎЏАБВГДЕЖЗИЙКЛ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, + $input = [1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, - 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100); + 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100]; $expected = 'МНОПРСТУФХЦЧШЩЪЫЬЭЮЯабвгдежзийклмнопрстуфхцчшщъыь'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(1401, 1402, 1403, 1404, 1405, 1406, 1407); + $input = [1401, 1402, 1403, 1404, 1405, 1406, 1407]; $expected = 'չպջռսվտ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615); + $input = [1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615]; $expected = 'فقكلمنهوىيًٌٍَُ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10041, 10042, 10043, 10044, + $input = [10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040, 10041, 10042, 10043, 10044, 10045, 10046, 10047, 10048, 10049, 10050, 10051, 10052, 10053, 10054, 10055, 10056, 10057, 10058, 10059, 10060, 10061, 10062, 10063, 10064, 10065, 10066, 10067, 10068, 10069, 10070, - 10071, 10072, 10073, 10074, 10075, 10076, 10077, 10078); + 10071, 10072, 10073, 10074, 10075, 10076, 10077, 10078]; $expected = '✰✱✲✳✴✵✶✷✸✹✺✻✼✽✾✿❀❁❂❃❄❅❆❇❈❉❊❋❌❍❎❏❐❑❒❓❔❕❖❗❘❙❚❛❜❝❞'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(11904, 11905, 11906, 11907, 11908, 11909, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, 11918, 11919, + $input = [11904, 11905, 11906, 11907, 11908, 11909, 11910, 11911, 11912, 11913, 11914, 11915, 11916, 11917, 11918, 11919, 11920, 11921, 11922, 11923, 11924, 11925, 11926, 11927, 11928, 11929, 11931, 11932, 11933, 11934, 11935, 11936, 11937, 11938, 11939, 11940, 11941, 11942, 11943, 11944, 11945, 11946, 11947, 11948, 11949, 11950, 11951, 11952, 11953, 11954, 11955, 11956, 11957, 11958, 11959, 11960, 11961, 11962, 11963, 11964, 11965, 11966, 11967, 11968, 11969, 11970, 11971, 11972, 11973, 11974, 11975, 11976, 11977, 11978, 11979, 11980, 11981, 11982, 11983, 11984, - 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, 11995, 11996, 11997, 11998, 11999, 12000); + 11985, 11986, 11987, 11988, 11989, 11990, 11991, 11992, 11993, 11994, 11995, 11996, 11997, 11998, 11999, 12000]; $expected = '⺀⺁⺂⺃⺄⺅⺆⺇⺈⺉⺊⺋⺌⺍⺎⺏⺐⺑⺒⺓⺔⺕⺖⺗⺘⺙⺛⺜⺝⺞⺟⺠⺡⺢⺣⺤⺥⺦⺧⺨⺩⺪⺫⺬⺭⺮⺯⺰⺱⺲⺳⺴⺵⺶⺷⺸⺹⺺⺻⺼⺽⺾⺿⻀⻁⻂⻃⻄⻅⻆⻇⻈⻉⻊⻋⻌⻍⻎⻏⻐⻑⻒⻓⻔⻕⻖⻗⻘⻙⻚⻛⻜⻝⻞⻟⻠'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(12101, 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, 12112, 12113, 12114, 12115, 12116, + $input = [12101, 12102, 12103, 12104, 12105, 12106, 12107, 12108, 12109, 12110, 12111, 12112, 12113, 12114, 12115, 12116, 12117, 12118, 12119, 12120, 12121, 12122, 12123, 12124, 12125, 12126, 12127, 12128, 12129, 12130, 12131, 12132, 12133, 12134, 12135, 12136, 12137, 12138, 12139, 12140, 12141, 12142, 12143, 12144, 12145, 12146, 12147, 12148, - 12149, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12159); + 12149, 12150, 12151, 12152, 12153, 12154, 12155, 12156, 12157, 12158, 12159]; $expected = '⽅⽆⽇⽈⽉⽊⽋⽌⽍⽎⽏⽐⽑⽒⽓⽔⽕⽖⽗⽘⽙⽚⽛⽜⽝⽞⽟⽠⽡⽢⽣⽤⽥⽦⽧⽨⽩⽪⽫⽬⽭⽮⽯⽰⽱⽲⽳⽴⽵⽶⽷⽸⽹⽺⽻⽼⽽⽾⽿'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(45601, 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, 45612, 45613, 45614, 45615, 45616, + $input = [45601, 45602, 45603, 45604, 45605, 45606, 45607, 45608, 45609, 45610, 45611, 45612, 45613, 45614, 45615, 45616, 45617, 45618, 45619, 45620, 45621, 45622, 45623, 45624, 45625, 45626, 45627, 45628, 45629, 45630, 45631, 45632, 45633, 45634, 45635, 45636, 45637, 45638, 45639, 45640, 45641, 45642, 45643, 45644, 45645, 45646, 45647, 45648, 45649, 45650, 45651, 45652, 45653, 45654, 45655, 45656, 45657, 45658, 45659, 45660, 45661, 45662, 45663, 45664, 45665, 45666, 45667, 45668, 45669, 45670, 45671, 45672, 45673, 45674, 45675, 45676, 45677, 45678, 45679, 45680, 45681, 45682, 45683, 45684, 45685, 45686, 45687, 45688, 45689, 45690, 45691, 45692, 45693, 45694, 45695, 45696, - 45697, 45698, 45699, 45700); + 45697, 45698, 45699, 45700]; $expected = '눡눢눣눤눥눦눧눨눩눪눫눬눭눮눯눰눱눲눳눴눵눶눷눸눹눺눻눼눽눾눿뉀뉁뉂뉃뉄뉅뉆뉇뉈뉉뉊뉋뉌뉍뉎뉏뉐뉑뉒뉓뉔뉕뉖뉗뉘뉙뉚뉛뉜뉝뉞뉟뉠뉡뉢뉣뉤뉥뉦뉧뉨뉩뉪뉫뉬뉭뉮뉯뉰뉱뉲뉳뉴뉵뉶뉷뉸뉹뉺뉻뉼뉽뉾뉿늀늁늂늃늄'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(65136, 65137, 65138, 65139, 65140, 65141, 65142, 65143, 65144, 65145, 65146, 65147, 65148, 65149, 65150, 65151, + $input = [65136, 65137, 65138, 65139, 65140, 65141, 65142, 65143, 65144, 65145, 65146, 65147, 65148, 65149, 65150, 65151, 65152, 65153, 65154, 65155, 65156, 65157, 65158, 65159, 65160, 65161, 65162, 65163, 65164, 65165, 65166, 65167, 65168, 65169, 65170, 65171, 65172, 65173, 65174, 65175, 65176, 65177, 65178, 65179, 65180, 65181, 65182, 65183, 65184, 65185, 65186, 65187, 65188, 65189, 65190, 65191, 65192, 65193, 65194, 65195, 65196, 65197, 65198, 65199, - 65200); + 65200]; $expected = 'ﹰﹱﹲﹳﹴ﹵ﹶﹷﹸﹹﹺﹻﹼﹽﹾﹿﺀﺁﺂﺃﺄﺅﺆﺇﺈﺉﺊﺋﺌﺍﺎﺏﺐﺑﺒﺓﺔﺕﺖﺗﺘﺙﺚﺛﺜﺝﺞﺟﺠﺡﺢﺣﺤﺥﺦﺧﺨﺩﺪﺫﺬﺭﺮﺯﺰ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(65201, 65202, 65203, 65204, 65205, 65206, 65207, 65208, 65209, 65210, 65211, 65212, 65213, 65214, 65215, 65216, + $input = [65201, 65202, 65203, 65204, 65205, 65206, 65207, 65208, 65209, 65210, 65211, 65212, 65213, 65214, 65215, 65216, 65217, 65218, 65219, 65220, 65221, 65222, 65223, 65224, 65225, 65226, 65227, 65228, 65229, 65230, 65231, 65232, 65233, 65234, 65235, 65236, 65237, 65238, 65239, 65240, 65241, 65242, 65243, 65244, 65245, 65246, 65247, 65248, 65249, 65250, 65251, 65252, 65253, 65254, 65255, 65256, 65257, 65258, 65259, 65260, 65261, 65262, 65263, 65264, - 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276); + 65265, 65266, 65267, 65268, 65269, 65270, 65271, 65272, 65273, 65274, 65275, 65276]; $expected = 'ﺱﺲﺳﺴﺵﺶﺷﺸﺹﺺﺻﺼﺽﺾﺿﻀﻁﻂﻃﻄﻅﻆﻇﻈﻉﻊﻋﻌﻍﻎﻏﻐﻑﻒﻓﻔﻕﻖﻗﻘﻙﻚﻛﻜﻝﻞﻟﻠﻡﻢﻣﻤﻥﻦﻧﻨﻩﻪﻫﻬﻭﻮﻯﻰﻱﻲﻳﻴﻵﻶﻷﻸﻹﻺﻻﻼ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, - 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370); + $input = [65345, 65346, 65347, 65348, 65349, 65350, 65351, 65352, 65353, 65354, 65355, 65356, 65357, 65358, 65359, 65360, + 65361, 65362, 65363, 65364, 65365, 65366, 65367, 65368, 65369, 65370]; $expected = 'abcdefghijklmnopqrstuvwxyz'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392, - 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400); + $input = [65377, 65378, 65379, 65380, 65381, 65382, 65383, 65384, 65385, 65386, 65387, 65388, 65389, 65390, 65391, 65392, + 65393, 65394, 65395, 65396, 65397, 65398, 65399, 65400]; $expected = '。「」、・ヲァィゥェォャュョッーアイウエオカキク'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, + $input = [65401, 65402, 65403, 65404, 65405, 65406, 65407, 65408, 65409, 65410, 65411, 65412, 65413, 65414, 65415, 65416, 65417, 65418, 65419, 65420, 65421, 65422, 65423, 65424, 65425, 65426, 65427, 65428, 65429, 65430, 65431, 65432, - 65433, 65434, 65435, 65436, 65437, 65438); + 65433, 65434, 65435, 65436, 65437, 65438]; $expected = 'ケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワン゙'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(292, 275, 314, 316, 335, 44, 32, 372, 337, 345, 316, 271, 33); + $input = [292, 275, 314, 316, 335, 44, 32, 372, 337, 345, 316, 271, 33]; $expected = 'Ĥēĺļŏ, Ŵőřļď!'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33); + $input = [72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33]; $expected = 'Hello, World!'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(168); + $input = [168]; $expected = '¨'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(191); + $input = [191]; $expected = '¿'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(269, 105, 110, 105); + $input = [269, 105, 110, 105]; $expected = 'čini'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(109, 111, 263, 105); + $input = [109, 111, 263, 105]; $expected = 'moći'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(100, 114, 382, 97, 118, 110, 105); + $input = [100, 114, 382, 97, 118, 110, 105]; $expected = 'državni'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(25226, 30334, 24230, 35774, 20026, 39318, 39029); + $input = [25226, 30334, 24230, 35774, 20026, 39318, 39029]; $expected = '把百度设为首页'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(19968, 20108, 19977, 21608, 27704, 40845); + $input = [19968, 20108, 19977, 21608, 27704, 40845]; $expected = '一二三周永龍'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(1280, 1282, 1284, 1286, 1288, 1290, 1292, 1294, 1296, 1298); + $input = [1280, 1282, 1284, 1286, 1288, 1290, 1292, 1294, 1296, 1298]; $expected = 'ԀԂԄԆԈԊԌԎԐԒ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(1281, 1283, 1285, 1287, 1289, 1291, 1293, 1295, 1296, 1298); + $input = [1281, 1283, 1285, 1287, 1289, 1291, 1293, 1295, 1296, 1298]; $expected = 'ԁԃԅԇԉԋԍԏԐԒ'; $result = Multibyte::ascii($input); $this->assertEquals($expected, $result); - $input = array(1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, + $input = [1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, - 1366, 1415); + 1366, 1415]; $result = Multibyte::ascii($input); $expected = 'ԱԲԳԴԵԶԷԸԹԺԻԼԽԾԿՀՁՂՃՄՅՆՇՈՉՊՋՌՍՎՏՐՑՒՓՔՕՖև'; $this->assertEquals($expected, $result); - $input = array(1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, + $input = [1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, - 1413, 1414, 1415); + 1413, 1414, 1415]; $result = Multibyte::ascii($input); $expected = 'աբգդեզէըթժիլխծկհձղճմյնշոչպջռսվտրցւփքօֆև'; $this->assertEquals($expected, $result); - $input = array(4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, 4272, 4273, 4274, - 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4289, 4290, 4291, 4292, 4293); + $input = [4256, 4257, 4258, 4259, 4260, 4261, 4262, 4263, 4264, 4265, 4266, 4267, 4268, 4269, 4270, 4271, 4272, 4273, 4274, + 4275, 4276, 4277, 4278, 4279, 4280, 4281, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4289, 4290, 4291, 4292, 4293]; $result = Multibyte::ascii($input); $expected = 'ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ'; $this->assertEquals($expected, $result); - $input = array(7680, 7682, 7684, 7686, 7688, 7690, 7692, 7694, 7696, 7698, 7700, 7702, 7704, 7706, 7708, 7710, 7712, 7714, + $input = [7680, 7682, 7684, 7686, 7688, 7690, 7692, 7694, 7696, 7698, 7700, 7702, 7704, 7706, 7708, 7710, 7712, 7714, 7716, 7718, 7720, 7722, 7724, 7726, 7728, 7730, 7732, 7734, 7736, 7738, 7740, 7742, 7744, 7746, 7748, 7750, 7752, 7754, 7756, 7758, 7760, 7762, 7764, 7766, 7768, 7770, 7772, 7774, 7776, 7778, 7780, 7782, 7784, 7786, 7788, 7790, 7792, 7794, 7796, 7798, 7800, 7802, 7804, 7806, 7808, 7810, 7812, 7814, 7816, 7818, 7820, 7822, 7824, 7826, 7828, 7830, 7831, 7832, 7833, 7834, 7840, 7842, 7844, 7846, 7848, 7850, 7852, 7854, 7856, 7858, 7860, 7862, 7864, 7866, 7868, 7870, 7872, 7874, 7876, 7878, 7880, 7882, 7884, 7886, 7888, 7890, 7892, - 7894, 7896, 7898, 7900, 7902, 7904, 7906, 7908, 7910, 7912, 7914, 7916, 7918, 7920, 7922, 7924, 7926, 7928); + 7894, 7896, 7898, 7900, 7902, 7904, 7906, 7908, 7910, 7912, 7914, 7916, 7918, 7920, 7922, 7924, 7926, 7928]; $result = Multibyte::ascii($input); $expected = 'ḀḂḄḆḈḊḌḎḐḒḔḖḘḚḜḞḠḢḤḦḨḪḬḮḰḲḴḶḸḺḼḾṀṂṄṆṈṊṌṎṐṒṔṖṘṚṜṞṠṢṤṦṨṪṬṮṰṲṴṶṸṺṼṾẀẂẄẆẈẊẌẎẐẒẔẖẗẘẙẚẠẢẤẦẨẪẬẮẰẲẴẶẸẺẼẾỀỂỄỆỈỊỌỎỐỒỔỖỘỚỜỞỠỢỤỦỨỪỬỮỰỲỴỶỸ'; $this->assertEquals($expected, $result); - $input = array(7681, 7683, 7685, 7687, 7689, 7691, 7693, 7695, 7697, 7699, 7701, 7703, 7705, 7707, 7709, 7711, 7713, 7715, + $input = [7681, 7683, 7685, 7687, 7689, 7691, 7693, 7695, 7697, 7699, 7701, 7703, 7705, 7707, 7709, 7711, 7713, 7715, 7717, 7719, 7721, 7723, 7725, 7727, 7729, 7731, 7733, 7735, 7737, 7739, 7741, 7743, 7745, 7747, 7749, 7751, 7753, 7755, 7757, 7759, 7761, 7763, 7765, 7767, 7769, 7771, 7773, 7775, 7777, 7779, 7781, 7783, 7785, 7787, 7789, 7791, 7793, 7795, 7797, 7799, 7801, 7803, 7805, 7807, 7809, 7811, 7813, 7815, 7817, 7819, 7821, 7823, 7825, 7827, 7829, 7830, 7831, 7832, 7833, 7834, 7841, 7843, 7845, 7847, 7849, 7851, 7853, 7855, 7857, 7859, 7861, 7863, 7865, 7867, 7869, 7871, 7873, 7875, 7877, 7879, 7881, 7883, 7885, 7887, 7889, 7891, 7893, 7895, - 7897, 7899, 7901, 7903, 7905, 7907, 7909, 7911, 7913, 7915, 7917, 7919, 7921, 7923, 7925, 7927, 7929); + 7897, 7899, 7901, 7903, 7905, 7907, 7909, 7911, 7913, 7915, 7917, 7919, 7921, 7923, 7925, 7927, 7929]; $result = Multibyte::ascii($input); $expected = 'ḁḃḅḇḉḋḍḏḑḓḕḗḙḛḝḟḡḣḥḧḩḫḭḯḱḳḵḷḹḻḽḿṁṃṅṇṉṋṍṏṑṓṕṗṙṛṝṟṡṣṥṧṩṫṭṯṱṳṵṷṹṻṽṿẁẃẅẇẉẋẍẏẑẓẕẖẗẘẙẚạảấầẩẫậắằẳẵặẹẻẽếềểễệỉịọỏốồổỗộớờởỡợụủứừửữựỳỵỷỹ'; $this->assertEquals($expected, $result); - $input = array(8486, 8490, 8491, 8498); + $input = [8486, 8490, 8491, 8498]; $result = Multibyte::ascii($input); $expected = 'ΩKÅℲ'; $this->assertEquals($expected, $result); - $input = array(969, 107, 229, 8526); + $input = [969, 107, 229, 8526]; $result = Multibyte::ascii($input); $expected = 'ωkåⅎ'; $this->assertEquals($expected, $result); - $input = array(8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 8554, 8555, 8556, 8557, 8558, 8559, 8579); + $input = [8544, 8545, 8546, 8547, 8548, 8549, 8550, 8551, 8552, 8553, 8554, 8555, 8556, 8557, 8558, 8559, 8579]; $result = Multibyte::ascii($input); $expected = 'ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫⅬⅭⅮⅯↃ'; $this->assertEquals($expected, $result); - $input = array(8560, 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8570, 8571, 8572, 8573, 8574, 8575, 8580); + $input = [8560, 8561, 8562, 8563, 8564, 8565, 8566, 8567, 8568, 8569, 8570, 8571, 8572, 8573, 8574, 8575, 8580]; $result = Multibyte::ascii($input); $expected = 'ⅰⅱⅲⅳⅴⅵⅶⅷⅸⅹⅺⅻⅼⅽⅾⅿↄ'; $this->assertEquals($expected, $result); - $input = array(9398, 9399, 9400, 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409, 9410, 9411, 9412, 9413, 9414, - 9415, 9416, 9417, 9418, 9419, 9420, 9421, 9422, 9423); + $input = [9398, 9399, 9400, 9401, 9402, 9403, 9404, 9405, 9406, 9407, 9408, 9409, 9410, 9411, 9412, 9413, 9414, + 9415, 9416, 9417, 9418, 9419, 9420, 9421, 9422, 9423]; $result = Multibyte::ascii($input); $expected = 'ⒶⒷⒸⒹⒺⒻⒼⒽⒾⒿⓀⓁⓂⓃⓄⓅⓆⓇⓈⓉⓊⓋⓌⓍⓎⓏ'; $this->assertEquals($expected, $result); - $input = array(9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433, 9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441, - 9442, 9443, 9444, 9445, 9446, 9447, 9448, 9449); + $input = [9424, 9425, 9426, 9427, 9428, 9429, 9430, 9431, 9432, 9433, 9434, 9435, 9436, 9437, 9438, 9439, 9440, 9441, + 9442, 9443, 9444, 9445, 9446, 9447, 9448, 9449]; $result = Multibyte::ascii($input); $expected = 'ⓐⓑⓒⓓⓔⓕⓖⓗⓘⓙⓚⓛⓜⓝⓞⓟⓠⓡⓢⓣⓤⓥⓦⓧⓨⓩ'; $this->assertEquals($expected, $result); - $input = array(11264, 11265, 11266, 11267, 11268, 11269, 11270, 11271, 11272, 11273, 11274, 11275, 11276, 11277, 11278, 11279, + $input = [11264, 11265, 11266, 11267, 11268, 11269, 11270, 11271, 11272, 11273, 11274, 11275, 11276, 11277, 11278, 11279, 11280, 11281, 11282, 11283, 11284, 11285, 11286, 11287, 11288, 11289, 11290, 11291, 11292, 11293, 11294, 11295, - 11296, 11297, 11298, 11299, 11300, 11301, 11302, 11303, 11304, 11305, 11306, 11307, 11308, 11309, 11310); + 11296, 11297, 11298, 11299, 11300, 11301, 11302, 11303, 11304, 11305, 11306, 11307, 11308, 11309, 11310]; $result = Multibyte::ascii($input); $expected = 'ⰀⰁⰂⰃⰄⰅⰆⰇⰈⰉⰊⰋⰌⰍⰎⰏⰐⰑⰒⰓⰔⰕⰖⰗⰘⰙⰚⰛⰜⰝⰞⰟⰠⰡⰢⰣⰤⰥⰦⰧⰨⰩⰪⰫⰬⰭⰮ'; $this->assertEquals($expected, $result); - $input = array(11312, 11313, 11314, 11315, 11316, 11317, 11318, 11319, 11320, 11321, 11322, 11323, 11324, 11325, 11326, 11327, + $input = [11312, 11313, 11314, 11315, 11316, 11317, 11318, 11319, 11320, 11321, 11322, 11323, 11324, 11325, 11326, 11327, 11328, 11329, 11330, 11331, 11332, 11333, 11334, 11335, 11336, 11337, 11338, 11339, 11340, 11341, 11342, 11343, - 11344, 11345, 11346, 11347, 11348, 11349, 11350, 11351, 11352, 11353, 11354, 11355, 11356, 11357, 11358); + 11344, 11345, 11346, 11347, 11348, 11349, 11350, 11351, 11352, 11353, 11354, 11355, 11356, 11357, 11358]; $result = Multibyte::ascii($input); $expected = 'ⰰⰱⰲⰳⰴⰵⰶⰷⰸⰹⰺⰻⰼⰽⰾⰿⱀⱁⱂⱃⱄⱅⱆⱇⱈⱉⱊⱋⱌⱍⱎⱏⱐⱑⱒⱓⱔⱕⱖⱗⱘⱙⱚⱛⱜⱝⱞ'; $this->assertEquals($expected, $result); - $input = array(11392, 11394, 11396, 11398, 11400, 11402, 11404, 11406, 11408, 11410, 11412, 11414, 11416, 11418, 11420, + $input = [11392, 11394, 11396, 11398, 11400, 11402, 11404, 11406, 11408, 11410, 11412, 11414, 11416, 11418, 11420, 11422, 11424, 11426, 11428, 11430, 11432, 11434, 11436, 11438, 11440, 11442, 11444, 11446, 11448, 11450, 11452, 11454, 11456, 11458, 11460, 11462, 11464, 11466, 11468, 11470, 11472, 11474, 11476, 11478, 11480, - 11482, 11484, 11486, 11488, 11490); + 11482, 11484, 11486, 11488, 11490]; $result = Multibyte::ascii($input); $expected = 'ⲀⲂⲄⲆⲈⲊⲌⲎⲐⲒⲔⲖⲘⲚⲜⲞⲠⲢⲤⲦⲨⲪⲬⲮⲰⲲⲴⲶⲸⲺⲼⲾⳀⳂⳄⳆⳈⳊⳌⳎⳐⳒⳔⳖⳘⳚⳜⳞⳠⳢ'; $this->assertEquals($expected, $result); - $input = array(11393, 11395, 11397, 11399, 11401, 11403, 11405, 11407, 11409, 11411, 11413, 11415, 11417, 11419, 11421, 11423, + $input = [11393, 11395, 11397, 11399, 11401, 11403, 11405, 11407, 11409, 11411, 11413, 11415, 11417, 11419, 11421, 11423, 11425, 11427, 11429, 11431, 11433, 11435, 11437, 11439, 11441, 11443, 11445, 11447, 11449, 11451, 11453, 11455, 11457, 11459, 11461, 11463, 11465, 11467, 11469, 11471, 11473, 11475, 11477, 11479, 11481, 11483, 11485, 11487, - 11489, 11491); + 11489, 11491]; $result = Multibyte::ascii($input); $expected = 'ⲁⲃⲅⲇⲉⲋⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⲳⲵⲷⲹⲻⲽⲿⳁⳃⳅⳇⳉⳋⳍⳏⳑⳓⳕⳗⳙⳛⳝⳟⳡⳣ'; $this->assertEquals($expected, $result); - $input = array(64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279); + $input = [64256, 64257, 64258, 64259, 64260, 64261, 64262, 64275, 64276, 64277, 64278, 64279]; $result = Multibyte::ascii($input); $expected = 'fffiflffifflſtstﬓﬔﬕﬖﬗ'; $this->assertEquals($expected, $result); diff --git a/lib/Cake/Test/Case/Log/CakeLogTest.php b/lib/Cake/Test/Case/Log/CakeLogTest.php index 5e804e4cb7..2e3f210378 100644 --- a/lib/Cake/Test/Case/Log/CakeLogTest.php +++ b/lib/Cake/Test/Case/Log/CakeLogTest.php @@ -45,23 +45,23 @@ public function setUp() : void { * @return void */ public function testImportingLoggers() { - App::build(array( - 'Lib' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Lib' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Lib' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); - $result = CakeLog::config('libtest', array( + $result = CakeLog::config('libtest', [ 'engine' => 'TestAppLog' - )); + ]); $this->assertTrue($result); - $this->assertEquals(CakeLog::configured(), array('libtest')); + $this->assertEquals(CakeLog::configured(), ['libtest']); - $result = CakeLog::config('plugintest', array( + $result = CakeLog::config('plugintest', [ 'engine' => 'TestPlugin.TestPluginLog' - )); + ]); $this->assertTrue($result); - $this->assertEquals(CakeLog::configured(), array('libtest', 'plugintest')); + $this->assertEquals(CakeLog::configured(), ['libtest', 'plugintest']); CakeLog::write(LOG_INFO, 'TestPluginLog is not a BaseLog descendant'); @@ -76,7 +76,7 @@ public function testImportingLoggers() { */ public function testImportingLoggerFailure() { $this->expectException(CakeLogException::class); - CakeLog::config('fail', array()); + CakeLog::config('fail', []); } /** @@ -85,7 +85,7 @@ public function testImportingLoggerFailure() { * @return void */ public function testValidKeyName() { - CakeLog::config('valid', array('engine' => 'File')); + CakeLog::config('valid', ['engine' => 'File']); $stream = CakeLog::stream('valid'); $this->assertInstanceOf('FileLog', $stream); CakeLog::drop('valid'); @@ -97,7 +97,7 @@ public function testValidKeyName() { * @return void */ public function testValidKeyNameLogSuffix() { - CakeLog::config('valid', array('engine' => 'FileLog')); + CakeLog::config('valid', ['engine' => 'FileLog']); $stream = CakeLog::stream('valid'); $this->assertInstanceOf('FileLog', $stream); CakeLog::drop('valid'); @@ -110,7 +110,7 @@ public function testValidKeyNameLogSuffix() { */ public function testInvalidKeyName() { $this->expectException(CakeLogException::class); - CakeLog::config('1nv', array('engine' => 'File')); + CakeLog::config('1nv', ['engine' => 'File']); } /** @@ -120,7 +120,7 @@ public function testInvalidKeyName() { */ public function testNotImplementingInterface() { $this->expectException(CakeLogException::class); - CakeLog::config('fail', array('engine' => 'stdClass')); + CakeLog::config('fail', ['engine' => 'stdClass']); } /** @@ -137,7 +137,7 @@ public function testNoStreamListenting() { $this->assertFalse(file_exists(LOGS . 'error.log')); $result = CakeLog::configured(); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); } /** @@ -146,12 +146,12 @@ public function testNoStreamListenting() { * @return void */ public function testConfig() { - CakeLog::config('file', array( + CakeLog::config('file', [ 'engine' => 'File', 'path' => LOGS - )); + ]); $result = CakeLog::configured(); - $this->assertEquals(array('file'), $result); + $this->assertEquals(['file'], $result); if (file_exists(LOGS . 'error.log')) { unlink(LOGS . 'error.log'); @@ -170,16 +170,16 @@ public function testConfig() { * @return void */ public function testDrop() { - CakeLog::config('file', array( + CakeLog::config('file', [ 'engine' => 'File', 'path' => LOGS - )); + ]); $result = CakeLog::configured(); - $this->assertEquals(array('file'), $result); + $this->assertEquals(['file'], $result); CakeLog::drop('file'); $result = CakeLog::configured(); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -188,10 +188,10 @@ public function testDrop() { * @return void */ public function testLogFileWriting() { - CakeLog::config('file', array( + CakeLog::config('file', [ 'engine' => 'File', 'path' => LOGS - )); + ]); if (file_exists(LOGS . 'error.log')) { unlink(LOGS . 'error.log'); } @@ -220,16 +220,16 @@ public function testSelectiveLoggingByLevel() { if (file_exists(LOGS . 'eggs.log')) { unlink(LOGS . 'eggs.log'); } - CakeLog::config('spam', array( + CakeLog::config('spam', [ 'engine' => 'File', 'types' => 'debug', 'file' => 'spam', - )); - CakeLog::config('eggs', array( + ]); + CakeLog::config('eggs', [ 'engine' => 'File', - 'types' => array('eggs', 'debug', 'error', 'warning'), + 'types' => ['eggs', 'debug', 'error', 'warning'], 'file' => 'eggs', - )); + ]); $testMessage = 'selective logging'; CakeLog::write(LOG_WARNING, $testMessage); @@ -260,10 +260,10 @@ public function testSelectiveLoggingByLevel() { */ public function testStreamEnable() { $this->expectException(CakeLogException::class); - CakeLog::config('spam', array( + CakeLog::config('spam', [ 'engine' => 'File', 'file' => 'spam', - )); + ]); $this->assertTrue(CakeLog::enabled('spam')); CakeLog::drop('spam'); CakeLog::enable('bogus_stream'); @@ -276,10 +276,10 @@ public function testStreamEnable() { */ public function testStreamDisable() { $this->expectException(CakeLogException::class); - CakeLog::config('spam', array( + CakeLog::config('spam', [ 'engine' => 'File', 'file' => 'spam', - )); + ]); $this->assertTrue(CakeLog::enabled('spam')); CakeLog::disable('spam'); $this->assertFalse(CakeLog::enabled('spam')); @@ -313,16 +313,16 @@ public function testStreamDisableInvalid() { * @return void */ protected function _resetLogConfig() { - CakeLog::config('debug', array( + CakeLog::config('debug', [ 'engine' => 'File', - 'types' => array('notice', 'info', 'debug'), + 'types' => ['notice', 'info', 'debug'], 'file' => 'debug', - )); - CakeLog::config('error', array( + ]); + CakeLog::config('error', [ 'engine' => 'File', - 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'), + 'types' => ['warning', 'error', 'critical', 'alert', 'emergency'], 'file' => 'error', - )); + ]); } /** @@ -359,12 +359,12 @@ protected function _deleteLogs() { public function testScopedLoggingBC() { $this->_resetLogConfig(); - CakeLog::config('shops', array( + CakeLog::config('shops', [ 'engine' => 'File', - 'types' => array('info', 'notice', 'warning'), - 'scopes' => array('transactions', 'orders'), + 'types' => ['info', 'notice', 'warning'], + 'scopes' => ['transactions', 'orders'], 'file' => 'shops', - )); + ]); $this->_deleteLogs(); CakeLog::write('info', 'info message'); @@ -413,18 +413,18 @@ public function testScopedLoggingBC() { public function testScopedLoggingExclusive() { $this->_deleteLogs(); - CakeLog::config('shops', array( + CakeLog::config('shops', [ 'engine' => 'File', - 'types' => array('info', 'notice', 'warning'), - 'scopes' => array('transactions', 'orders'), + 'types' => ['info', 'notice', 'warning'], + 'scopes' => ['transactions', 'orders'], 'file' => 'shops.log', - )); - CakeLog::config('eggs', array( + ]); + CakeLog::config('eggs', [ 'engine' => 'File', - 'types' => array('info', 'notice', 'warning'), - 'scopes' => array('eggs'), + 'types' => ['info', 'notice', 'warning'], + 'scopes' => ['eggs'], 'file' => 'eggs.log', - )); + ]); CakeLog::write('info', 'transactions message', 'transactions'); $this->assertFalse(file_exists(LOGS . 'eggs.log')); @@ -446,23 +446,23 @@ public function testScopedLogging() { $this->_resetLogConfig(); $this->_deleteLogs(); - CakeLog::config('string-scope', array( + CakeLog::config('string-scope', [ 'engine' => 'File', - 'types' => array('info', 'notice', 'warning'), + 'types' => ['info', 'notice', 'warning'], 'scopes' => 'string-scope', 'file' => 'string-scope.log' - )); + ]); CakeLog::write('info', 'info message', 'string-scope'); $this->assertTrue(file_exists(LOGS . 'string-scope.log')); CakeLog::drop('string-scope'); - CakeLog::config('shops', array( + CakeLog::config('shops', [ 'engine' => 'File', - 'types' => array('info', 'notice', 'warning'), - 'scopes' => array('transactions', 'orders'), + 'types' => ['info', 'notice', 'warning'], + 'scopes' => ['transactions', 'orders'], 'file' => 'shops.log', - )); + ]); CakeLog::write('info', 'info message', 'transactions'); $this->assertFalse(file_exists(LOGS . 'error.log')); @@ -513,10 +513,10 @@ public function testBogusTypeAndScope() { $this->_resetLogConfig(); $this->_deleteLogs(); - CakeLog::config('file', array( + CakeLog::config('file', [ 'engine' => 'File', 'path' => LOGS - )); + ]); CakeLog::write('bogus', 'bogus message'); $this->assertTrue(file_exists(LOGS . 'bogus.log')); @@ -554,12 +554,12 @@ public function testConvenienceScopedLogging() { } $this->_resetLogConfig(); - CakeLog::config('shops', array( + CakeLog::config('shops', [ 'engine' => 'File', - 'types' => array('info', 'debug', 'notice', 'warning'), - 'scopes' => array('transactions', 'orders'), + 'types' => ['info', 'debug', 'notice', 'warning'], + 'scopes' => ['transactions', 'orders'], 'file' => 'shops', - )); + ]); CakeLog::info('info message', 'transactions'); $this->assertFalse(file_exists(LOGS . 'error.log')); @@ -593,16 +593,16 @@ public function testConvenienceScopedLogging() { public function testConvenienceMethods() { $this->_deleteLogs(); - CakeLog::config('debug', array( + CakeLog::config('debug', [ 'engine' => 'File', - 'types' => array('notice', 'info', 'debug'), + 'types' => ['notice', 'info', 'debug'], 'file' => 'debug', - )); - CakeLog::config('error', array( + ]); + CakeLog::config('error', [ 'engine' => 'File', - 'types' => array('emergency', 'alert', 'critical', 'error', 'warning'), + 'types' => ['emergency', 'alert', 'critical', 'error', 'warning'], 'file' => 'error', - )); + ]); $testMessage = 'emergency message'; CakeLog::emergency($testMessage); @@ -672,25 +672,25 @@ public function testLevelCustomization() { $levels = CakeLog::defaultLevels(); $this->assertNotEmpty($levels); $result = array_keys($levels); - $this->assertEquals(array(0, 1, 2, 3, 4, 5, 6, 7), $result); + $this->assertEquals([0, 1, 2, 3, 4, 5, 6, 7], $result); - $levels = CakeLog::levels(array('foo', 'bar')); + $levels = CakeLog::levels(['foo', 'bar']); CakeLog::defaultLevels(); $this->assertEquals('foo', $levels[8]); $this->assertEquals('bar', $levels[9]); - $levels = CakeLog::levels(array(11 => 'spam', 'bar' => 'eggs')); + $levels = CakeLog::levels([11 => 'spam', 'bar' => 'eggs']); CakeLog::defaultLevels(); $this->assertEquals('spam', $levels[8]); $this->assertEquals('eggs', $levels[9]); - $levels = CakeLog::levels(array(11 => 'spam', 'bar' => 'eggs'), false); + $levels = CakeLog::levels([11 => 'spam', 'bar' => 'eggs'], false); CakeLog::defaultLevels(); - $this->assertEquals(array('spam', 'eggs'), $levels); + $this->assertEquals(['spam', 'eggs'], $levels); - $levels = CakeLog::levels(array('ham', 9 => 'spam', '12' => 'fam'), false); + $levels = CakeLog::levels(['ham', 9 => 'spam', '12' => 'fam'], false); CakeLog::defaultLevels(); - $this->assertEquals(array('ham', 'spam', 'fam'), $levels); + $this->assertEquals(['ham', 'spam', 'fam'], $levels); } /** @@ -702,7 +702,7 @@ public function testCustomLevelWrites() { $this->_deleteLogs(); $this->_resetLogConfig(); - CakeLog::levels(array('spam', 'eggs')); + CakeLog::levels(['spam', 'eggs']); $testMessage = 'error message'; CakeLog::write('error', $testMessage); @@ -711,16 +711,16 @@ public function testCustomLevelWrites() { $contents = file_get_contents(LOGS . 'error.log'); $this->assertStringContainsString('Error: ' . $testMessage, $contents); - CakeLog::config('spam', array( + CakeLog::config('spam', [ 'engine' => 'File', 'file' => 'spam.log', 'types' => 'spam', - )); - CakeLog::config('eggs', array( + ]); + CakeLog::config('eggs', [ 'engine' => 'File', 'file' => 'eggs.log', - 'types' => array('spam', 'eggs'), - )); + 'types' => ['spam', 'eggs'], + ]); $testMessage = 'spam message'; CakeLog::write('spam', $testMessage); diff --git a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php index 4de920e907..4213b51f0c 100644 --- a/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/ConsoleLogTest.php @@ -49,16 +49,16 @@ class ConsoleLogTest extends CakeTestCase { public function setUp() : void { parent::setUp(); - CakeLog::config('debug', array( + CakeLog::config('debug', [ 'engine' => 'File', - 'types' => array('notice', 'info', 'debug'), + 'types' => ['notice', 'info', 'debug'], 'file' => 'debug', - )); - CakeLog::config('error', array( + ]); + CakeLog::config('error', [ 'engine' => 'File', - 'types' => array('error', 'warning'), + 'types' => ['error', 'warning'], 'file' => 'error', - )); + ]); } public function tearDown() : void { @@ -77,13 +77,13 @@ public function tearDown() : void { * @return void */ public function testConsoleOutputWrites() { - TestCakeLog::config('test_console_log', array( + TestCakeLog::config('test_console_log', [ 'engine' => 'TestConsole', - )); + ]); - $mock = $this->getMock('TestConsoleLog', array('write'), array( - array('types' => 'error'), - )); + $mock = $this->getMock('TestConsoleLog', ['write'], [ + ['types' => 'error'], + ]); TestCakeLog::replace('test_console_log', $mock); $message = 'Test error message'; @@ -98,12 +98,12 @@ public function testConsoleOutputWrites() { * @return void */ public function testCombinedLogWriting() { - TestCakeLog::config('test_console_log', array( + TestCakeLog::config('test_console_log', [ 'engine' => 'TestConsole', - )); - $mock = $this->getMock('TestConsoleLog', array('write'), array( - array('types' => 'error'), - )); + ]); + $mock = $this->getMock('TestConsoleLog', ['write'], [ + ['types' => 'error'], + ]); TestCakeLog::replace('test_console_log', $mock); // log to both file and console @@ -136,9 +136,9 @@ public function testCombinedLogWriting() { * @return void */ public function testDefaultOutputAs() { - TestCakeLog::config('test_console_log', array( + TestCakeLog::config('test_console_log', [ 'engine' => 'TestConsole', - )); + ]); if ((DS === '\\' && !(bool)env('ANSICON') && env('ConEmuANSI') !== 'ON') || (function_exists('posix_isatty') && !posix_isatty(null)) ) { diff --git a/lib/Cake/Test/Case/Log/Engine/FileLogTest.php b/lib/Cake/Test/Case/Log/Engine/FileLogTest.php index 30a4349996..6e37ff7eb0 100644 --- a/lib/Cake/Test/Case/Log/Engine/FileLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/FileLogTest.php @@ -77,11 +77,11 @@ public function testRotation() { $this->_deleteLogs($path); file_put_contents($path . 'error.log', "this text is under 35 bytes\n"); - $log = new FileLog(array( + $log = new FileLog([ 'path' => $path, 'size' => 35, 'rotate' => 2 - )); + ]); $log->write('warning', 'Test warning one'); $this->assertTrue(file_exists($path . 'error.log')); @@ -135,11 +135,11 @@ public function testRotation() { $this->assertMatchesRegularExpression('/Warning: Test warning second/', $result); file_put_contents($path . 'debug.log', "this text is just greater than 35 bytes\n"); - $log = new FileLog(array( + $log = new FileLog([ 'path' => $path, 'size' => 35, 'rotate' => 0 - )); + ]); file_put_contents($path . 'debug.log.0000000000', "The oldest log file with over 35 bytes.\n"); $log->write('debug', 'Test debug'); $this->assertTrue(file_exists($path . 'debug.log')); @@ -158,21 +158,21 @@ public function testMaskSetting() { $path = TMP . 'tests' . DS; $this->_deleteLogs($path); - $log = new FileLog(array('path' => $path, 'mask' => 0666)); + $log = new FileLog(['path' => $path, 'mask' => 0666]); $log->write('warning', 'Test warning one'); $result = substr(sprintf('%o', fileperms($path . 'error.log')), -4); $expected = '0666'; $this->assertEquals($expected, $result); unlink($path . 'error.log'); - $log = new FileLog(array('path' => $path, 'mask' => 0644)); + $log = new FileLog(['path' => $path, 'mask' => 0644]); $log->write('warning', 'Test warning two'); $result = substr(sprintf('%o', fileperms($path . 'error.log')), -4); $expected = '0644'; $this->assertEquals($expected, $result); unlink($path . 'error.log'); - $log = new FileLog(array('path' => $path, 'mask' => 0640)); + $log = new FileLog(['path' => $path, 'mask' => 0640]); $log->write('warning', 'Test warning three'); $result = substr(sprintf('%o', fileperms($path . 'error.log')), -4); $expected = '0640'; diff --git a/lib/Cake/Test/Case/Log/Engine/SyslogLogTest.php b/lib/Cake/Test/Case/Log/Engine/SyslogLogTest.php index f4a99e8491..3351bf6ac0 100644 --- a/lib/Cake/Test/Case/Log/Engine/SyslogLogTest.php +++ b/lib/Cake/Test/Case/Log/Engine/SyslogLogTest.php @@ -29,17 +29,17 @@ class SyslogLogTest extends CakeTestCase { * @return void */ public function testOpenLog() { - $log = $this->getMock('SyslogLog', array('_open', '_write')); + $log = $this->getMock('SyslogLog', ['_open', '_write']); $log->expects($this->once())->method('_open')->with('', LOG_ODELAY, LOG_USER); $log->write('debug', 'message'); - $log = $this->getMock('SyslogLog', array('_open', '_write')); - $log->config(array( + $log = $this->getMock('SyslogLog', ['_open', '_write']); + $log->config([ 'prefix' => 'thing', 'flag' => LOG_NDELAY, 'facility' => LOG_MAIL, 'format' => '%s: %s' - )); + ]); $log->expects($this->once())->method('_open') ->with('thing', LOG_NDELAY, LOG_MAIL); $log->write('debug', 'message'); @@ -52,7 +52,7 @@ public function testOpenLog() { * @return void */ public function testWriteOneLine($type, $expected) { - $log = $this->getMock('SyslogLog', array('_open', '_write')); + $log = $this->getMock('SyslogLog', ['_open', '_write']); $log->expects($this->once())->method('_write')->with($expected, $type . ': Foo'); $log->write($type, 'Foo'); } @@ -63,7 +63,7 @@ public function testWriteOneLine($type, $expected) { * @return void */ public function testWriteMultiLine() { - $log = $this->getMock('SyslogLog', array('_open', '_write')); + $log = $this->getMock('SyslogLog', ['_open', '_write']); $log->expects($this->at(1))->method('_write')->with(LOG_DEBUG, 'debug: Foo'); $log->expects($this->at(2))->method('_write')->with(LOG_DEBUG, 'debug: Bar'); $log->expects($this->exactly(2))->method('_write'); @@ -76,16 +76,16 @@ public function testWriteMultiLine() { * @return array */ public function typesProvider() { - return array( - array('emergency', LOG_EMERG), - array('alert', LOG_ALERT), - array('critical', LOG_CRIT), - array('error', LOG_ERR), - array('warning', LOG_WARNING), - array('notice', LOG_NOTICE), - array('info', LOG_INFO), - array('debug', LOG_DEBUG) - ); + return [ + ['emergency', LOG_EMERG], + ['alert', LOG_ALERT], + ['critical', LOG_CRIT], + ['error', LOG_ERR], + ['warning', LOG_WARNING], + ['notice', LOG_NOTICE], + ['info', LOG_INFO], + ['debug', LOG_DEBUG] + ]; } } diff --git a/lib/Cake/Test/Case/Log/LogEngineCollectionTest.php b/lib/Cake/Test/Case/Log/LogEngineCollectionTest.php index 9cda882a84..3a4b3f3186 100644 --- a/lib/Cake/Test/Case/Log/LogEngineCollectionTest.php +++ b/lib/Cake/Test/Case/Log/LogEngineCollectionTest.php @@ -51,7 +51,7 @@ public function setUp() : void { * @return void */ public function testLoad() { - $result = $this->Collection->load('key', array('engine' => 'File')); + $result = $this->Collection->load('key', ['engine' => 'File']); $this->assertInstanceOf('CakeLogInterface', $result); } @@ -61,7 +61,7 @@ public function testLoad() { * @return void */ public function testLoadWithSuffix() { - $result = $this->Collection->load('key', array('engine' => 'FileLog')); + $result = $this->Collection->load('key', ['engine' => 'FileLog']); $this->assertInstanceOf('CakeLogInterface', $result); } @@ -71,7 +71,7 @@ public function testLoadWithSuffix() { * @return void */ public function testLoadWithSuffixAtBeginning() { - $result = $this->Collection->load('key', array('engine' => 'LoggerEngine')); + $result = $this->Collection->load('key', ['engine' => 'LoggerEngine']); $this->assertInstanceOf('CakeLogInterface', $result); } @@ -82,7 +82,7 @@ public function testLoadWithSuffixAtBeginning() { */ public function testLoadInvalid() { $this->expectException(CakeLogException::class); - $result = $this->Collection->load('key', array('engine' => 'ImaginaryFile')); + $result = $this->Collection->load('key', ['engine' => 'ImaginaryFile']); $this->assertInstanceOf('CakeLogInterface', $result); } diff --git a/lib/Cake/Test/Case/Model/AclNodeTest.php b/lib/Cake/Test/Case/Model/AclNodeTest.php index 7041567a82..84a901adeb 100644 --- a/lib/Cake/Test/Case/Model/AclNodeTest.php +++ b/lib/Cake/Test/Case/Model/AclNodeTest.php @@ -60,7 +60,7 @@ class DbAroTest extends DbAclNodeTestBase { * * @var array */ - public $hasAndBelongsToMany = array('DbAcoTest' => array('with' => 'DbPermissionTest')); + public $hasAndBelongsToMany = ['DbAcoTest' => ['with' => 'DbPermissionTest']]; } /** @@ -82,7 +82,7 @@ class DbAcoTest extends DbAclNodeTestBase { * * @var array */ - public $hasAndBelongsToMany = array('DbAroTest' => array('with' => 'DbPermissionTest')); + public $hasAndBelongsToMany = ['DbAroTest' => ['with' => 'DbPermissionTest']]; } /** @@ -111,7 +111,7 @@ class DbPermissionTest extends CakeTestModel { * * @var array */ - public $belongsTo = array('DbAroTest' => array('foreignKey' => 'aro_id'), 'DbAcoTest' => array('foreignKey' => 'aco_id')); + public $belongsTo = ['DbAroTest' => ['foreignKey' => 'aro_id'], 'DbAcoTest' => ['foreignKey' => 'aco_id']]; } /** @@ -133,7 +133,7 @@ class DbAcoActionTest extends CakeTestModel { * * @var array */ - public $belongsTo = array('DbAcoTest' => array('foreignKey' => 'aco_id')); + public $belongsTo = ['DbAcoTest' => ['foreignKey' => 'aco_id']]; } /** @@ -167,7 +167,7 @@ public function bindNode($ref = null) { if (Configure::read('DbAclbindMode') === 'string') { return 'ROOT/admins/Gandalf'; } elseif (Configure::read('DbAclbindMode') === 'array') { - return array('DbAroTest' => array('DbAroTest.model' => 'AuthUser', 'DbAroTest.foreign_key' => 2)); + return ['DbAroTest' => ['DbAroTest.model' => 'AuthUser', 'DbAroTest.foreign_key' => 2]]; } } @@ -204,7 +204,7 @@ class AclNodeTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.aro', 'core.aco', 'core.aros_aco', 'core.aco_action', 'core.auth_user'); + public $fixtures = ['core.aro', 'core.aco', 'core.aros_aco', 'core.aco_action', 'core.auth_user']; /** * setUp method @@ -225,27 +225,27 @@ public function setUp() : void { public function testNode() { $Aco = new DbAcoTest(); $result = Hash::extract($Aco->node('Controller1'), '{n}.DbAcoTest.id'); - $expected = array(2, 1); + $expected = [2, 1]; $this->assertEquals($expected, $result); $result = Hash::extract($Aco->node('Controller1/action1'), '{n}.DbAcoTest.id'); - $expected = array(3, 2, 1); + $expected = [3, 2, 1]; $this->assertEquals($expected, $result); $result = Hash::extract($Aco->node('Controller2/action1'), '{n}.DbAcoTest.id'); - $expected = array(7, 6, 1); + $expected = [7, 6, 1]; $this->assertEquals($expected, $result); $result = Hash::extract($Aco->node('Controller1/action2'), '{n}.DbAcoTest.id'); - $expected = array(5, 2, 1); + $expected = [5, 2, 1]; $this->assertEquals($expected, $result); $result = Hash::extract($Aco->node('Controller1/action1/record1'), '{n}.DbAcoTest.id'); - $expected = array(4, 3, 2, 1); + $expected = [4, 3, 2, 1]; $this->assertEquals($expected, $result); $result = Hash::extract($Aco->node('Controller2/action1/record1'), '{n}.DbAcoTest.id'); - $expected = array(8, 7, 6, 1); + $expected = [8, 7, 6, 1]; $this->assertEquals($expected, $result); $this->assertFalse($Aco->node('Controller2/action3')); @@ -275,13 +275,13 @@ public function testNodeWithDuplicatePathSegments() { public function testNodeArrayFind() { $Aro = new DbAroTest(); Configure::write('DbAclbindMode', 'string'); - $result = Hash::extract($Aro->node(array('DbAroUserTest' => array('id' => '1', 'foreign_key' => '1'))), '{n}.DbAroTest.id'); - $expected = array(3, 2, 1); + $result = Hash::extract($Aro->node(['DbAroUserTest' => ['id' => '1', 'foreign_key' => '1']]), '{n}.DbAroTest.id'); + $expected = [3, 2, 1]; $this->assertEquals($expected, $result); Configure::write('DbAclbindMode', 'array'); - $result = Hash::extract($Aro->node(array('DbAroUserTest' => array('id' => 4, 'foreign_key' => 2))), '{n}.DbAroTest.id'); - $expected = array(4); + $result = Hash::extract($Aro->node(['DbAroUserTest' => ['id' => 4, 'foreign_key' => 2]]), '{n}.DbAroTest.id'); + $expected = [4]; $this->assertEquals($expected, $result); } @@ -295,12 +295,12 @@ public function testNodeObjectFind() { $Model = new DbAroUserTest(); $Model->id = 1; $result = Hash::extract($Aro->node($Model), '{n}.DbAroTest.id'); - $expected = array(3, 2, 1); + $expected = [3, 2, 1]; $this->assertEquals($expected, $result); $Model->id = 2; $result = Hash::extract($Aro->node($Model), '{n}.DbAroTest.id'); - $expected = array(4, 2, 1); + $expected = [4, 2, 1]; $this->assertEquals($expected, $result); } @@ -314,17 +314,17 @@ public function testNodeAliasParenting() { $db = $Aco->getDataSource(); $db->truncate($Aco); - $Aco->create(array('model' => null, 'foreign_key' => null, 'parent_id' => null, 'alias' => 'Application')); + $Aco->create(['model' => null, 'foreign_key' => null, 'parent_id' => null, 'alias' => 'Application']); $Aco->save(); - $Aco->create(array('model' => null, 'foreign_key' => null, 'parent_id' => $Aco->id, 'alias' => 'Pages')); + $Aco->create(['model' => null, 'foreign_key' => null, 'parent_id' => $Aco->id, 'alias' => 'Pages']); $Aco->save(); $result = $Aco->find('all'); - $expected = array( - array('DbAcoTest' => array('id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'Application', 'lft' => '1', 'rght' => '4'), 'DbAroTest' => array()), - array('DbAcoTest' => array('id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'Pages', 'lft' => '2', 'rght' => '3'), 'DbAroTest' => array()) - ); + $expected = [ + ['DbAcoTest' => ['id' => '1', 'parent_id' => null, 'model' => null, 'foreign_key' => null, 'alias' => 'Application', 'lft' => '1', 'rght' => '4'], 'DbAroTest' => []], + ['DbAcoTest' => ['id' => '2', 'parent_id' => '1', 'model' => null, 'foreign_key' => null, 'alias' => 'Pages', 'lft' => '2', 'rght' => '3'], 'DbAroTest' => []] + ]; $this->assertEquals($expected, $result); } @@ -334,19 +334,19 @@ public function testNodeAliasParenting() { * @return void */ public function testNodeActionAuthorize() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $Aro = new DbAroTest(); $Aro->create(); - $Aro->save(array('model' => 'TestPluginAuthUser', 'foreign_key' => 1)); + $Aro->save(['model' => 'TestPluginAuthUser', 'foreign_key' => 1]); $result = $Aro->id; $expected = 5; $this->assertEquals($expected, $result); - $node = $Aro->node(array('TestPlugin.TestPluginAuthUser' => array('id' => 1, 'user' => 'mariano'))); + $node = $Aro->node(['TestPlugin.TestPluginAuthUser' => ['id' => 1, 'user' => 'mariano']]); $result = Hash::get($node, '0.DbAroTest.id'); $expected = $Aro->id; $this->assertEquals($expected, $result); diff --git a/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php index f963a88701..a6866d8067 100644 --- a/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/AclBehaviorTest.php @@ -43,31 +43,31 @@ class AclPerson extends CakeTestModel { * * @var array */ - public $actsAs = array('Acl' => 'both'); + public $actsAs = ['Acl' => 'both']; /** * belongsTo property * * @var array */ - public $belongsTo = array( - 'Mother' => array( + public $belongsTo = [ + 'Mother' => [ 'className' => 'AclPerson', 'foreignKey' => 'mother_id', - ) - ); + ] + ]; /** * hasMany property * * @var array */ - public $hasMany = array( - 'Child' => array( + public $hasMany = [ + 'Child' => [ 'className' => 'AclPerson', 'foreignKey' => 'mother_id' - ) - ); + ] + ]; /** * parentNode method @@ -86,7 +86,7 @@ public function parentNode() { if (!$motherId) { return null; } - return array('AclPerson' => array('id' => $motherId)); + return ['AclPerson' => ['id' => $motherId]]; } } @@ -117,7 +117,7 @@ class AclUser extends CakeTestModel { * * @var array */ - public $actsAs = array('Acl' => array('type' => 'requester')); + public $actsAs = ['Acl' => ['type' => 'requester']]; /** * parentNode @@ -156,7 +156,7 @@ class AclPost extends CakeTestModel { * * @var array */ - public $actsAs = array('Acl' => array('type' => 'Controlled')); + public $actsAs = ['Acl' => ['type' => 'Controlled']]; /** * parentNode @@ -195,7 +195,7 @@ class AclBehaviorTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.person', 'core.user', 'core.post', 'core.aco', 'core.aro', 'core.aros_aco'); + public $fixtures = ['core.person', 'core.user', 'core.post', 'core.aco', 'core.aro', 'core.aros_aco']; /** * Set up the test @@ -258,87 +258,87 @@ public function testSetupMulti() { */ public function testAfterSave() { $Post = new AclPost(); - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'author_id' => 1, 'title' => 'Acl Post', 'body' => 'post body', 'published' => 1 - ), - ); + ], + ]; $Post->save($data); - $result = $this->Aco->find('first', array( - 'conditions' => array('Aco.model' => 'Post', 'Aco.foreign_key' => $Post->id) - )); + $result = $this->Aco->find('first', [ + 'conditions' => ['Aco.model' => 'Post', 'Aco.foreign_key' => $Post->id] + ]); $this->assertTrue(is_array($result)); $this->assertEquals('Post', $result['Aco']['model']); $this->assertEquals($Post->id, $result['Aco']['foreign_key']); - $aroData = array( - 'Aro' => array( + $aroData = [ + 'Aro' => [ 'model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => null - ) - ); + ] + ]; $this->Aro->save($aroData); - $acoData = array( - 'Aco' => array( + $acoData = [ + 'Aco' => [ 'model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => null - ) - ); + ] + ]; $this->Aco->save($acoData); $Person = new AclPerson(); - $data = array( - 'AclPerson' => array( + $data = [ + 'AclPerson' => [ 'name' => 'Trent', 'mother_id' => 2, 'father_id' => 3, - ), - ); + ], + ]; $Person->save($data); - $result = $this->Aro->find('first', array( - 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id) - )); + $result = $this->Aro->find('first', [ + 'conditions' => ['Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id] + ]); $this->assertTrue(is_array($result)); $this->assertEquals(5, $result['Aro']['parent_id']); - $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro'); + $node = $Person->node(['model' => 'AclPerson', 'foreign_key' => 8], 'Aro'); $this->assertEquals(2, count($node)); $this->assertEquals(5, $node[0]['Aro']['parent_id']); $this->assertEquals(null, $node[1]['Aro']['parent_id']); - $aroData = array( - 'Aro' => array( + $aroData = [ + 'Aro' => [ 'model' => 'AclPerson', 'foreign_key' => 1, 'parent_id' => null - ) - ); + ] + ]; $this->Aro->create(); $this->Aro->save($aroData); - $acoData = array( - 'Aco' => array( + $acoData = [ + 'Aco' => [ 'model' => 'AclPerson', 'foreign_key' => 1, 'parent_id' => null - )); + ]]; $this->Aco->create(); $this->Aco->save($acoData); $Person->read(null, 8); $Person->set('mother_id', 1); $Person->save(); - $result = $this->Aro->find('first', array( - 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id) - )); + $result = $this->Aro->find('first', [ + 'conditions' => ['Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id] + ]); $this->assertTrue(is_array($result)); $this->assertEquals(7, $result['Aro']['parent_id']); - $node = $Person->node(array('model' => 'AclPerson', 'foreign_key' => 8), 'Aro'); + $node = $Person->node(['model' => 'AclPerson', 'foreign_key' => 8], 'Aro'); $this->assertEquals(2, count($node)); $this->assertEquals(7, $node[0]['Aro']['parent_id']); $this->assertEquals(null, $node[1]['Aro']['parent_id']); @@ -350,43 +350,43 @@ public function testAfterSave() { * @return void */ public function testAfterSaveUpdateParentIdNotNull() { - $aroData = array( - 'Aro' => array( + $aroData = [ + 'Aro' => [ 'model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => null - ) - ); + ] + ]; $this->Aro->save($aroData); - $acoData = array( - 'Aco' => array( + $acoData = [ + 'Aco' => [ 'model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => null - ) - ); + ] + ]; $this->Aco->save($acoData); $Person = new AclPerson(); - $data = array( - 'AclPerson' => array( + $data = [ + 'AclPerson' => [ 'name' => 'Trent', 'mother_id' => 2, 'father_id' => 3, - ), - ); + ], + ]; $Person->save($data); - $result = $this->Aro->find('first', array( - 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id) - )); + $result = $this->Aro->find('first', [ + 'conditions' => ['Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id] + ]); $this->assertTrue(is_array($result)); $this->assertEquals(5, $result['Aro']['parent_id']); - $Person->save(array('id' => $Person->id, 'name' => 'Bruce')); - $result = $this->Aro->find('first', array( - 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id) - )); + $Person->save(['id' => $Person->id, 'name' => 'Bruce']); + $result = $this->Aro->find('first', [ + 'conditions' => ['Aro.model' => 'AclPerson', 'Aro.foreign_key' => $Person->id] + ]); $this->assertEquals(5, $result['Aro']['parent_id']); } @@ -396,32 +396,32 @@ public function testAfterSaveUpdateParentIdNotNull() { * @return void */ public function testAfterDelete() { - $aroData = array( - 'Aro' => array( + $aroData = [ + 'Aro' => [ 'model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => null - ) - ); + ] + ]; $this->Aro->save($aroData); - $acoData = array( - 'Aco' => array( + $acoData = [ + 'Aco' => [ 'model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => null - ) - ); + ] + ]; $this->Aco->save($acoData); $Person = new AclPerson(); - $data = array( - 'AclPerson' => array( + $data = [ + 'AclPerson' => [ 'name' => 'Trent', 'mother_id' => 2, 'father_id' => 3, - ), - ); + ], + ]; $Person->save($data); $id = $Person->id; $node = $Person->node(null, 'Aro'); @@ -430,33 +430,33 @@ public function testAfterDelete() { $this->assertEquals(null, $node[1]['Aro']['parent_id']); $Person->delete($id); - $result = $this->Aro->find('first', array( - 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $id) - )); + $result = $this->Aro->find('first', [ + 'conditions' => ['Aro.model' => 'AclPerson', 'Aro.foreign_key' => $id] + ]); $this->assertTrue(empty($result)); - $result = $this->Aro->find('first', array( - 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => 2) - )); + $result = $this->Aro->find('first', [ + 'conditions' => ['Aro.model' => 'AclPerson', 'Aro.foreign_key' => 2] + ]); $this->assertFalse(empty($result)); - $data = array( - 'AclPerson' => array( + $data = [ + 'AclPerson' => [ 'name' => 'Trent', 'mother_id' => 2, 'father_id' => 3, - ), - ); + ], + ]; $Person->save($data); $id = $Person->id; $Person->delete(2); - $result = $this->Aro->find('first', array( - 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => $id) - )); + $result = $this->Aro->find('first', [ + 'conditions' => ['Aro.model' => 'AclPerson', 'Aro.foreign_key' => $id] + ]); $this->assertTrue(empty($result)); - $result = $this->Aro->find('first', array( - 'conditions' => array('Aro.model' => 'AclPerson', 'Aro.foreign_key' => 2) - )); + $result = $this->Aro->find('first', [ + 'conditions' => ['Aro.model' => 'AclPerson', 'Aro.foreign_key' => 2] + ]); $this->assertTrue(empty($result)); } @@ -467,13 +467,13 @@ public function testAfterDelete() { */ public function testNode() { $Person = new AclPerson(); - $aroData = array( - 'Aro' => array( + $aroData = [ + 'Aro' => [ 'model' => 'AclPerson', 'foreign_key' => 2, 'parent_id' => null - ) - ); + ] + ]; $this->Aro->save($aroData); $Person->id = 2; diff --git a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php index 9c5e639ee0..328f3e2a5b 100644 --- a/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php @@ -19,7 +19,7 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); -require_once dirname(dirname(__FILE__)) . DS . 'models.php'; +require_once dirname(__FILE__, 2) . DS . 'models.php'; /** * ContainableTest class @@ -33,12 +33,12 @@ class ContainableBehaviorTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.article', 'core.article_featured', 'core.article_featureds_tags', 'core.articles_tag', 'core.attachment', 'core.category', 'core.comment', 'core.featured', 'core.tag', 'core.user', 'core.join_a', 'core.join_b', 'core.join_c', 'core.join_a_c', 'core.join_a_b' - ); + ]; /** * Method executed before each test @@ -51,15 +51,15 @@ public function setUp() : void { $this->Article = ClassRegistry::init('Article'); $this->Tag = ClassRegistry::init('Tag'); - $this->User->bindModel(array( - 'hasMany' => array('Article', 'ArticleFeatured', 'Comment') - ), false); - $this->User->ArticleFeatured->unbindModel(array('belongsTo' => array('Category')), false); + $this->User->bindModel([ + 'hasMany' => ['Article', 'ArticleFeatured', 'Comment'] + ], false); + $this->User->ArticleFeatured->unbindModel(['belongsTo' => ['Category']], false); $this->User->ArticleFeatured->hasMany['Comment']['foreignKey'] = 'article_id'; - $this->Tag->bindModel(array( - 'hasAndBelongsToMany' => array('Article') - ), false); + $this->Tag->bindModel([ + 'hasAndBelongsToMany' => ['Article'] + ], false); $this->User->Behaviors->load('Containable'); $this->Article->Behaviors->load('Containable'); @@ -84,64 +84,64 @@ public function tearDown() : void { * @return void */ public function testContainments() { - $r = $this->_containments($this->Article, array('Comment' => array('conditions' => array('Comment.user_id' => 2)))); + $r = $this->_containments($this->Article, ['Comment' => ['conditions' => ['Comment.user_id' => 2]]]); $this->assertTrue(Set::matches('/Article/keep/Comment/conditions[Comment.user_id=2]', $r)); - $r = $this->_containments($this->User, array( - 'ArticleFeatured' => array( - 'Featured' => array( + $r = $this->_containments($this->User, [ + 'ArticleFeatured' => [ + 'Featured' => [ 'id', 'Category' => 'name' - ) - ))); - $this->assertEquals(array('id'), Hash::extract($r, 'ArticleFeatured.keep.Featured.fields')); + ] + ]]); + $this->assertEquals(['id'], Hash::extract($r, 'ArticleFeatured.keep.Featured.fields')); - $r = $this->_containments($this->Article, array( - 'Comment' => array( + $r = $this->_containments($this->Article, [ + 'Comment' => [ 'User', - 'conditions' => array('Comment' => array('user_id' => 2)), - ), - )); + 'conditions' => ['Comment' => ['user_id' => 2]], + ], + ]); $this->assertTrue(Set::matches('/User', $r)); $this->assertTrue(Set::matches('/Comment', $r)); $this->assertTrue(Set::matches('/Article/keep/Comment/conditions/Comment[user_id=2]', $r)); - $r = $this->_containments($this->Article, array('Comment(comment, published)' => 'Attachment(attachment)', 'User(user)')); + $r = $this->_containments($this->Article, ['Comment(comment, published)' => 'Attachment(attachment)', 'User(user)']); $this->assertTrue(Set::matches('/Comment', $r)); $this->assertTrue(Set::matches('/User', $r)); $this->assertTrue(Set::matches('/Article/keep/Comment', $r)); $this->assertTrue(Set::matches('/Article/keep/User', $r)); - $this->assertEquals(array('comment', 'published'), Hash::extract($r, 'Article.keep.Comment.fields')); - $this->assertEquals(array('user'), Hash::extract($r, 'Article.keep.User.fields')); + $this->assertEquals(['comment', 'published'], Hash::extract($r, 'Article.keep.Comment.fields')); + $this->assertEquals(['user'], Hash::extract($r, 'Article.keep.User.fields')); $this->assertTrue(Set::matches('/Comment/keep/Attachment', $r)); - $this->assertEquals(array('attachment'), Hash::extract($r, 'Comment.keep.Attachment.fields')); + $this->assertEquals(['attachment'], Hash::extract($r, 'Comment.keep.Attachment.fields')); - $r = $this->_containments($this->Article, array('Comment' => array('limit' => 1))); - $this->assertEquals(array('Comment', 'Article'), array_keys($r)); + $r = $this->_containments($this->Article, ['Comment' => ['limit' => 1]]); + $this->assertEquals(['Comment', 'Article'], array_keys($r)); $result = Hash::extract($r, 'Comment[keep]'); - $this->assertEquals(array('keep' => array()), array_shift($result)); + $this->assertEquals(['keep' => []], array_shift($result)); $this->assertTrue(Set::matches('/Article/keep/Comment', $r)); $result = Hash::extract($r, 'Article.keep'); - $this->assertEquals(array('limit' => 1), array_shift($result)); + $this->assertEquals(['limit' => 1], array_shift($result)); - $r = $this->_containments($this->Article, array('Comment.User')); - $this->assertEquals(array('User', 'Comment', 'Article'), array_keys($r)); + $r = $this->_containments($this->Article, ['Comment.User']); + $this->assertEquals(['User', 'Comment', 'Article'], array_keys($r)); $result = Hash::extract($r, 'User[keep]'); - $this->assertEquals(array('keep' => array()), array_shift($result)); + $this->assertEquals(['keep' => []], array_shift($result)); $result = Hash::extract($r, 'Comment[keep]'); - $this->assertEquals(array('keep' => array('User' => array())), array_shift($result)); + $this->assertEquals(['keep' => ['User' => []]], array_shift($result)); $result = Hash::extract($r, 'Article[keep]'); - $this->assertEquals(array('keep' => array('Comment' => array())), array_shift($result)); + $this->assertEquals(['keep' => ['Comment' => []]], array_shift($result)); - $r = $this->_containments($this->Tag, array('Article' => array('User' => array('Comment' => array( - 'Attachment' => array('conditions' => array('Attachment.id >' => 1)) - ))))); + $r = $this->_containments($this->Tag, ['Article' => ['User' => ['Comment' => [ + 'Attachment' => ['conditions' => ['Attachment.id >' => 1]] + ]]]]); $this->assertTrue(Set::matches('/Attachment', $r)); $this->assertTrue(Set::matches('/Comment/keep/Attachment/conditions', $r)); - $this->assertEquals(array('Attachment.id >' => 1), $r['Comment']['keep']['Attachment']['conditions']); + $this->assertEquals(['Attachment.id >' => 1], $r['Comment']['keep']['Attachment']['conditions']); $this->assertTrue(Set::matches('/User/keep/Comment', $r)); $this->assertTrue(Set::matches('/Article/keep/User', $r)); $this->assertTrue(Set::matches('/Tag/keep/Article', $r)); @@ -154,7 +154,7 @@ public function testContainments() { */ public function testInvalidContainments() { $this->expectWarning(); - $this->_containments($this->Article, array('Comment', 'InvalidBinding')); + $this->_containments($this->Article, ['Comment', 'InvalidBinding']); } /** @@ -163,8 +163,8 @@ public function testInvalidContainments() { * @return void */ public function testInvalidContainmentsNoNotices() { - $this->Article->Behaviors->load('Containable', array('notices' => false)); - $this->_containments($this->Article, array('Comment', 'InvalidBinding')); + $this->Article->Behaviors->load('Containable', ['notices' => false]); + $this->_containments($this->Article, ['Comment', 'InvalidBinding']); } /** @@ -173,59 +173,59 @@ public function testInvalidContainmentsNoNotices() { * @return void */ public function testBeforeFind() { - $r = $this->Article->find('all', array('contain' => array('Comment'))); + $r = $this->Article->find('all', ['contain' => ['Comment']]); $this->assertFalse(Set::matches('/User', $r)); $this->assertTrue(Set::matches('/Comment', $r)); $this->assertFalse(Set::matches('/Comment/User', $r)); - $r = $this->Article->find('all', array('contain' => 'Comment.User')); + $r = $this->Article->find('all', ['contain' => 'Comment.User']); $this->assertTrue(Set::matches('/Comment/User', $r)); $this->assertFalse(Set::matches('/Comment/Article', $r)); - $r = $this->Article->find('all', array('contain' => array('Comment' => array('User', 'Article')))); + $r = $this->Article->find('all', ['contain' => ['Comment' => ['User', 'Article']]]); $this->assertTrue(Set::matches('/Comment/User', $r)); $this->assertTrue(Set::matches('/Comment/Article', $r)); - $r = $this->Article->find('all', array('contain' => array('Comment' => array('conditions' => array('Comment.user_id' => 2))))); + $r = $this->Article->find('all', ['contain' => ['Comment' => ['conditions' => ['Comment.user_id' => 2]]]]); $this->assertFalse(Set::matches('/Comment[user_id!=2]', $r)); $this->assertTrue(Set::matches('/Comment[user_id=2]', $r)); - $r = $this->Article->find('all', array('contain' => array('Comment.user_id = 2'))); + $r = $this->Article->find('all', ['contain' => ['Comment.user_id = 2']]); $this->assertFalse(Set::matches('/Comment[user_id!=2]', $r)); - $r = $this->Article->find('all', array('contain' => 'Comment.id DESC')); + $r = $this->Article->find('all', ['contain' => 'Comment.id DESC']); $ids = $descIds = Hash::extract($r, 'Comment[1].id'); rsort($descIds); $this->assertEquals($ids, $descIds); - $r = $this->Article->find('all', array('contain' => 'Comment')); + $r = $this->Article->find('all', ['contain' => 'Comment']); $this->assertTrue(Set::matches('/Comment[user_id!=2]', $r)); - $r = $this->Article->find('all', array('contain' => array('Comment' => array('fields' => 'comment')))); + $r = $this->Article->find('all', ['contain' => ['Comment' => ['fields' => 'comment']]]); $this->assertFalse(Set::matches('/Comment/created', $r)); $this->assertTrue(Set::matches('/Comment/comment', $r)); $this->assertFalse(Set::matches('/Comment/updated', $r)); - $r = $this->Article->find('all', array('contain' => array('Comment' => array('fields' => array('comment', 'updated'))))); + $r = $this->Article->find('all', ['contain' => ['Comment' => ['fields' => ['comment', 'updated']]]]); $this->assertFalse(Set::matches('/Comment/created', $r)); $this->assertTrue(Set::matches('/Comment/comment', $r)); $this->assertTrue(Set::matches('/Comment/updated', $r)); - $r = $this->Article->find('all', array('contain' => array('Comment' => array('comment', 'updated')))); + $r = $this->Article->find('all', ['contain' => ['Comment' => ['comment', 'updated']]]); $this->assertFalse(Set::matches('/Comment/created', $r)); $this->assertTrue(Set::matches('/Comment/comment', $r)); $this->assertTrue(Set::matches('/Comment/updated', $r)); - $r = $this->Article->find('all', array('contain' => array('Comment(comment,updated)'))); + $r = $this->Article->find('all', ['contain' => ['Comment(comment,updated)']]); $this->assertFalse(Set::matches('/Comment/created', $r)); $this->assertTrue(Set::matches('/Comment/comment', $r)); $this->assertTrue(Set::matches('/Comment/updated', $r)); - $r = $this->Article->find('all', array('contain' => 'Comment.created')); + $r = $this->Article->find('all', ['contain' => 'Comment.created']); $this->assertTrue(Set::matches('/Comment/created', $r)); $this->assertFalse(Set::matches('/Comment/comment', $r)); - $r = $this->Article->find('all', array('contain' => array('User.Article(title)', 'Comment(comment)'))); + $r = $this->Article->find('all', ['contain' => ['User.Article(title)', 'Comment(comment)']]); $this->assertFalse(Set::matches('/Comment/Article', $r)); $this->assertFalse(Set::matches('/Comment/User', $r)); $this->assertTrue(Set::matches('/Comment/comment', $r)); @@ -233,7 +233,7 @@ public function testBeforeFind() { $this->assertTrue(Set::matches('/User/Article/title', $r)); $this->assertFalse(Set::matches('/User/Article/created', $r)); - $r = $this->Article->find('all', array('contain' => array())); + $r = $this->Article->find('all', ['contain' => []]); $this->assertFalse(Set::matches('/User', $r)); $this->assertFalse(Set::matches('/Comment', $r)); } @@ -245,7 +245,7 @@ public function testBeforeFind() { */ public function testBeforeFindWithNonExistingBinding() { $this->expectWarning(); - $this->Article->find('all', array('contain' => array('Comment' => 'NonExistingBinding'))); + $this->Article->find('all', ['contain' => ['Comment' => 'NonExistingBinding']]); } /** @@ -271,19 +271,19 @@ public function testContain() { public function testContainFindList() { $this->Article->contain('Comment.User'); $result = $this->Article->find('list'); - $expected = array( + $expected = [ 1 => 'First Article', 2 => 'Second Article', 3 => 'Third Article' - ); + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('list', array('fields' => array('Article.id', 'User.id'), 'contain' => array('User'))); - $expected = array( + $result = $this->Article->find('list', ['fields' => ['Article.id', 'User.id'], 'contain' => ['User']]); + $expected = [ 1 => '1', 2 => '3', 3 => '1' - ); + ]; $this->assertEquals($expected, $result); } @@ -294,9 +294,9 @@ public function testContainFindList() { */ public function testContainAndContainOption() { $this->Article->contain(); - $r = $this->Article->find('all', array( - 'contain' => array('Comment') - )); + $r = $this->Article->find('all', [ + 'contain' => ['Comment'] + ]); $this->assertTrue(isset($r[0]['Comment']), 'No comment returned'); } @@ -306,21 +306,21 @@ public function testContainAndContainOption() { * @return void */ public function testFindEmbeddedNoBindings() { - $result = $this->Article->find('all', array('contain' => false)); - $expected = array( - array('Article' => array( + $result = $this->Article->find('all', ['contain' => false]); + $expected = [ + ['Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - )) - ); + ]] + ]; $this->assertEquals($expected, $result); } @@ -331,104 +331,104 @@ public function testFindEmbeddedNoBindings() { */ public function testFindFirstLevel() { $this->Article->contain('User'); - $result = $this->Article->find('all', array('recursive' => 1)); - $expected = array( - array( - 'Article' => array( + $result = $this->Article->find('all', ['recursive' => 1]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $this->Article->contain('User', 'Comment'); - $result = $this->Article->find('all', array('recursive' => 1)); - $expected = array( - array( - 'Article' => array( + $result = $this->Article->find('all', ['recursive' => 1]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - ), - array( + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ) - ), - array( - 'Article' => array( + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ), - array( + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ) - ) - ), - array( - 'Article' => array( + ] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array() - ) - ); + ], + 'Comment' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -438,103 +438,103 @@ public function testFindFirstLevel() { * @return void */ public function testFindEmbeddedFirstLevel() { - $result = $this->Article->find('all', array('contain' => array('User'))); - $expected = array( - array( - 'Article' => array( + $result = $this->Article->find('all', ['contain' => ['User']]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array('contain' => array('User', 'Comment'))); - $expected = array( - array( - 'Article' => array( + $result = $this->Article->find('all', ['contain' => ['User', 'Comment']]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - ), - array( + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ) - ), - array( - 'Article' => array( + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ), - array( + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ) - ) - ), - array( - 'Article' => array( + ] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array() - ) - ); + ], + 'Comment' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -544,402 +544,402 @@ public function testFindEmbeddedFirstLevel() { * @return void */ public function testFindSecondLevel() { - $this->Article->contain(array('Comment' => 'User')); - $result = $this->Article->find('all', array('recursive' => 2)); - $expected = array( - array( - 'Article' => array( + $this->Article->contain(['Comment' => 'User']); + $result = $this->Article->find('all', ['recursive' => 2]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'User' => array( + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ) - ), - array( + ] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'User' => array( + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ) - ), - array( + ] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'User' => array( + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( + ] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'User' => array( + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'User' => array( + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'User' => array( + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'Comment' => array() - ) - ); + ], + 'Comment' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->Article->contain(array('User' => 'ArticleFeatured')); - $result = $this->Article->find('all', array('recursive' => 2)); - $expected = array( - array( - 'Article' => array( + $this->Article->contain(['User' => 'ArticleFeatured']); + $result = $this->Article->find('all', ['recursive' => 2]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $this->Article->contain(array('User' => array('id', 'ArticleFeatured'))); - $result = $this->Article->find('all', array('recursive' => 2)); - $expected = array( - array( - 'Article' => array( + $this->Article->contain(['User' => ['id', 'ArticleFeatured']]); + $result = $this->Article->find('all', ['recursive' => 2]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $this->Article->contain(array('User' => array('ArticleFeatured', 'Comment'))); - $result = $this->Article->find('all', array('recursive' => 2)); - $expected = array( - array( - 'Article' => array( + $this->Article->contain(['User' => ['ArticleFeatured', 'Comment']]); + $result = $this->Article->find('all', ['recursive' => 2]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - array( + ], + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), - 'Comment' => array() - ) - ), - array( - 'Article' => array( + ] + ], + 'Comment' => [] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - array( + ], + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $this->Article->contain(array('User' => array('ArticleFeatured')), 'Tag', array('Comment' => 'Attachment')); - $result = $this->Article->find('all', array('recursive' => 2)); - $expected = array( - array( - 'Article' => array( + $this->Article->contain(['User' => ['ArticleFeatured']], 'Tag', ['Comment' => 'Attachment']); + $result = $this->Article->find('all', ['recursive' => 2]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ), - 'Comment' => array( - array( + ] + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Attachment' => array() - ) - ), - 'Tag' => array( - array('id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), - array('id' => 2, 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31') - ) - ), - array( - 'Article' => array( + 'Attachment' => [] + ] + ], + 'Tag' => [ + ['id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'], + ['id' => 2, 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ) - ), - 'Comment' => array( - array( + ] + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Attachment' => array( + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Attachment' => array() - ) - ), - 'Tag' => array( - array('id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), - array('id' => 3, 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31') - ) - ), - array( - 'Article' => array( + 'Attachment' => [] + ] + ], + 'Tag' => [ + ['id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'], + ['id' => 3, 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31'] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ), - 'Comment' => array(), - 'Tag' => array() - ) - ); + ] + ] + ], + 'Comment' => [], + 'Tag' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -949,339 +949,339 @@ public function testFindSecondLevel() { * @return void */ public function testFindEmbeddedSecondLevel() { - $result = $this->Article->find('all', array('contain' => array('Comment' => 'User'))); - $expected = array( - array( - 'Article' => array( + $result = $this->Article->find('all', ['contain' => ['Comment' => 'User']]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'User' => array( + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ) - ), - array( + ] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'User' => array( + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ) - ), - array( + ] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'User' => array( + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( + ] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'User' => array( + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'User' => array( + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'User' => array( + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'Comment' => array() - ) - ); + ], + 'Comment' => [] + ] + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array('contain' => array('User' => 'ArticleFeatured'))); - $expected = array( - array( - 'Article' => array( + $result = $this->Article->find('all', ['contain' => ['User' => 'ArticleFeatured']]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array('contain' => array('User' => array('ArticleFeatured', 'Comment')))); - $expected = array( - array( - 'Article' => array( + $result = $this->Article->find('all', ['contain' => ['User' => ['ArticleFeatured', 'Comment']]]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - array( + ], + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ) - ) - ) - ), - array( - 'Article' => array( + ] + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), - 'Comment' => array() - ) - ), - array( - 'Article' => array( + ] + ], + 'Comment' => [] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - array( + ], + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array('contain' => array('User' => 'ArticleFeatured', 'Tag', 'Comment' => 'Attachment'))); - $expected = array( - array( - 'Article' => array( + $result = $this->Article->find('all', ['contain' => ['User' => 'ArticleFeatured', 'Tag', 'Comment' => 'Attachment']]); + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ), - 'Comment' => array( - array( + ] + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Attachment' => array() - ) - ), - 'Tag' => array( - array('id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), - array('id' => 2, 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31') - ) - ), - array( - 'Article' => array( + 'Attachment' => [] + ] + ], + 'Tag' => [ + ['id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'], + ['id' => 2, 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'] + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ) - ), - 'Comment' => array( - array( + ] + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Attachment' => array( + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Attachment' => array() - ) - ), - 'Tag' => array( - array('id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), - array('id' => 3, 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31') - ) - ), - array( - 'Article' => array( + 'Attachment' => [] + ] + ], + 'Tag' => [ + ['id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'], + ['id' => 3, 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31'] + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'ArticleFeatured' => array( - array( + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ), - 'Comment' => array(), - 'Tag' => array() - ) - ); + ] + ] + ], + 'Comment' => [], + 'Tag' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -1291,317 +1291,317 @@ public function testFindEmbeddedSecondLevel() { * @return void */ public function testFindThirdLevel() { - $this->User->contain(array('ArticleFeatured' => array('Featured' => 'Category'))); - $result = $this->User->find('all', array('recursive' => 3)); - $expected = array( - array( - 'User' => array( + $this->User->contain(['ArticleFeatured' => ['Featured' => 'Category']]); + $result = $this->User->find('all', ['recursive' => 3]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ) - ), - array( + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ) - ) - ) - ), - array( - 'User' => array( + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->User->contain(array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment')))); - $result = $this->User->find('all', array('recursive' => 3)); - $expected = array( - array( - 'User' => array( + $this->User->contain(['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => ['Article', 'Attachment']]]); + $result = $this->User->find('all', ['recursive' => 3]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ) - ) - ), - array( + ], + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + ], + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->User->contain(array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => 'Attachment'), 'Article')); - $result = $this->User->find('all', array('recursive' => 3)); - $expected = array( - array( - 'User' => array( + $this->User->contain(['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => 'Attachment'], 'Article']); + $result = $this->User->find('all', ['recursive' => 3]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - 'ArticleFeatured' => array( - array( + ] + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Attachment' => array() - ) - ) - ), - array( + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Article' => array(), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'Article' => [], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), - 'ArticleFeatured' => array( - array( + ] + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Attachment' => array( + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'Article' => array(), - 'ArticleFeatured' => array() - ) - ); + ], + 'Article' => [], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -1611,314 +1611,314 @@ public function testFindThirdLevel() { * @return void */ public function testFindEmbeddedThirdLevel() { - $result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => 'Category')))); - $expected = array( - array( - 'User' => array( + $result = $this->User->find('all', ['contain' => ['ArticleFeatured' => ['Featured' => 'Category']]]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ) - ), - array( + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ) - ) - ) - ), - array( - 'User' => array( + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment'))))); - $expected = array( - array( - 'User' => array( + $result = $this->User->find('all', ['contain' => ['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => ['Article', 'Attachment']]]]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ) - ) - ), - array( + ], + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + ], + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => 'Attachment'), 'Article'))); - $expected = array( - array( - 'User' => array( + $result = $this->User->find('all', ['contain' => ['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => 'Attachment'], 'Article']]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - 'ArticleFeatured' => array( - array( + ] + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Attachment' => array() - ) - ) - ), - array( + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Article' => array(), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'Article' => [], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), - 'ArticleFeatured' => array( - array( + ] + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Attachment' => array( + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'Article' => array(), - 'ArticleFeatured' => array() - ) - ); + ], + 'Article' => [], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -1928,77 +1928,77 @@ public function testFindEmbeddedThirdLevel() { * @return void */ public function testSettingsThirdLevel() { - $result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => array('Category' => array('id', 'name')))))); - $expected = array( - array( - 'User' => array( + $result = $this->User->find('all', ['contain' => ['ArticleFeatured' => ['Featured' => ['Category' => ['id', 'name']]]]]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'name' => 'Category 1' - ) - ) - ), - array( + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'name' => 'Category 1' - ) - ) - ) - ) - ), - array( - 'User' => array( + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $r = $this->User->find('all', array('contain' => array( - 'ArticleFeatured' => array( + $r = $this->User->find('all', ['contain' => [ + 'ArticleFeatured' => [ 'id', 'title', - 'Featured' => array( + 'Featured' => [ 'id', 'category_id', - 'Category' => array('id', 'name') - ) - ) - ))); + 'Category' => ['id', 'name'] + ] + ] + ]]); $this->assertTrue(Set::matches('/User[id=1]', $r)); $this->assertFalse(Set::matches('/Article', $r) || Set::matches('/Comment', $r)); @@ -2011,15 +2011,15 @@ public function testSettingsThirdLevel() { $this->assertTrue(Set::matches('/ArticleFeatured/Featured[id=1]/Category[id=1]', $r)); $this->assertTrue(Set::matches('/ArticleFeatured/Featured[id=1]/Category[name=Category 1]', $r)); - $r = $this->User->find('all', array('contain' => array( - 'ArticleFeatured' => array( + $r = $this->User->find('all', ['contain' => [ + 'ArticleFeatured' => [ 'title', - 'Featured' => array( + 'Featured' => [ 'id', 'Category' => 'name' - ) - ) - ))); + ] + ] + ]]); $this->assertTrue(Set::matches('/User[id=1]', $r)); $this->assertFalse(Set::matches('/Article', $r) || Set::matches('/Comment', $r)); @@ -2031,139 +2031,139 @@ public function testSettingsThirdLevel() { $this->assertTrue(Set::matches('/ArticleFeatured/Featured[id=1]', $r)); $this->assertTrue(Set::matches('/ArticleFeatured/Featured[id=1]/Category[name=Category 1]', $r)); - $result = $this->User->find('all', array('contain' => array( - 'ArticleFeatured' => array( + $result = $this->User->find('all', ['contain' => [ + 'ArticleFeatured' => [ 'title', - 'Featured' => array( + 'Featured' => [ 'category_id', 'Category' => 'name' - ) - ) - ))); - $expected = array( - array( - 'User' => array( + ] + ] + ]]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'title' => 'First Article', 'id' => 1, 'user_id' => 1, - 'Featured' => array( + 'Featured' => [ 'category_id' => 1, 'id' => 1, - 'Category' => array( + 'Category' => [ 'name' => 'Category 1' - ) - ) - ), - array( + ] + ] + ], + [ 'title' => 'Third Article', 'id' => 3, 'user_id' => 1, - 'Featured' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'title' => 'Second Article', 'id' => 2, 'user_id' => 3, - 'Featured' => array( + 'Featured' => [ 'category_id' => 1, 'id' => 2, - 'Category' => array( + 'Category' => [ 'name' => 'Category 1' - ) - ) - ) - ) - ), - array( - 'User' => array( + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $orders = array( + $orders = [ 'title DESC', 'title DESC, published DESC', - array('title' => 'DESC'), array('title' => 'DESC', 'published' => 'DESC'), - ); + ['title' => 'DESC'], ['title' => 'DESC', 'published' => 'DESC'], + ]; foreach ($orders as $order) { - $result = $this->User->find('all', array('contain' => array( - 'ArticleFeatured' => array( + $result = $this->User->find('all', ['contain' => [ + 'ArticleFeatured' => [ 'title', 'order' => $order, - 'Featured' => array( + 'Featured' => [ 'category_id', 'Category' => 'name' - ) - ) - ))); - $expected = array( - array( - 'User' => array( + ] + ] + ]]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'title' => 'Third Article', 'id' => 3, 'user_id' => 1, - 'Featured' => array() - ), - array( + 'Featured' => [] + ], + [ 'title' => 'First Article', 'id' => 1, 'user_id' => 1, - 'Featured' => array( + 'Featured' => [ 'category_id' => 1, 'id' => 1, - 'Category' => array( + 'Category' => [ 'name' => 'Category 1' - ) - ) - ) - ) - ), - array( - 'User' => array( + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'title' => 'Second Article', 'id' => 2, 'user_id' => 3, - 'Featured' => array( + 'Featured' => [ 'category_id' => 1, 'id' => 2, - 'Category' => array( + 'Category' => [ 'name' => 'Category 1' - ) - ) - ) - ) - ), - array( - 'User' => array( + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); } } @@ -2174,321 +2174,321 @@ public function testSettingsThirdLevel() { * @return void */ public function testFindThirdLevelNonReset() { - $this->User->contain(false, array('ArticleFeatured' => array('Featured' => 'Category'))); - $result = $this->User->find('all', array('recursive' => 3)); - $expected = array( - array( - 'User' => array( + $this->User->contain(false, ['ArticleFeatured' => ['Featured' => 'Category']]); + $result = $this->User->find('all', ['recursive' => 3]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ) - ), - array( + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ) - ) - ) - ), - array( - 'User' => array( + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); $this->User->resetBindings(); - $this->User->contain(false, array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment')))); - $result = $this->User->find('all', array('recursive' => 3)); - $expected = array( - array( - 'User' => array( + $this->User->contain(false, ['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => ['Article', 'Attachment']]]); + $result = $this->User->find('all', ['recursive' => 3]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ) - ) - ), - array( + ], + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + ], + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); $this->User->resetBindings(); - $this->User->contain(false, array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => 'Attachment'), 'Article')); - $result = $this->User->find('all', array('recursive' => 3)); - $expected = array( - array( - 'User' => array( + $this->User->contain(false, ['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => 'Attachment'], 'Article']); + $result = $this->User->find('all', ['recursive' => 3]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - 'ArticleFeatured' => array( - array( + ] + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Attachment' => array() - ) - ) - ), - array( + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Article' => array(), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'Article' => [], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), - 'ArticleFeatured' => array( - array( + ] + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Attachment' => array( + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'Article' => array(), - 'ArticleFeatured' => array() - ) - ); + ], + 'Article' => [], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -2498,487 +2498,487 @@ public function testFindThirdLevelNonReset() { * @return void */ public function testFindEmbeddedThirdLevelNonReset() { - $result = $this->User->find('all', array('reset' => false, 'contain' => array('ArticleFeatured' => array('Featured' => 'Category')))); - $expected = array( - array( - 'User' => array( + $result = $this->User->find('all', ['reset' => false, 'contain' => ['ArticleFeatured' => ['Featured' => 'Category']]]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ) - ), - array( + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ) - ) - ) - ), - array( - 'User' => array( + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->_assertBindings($this->User, array('hasMany' => array('ArticleFeatured'))); - $this->_assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'))); - $this->_assertBindings($this->User->ArticleFeatured->Featured, array('belongsTo' => array('Category'))); + $this->_assertBindings($this->User, ['hasMany' => ['ArticleFeatured']]); + $this->_assertBindings($this->User->ArticleFeatured, ['hasOne' => ['Featured']]); + $this->_assertBindings($this->User->ArticleFeatured->Featured, ['belongsTo' => ['Category']]); $this->User->resetBindings(); - $this->_assertBindings($this->User, array('hasMany' => array('Article', 'ArticleFeatured', 'Comment'))); - $this->_assertBindings($this->User->ArticleFeatured, array('belongsTo' => array('User'), 'hasOne' => array('Featured'), 'hasMany' => array('Comment'), 'hasAndBelongsToMany' => array('Tag'))); - $this->_assertBindings($this->User->ArticleFeatured->Featured, array('belongsTo' => array('ArticleFeatured', 'Category'))); - $this->_assertBindings($this->User->ArticleFeatured->Comment, array('belongsTo' => array('Article', 'User'), 'hasOne' => array('Attachment'))); + $this->_assertBindings($this->User, ['hasMany' => ['Article', 'ArticleFeatured', 'Comment']]); + $this->_assertBindings($this->User->ArticleFeatured, ['belongsTo' => ['User'], 'hasOne' => ['Featured'], 'hasMany' => ['Comment'], 'hasAndBelongsToMany' => ['Tag']]); + $this->_assertBindings($this->User->ArticleFeatured->Featured, ['belongsTo' => ['ArticleFeatured', 'Category']]); + $this->_assertBindings($this->User->ArticleFeatured->Comment, ['belongsTo' => ['Article', 'User'], 'hasOne' => ['Attachment']]); - $result = $this->User->find('all', array('reset' => false, 'contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment'))))); - $expected = array( - array( - 'User' => array( + $result = $this->User->find('all', ['reset' => false, 'contain' => ['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => ['Article', 'Attachment']]]]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ) - ) - ), - array( + ], + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + ], + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->_assertBindings($this->User, array('hasMany' => array('ArticleFeatured'))); - $this->_assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'), 'hasMany' => array('Comment'))); - $this->_assertBindings($this->User->ArticleFeatured->Featured, array('belongsTo' => array('Category'))); - $this->_assertBindings($this->User->ArticleFeatured->Comment, array('belongsTo' => array('Article'), 'hasOne' => array('Attachment'))); + $this->_assertBindings($this->User, ['hasMany' => ['ArticleFeatured']]); + $this->_assertBindings($this->User->ArticleFeatured, ['hasOne' => ['Featured'], 'hasMany' => ['Comment']]); + $this->_assertBindings($this->User->ArticleFeatured->Featured, ['belongsTo' => ['Category']]); + $this->_assertBindings($this->User->ArticleFeatured->Comment, ['belongsTo' => ['Article'], 'hasOne' => ['Attachment']]); $this->User->resetBindings(); - $this->_assertBindings($this->User, array('hasMany' => array('Article', 'ArticleFeatured', 'Comment'))); - $this->_assertBindings($this->User->ArticleFeatured, array('belongsTo' => array('User'), 'hasOne' => array('Featured'), 'hasMany' => array('Comment'), 'hasAndBelongsToMany' => array('Tag'))); - $this->_assertBindings($this->User->ArticleFeatured->Featured, array('belongsTo' => array('ArticleFeatured', 'Category'))); - $this->_assertBindings($this->User->ArticleFeatured->Comment, array('belongsTo' => array('Article', 'User'), 'hasOne' => array('Attachment'))); - - $result = $this->User->find('all', array('contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => array('Article', 'Attachment')), false))); - $expected = array( - array( - 'User' => array( + $this->_assertBindings($this->User, ['hasMany' => ['Article', 'ArticleFeatured', 'Comment']]); + $this->_assertBindings($this->User->ArticleFeatured, ['belongsTo' => ['User'], 'hasOne' => ['Featured'], 'hasMany' => ['Comment'], 'hasAndBelongsToMany' => ['Tag']]); + $this->_assertBindings($this->User->ArticleFeatured->Featured, ['belongsTo' => ['ArticleFeatured', 'Category']]); + $this->_assertBindings($this->User->ArticleFeatured->Comment, ['belongsTo' => ['Article', 'User'], 'hasOne' => ['Attachment']]); + + $result = $this->User->find('all', ['contain' => ['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => ['Article', 'Attachment']], false]]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ), - array( + ], + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Article' => array( + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Attachment' => array() - ) - ) - ), - array( + ], + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'ArticleFeatured' => array( - array( + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Article' => array( + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + ], + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'ArticleFeatured' => array() - ) - ); + ], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->_assertBindings($this->User, array('hasMany' => array('ArticleFeatured'))); - $this->_assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'), 'hasMany' => array('Comment'))); - $this->_assertBindings($this->User->ArticleFeatured->Featured, array('belongsTo' => array('Category'))); - $this->_assertBindings($this->User->ArticleFeatured->Comment, array('belongsTo' => array('Article'), 'hasOne' => array('Attachment'))); + $this->_assertBindings($this->User, ['hasMany' => ['ArticleFeatured']]); + $this->_assertBindings($this->User->ArticleFeatured, ['hasOne' => ['Featured'], 'hasMany' => ['Comment']]); + $this->_assertBindings($this->User->ArticleFeatured->Featured, ['belongsTo' => ['Category']]); + $this->_assertBindings($this->User->ArticleFeatured->Comment, ['belongsTo' => ['Article'], 'hasOne' => ['Attachment']]); $this->User->resetBindings(); - $this->_assertBindings($this->User, array('hasMany' => array('Article', 'ArticleFeatured', 'Comment'))); - $this->_assertBindings($this->User->ArticleFeatured, array('belongsTo' => array('User'), 'hasOne' => array('Featured'), 'hasMany' => array('Comment'), 'hasAndBelongsToMany' => array('Tag'))); - $this->_assertBindings($this->User->ArticleFeatured->Featured, array('belongsTo' => array('ArticleFeatured', 'Category'))); - $this->_assertBindings($this->User->ArticleFeatured->Comment, array('belongsTo' => array('Article', 'User'), 'hasOne' => array('Attachment'))); - - $result = $this->User->find('all', array('reset' => false, 'contain' => array('ArticleFeatured' => array('Featured' => 'Category', 'Comment' => 'Attachment'), 'Article'))); - $expected = array( - array( - 'User' => array( + $this->_assertBindings($this->User, ['hasMany' => ['Article', 'ArticleFeatured', 'Comment']]); + $this->_assertBindings($this->User->ArticleFeatured, ['belongsTo' => ['User'], 'hasOne' => ['Featured'], 'hasMany' => ['Comment'], 'hasAndBelongsToMany' => ['Tag']]); + $this->_assertBindings($this->User->ArticleFeatured->Featured, ['belongsTo' => ['ArticleFeatured', 'Category']]); + $this->_assertBindings($this->User->ArticleFeatured->Comment, ['belongsTo' => ['Article', 'User'], 'hasOne' => ['Attachment']]); + + $result = $this->User->find('all', ['reset' => false, 'contain' => ['ArticleFeatured' => ['Featured' => 'Category', 'Comment' => 'Attachment'], 'Article']]); + $expected = [ + [ + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - 'ArticleFeatured' => array( - array( + ] + ], + 'ArticleFeatured' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Featured' => array( + 'Featured' => [ 'id' => 1, 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31', - 'Attachment' => array() - ), - array( + 'Attachment' => [] + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31', - 'Attachment' => array() - ) - ) - ), - array( + 'Attachment' => [] + ] + ] + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Featured' => array(), - 'Comment' => array() - ) - ) - ), - array( - 'User' => array( + 'Featured' => [], + 'Comment' => [] + ] + ] + ], + [ + 'User' => [ 'id' => 2, 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Article' => array(), - 'ArticleFeatured' => array() - ), - array( - 'User' => array( + ], + 'Article' => [], + 'ArticleFeatured' => [] + ], + [ + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), - 'ArticleFeatured' => array( - array( + ] + ], + 'ArticleFeatured' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'Featured' => array( + 'Featured' => [ 'id' => 2, 'article_featured_id' => 2, 'category_id' => 1, 'published_date' => '2007-03-31 10:39:23', 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Category' => array( + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ) - ), - 'Comment' => array( - array( + ] + ], + 'Comment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Attachment' => array( + 'Attachment' => [ 'id' => 1, 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Attachment' => array() - ) - ) - ) - ) - ), - array( - 'User' => array( + 'Attachment' => [] + ] + ] + ] + ] + ], + [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'Article' => array(), - 'ArticleFeatured' => array() - ) - ); + ], + 'Article' => [], + 'ArticleFeatured' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->_assertBindings($this->User, array('hasMany' => array('Article', 'ArticleFeatured'))); + $this->_assertBindings($this->User, ['hasMany' => ['Article', 'ArticleFeatured']]); $this->_assertBindings($this->User->Article); - $this->_assertBindings($this->User->ArticleFeatured, array('hasOne' => array('Featured'), 'hasMany' => array('Comment'))); - $this->_assertBindings($this->User->ArticleFeatured->Featured, array('belongsTo' => array('Category'))); - $this->_assertBindings($this->User->ArticleFeatured->Comment, array('hasOne' => array('Attachment'))); + $this->_assertBindings($this->User->ArticleFeatured, ['hasOne' => ['Featured'], 'hasMany' => ['Comment']]); + $this->_assertBindings($this->User->ArticleFeatured->Featured, ['belongsTo' => ['Category']]); + $this->_assertBindings($this->User->ArticleFeatured->Comment, ['hasOne' => ['Attachment']]); $this->User->resetBindings(); - $this->_assertBindings($this->User, array('hasMany' => array('Article', 'ArticleFeatured', 'Comment'))); - $this->_assertBindings($this->User->Article, array('belongsTo' => array('User'), 'hasMany' => array('Comment'), 'hasAndBelongsToMany' => array('Tag'))); - $this->_assertBindings($this->User->ArticleFeatured, array('belongsTo' => array('User'), 'hasOne' => array('Featured'), 'hasMany' => array('Comment'), 'hasAndBelongsToMany' => array('Tag'))); - $this->_assertBindings($this->User->ArticleFeatured->Featured, array('belongsTo' => array('ArticleFeatured', 'Category'))); - $this->_assertBindings($this->User->ArticleFeatured->Comment, array('belongsTo' => array('Article', 'User'), 'hasOne' => array('Attachment'))); + $this->_assertBindings($this->User, ['hasMany' => ['Article', 'ArticleFeatured', 'Comment']]); + $this->_assertBindings($this->User->Article, ['belongsTo' => ['User'], 'hasMany' => ['Comment'], 'hasAndBelongsToMany' => ['Tag']]); + $this->_assertBindings($this->User->ArticleFeatured, ['belongsTo' => ['User'], 'hasOne' => ['Featured'], 'hasMany' => ['Comment'], 'hasAndBelongsToMany' => ['Tag']]); + $this->_assertBindings($this->User->ArticleFeatured->Featured, ['belongsTo' => ['ArticleFeatured', 'Category']]); + $this->_assertBindings($this->User->ArticleFeatured->Comment, ['belongsTo' => ['Article', 'User'], 'hasOne' => ['Attachment']]); } /** @@ -2987,71 +2987,71 @@ public function testFindEmbeddedThirdLevelNonReset() { * @return void */ public function testEmbeddedFindFields() { - $result = $this->Article->find('all', array( - 'contain' => array('User(user)'), - 'fields' => array('title'), - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array('Article' => array('title' => 'First Article'), 'User' => array('user' => 'mariano', 'id' => 1)), - array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)), - array('Article' => array('title' => 'Third Article'), 'User' => array('user' => 'mariano', 'id' => 1)), - ); + $result = $this->Article->find('all', [ + 'contain' => ['User(user)'], + 'fields' => ['title'], + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + ['Article' => ['title' => 'First Article'], 'User' => ['user' => 'mariano', 'id' => 1]], + ['Article' => ['title' => 'Second Article'], 'User' => ['user' => 'larry', 'id' => 3]], + ['Article' => ['title' => 'Third Article'], 'User' => ['user' => 'mariano', 'id' => 1]], + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array( - 'contain' => array('User(id, user)'), - 'fields' => array('title'), - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array('Article' => array('title' => 'First Article'), 'User' => array('user' => 'mariano', 'id' => 1)), - array('Article' => array('title' => 'Second Article'), 'User' => array('user' => 'larry', 'id' => 3)), - array('Article' => array('title' => 'Third Article'), 'User' => array('user' => 'mariano', 'id' => 1)), - ); + $result = $this->Article->find('all', [ + 'contain' => ['User(id, user)'], + 'fields' => ['title'], + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + ['Article' => ['title' => 'First Article'], 'User' => ['user' => 'mariano', 'id' => 1]], + ['Article' => ['title' => 'Second Article'], 'User' => ['user' => 'larry', 'id' => 3]], + ['Article' => ['title' => 'Third Article'], 'User' => ['user' => 'mariano', 'id' => 1]], + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array( - 'contain' => array( + $result = $this->Article->find('all', [ + 'contain' => [ 'Comment(comment, published)' => 'Attachment(attachment)', 'User(user)' - ), - 'fields' => array('title'), - 'order' => array('Article.id' => 'ASC') - )); + ], + 'fields' => ['title'], + 'order' => ['Article.id' => 'ASC'] + ]); if (!empty($result)) { foreach ($result as $i => $article) { foreach ($article['Comment'] as $j => $comment) { - $result[$i]['Comment'][$j] = array_diff_key($comment, array('id' => true)); + $result[$i]['Comment'][$j] = array_diff_key($comment, ['id' => true]); } } } - $expected = array( - array( - 'Article' => array('title' => 'First Article', 'id' => 1), - 'User' => array('user' => 'mariano', 'id' => 1), - 'Comment' => array( - array('comment' => 'First Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => array()), - array('comment' => 'Second Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => array()), - array('comment' => 'Third Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => array()), - array('comment' => 'Fourth Comment for First Article', 'published' => 'N', 'article_id' => 1, 'Attachment' => array()), - ) - ), - array( - 'Article' => array('title' => 'Second Article', 'id' => 2), - 'User' => array('user' => 'larry', 'id' => 3), - 'Comment' => array( - array('comment' => 'First Comment for Second Article', 'published' => 'Y', 'article_id' => 2, 'Attachment' => array( + $expected = [ + [ + 'Article' => ['title' => 'First Article', 'id' => 1], + 'User' => ['user' => 'mariano', 'id' => 1], + 'Comment' => [ + ['comment' => 'First Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => []], + ['comment' => 'Second Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => []], + ['comment' => 'Third Comment for First Article', 'published' => 'Y', 'article_id' => 1, 'Attachment' => []], + ['comment' => 'Fourth Comment for First Article', 'published' => 'N', 'article_id' => 1, 'Attachment' => []], + ] + ], + [ + 'Article' => ['title' => 'Second Article', 'id' => 2], + 'User' => ['user' => 'larry', 'id' => 3], + 'Comment' => [ + ['comment' => 'First Comment for Second Article', 'published' => 'Y', 'article_id' => 2, 'Attachment' => [ 'attachment' => 'attachment.zip', 'id' => 1 - )), - array('comment' => 'Second Comment for Second Article', 'published' => 'Y', 'article_id' => 2, 'Attachment' => array()) - ) - ), - array( - 'Article' => array('title' => 'Third Article', 'id' => 3), - 'User' => array('user' => 'mariano', 'id' => 1), - 'Comment' => array() - ), - ); + ]], + ['comment' => 'Second Comment for Second Article', 'published' => 'Y', 'article_id' => 2, 'Attachment' => []] + ] + ], + [ + 'Article' => ['title' => 'Third Article', 'id' => 3], + 'User' => ['user' => 'mariano', 'id' => 1], + 'Comment' => [] + ], + ]; $this->assertEquals($expected, $result); } @@ -3061,26 +3061,26 @@ public function testEmbeddedFindFields() { * @return void */ public function testHasOneFieldsInContain() { - $this->Article->unbindModel(array( - 'hasMany' => array('Comment') - ), true); + $this->Article->unbindModel([ + 'hasMany' => ['Comment'] + ], true); unset($this->Article->Comment); - $this->Article->bindModel(array( - 'hasOne' => array('Comment') - )); - - $result = $this->Article->find('all', array( - 'fields' => array('title', 'body'), - 'contain' => array( - 'Comment' => array( - 'fields' => array('comment') - ), - 'User' => array( - 'fields' => array('user') - ) - ), + $this->Article->bindModel([ + 'hasOne' => ['Comment'] + ]); + + $result = $this->Article->find('all', [ + 'fields' => ['title', 'body'], + 'contain' => [ + 'Comment' => [ + 'fields' => ['comment'] + ], + 'User' => [ + 'fields' => ['user'] + ] + ], 'order' => 'Article.id ASC', - )); + ]); $this->assertTrue(isset($result[0]['Article']['title']), 'title missing %s'); $this->assertTrue(isset($result[0]['Article']['body']), 'body missing %s'); $this->assertTrue(isset($result[0]['Comment']['comment']), 'comment missing %s'); @@ -3095,125 +3095,125 @@ public function testHasOneFieldsInContain() { * @return void */ public function testFindConditionalBinding() { - $this->Article->contain(array( + $this->Article->contain([ 'User(user)', - 'Tag' => array( - 'fields' => array('tag', 'created'), - 'conditions' => array('created >=' => '2007-03-18 12:24') - ) - )); - $result = $this->Article->find('all', array( - 'fields' => array('title'), - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array( - 'Article' => array('id' => 1, 'title' => 'First Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array(array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23')) - ), - array( - 'Article' => array('id' => 2, 'title' => 'Second Article'), - 'User' => array('id' => 3, 'user' => 'larry'), - 'Tag' => array(array('tag' => 'tag3', 'created' => '2007-03-18 12:26:23')) - ), - array( - 'Article' => array('id' => 3, 'title' => 'Third Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array() - ) - ); + 'Tag' => [ + 'fields' => ['tag', 'created'], + 'conditions' => ['created >=' => '2007-03-18 12:24'] + ] + ]); + $result = $this->Article->find('all', [ + 'fields' => ['title'], + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + [ + 'Article' => ['id' => 1, 'title' => 'First Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [['tag' => 'tag2', 'created' => '2007-03-18 12:24:23']] + ], + [ + 'Article' => ['id' => 2, 'title' => 'Second Article'], + 'User' => ['id' => 3, 'user' => 'larry'], + 'Tag' => [['tag' => 'tag3', 'created' => '2007-03-18 12:26:23']] + ], + [ + 'Article' => ['id' => 3, 'title' => 'Third Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created')))); - $result = $this->Article->find('all', array('fields' => array('title'), 'order' => array('Article.id' => 'ASC'))); - $expected = array( - array( - 'Article' => array('id' => 1, 'title' => 'First Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array( - array('tag' => 'tag1', 'created' => '2007-03-18 12:22:23'), - array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23') - ) - ), - array( - 'Article' => array('id' => 2, 'title' => 'Second Article'), - 'User' => array('id' => 3, 'user' => 'larry'), - 'Tag' => array( - array('tag' => 'tag1', 'created' => '2007-03-18 12:22:23'), - array('tag' => 'tag3', 'created' => '2007-03-18 12:26:23') - ) - ), - array( - 'Article' => array('id' => 3, 'title' => 'Third Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array() - ) - ); + $this->Article->contain(['User(id,user)', 'Tag' => ['fields' => ['tag', 'created']]]); + $result = $this->Article->find('all', ['fields' => ['title'], 'order' => ['Article.id' => 'ASC']]); + $expected = [ + [ + 'Article' => ['id' => 1, 'title' => 'First Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [ + ['tag' => 'tag1', 'created' => '2007-03-18 12:22:23'], + ['tag' => 'tag2', 'created' => '2007-03-18 12:24:23'] + ] + ], + [ + 'Article' => ['id' => 2, 'title' => 'Second Article'], + 'User' => ['id' => 3, 'user' => 'larry'], + 'Tag' => [ + ['tag' => 'tag1', 'created' => '2007-03-18 12:22:23'], + ['tag' => 'tag3', 'created' => '2007-03-18 12:26:23'] + ] + ], + [ + 'Article' => ['id' => 3, 'title' => 'Third Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [] + ] + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array( - 'fields' => array('title'), - 'contain' => array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created'))), - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array( - 'Article' => array('id' => 1, 'title' => 'First Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array( - array('tag' => 'tag1', 'created' => '2007-03-18 12:22:23'), - array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23') - ) - ), - array( - 'Article' => array('id' => 2, 'title' => 'Second Article'), - 'User' => array('id' => 3, 'user' => 'larry'), - 'Tag' => array( - array('tag' => 'tag1', 'created' => '2007-03-18 12:22:23'), - array('tag' => 'tag3', 'created' => '2007-03-18 12:26:23') - ) - ), - array( - 'Article' => array('id' => 3, 'title' => 'Third Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array() - ) - ); + $result = $this->Article->find('all', [ + 'fields' => ['title'], + 'contain' => ['User(id,user)', 'Tag' => ['fields' => ['tag', 'created']]], + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + [ + 'Article' => ['id' => 1, 'title' => 'First Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [ + ['tag' => 'tag1', 'created' => '2007-03-18 12:22:23'], + ['tag' => 'tag2', 'created' => '2007-03-18 12:24:23'] + ] + ], + [ + 'Article' => ['id' => 2, 'title' => 'Second Article'], + 'User' => ['id' => 3, 'user' => 'larry'], + 'Tag' => [ + ['tag' => 'tag1', 'created' => '2007-03-18 12:22:23'], + ['tag' => 'tag3', 'created' => '2007-03-18 12:26:23'] + ] + ], + [ + 'Article' => ['id' => 3, 'title' => 'Third Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [] + ] + ]; $this->assertEquals($expected, $result); - $this->Article->contain(array( + $this->Article->contain([ 'User(id,user)', - 'Tag' => array( - 'fields' => array('tag', 'created'), - 'conditions' => array('created >=' => '2007-03-18 12:24') - ) - )); - $result = $this->Article->find('all', array('fields' => array('title'), 'order' => array('Article.id' => 'ASC'))); - $expected = array( - array( - 'Article' => array('id' => 1, 'title' => 'First Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array(array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23')) - ), - array( - 'Article' => array('id' => 2, 'title' => 'Second Article'), - 'User' => array('id' => 3, 'user' => 'larry'), - 'Tag' => array(array('tag' => 'tag3', 'created' => '2007-03-18 12:26:23')) - ), - array( - 'Article' => array('id' => 3, 'title' => 'Third Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array() - ) - ); + 'Tag' => [ + 'fields' => ['tag', 'created'], + 'conditions' => ['created >=' => '2007-03-18 12:24'] + ] + ]); + $result = $this->Article->find('all', ['fields' => ['title'], 'order' => ['Article.id' => 'ASC']]); + $expected = [ + [ + 'Article' => ['id' => 1, 'title' => 'First Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [['tag' => 'tag2', 'created' => '2007-03-18 12:24:23']] + ], + [ + 'Article' => ['id' => 2, 'title' => 'Second Article'], + 'User' => ['id' => 3, 'user' => 'larry'], + 'Tag' => [['tag' => 'tag3', 'created' => '2007-03-18 12:26:23']] + ], + [ + 'Article' => ['id' => 3, 'title' => 'Third Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [] + ] + ]; $this->assertEquals($expected, $result); $this->assertTrue(empty($this->User->Article->hasAndBelongsToMany['Tag']['conditions'])); - $result = $this->User->find('all', array('contain' => array( - 'Article.Tag' => array('conditions' => array('created >=' => '2007-03-18 12:24')) - ))); + $result = $this->User->find('all', ['contain' => [ + 'Article.Tag' => ['conditions' => ['created >=' => '2007-03-18 12:24']] + ]]); $this->assertTrue(Set::matches('/User[id=1]', $result)); $this->assertFalse(Set::matches('/Article[id=1]/Tag[id=1]', $result)); @@ -3222,9 +3222,9 @@ public function testFindConditionalBinding() { $this->assertTrue(empty($this->User->Article->hasAndBelongsToMany['Tag']['order'])); - $result = $this->User->find('all', array('contain' => array( - 'Article.Tag' => array('order' => 'created DESC') - ))); + $result = $this->User->find('all', ['contain' => [ + 'Article.Tag' => ['order' => 'created DESC'] + ]]); $this->assertTrue(Set::matches('/User[id=1]', $result)); $this->assertTrue(Set::matches('/Article[id=1]/Tag[id=1]', $result)); @@ -3242,56 +3242,56 @@ public function testOtherFinds() { $expected = 3; $this->assertEquals($expected, $result); - $result = $this->Article->find('count', array('conditions' => array('Article.id >' => '1'))); + $result = $this->Article->find('count', ['conditions' => ['Article.id >' => '1']]); $expected = 2; $this->assertEquals($expected, $result); - $result = $this->Article->find('count', array('contain' => array())); + $result = $this->Article->find('count', ['contain' => []]); $expected = 3; $this->assertEquals($expected, $result); - $this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created'), 'conditions' => array('created >=' => '2007-03-18 12:24')))); - $result = $this->Article->find('first', array('fields' => array('title'))); - $expected = array( - 'Article' => array('id' => 1, 'title' => 'First Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array(array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23')) - ); + $this->Article->contain(['User(id,user)', 'Tag' => ['fields' => ['tag', 'created'], 'conditions' => ['created >=' => '2007-03-18 12:24']]]); + $result = $this->Article->find('first', ['fields' => ['title']]); + $expected = [ + 'Article' => ['id' => 1, 'title' => 'First Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [['tag' => 'tag2', 'created' => '2007-03-18 12:24:23']] + ]; $this->assertEquals($expected, $result); - $this->Article->contain(array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created')))); - $result = $this->Article->find('first', array('fields' => array('title'))); - $expected = array( - 'Article' => array('id' => 1, 'title' => 'First Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array( - array('tag' => 'tag1', 'created' => '2007-03-18 12:22:23'), - array('tag' => 'tag2', 'created' => '2007-03-18 12:24:23') - ) - ); + $this->Article->contain(['User(id,user)', 'Tag' => ['fields' => ['tag', 'created']]]); + $result = $this->Article->find('first', ['fields' => ['title']]); + $expected = [ + 'Article' => ['id' => 1, 'title' => 'First Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [ + ['tag' => 'tag1', 'created' => '2007-03-18 12:22:23'], + ['tag' => 'tag2', 'created' => '2007-03-18 12:24:23'] + ] + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('first', array( - 'fields' => array('title'), + $result = $this->Article->find('first', [ + 'fields' => ['title'], 'order' => 'Article.id DESC', - 'contain' => array('User(id,user)', 'Tag' => array('fields' => array('tag', 'created'))) - )); - $expected = array( - 'Article' => array('id' => 3, 'title' => 'Third Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Tag' => array() - ); + 'contain' => ['User(id,user)', 'Tag' => ['fields' => ['tag', 'created']]] + ]); + $expected = [ + 'Article' => ['id' => 3, 'title' => 'Third Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Tag' => [] + ]; $this->assertEquals($expected, $result); - $result = $this->Article->find('list', array( - 'contain' => array('User(id,user)'), - 'fields' => array('Article.id', 'Article.title') - )); - $expected = array( + $result = $this->Article->find('list', [ + 'contain' => ['User(id,user)'], + 'fields' => ['Article.id', 'Article.title'] + ]); + $expected = [ 1 => 'First Article', 2 => 'Second Article', 3 => 'Third Article' - ); + ]; $this->assertEquals($expected, $result); } @@ -3303,31 +3303,31 @@ public function testOtherFinds() { public function testOriginalAssociations() { $this->Article->Comment->Behaviors->load('Containable'); - $options = array( - 'conditions' => array( + $options = [ + 'conditions' => [ 'Comment.published' => 'Y', - ), + ], 'contain' => 'User', 'recursive' => 1 - ); + ]; $firstResult = $this->Article->Comment->find('all', $options); - $this->Article->Comment->find('all', array( - 'conditions' => array( + $this->Article->Comment->find('all', [ + 'conditions' => [ 'User.user' => 'mariano' - ), - 'fields' => array('User.password'), - 'contain' => array('User.password'), - )); + ], + 'fields' => ['User.password'], + 'contain' => ['User.password'], + ]); $result = $this->Article->Comment->find('all', $options); $this->assertEquals($firstResult, $result); - $this->Article->unbindModel(array('hasMany' => array('Comment'), 'belongsTo' => array('User'), 'hasAndBelongsToMany' => array('Tag')), false); - $this->Article->bindModel(array('hasMany' => array('Comment'), 'belongsTo' => array('User')), false); + $this->Article->unbindModel(['hasMany' => ['Comment'], 'belongsTo' => ['User'], 'hasAndBelongsToMany' => ['Tag']], false); + $this->Article->bindModel(['hasMany' => ['Comment'], 'belongsTo' => ['User']], false); - $r = $this->Article->find('all', array('contain' => array('Comment(comment)', 'User(user)'), 'fields' => array('title'))); + $r = $this->Article->find('all', ['contain' => ['Comment(comment)', 'User(user)'], 'fields' => ['title']]); $this->assertTrue(Set::matches('/Article[id=1]', $r)); $this->assertTrue(Set::matches('/User[id=1]', $r)); $this->assertTrue(Set::matches('/Comment[article_id=1]', $r)); @@ -3339,47 +3339,47 @@ public function testOriginalAssociations() { $this->assertTrue(Set::matches('/Comment[article_id=1]', $r)); $this->assertTrue(Set::matches('/Comment[id=1]', $r)); - $this->Article->bindModel(array('hasAndBelongsToMany' => array('Tag')), false); - - $this->Article->contain(false, array('User(id,user)', 'Comment' => array('fields' => array('comment'), 'conditions' => array('created >=' => '2007-03-18 10:49')))); - $result = $this->Article->find('all', array('fields' => array('title'), 'limit' => 1, 'page' => 1, 'order' => 'Article.id ASC')); - $expected = array(array( - 'Article' => array('id' => 1, 'title' => 'First Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Comment' => array( - array('comment' => 'Third Comment for First Article', 'article_id' => 1), - array('comment' => 'Fourth Comment for First Article', 'article_id' => 1) - ) - )); + $this->Article->bindModel(['hasAndBelongsToMany' => ['Tag']], false); + + $this->Article->contain(false, ['User(id,user)', 'Comment' => ['fields' => ['comment'], 'conditions' => ['created >=' => '2007-03-18 10:49']]]); + $result = $this->Article->find('all', ['fields' => ['title'], 'limit' => 1, 'page' => 1, 'order' => 'Article.id ASC']); + $expected = [[ + 'Article' => ['id' => 1, 'title' => 'First Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Comment' => [ + ['comment' => 'Third Comment for First Article', 'article_id' => 1], + ['comment' => 'Fourth Comment for First Article', 'article_id' => 1] + ] + ]]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array('fields' => array('title', 'User.id', 'User.user'), 'limit' => 1, 'page' => 2, 'order' => 'Article.id ASC')); - $expected = array(array( - 'Article' => array('id' => 2, 'title' => 'Second Article'), - 'User' => array('id' => 3, 'user' => 'larry'), - 'Comment' => array( - array('comment' => 'First Comment for Second Article', 'article_id' => 2), - array('comment' => 'Second Comment for Second Article', 'article_id' => 2) - ) - )); + $result = $this->Article->find('all', ['fields' => ['title', 'User.id', 'User.user'], 'limit' => 1, 'page' => 2, 'order' => 'Article.id ASC']); + $expected = [[ + 'Article' => ['id' => 2, 'title' => 'Second Article'], + 'User' => ['id' => 3, 'user' => 'larry'], + 'Comment' => [ + ['comment' => 'First Comment for Second Article', 'article_id' => 2], + ['comment' => 'Second Comment for Second Article', 'article_id' => 2] + ] + ]]; $this->assertEquals($expected, $result); - $result = $this->Article->find('all', array('fields' => array('title', 'User.id', 'User.user'), 'limit' => 1, 'page' => 3, 'order' => 'Article.id ASC')); - $expected = array(array( - 'Article' => array('id' => 3, 'title' => 'Third Article'), - 'User' => array('id' => 1, 'user' => 'mariano'), - 'Comment' => array() - )); + $result = $this->Article->find('all', ['fields' => ['title', 'User.id', 'User.user'], 'limit' => 1, 'page' => 3, 'order' => 'Article.id ASC']); + $expected = [[ + 'Article' => ['id' => 3, 'title' => 'Third Article'], + 'User' => ['id' => 1, 'user' => 'mariano'], + 'Comment' => [] + ]]; $this->assertEquals($expected, $result); - $this->Article->contain(false, array('User' => array('fields' => 'user'), 'Comment')); + $this->Article->contain(false, ['User' => ['fields' => 'user'], 'Comment']); $result = $this->Article->find('all'); $this->assertTrue(Set::matches('/Article[id=1]', $result)); $this->assertTrue(Set::matches('/User[user=mariano]', $result)); $this->assertTrue(Set::matches('/Comment[article_id=1]', $result)); $this->Article->resetBindings(); - $this->Article->contain(false, array('User' => array('fields' => array('user')), 'Comment')); + $this->Article->contain(false, ['User' => ['fields' => ['user']], 'Comment']); $result = $this->Article->find('all'); $this->assertTrue(Set::matches('/Article[id=1]', $result)); $this->assertTrue(Set::matches('/User[user=mariano]', $result)); @@ -3395,17 +3395,17 @@ public function testOriginalAssociations() { public function testResetAddedAssociation() { $this->assertTrue(empty($this->Article->hasMany['ArticlesTag'])); - $this->Article->bindModel(array( - 'hasMany' => array('ArticlesTag') - )); + $this->Article->bindModel([ + 'hasMany' => ['ArticlesTag'] + ]); $this->assertTrue(!empty($this->Article->hasMany['ArticlesTag'])); - $result = $this->Article->find('first', array( - 'conditions' => array('Article.id' => 1), - 'contain' => array('ArticlesTag') - )); + $result = $this->Article->find('first', [ + 'conditions' => ['Article.id' => 1], + 'contain' => ['ArticlesTag'] + ]); - $expected = array('Article', 'ArticlesTag'); + $expected = ['Article', 'ArticlesTag']; $this->assertTrue(!empty($result)); $this->assertEquals('First Article', $result['Article']['title']); $this->assertTrue(!empty($result['ArticlesTag'])); @@ -3421,8 +3421,8 @@ public function testResetAddedAssociation() { $this->JoinB->Behaviors->load('Containable'); $this->JoinC->Behaviors->load('Containable'); - $this->JoinA->JoinB->find('all', array('contain' => array('JoinA'))); - $this->JoinA->bindModel(array('hasOne' => array('JoinAsJoinC' => array('joinTable' => 'as_cs'))), false); + $this->JoinA->JoinB->find('all', ['contain' => ['JoinA']]); + $this->JoinA->bindModel(['hasOne' => ['JoinAsJoinC' => ['joinTable' => 'as_cs']]], false); $result = $this->JoinA->hasOne; $this->JoinA->find('all'); $resultAfter = $this->JoinA->hasOne; @@ -3439,23 +3439,23 @@ public function testResetAssociation() { $this->Article->Comment->Behaviors->load('Containable'); $this->Article->User->Behaviors->load('Containable'); - $initialOptions = array( - 'conditions' => array( + $initialOptions = [ + 'conditions' => [ 'Comment.published' => 'Y', - ), + ], 'contain' => 'User', 'recursive' => 1, - ); + ]; $initialModels = $this->Article->Comment->find('all', $initialOptions); - $findOptions = array( - 'conditions' => array( + $findOptions = [ + 'conditions' => [ 'User.user' => 'mariano', - ), - 'fields' => array('User.password'), - 'contain' => array('User.password') - ); + ], + 'fields' => ['User.password'], + 'contain' => ['User.password'] + ]; $result = $this->Article->Comment->find('all', $findOptions); $result = $this->Article->Comment->find('all', $initialOptions); $this->assertEquals($initialModels, $result); @@ -3467,10 +3467,10 @@ public function testResetAssociation() { * @return void */ public function testResetDeeperHasOneAssociations() { - $this->Article->User->unbindModel(array( - 'hasMany' => array('ArticleFeatured', 'Comment') - ), false); - $userHasOne = array('hasOne' => array('ArticleFeatured', 'Comment')); + $this->Article->User->unbindModel([ + 'hasMany' => ['ArticleFeatured', 'Comment'] + ], false); + $userHasOne = ['hasOne' => ['ArticleFeatured', 'Comment']]; $this->Article->User->bindModel($userHasOne, false); $expected = $this->Article->User->hasOne; @@ -3479,46 +3479,46 @@ public function testResetDeeperHasOneAssociations() { $this->Article->User->bindModel($userHasOne, false); $expected = $this->Article->User->hasOne; - $this->Article->find('all', array( - 'contain' => array( - 'User' => array('ArticleFeatured', 'Comment') - ) - )); + $this->Article->find('all', [ + 'contain' => [ + 'User' => ['ArticleFeatured', 'Comment'] + ] + ]); $this->assertEquals($expected, $this->Article->User->hasOne); $this->Article->User->bindModel($userHasOne, false); $expected = $this->Article->User->hasOne; - $this->Article->find('all', array( - 'contain' => array( - 'User' => array( + $this->Article->find('all', [ + 'contain' => [ + 'User' => [ 'ArticleFeatured', - 'Comment' => array('fields' => array('created')) - ) - ) - )); + 'Comment' => ['fields' => ['created']] + ] + ] + ]); $this->assertEquals($expected, $this->Article->User->hasOne); $this->Article->User->bindModel($userHasOne, false); $expected = $this->Article->User->hasOne; - $this->Article->find('all', array( - 'contain' => array( - 'User' => array( - 'Comment' => array('fields' => array('created')) - ) - ) - )); + $this->Article->find('all', [ + 'contain' => [ + 'User' => [ + 'Comment' => ['fields' => ['created']] + ] + ] + ]); $this->assertEquals($expected, $this->Article->User->hasOne); $this->Article->User->bindModel($userHasOne, false); $expected = $this->Article->User->hasOne; - $this->Article->find('all', array( - 'contain' => array( - 'User.ArticleFeatured' => array( - 'conditions' => array('ArticleFeatured.published' => 'Y') - ), + $this->Article->find('all', [ + 'contain' => [ + 'User.ArticleFeatured' => [ + 'conditions' => ['ArticleFeatured.published' => 'Y'] + ], 'User.Comment' - ) - )); + ] + ]); $this->assertEquals($expected, $this->Article->User->hasOne); } @@ -3528,24 +3528,24 @@ public function testResetDeeperHasOneAssociations() { * @return void */ public function testResetMultipleHabtmAssociations() { - $articleHabtm = array( - 'hasAndBelongsToMany' => array( - 'Tag' => array( + $articleHabtm = [ + 'hasAndBelongsToMany' => [ + 'Tag' => [ 'className' => 'Tag', 'joinTable' => 'articles_tags', 'foreignKey' => 'article_id', 'associationForeignKey' => 'tag_id' - ), - 'ShortTag' => array( + ], + 'ShortTag' => [ 'className' => 'Tag', 'joinTable' => 'articles_tags', 'foreignKey' => 'article_id', 'associationForeignKey' => 'tag_id', // LENGTH function mysql-only, using LIKE does almost the same 'conditions' => "ShortTag.tag LIKE '???'" - ) - ) - ); + ] + ] + ]; $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); @@ -3556,61 +3556,61 @@ public function testResetMultipleHabtmAssociations() { $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => 'Tag.tag')); + $this->Article->find('all', ['contain' => 'Tag.tag']); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => 'Tag')); + $this->Article->find('all', ['contain' => 'Tag']); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => array('Tag' => array('fields' => array(null))))); + $this->Article->find('all', ['contain' => ['Tag' => ['fields' => [null]]]]); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => array('Tag' => array('fields' => array('Tag.tag'))))); + $this->Article->find('all', ['contain' => ['Tag' => ['fields' => ['Tag.tag']]]]); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => array('Tag' => array('fields' => array('Tag.tag', 'Tag.created'))))); + $this->Article->find('all', ['contain' => ['Tag' => ['fields' => ['Tag.tag', 'Tag.created']]]]); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => 'ShortTag.tag')); + $this->Article->find('all', ['contain' => 'ShortTag.tag']); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => 'ShortTag')); + $this->Article->find('all', ['contain' => 'ShortTag']); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => array('ShortTag' => array('fields' => array(null))))); + $this->Article->find('all', ['contain' => ['ShortTag' => ['fields' => [null]]]]); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => array('ShortTag' => array('fields' => array('ShortTag.tag'))))); + $this->Article->find('all', ['contain' => ['ShortTag' => ['fields' => ['ShortTag.tag']]]]); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); $this->Article->resetBindings(); $this->Article->bindModel($articleHabtm, false); $expected = $this->Article->hasAndBelongsToMany; - $this->Article->find('all', array('contain' => array('ShortTag' => array('fields' => array('ShortTag.tag', 'ShortTag.created'))))); + $this->Article->find('all', ['contain' => ['ShortTag' => ['fields' => ['ShortTag.tag', 'ShortTag.created']]]]); $this->assertEquals($expected, $this->Article->hasAndBelongsToMany); } @@ -3620,31 +3620,31 @@ public function testResetMultipleHabtmAssociations() { * @return void */ public function testBindMultipleTimesWithFind() { - $binding = array( - 'hasOne' => array( - 'ArticlesTag' => array( + $binding = [ + 'hasOne' => [ + 'ArticlesTag' => [ 'foreignKey' => false, 'type' => 'INNER', - 'conditions' => array( + 'conditions' => [ 'ArticlesTag.article_id = Article.id' - ) - ), - 'Tag' => array( + ] + ], + 'Tag' => [ 'type' => 'INNER', 'foreignKey' => false, - 'conditions' => array( + 'conditions' => [ 'ArticlesTag.tag_id = Tag.id' - ) - ) - ) - ); - $this->Article->unbindModel(array('hasAndBelongsToMany' => array('Tag'))); + ] + ] + ] + ]; + $this->Article->unbindModel(['hasAndBelongsToMany' => ['Tag']]); $this->Article->bindModel($binding); - $result = $this->Article->find('all', array('limit' => 1, 'contain' => array('ArticlesTag', 'Tag'))); + $result = $this->Article->find('all', ['limit' => 1, 'contain' => ['ArticlesTag', 'Tag']]); - $this->Article->unbindModel(array('hasAndBelongsToMany' => array('Tag'))); + $this->Article->unbindModel(['hasAndBelongsToMany' => ['Tag']]); $this->Article->bindModel($binding); - $result = $this->Article->find('all', array('limit' => 1, 'contain' => array('ArticlesTag', 'Tag'))); + $result = $this->Article->find('all', ['limit' => 1, 'contain' => ['ArticlesTag', 'Tag']]); $associated = $this->Article->getAssociated(); $this->assertEquals('hasAndBelongsToMany', $associated['Tag']); @@ -3672,10 +3672,10 @@ public function testAutoFieldsWithMultipleDatabases() { $this->Article->User->setDataSource('test2'); - $result = $this->Article->find('all', array( - 'fields' => array('Article.title'), - 'contain' => array('User') - )); + $result = $this->Article->find('all', [ + 'fields' => ['Article.title'], + 'contain' => ['User'] + ]); $this->assertTrue(isset($result[0]['Article'])); $this->assertTrue(isset($result[0]['User'])); } @@ -3687,7 +3687,7 @@ public function testAutoFieldsWithMultipleDatabases() { */ public function testAutoFieldsWithRecursiveNegativeOne() { $this->Article->recursive = -1; - $result = $this->Article->field('title', array('Article.title' => 'First Article')); + $result = $this->Article->field('title', ['Article.title' => 'First Article']); $this->assertNoErrors(); $this->assertEquals('First Article', $result, 'Field is wrong'); } @@ -3698,9 +3698,9 @@ public function testAutoFieldsWithRecursiveNegativeOne() { * @return void */ public function testFindAllReturn() { - $result = $this->Article->find('all', array( - 'conditions' => array('Article.id' => 999999999) - )); + $result = $this->Article->find('all', [ + 'conditions' => ['Article.id' => 999999999] + ]); $this->assertEmpty($result, 'Should be empty.'); } @@ -3712,16 +3712,16 @@ public function testFindAllReturn() { public function testLazyLoad() { // Local set up $this->User = ClassRegistry::init('User'); - $this->User->bindModel(array( - 'hasMany' => array('Article', 'ArticleFeatured', 'Comment') - ), false); + $this->User->bindModel([ + 'hasMany' => ['Article', 'ArticleFeatured', 'Comment'] + ], false); try { - $this->User->find('first', array( + $this->User->find('first', [ 'contain' => 'Comment', 'lazyLoad' => true - )); - } catch (Exception $e) { + ]); + } catch (Exception) { $exceptions = true; } $this->assertTrue(empty($exceptions)); @@ -3734,14 +3734,14 @@ public function testLazyLoad() { * @param array $contain * @return void */ - protected function _containments($Model, $contain = array()) { + protected function _containments($Model, $contain = []) { if (!is_array($Model)) { $result = $Model->containments($contain); return $this->_containments($result['models']); } $result = $Model; foreach ($result as $i => $containment) { - $result[$i] = array_diff_key($containment, array('instance' => true)); + $result[$i] = array_diff_key($containment, ['instance' => true]); } return $result; } @@ -3753,13 +3753,13 @@ protected function _containments($Model, $contain = array()) { * @param array $expected * @return void */ - protected function _assertBindings(Model $Model, $expected = array()) { - $expected = array_merge(array( - 'belongsTo' => array(), - 'hasOne' => array(), - 'hasMany' => array(), - 'hasAndBelongsToMany' => array() - ), $expected); + protected function _assertBindings(Model $Model, $expected = []) { + $expected = array_merge([ + 'belongsTo' => [], + 'hasOne' => [], + 'hasMany' => [], + 'hasAndBelongsToMany' => [] + ], $expected); foreach ($expected as $binding => $expect) { $this->assertEquals($expect, array_keys($Model->$binding)); } diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index 93b5b3fad7..15f3cf17e7 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -16,7 +16,7 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); -require_once dirname(dirname(__FILE__)) . DS . 'models.php'; +require_once dirname(__FILE__, 2) . DS . 'models.php'; /** * TranslateBehaviorTest class @@ -37,11 +37,11 @@ class TranslateBehaviorTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.translated_item', 'core.translate', 'core.translate_table', 'core.translated_article', 'core.translate_article', 'core.user', 'core.comment', 'core.tag', 'core.articles_tag', 'core.translate_with_prefix' - ); + ]; /** * Test that count queries with conditions get the correct joins @@ -53,11 +53,11 @@ public function testCountWithConditions() { $Model = new TranslatedItem(); $Model->locale = 'eng'; - $result = $Model->find('count', array( - 'conditions' => array( + $result = $Model->find('count', [ + 'conditions' => [ 'I18n__content.locale' => 'eng' - ) - )); + ] + ]); $this->assertEquals(3, $result); } @@ -70,13 +70,13 @@ public function testTranslateModel() { $this->loadFixtures('TranslateTable', 'Tag', 'TranslatedItem', 'Translate', 'User', 'TranslatedArticle', 'TranslateArticle'); $TestModel = new Tag(); $TestModel->translateTable = 'another_i18n'; - $TestModel->Behaviors->load('Translate', array('title')); + $TestModel->Behaviors->load('Translate', ['title']); $translateModel = $TestModel->Behaviors->Translate->translateModel($TestModel); $this->assertEquals('I18nModel', $translateModel->name); $this->assertEquals('another_i18n', $translateModel->useTable); $TestModel = new User(); - $TestModel->Behaviors->load('Translate', array('title')); + $TestModel->Behaviors->load('Translate', ['title']); $translateModel = $TestModel->Behaviors->Translate->translateModel($TestModel); $this->assertEquals('I18nModel', $translateModel->name); $this->assertEquals('i18n', $translateModel->useTable); @@ -104,19 +104,19 @@ public function testLocaleFalsePlain() { $TestModel->locale = false; $result = $TestModel->read(null, 1); - $expected = array('TranslatedItem' => array( + $expected = ['TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'translated_article_id' => 1, - )); + ]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('fields' => array('slug'))); - $expected = array( - array('TranslatedItem' => array('slug' => 'first_translated')), - array('TranslatedItem' => array('slug' => 'second_translated')), - array('TranslatedItem' => array('slug' => 'third_translated')) - ); + $result = $TestModel->find('all', ['fields' => ['slug']]); + $expected = [ + ['TranslatedItem' => ['slug' => 'first_translated']], + ['TranslatedItem' => ['slug' => 'second_translated']], + ['TranslatedItem' => ['slug' => 'third_translated']] + ]; $this->assertEquals($expected, $result); } @@ -131,46 +131,46 @@ public function testLocaleFalseAssociations() { $TestModel = new TranslatedItem(); $TestModel->locale = false; $TestModel->unbindTranslation(); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedItem' => array('id' => 1, 'slug' => 'first_translated', 'translated_article_id' => 1), - 'Title' => array( - array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'), - array('id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'), - array('id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1') - ), - 'Content' => array( - array('id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'), - array('id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'), - array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1') - ) - ); + $expected = [ + 'TranslatedItem' => ['id' => 1, 'slug' => 'first_translated', 'translated_article_id' => 1], + 'Title' => [ + ['id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'], + ['id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'], + ['id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1'] + ], + 'Content' => [ + ['id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'], + ['id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'], + ['id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1'] + ] + ]; $this->assertEquals($expected, $result); - $TestModel->hasMany['Title']['fields'] = $TestModel->hasMany['Content']['fields'] = array('content'); + $TestModel->hasMany['Title']['fields'] = $TestModel->hasMany['Content']['fields'] = ['content']; $TestModel->hasMany['Title']['conditions']['locale'] = $TestModel->hasMany['Content']['conditions']['locale'] = 'eng'; - $result = $TestModel->find('all', array('fields' => array('TranslatedItem.slug'))); - $expected = array( - array( - 'TranslatedItem' => array('id' => 1, 'slug' => 'first_translated'), - 'Title' => array(array('foreign_key' => 1, 'content' => 'Title #1')), - 'Content' => array(array('foreign_key' => 1, 'content' => 'Content #1')) - ), - array( - 'TranslatedItem' => array('id' => 2, 'slug' => 'second_translated'), - 'Title' => array(array('foreign_key' => 2, 'content' => 'Title #2')), - 'Content' => array(array('foreign_key' => 2, 'content' => 'Content #2')) - ), - array( - 'TranslatedItem' => array('id' => 3, 'slug' => 'third_translated'), - 'Title' => array(array('foreign_key' => 3, 'content' => 'Title #3')), - 'Content' => array(array('foreign_key' => 3, 'content' => 'Content #3')) - ) - ); + $result = $TestModel->find('all', ['fields' => ['TranslatedItem.slug']]); + $expected = [ + [ + 'TranslatedItem' => ['id' => 1, 'slug' => 'first_translated'], + 'Title' => [['foreign_key' => 1, 'content' => 'Title #1']], + 'Content' => [['foreign_key' => 1, 'content' => 'Content #1']] + ], + [ + 'TranslatedItem' => ['id' => 2, 'slug' => 'second_translated'], + 'Title' => [['foreign_key' => 2, 'content' => 'Title #2']], + 'Content' => [['foreign_key' => 2, 'content' => 'Content #2']] + ], + [ + 'TranslatedItem' => ['id' => 3, 'slug' => 'third_translated'], + 'Title' => [['foreign_key' => 3, 'content' => 'Title #3']], + 'Content' => [['foreign_key' => 3, 'content' => 'Content #3']] + ] + ]; $this->assertEquals($expected, $result); } @@ -186,77 +186,77 @@ public function testLocaleSingle() { $TestModel->locale = 'eng'; $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'Title #1', 'content' => 'Content #1', 'translated_article_id' => 1, - ) - ); + ] + ]; $this->assertEquals($expected, $result); $result = $TestModel->find('all'); - $expected = array( - array( - 'TranslatedItem' => array( + $expected = [ + [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'Title #1', 'content' => 'Content #1', 'translated_article_id' => 1, - ) - ), - array( - 'TranslatedItem' => array( + ] + ], + [ + 'TranslatedItem' => [ 'id' => 2, 'slug' => 'second_translated', 'locale' => 'eng', 'title' => 'Title #2', 'content' => 'Content #2', 'translated_article_id' => 1, - ) - ), - array( - 'TranslatedItem' => array( + ] + ], + [ + 'TranslatedItem' => [ 'id' => 3, 'slug' => 'third_translated', 'locale' => 'eng', 'title' => 'Title #3', 'content' => 'Content #3', 'translated_article_id' => 1, - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->field('title', array('TranslatedItem.id' => 1)); + $result = $TestModel->field('title', ['TranslatedItem.id' => 1]); $expected = 'Title #1'; $this->assertEquals($expected, $result); $result = $TestModel->read('title', 1); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'Title #1', 'translated_article_id' => 1, - ) - ); + ] + ]; $this->assertEquals($expected, $result); $result = $TestModel->read('id, title', 1); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 1, 'locale' => 'eng', 'title' => 'Title #1', - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -270,34 +270,34 @@ public function testLocaleSingleWithConditions() { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; - $result = $TestModel->find('all', array('conditions' => array('slug' => 'first_translated'))); - $expected = array( - array( - 'TranslatedItem' => array( + $result = $TestModel->find('all', ['conditions' => ['slug' => 'first_translated']]); + $expected = [ + [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'Title #1', 'content' => 'Content #1', 'translated_article_id' => 1, - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('conditions' => "TranslatedItem.slug = 'first_translated'")); - $expected = array( - array( - 'TranslatedItem' => array( + $result = $TestModel->find('all', ['conditions' => "TranslatedItem.slug = 'first_translated'"]); + $expected = [ + [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'Title #1', 'content' => 'Content #1', 'translated_article_id' => 1, - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); } @@ -311,26 +311,26 @@ public function testLocaleSingleCountWithConditions() { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; - $result = $TestModel->find('all', array( - 'conditions' => array('slug' => 'first_translated') - )); - $expected = array( - array( - 'TranslatedItem' => array( + $result = $TestModel->find('all', [ + 'conditions' => ['slug' => 'first_translated'] + ]); + $expected = [ + [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'Title #1', 'content' => 'Content #1', 'translated_article_id' => 1, - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('count', array( - 'conditions' => array('slug' => 'first_translated') - )); + $result = $TestModel->find('count', [ + 'conditions' => ['slug' => 'first_translated'] + ]); $expected = 1; $this->assertEquals($expected, $result); } @@ -346,71 +346,71 @@ public function testLocaleSingleAssociations() { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; $TestModel->unbindTranslation(); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'Title #1', 'content' => 'Content #1', 'translated_article_id' => 1, - ), - 'Title' => array( - array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'), - array('id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'), - array('id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1') - ), - 'Content' => array( - array('id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'), - array('id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'), - array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1') - ) - ); + ], + 'Title' => [ + ['id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Title #1'], + ['id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'], + ['id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1'] + ], + 'Content' => [ + ['id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'], + ['id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'], + ['id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Obsah #1'] + ] + ]; $this->assertEquals($expected, $result); - $TestModel->hasMany['Title']['fields'] = $TestModel->hasMany['Content']['fields'] = array('content'); + $TestModel->hasMany['Title']['fields'] = $TestModel->hasMany['Content']['fields'] = ['content']; $TestModel->hasMany['Title']['conditions']['locale'] = $TestModel->hasMany['Content']['conditions']['locale'] = 'eng'; - $result = $TestModel->find('all', array('fields' => array('TranslatedItem.title'))); - $expected = array( - array( - 'TranslatedItem' => array( + $result = $TestModel->find('all', ['fields' => ['TranslatedItem.title']]); + $expected = [ + [ + 'TranslatedItem' => [ 'id' => 1, 'locale' => 'eng', 'title' => 'Title #1', 'slug' => 'first_translated', 'translated_article_id' => 1, - ), - 'Title' => array(array('foreign_key' => 1, 'content' => 'Title #1')), - 'Content' => array(array('foreign_key' => 1, 'content' => 'Content #1')) - ), - array( - 'TranslatedItem' => array( + ], + 'Title' => [['foreign_key' => 1, 'content' => 'Title #1']], + 'Content' => [['foreign_key' => 1, 'content' => 'Content #1']] + ], + [ + 'TranslatedItem' => [ 'id' => 2, 'locale' => 'eng', 'title' => 'Title #2', 'slug' => 'second_translated', 'translated_article_id' => 1, - ), - 'Title' => array(array('foreign_key' => 2, 'content' => 'Title #2')), - 'Content' => array(array('foreign_key' => 2, 'content' => 'Content #2')) - ), - array( - 'TranslatedItem' => array( + ], + 'Title' => [['foreign_key' => 2, 'content' => 'Title #2']], + 'Content' => [['foreign_key' => 2, 'content' => 'Content #2']] + ], + [ + 'TranslatedItem' => [ 'id' => 3, 'locale' => 'eng', 'title' => 'Title #3', 'slug' => 'third_translated', 'translated_article_id' => 1, - ), - 'Title' => array(array('foreign_key' => 3, 'content' => 'Title #3')), - 'Content' => array(array('foreign_key' => 3, 'content' => 'Content #3')) - ) - ); + ], + 'Title' => [['foreign_key' => 3, 'content' => 'Title #3']], + 'Content' => [['foreign_key' => 3, 'content' => 'Content #3']] + ] + ]; $this->assertEquals($expected, $result); } @@ -424,20 +424,20 @@ public function testFetchTranslationsWithZero() { $model = new TranslatedItem(); $translateModel = $model->translateModel(); - $translateModel->updateAll(array('content' => "'0'")); + $translateModel->updateAll(['content' => "'0'"]); $model->locale = 'eng'; $result = $model->read(null, 1); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => '0', 'content' => '0', 'translated_article_id' => 1, - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -450,52 +450,52 @@ public function testLocaleMultiple() { $this->loadFixtures('Translate', 'TranslatedItem'); $TestModel = new TranslatedItem(); - $TestModel->locale = array('deu', 'eng', 'cze'); + $TestModel->locale = ['deu', 'eng', 'cze']; $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'deu', 'title' => 'Titel #1', 'content' => 'Inhalt #1', 'translated_article_id' => 1, - ) - ); + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('fields' => array('slug', 'title', 'content'))); - $expected = array( - array( - 'TranslatedItem' => array( + $result = $TestModel->find('all', ['fields' => ['slug', 'title', 'content']]); + $expected = [ + [ + 'TranslatedItem' => [ 'slug' => 'first_translated', 'locale' => 'deu', 'content' => 'Inhalt #1', 'title' => 'Titel #1', - ) - ), - array( - 'TranslatedItem' => array( + ] + ], + [ + 'TranslatedItem' => [ 'slug' => 'second_translated', 'locale' => 'deu', 'title' => 'Titel #2', 'content' => 'Inhalt #2', - ) - ), - array( - 'TranslatedItem' => array( + ] + ], + [ + 'TranslatedItem' => [ 'slug' => 'third_translated', 'locale' => 'deu', 'title' => 'Titel #3', 'content' => 'Inhalt #3', - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $TestModel = new TranslatedItem(); - $TestModel->locale = array('pt-br'); + $TestModel->locale = ['pt-br']; $result = $TestModel->find('all'); $this->assertCount(3, $result, '3 records should have been found, no SQL error.'); } @@ -511,42 +511,42 @@ public function testMissingTranslation() { $TestModel = new TranslatedItem(); $TestModel->locale = 'rus'; $result = $TestModel->read(null, 1); - $this->assertSame(array(), $result); + $this->assertSame([], $result); - $TestModel->locale = array('rus'); + $TestModel->locale = ['rus']; $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'rus', 'title' => '', 'content' => '', 'translated_article_id' => 1, - ) - ); + ] + ]; $this->assertEquals($expected, $result); } public function testMissingTranslationLeftJoin() { $this->loadFixtures('Translate', 'TranslatedItem'); - $expected = array( - 'TranslatedItem' => Array ( + $expected = [ + 'TranslatedItem' => [ 'id' => '1', 'translated_article_id' => '1', 'slug' => 'first_translated', 'locale' => 'rus', 'content' => '', 'title' => '', - ), - ); + ], + ]; $TestModel = new TranslatedItemLeftJoin(); $TestModel->locale = 'rus'; $result = $TestModel->read(null, 1); $this->assertEquals($expected, $result); - $TestModel->locale = array('rus'); + $TestModel->locale = ['rus']; $result = $TestModel->read(null, 1); $this->assertEquals($expected, $result); } @@ -562,8 +562,8 @@ public function testTranslatedFindList() { $TestModel = new TranslatedItem(); $TestModel->locale = 'deu'; $TestModel->displayField = 'title'; - $result = $TestModel->find('list', array('recursive' => 1)); - $expected = array(1 => 'Titel #1', 2 => 'Titel #2', 3 => 'Titel #3'); + $result = $TestModel->find('list', ['recursive' => 1]); + $expected = [1 => 'Titel #1', 2 => 'Titel #2', 3 => 'Titel #3']; $this->assertEquals($expected, $result); // SQL Server trigger an error and stops the page even if the debug = 0 @@ -571,16 +571,16 @@ public function testTranslatedFindList() { $debug = Configure::read('debug'); Configure::write('debug', 0); - $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => false)); - $this->assertSame(array(), $result); + $result = $TestModel->find('list', ['recursive' => 1, 'callbacks' => false]); + $this->assertSame([], $result); - $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'after')); - $this->assertSame(array(), $result); + $result = $TestModel->find('list', ['recursive' => 1, 'callbacks' => 'after']); + $this->assertSame([], $result); Configure::write('debug', $debug); } - $result = $TestModel->find('list', array('recursive' => 1, 'callbacks' => 'before')); - $expected = array(1 => null, 2 => null, 3 => null); + $result = $TestModel->find('list', ['recursive' => 1, 'callbacks' => 'before']); + $expected = [1 => null, 2 => null, 3 => null]; $this->assertEquals($expected, $result); } @@ -594,28 +594,28 @@ public function testReadSelectedFields() { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; - $result = $TestModel->find('all', array('fields' => array('slug', 'TranslatedItem.content'))); - $expected = array( - array('TranslatedItem' => array('slug' => 'first_translated', 'locale' => 'eng', 'content' => 'Content #1')), - array('TranslatedItem' => array('slug' => 'second_translated', 'locale' => 'eng', 'content' => 'Content #2')), - array('TranslatedItem' => array('slug' => 'third_translated', 'locale' => 'eng', 'content' => 'Content #3')) - ); + $result = $TestModel->find('all', ['fields' => ['slug', 'TranslatedItem.content']]); + $expected = [ + ['TranslatedItem' => ['slug' => 'first_translated', 'locale' => 'eng', 'content' => 'Content #1']], + ['TranslatedItem' => ['slug' => 'second_translated', 'locale' => 'eng', 'content' => 'Content #2']], + ['TranslatedItem' => ['slug' => 'third_translated', 'locale' => 'eng', 'content' => 'Content #3']] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('fields' => array('TranslatedItem.slug', 'content'))); + $result = $TestModel->find('all', ['fields' => ['TranslatedItem.slug', 'content']]); $this->assertEquals($expected, $result); - $TestModel->locale = array('eng', 'deu', 'cze'); - $delete = array(array('locale' => 'deu'), array('field' => 'content', 'locale' => 'eng')); + $TestModel->locale = ['eng', 'deu', 'cze']; + $delete = [['locale' => 'deu'], ['field' => 'content', 'locale' => 'eng']]; $I18nModel = ClassRegistry::getObject('TranslateTestModel'); - $I18nModel->deleteAll(array('or' => $delete)); - - $result = $TestModel->find('all', array('fields' => array('title', 'content'))); - $expected = array( - array('TranslatedItem' => array('locale' => 'eng', 'title' => 'Title #1', 'content' => 'Obsah #1')), - array('TranslatedItem' => array('locale' => 'eng', 'title' => 'Title #2', 'content' => 'Obsah #2')), - array('TranslatedItem' => array('locale' => 'eng', 'title' => 'Title #3', 'content' => 'Obsah #3')) - ); + $I18nModel->deleteAll(['or' => $delete]); + + $result = $TestModel->find('all', ['fields' => ['title', 'content']]); + $expected = [ + ['TranslatedItem' => ['locale' => 'eng', 'title' => 'Title #1', 'content' => 'Obsah #1']], + ['TranslatedItem' => ['locale' => 'eng', 'title' => 'Title #2', 'content' => 'Obsah #2']], + ['TranslatedItem' => ['locale' => 'eng', 'title' => 'Title #3', 'content' => 'Obsah #3']] + ]; $this->assertEquals($expected, $result); } @@ -629,16 +629,16 @@ public function testSaveCreate() { $TestModel = new TranslatedItem(); $TestModel->locale = 'spa'; - $data = array( + $data = [ 'slug' => 'fourth_translated', 'title' => 'Leyenda #4', 'content' => 'Contenido #4', 'translated_article_id' => 1, - ); + ]; $TestModel->create($data); $TestModel->save(); $result = $TestModel->read(); - $expected = array('TranslatedItem' => array_merge($data, array('id' => $TestModel->id, 'locale' => 'spa'))); + $expected = ['TranslatedItem' => array_merge($data, ['id' => $TestModel->id, 'locale' => 'spa'])]; $this->assertEquals($expected, $result); } @@ -650,25 +650,25 @@ public function testSaveCreate() { public function testSaveDeleteIgnoreAlias() { $this->loadFixtures('Translate', 'TranslatedItem'); - $TestModel = new TranslatedItem(array('alias' => 'SomethingElse')); + $TestModel = new TranslatedItem(['alias' => 'SomethingElse']); $TestModel->locale = 'spa'; - $data = array( + $data = [ 'slug' => 'fourth_translated', 'title' => 'Leyenda #4', 'content' => 'Contenido #4', 'translated_article_id' => 1, - ); + ]; $TestModel->create($data); $TestModel->save(); $id = $TestModel->id; $result = $TestModel->read(); - $expected = array($TestModel->alias => array_merge($data, array('id' => $id, 'locale' => 'spa'))); + $expected = [$TestModel->alias => array_merge($data, ['id' => $id, 'locale' => 'spa'])]; $this->assertEquals($expected, $result); $TestModel->delete($id); - $result = $TestModel->translateModel()->find('count', array( - 'conditions' => array('foreign_key' => $id) - )); + $result = $TestModel->translateModel()->find('count', [ + 'conditions' => ['foreign_key' => $id] + ]); $this->assertEquals(0, $result); } @@ -681,24 +681,24 @@ public function testSaveMultipleLocales() { $this->loadFixtures('Translate', 'TranslatedItem'); $TestModel = new TranslatedItem(); - $data = array( + $data = [ 'slug' => 'fourth_translated', - 'title' => array( + 'title' => [ 'eng' => 'Title #4', 'spa' => 'Leyenda #4', - ), - 'content' => array( + ], + 'content' => [ 'eng' => 'Content #4', 'spa' => 'Contenido #4', - ), + ], 'translated_article_id' => 1, - ); + ]; $TestModel->create(); $TestModel->save($data); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); - $TestModel->locale = array('eng', 'spa'); + $TestModel->locale = ['eng', 'spa']; $result = $TestModel->read(); $this->assertCount(2, $result['Title']); @@ -719,24 +719,24 @@ public function testSaveAssociatedMultipleLocale() { $this->loadFixtures('Translate', 'TranslatedItem'); $TestModel = new TranslatedItem(); - $data = array( + $data = [ 'slug' => 'fourth_translated', - 'title' => array( + 'title' => [ 'eng' => 'Title #4', 'spa' => 'Leyenda #4', - ), - 'content' => array( + ], + 'content' => [ 'eng' => 'Content #4', 'spa' => 'Contenido #4', - ), + ], 'translated_article_id' => 1, - ); + ]; $TestModel->create(); $TestModel->saveAssociated($data); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); - $TestModel->locale = array('eng', 'spa'); + $TestModel->locale = ['eng', 'spa']; $result = $TestModel->read(); $this->assertCount(2, $result['Title']); $this->assertCount(2, $result['Content']); @@ -751,43 +751,43 @@ public function testSaveAssociatedAtomic() { $this->loadFixtures('Translate', 'TranslatedItem'); $TestModel = new TranslatedItem(); - $data = array( + $data = [ 'slug' => 'fourth_translated', - 'title' => array( + 'title' => [ 'eng' => 'Title #4' - ), - 'content' => array( + ], + 'content' => [ 'eng' => 'Content #4' - ), + ], 'translated_article_id' => 1, - ); - $Mock = $this->getMockForModel('TranslateTestModel', array('save')); + ]; + $Mock = $this->getMockForModel('TranslateTestModel', ['save']); $TestModel->Behaviors->Translate->runtime[$TestModel->alias]['model'] = $Mock; - $with = array( - 'TranslateTestModel' => array ( + $with = [ + 'TranslateTestModel' => [ 'model' => 'TranslatedItem', 'foreign_key' => '4', 'field' => 'content', 'locale' => 'eng', 'content' => 'Content #4', - ) - ); - $Mock->expects($this->at(0))->method('save')->with($with, array('atomic' => false)); + ] + ]; + $Mock->expects($this->at(0))->method('save')->with($with, ['atomic' => false]); - $with = array( - 'TranslateTestModel' => array ( + $with = [ + 'TranslateTestModel' => [ 'model' => 'TranslatedItem', 'foreign_key' => '4', 'field' => 'title', 'locale' => 'eng', 'content' => 'Title #4', - ) - ); - $Mock->expects($this->at(1))->method('save')->with($with, array('atomic' => false)); + ] + ]; + $Mock->expects($this->at(1))->method('save')->with($with, ['atomic' => false]); $TestModel->create(); - $TestModel->saveAssociated($data, array('atomic' => false)); + $TestModel->saveAssociated($data, ['atomic' => false]); } /** @@ -800,21 +800,21 @@ public function testSavePartialFields() { $TestModel = new TranslatedItem(); $TestModel->locale = 'spa'; - $data = array( + $data = [ 'slug' => 'fourth_translated', 'title' => 'Leyenda #4', - ); + ]; $TestModel->create($data); $TestModel->save(); $result = $TestModel->read(); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => $TestModel->id, 'translated_article_id' => null, 'locale' => 'spa', 'content' => '', - ) + $data - ); + ] + $data + ]; $this->assertEquals($expected, $result); } @@ -828,63 +828,63 @@ public function testSavePartialFieldMultipleLocales() { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; - $data = array( + $data = [ 'slug' => 'fifth_translated', - 'title' => array('eng' => 'Title #5', 'spa' => 'Leyenda #5'), - ); + 'title' => ['eng' => 'Title #5', 'spa' => 'Leyenda #5'], + ]; $TestModel->create($data); $TestModel->save(); $TestModel->unbindTranslation(); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); $result = $TestModel->read(null, $TestModel->id); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => '4', 'translated_article_id' => null, 'slug' => 'fifth_translated', 'locale' => 'eng', 'title' => 'Title #5', 'content' => '' - ), - 'Title' => array( - 0 => array( + ], + 'Title' => [ + 0 => [ 'id' => '19', 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => '4', 'field' => 'title', 'content' => 'Title #5' - ), - 1 => array( + ], + 1 => [ 'id' => '20', 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => '4', 'field' => 'title', 'content' => 'Leyenda #5' - ) - ), - 'Content' => array( - 0 => array( + ] + ], + 'Content' => [ + 0 => [ 'id' => '21', 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => '4', 'field' => 'content', 'content' => '' - ), - 1 => array( + ], + 1 => [ 'id' => '22', 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => '4', 'field' => 'content', 'content' => '' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); } @@ -898,15 +898,15 @@ public function testSaveUpdate() { $TestModel = new TranslatedItem(); $TestModel->locale = 'spa'; - $oldData = array('slug' => 'fourth_translated', 'title' => 'Leyenda #4', 'translated_article_id' => 1); + $oldData = ['slug' => 'fourth_translated', 'title' => 'Leyenda #4', 'translated_article_id' => 1]; $TestModel->create($oldData); $TestModel->save(); $id = $TestModel->id; - $newData = array('id' => $id, 'content' => 'Contenido #4'); + $newData = ['id' => $id, 'content' => 'Contenido #4']; $TestModel->create($newData); $TestModel->save(); $result = $TestModel->read(null, $id); - $expected = array('TranslatedItem' => array_merge($oldData, $newData, array('locale' => 'spa'))); + $expected = ['TranslatedItem' => array_merge($oldData, $newData, ['locale' => 'spa'])]; $this->assertEquals($expected, $result); } @@ -920,38 +920,38 @@ public function testMultipleCreate() { $TestModel = new TranslatedItem(); $TestModel->locale = 'deu'; - $data = array( + $data = [ 'slug' => 'new_translated', - 'title' => array('eng' => 'New title', 'spa' => 'Nuevo leyenda'), - 'content' => array('eng' => 'New content', 'spa' => 'Nuevo contenido') - ); + 'title' => ['eng' => 'New title', 'spa' => 'Nuevo leyenda'], + 'content' => ['eng' => 'New content', 'spa' => 'Nuevo contenido'] + ]; $TestModel->create($data); $TestModel->save(); $TestModel->unbindTranslation(); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); - $TestModel->locale = array('eng', 'spa'); + $TestModel->locale = ['eng', 'spa']; $result = $TestModel->read(); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 4, 'slug' => 'new_translated', 'locale' => 'eng', 'title' => 'New title', 'content' => 'New content', 'translated_article_id' => null, - ), - 'Title' => array( - array('id' => 21, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'title', 'content' => 'New title'), - array('id' => 22, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'title', 'content' => 'Nuevo leyenda') - ), - 'Content' => array( - array('id' => 19, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'content', 'content' => 'New content'), - array('id' => 20, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'content', 'content' => 'Nuevo contenido') - ) - ); + ], + 'Title' => [ + ['id' => 21, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'title', 'content' => 'New title'], + ['id' => 22, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'title', 'content' => 'Nuevo leyenda'] + ], + 'Content' => [ + ['id' => 19, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'content', 'content' => 'New content'], + ['id' => 20, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 4, 'field' => 'content', 'content' => 'Nuevo contenido'] + ] + ]; $this->assertEquals($expected, $result); } @@ -966,42 +966,42 @@ public function testMultipleUpdate() { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; $TestModel->validate['title'] = 'notBlank'; - $data = array('TranslatedItem' => array( + $data = ['TranslatedItem' => [ 'id' => 1, - 'title' => array('eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'), - 'content' => array('eng' => 'New Content #1', 'deu' => 'Neue Inhalt #1', 'cze' => 'Novy Obsah #1') - )); + 'title' => ['eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'], + 'content' => ['eng' => 'New Content #1', 'deu' => 'Neue Inhalt #1', 'cze' => 'Novy Obsah #1'] + ]]; $TestModel->create(); $TestModel->save($data); $TestModel->unbindTranslation(); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => '1', 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'New Title #1', 'content' => 'New Content #1', 'translated_article_id' => 1, - ), - 'Title' => array( - array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'New Title #1'), - array('id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Neue Titel #1'), - array('id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Novy Titulek #1') - ), - 'Content' => array( - array('id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'New Content #1'), - array('id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Neue Inhalt #1'), - array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Novy Obsah #1') - ) - ); + ], + 'Title' => [ + ['id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'New Title #1'], + ['id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Neue Titel #1'], + ['id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Novy Titulek #1'] + ], + 'Content' => [ + ['id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'New Content #1'], + ['id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Neue Inhalt #1'], + ['id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Novy Obsah #1'] + ] + ]; $this->assertEquals($expected, $result); $TestModel->unbindTranslation($translations); - $TestModel->bindTranslation(array('title', 'content'), false); + $TestModel->bindTranslation(['title', 'content'], false); } /** @@ -1013,42 +1013,42 @@ public function testMixedCreateUpdateWithArrayLocale() { $this->loadFixtures('Translate', 'TranslatedItem'); $TestModel = new TranslatedItem(); - $TestModel->locale = array('cze', 'deu'); - $data = array('TranslatedItem' => array( + $TestModel->locale = ['cze', 'deu']; + $data = ['TranslatedItem' => [ 'id' => 1, - 'title' => array('eng' => 'Updated Title #1', 'spa' => 'Nuevo leyenda #1'), + 'title' => ['eng' => 'Updated Title #1', 'spa' => 'Nuevo leyenda #1'], 'content' => 'Upraveny obsah #1' - )); + ]]; $TestModel->create(); $TestModel->save($data); $TestModel->unbindTranslation(); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); $result = $TestModel->read(null, 1); $result['Title'] = Hash::sort($result['Title'], '{n}.id', 'asc'); $result['Content'] = Hash::sort($result['Content'], '{n}.id', 'asc'); - $expected = array( - 'TranslatedItem' => array( + $expected = [ + 'TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'cze', 'title' => 'Titulek #1', 'content' => 'Upraveny obsah #1', 'translated_article_id' => 1, - ), - 'Title' => array( - array('id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Updated Title #1'), - array('id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'), - array('id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1'), - array('id' => 19, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Nuevo leyenda #1') - ), - 'Content' => array( - array('id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'), - array('id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'), - array('id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Upraveny obsah #1') - ) - ); + ], + 'Title' => [ + ['id' => 1, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Updated Title #1'], + ['id' => 3, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titel #1'], + ['id' => 5, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Titulek #1'], + ['id' => 19, 'locale' => 'spa', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'title', 'content' => 'Nuevo leyenda #1'] + ], + 'Content' => [ + ['id' => 2, 'locale' => 'eng', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Content #1'], + ['id' => 4, 'locale' => 'deu', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Inhalt #1'], + ['id' => 6, 'locale' => 'cze', 'model' => 'TranslatedItem', 'foreign_key' => 1, 'field' => 'content', 'content' => 'Upraveny obsah #1'] + ] + ]; $this->assertEquals($expected, $result); } @@ -1063,33 +1063,33 @@ public function testSaveAllTranslatedAssociations() { $Model = new TranslatedArticle(); $Model->locale = 'eng'; - $data = array( - 'TranslatedArticle' => array( + $data = [ + 'TranslatedArticle' => [ 'id' => 4, 'user_id' => 1, 'published' => 'Y', 'title' => 'Title (eng) #1', 'body' => 'Body (eng) #1' - ), - 'TranslatedItem' => array( - array( + ], + 'TranslatedItem' => [ + [ 'slug' => '', 'title' => 'Nuevo leyenda #1', 'content' => 'Upraveny obsah #1' - ), - array( + ], + [ 'slug' => '', 'title' => 'New Title #2', 'content' => 'New Content #2' - ), - ) - ); + ], + ] + ]; $result = $Model->saveAll($data); $this->assertTrue($result); - $result = $Model->TranslatedItem->find('all', array( - 'conditions' => array('translated_article_id' => $Model->id) - )); + $result = $Model->TranslatedItem->find('all', [ + 'conditions' => ['translated_article_id' => $Model->id] + ]); $this->assertCount(2, $result); $this->assertEquals($data['TranslatedItem'][0]['title'], $result[0]['TranslatedItem']['title']); $this->assertEquals($data['TranslatedItem'][1]['title'], $result[1]['TranslatedItem']['title']); @@ -1107,24 +1107,24 @@ public function testValidation() { $TestModel = new TranslatedItem(); $TestModel->locale = 'eng'; $TestModel->validate['title'] = '/Only this title/'; - $data = array( - 'TranslatedItem' => array( + $data = [ + 'TranslatedItem' => [ 'id' => 1, - 'title' => array('eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'), - 'content' => array('eng' => 'New Content #1', 'deu' => 'Neue Inhalt #1', 'cze' => 'Novy Obsah #1') - ) - ); + 'title' => ['eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'], + 'content' => ['eng' => 'New Content #1', 'deu' => 'Neue Inhalt #1', 'cze' => 'Novy Obsah #1'] + ] + ]; $TestModel->create(); $this->assertFalse($TestModel->save($data)); - $this->assertEquals(array('This field cannot be left blank'), $TestModel->validationErrors['title']); + $this->assertEquals(['This field cannot be left blank'], $TestModel->validationErrors['title']); $TestModel->locale = 'eng'; $TestModel->validate['title'] = '/Only this title/'; - $data = array('TranslatedItem' => array( + $data = ['TranslatedItem' => [ 'id' => 1, - 'title' => array('eng' => 'Only this title', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'), - 'content' => array('eng' => 'New Content #1', 'deu' => 'Neue Inhalt #1', 'cze' => 'Novy Obsah #1') - )); + 'title' => ['eng' => 'Only this title', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'], + 'content' => ['eng' => 'New Content #1', 'deu' => 'Neue Inhalt #1', 'cze' => 'Novy Obsah #1'] + ]]; $TestModel->create(); $result = $TestModel->save($data); $this->assertFalse(empty($result)); @@ -1140,20 +1140,20 @@ public function testFieldsRestoreAfterBind() { $TestModel = new TranslatedItem(); - $translations = array('title' => 'Title'); + $translations = ['title' => 'Title']; $TestModel->bindTranslation($translations); $result = $TestModel->find('first'); - $TestModel->find('first', array( - 'fields' => array( + $TestModel->find('first', [ + 'fields' => [ 'TranslatedItem.title', - ), - )); - $TestModel->find('first', array( - 'fields' => array( + ], + ]); + $TestModel->find('first', [ + 'fields' => [ 'TranslatedItem.title', - ), - )); + ], + ]); $this->assertArrayHasKey('Title', $result); $this->assertArrayHasKey('content', $result['Title'][0]); $this->assertArrayNotHasKey('title', $result); @@ -1174,16 +1174,16 @@ public function testAttachDetach() { $TestModel = new TranslatedItem(); $TestModel->unbindTranslation(); - $translations = array('title' => 'Title', 'content' => 'Content'); + $translations = ['title' => 'Title', 'content' => 'Content']; $TestModel->bindTranslation($translations, false); $result = array_keys($TestModel->hasMany); - $expected = array('Title', 'Content'); + $expected = ['Title', 'Content']; $this->assertEquals($expected, $result); $TestModel->Behaviors->unload('Translate'); $result = array_keys($TestModel->hasMany); - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); $result = isset($TestModel->Behaviors->Translate); @@ -1195,9 +1195,9 @@ public function testAttachDetach() { $result = isset($Behavior->runtime[$TestModel->alias]); $this->assertFalse($result); - $TestModel->Behaviors->load('Translate', array('title' => 'Title', 'content' => 'Content')); + $TestModel->Behaviors->load('Translate', ['title' => 'Title', 'content' => 'Content']); $result = array_keys($TestModel->hasMany); - $expected = array('Title', 'Content'); + $expected = ['Title', 'Content']; $this->assertEquals($expected, $result); $result = isset($TestModel->Behaviors->Translate); @@ -1223,16 +1223,16 @@ public function testAnotherTranslateTable() { $TestModel = new TranslatedItemWithTable(); $TestModel->locale = 'eng'; $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedItemWithTable' => array( + $expected = [ + 'TranslatedItemWithTable' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'title' => 'Another Title #1', 'content' => 'Another Content #1', 'translated_article_id' => 1, - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -1249,8 +1249,8 @@ public function testTranslateWithAssociations() { $recursive = $TestModel->recursive; $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedArticle' => array( + $expected = [ + 'TranslatedArticle' => [ 'id' => 1, 'user_id' => 1, 'published' => 'Y', @@ -1259,38 +1259,38 @@ public function testTranslateWithAssociations() { 'locale' => 'eng', 'title' => 'Title (eng) #1', 'body' => 'Body (eng) #1' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'TranslatedItem' => array( - array( + ], + 'TranslatedItem' => [ + [ 'id' => 1, 'translated_article_id' => 1, 'slug' => 'first_translated' - ), - array( + ], + [ 'id' => 2, 'translated_article_id' => 1, 'slug' => 'second_translated' - ), - array( + ], + [ 'id' => 3, 'translated_article_id' => 1, 'slug' => 'third_translated' - ), - ) - ); + ], + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('recursive' => -1)); - $expected = array( - array( - 'TranslatedArticle' => array( + $result = $TestModel->find('all', ['recursive' => -1]); + $expected = [ + [ + 'TranslatedArticle' => [ 'id' => 1, 'user_id' => 1, 'published' => 'Y', @@ -1299,10 +1299,10 @@ public function testTranslateWithAssociations() { 'locale' => 'eng', 'title' => 'Title (eng) #1', 'body' => 'Body (eng) #1' - ) - ), - array( - 'TranslatedArticle' => array( + ] + ], + [ + 'TranslatedArticle' => [ 'id' => 2, 'user_id' => 3, 'published' => 'Y', @@ -1311,10 +1311,10 @@ public function testTranslateWithAssociations() { 'locale' => 'eng', 'title' => 'Title (eng) #2', 'body' => 'Body (eng) #2' - ) - ), - array( - 'TranslatedArticle' => array( + ] + ], + [ + 'TranslatedArticle' => [ 'id' => 3, 'user_id' => 1, 'published' => 'Y', @@ -1323,16 +1323,16 @@ public function testTranslateWithAssociations() { 'locale' => 'eng', 'title' => 'Title (eng) #3', 'body' => 'Body (eng) #3' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $this->assertEquals($TestModel->recursive, $recursive); $TestModel->recursive = -1; $result = $TestModel->read(null, 1); - $expected = array( - 'TranslatedArticle' => array( + $expected = [ + 'TranslatedArticle' => [ 'id' => 1, 'user_id' => 1, 'published' => 'Y', @@ -1341,8 +1341,8 @@ public function testTranslateWithAssociations() { 'locale' => 'eng', 'title' => 'Title (eng) #1', 'body' => 'Body (eng) #1' - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -1357,14 +1357,14 @@ public function testTranslateTableWithPrefix() { $TestModel = new TranslatedItem2; $TestModel->locale = 'eng'; $result = $TestModel->read(null, 1); - $expected = array('TranslatedItem' => array( + $expected = ['TranslatedItem' => [ 'id' => 1, 'slug' => 'first_translated', 'locale' => 'eng', 'content' => 'Content #1', 'title' => 'Title #1', 'translated_article_id' => 1, - )); + ]]; $this->assertEquals($expected, $result); } @@ -1378,9 +1378,9 @@ public function testUnbindTranslationInfinteLoop() { $TestModel = new TranslatedItem(); $TestModel->Behaviors->unload('Translate'); - $TestModel->actsAs = array(); + $TestModel->actsAs = []; $TestModel->Behaviors->load('Translate'); - $TestModel->bindTranslation(array('title', 'content'), true); + $TestModel->bindTranslation(['title', 'content'], true); $result = $TestModel->unbindTranslation(); $this->assertFalse($result); @@ -1395,7 +1395,7 @@ public function testExceptionOnNameTranslation() { $this->expectException(CakeException::class); $this->loadFixtures('Translate', 'TranslatedItem'); $TestModel = new TranslatedItem(); - $TestModel->bindTranslation(array('name' => 'name')); + $TestModel->bindTranslation(['name' => 'name']); } /** @@ -1407,12 +1407,12 @@ public function testUnbindTranslation() { $this->loadFixtures('Translate', 'TranslatedItem'); $Model = new TranslatedItem(); $Model->unbindTranslation(); - $Model->bindTranslation(array('body', 'slug'), false); + $Model->bindTranslation(['body', 'slug'], false); $result = $Model->Behaviors->Translate->settings['TranslatedItem']; - $this->assertEquals(array('body', 'slug'), $result); + $this->assertEquals(['body', 'slug'], $result); - $Model->unbindTranslation(array('body')); + $Model->unbindTranslation(['body']); $result = $Model->Behaviors->Translate->settings['TranslatedItem']; $this->assertNotContains('body', $result); @@ -1431,24 +1431,24 @@ public function testNoExtraRowsForAssociatedTranslations() { $TestModel = new TranslatedItem(); $TestModel->locale = 'spa'; $TestModel->unbindTranslation(); - $TestModel->bindTranslation(array('name' => 'nameTranslate')); + $TestModel->bindTranslation(['name' => 'nameTranslate']); - $data = array( - 'TranslatedItem' => array( + $data = [ + 'TranslatedItem' => [ 'slug' => 'spanish-name', 'name' => 'Spanish name', - ), - ); + ], + ]; $TestModel->create($data); $TestModel->save(); $Translate = $TestModel->translateModel(); - $results = $Translate->find('all', array( - 'conditions' => array( + $results = $Translate->find('all', [ + 'conditions' => [ 'locale' => $TestModel->locale, 'foreign_key' => $TestModel->id - ) - )); + ] + ]); $this->assertCount(1, $results, 'Only one field should be saved'); $this->assertEquals('name', $results[0]['TranslateTestModel']['field']); } @@ -1461,77 +1461,77 @@ public function testBeforeFindAllI18nConditions() { $TestModel = new TranslatedArticle(); $TestModel->cacheQueries = false; $TestModel->locale = 'eng'; - $expected = array( - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + $expected = [ + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'fields' => null, - 'joins' => array( - array( + 'joins' => [ + [ 'type' => 'INNER', 'alias' => 'I18n__title', - 'table' => (object)array( + 'table' => (object)[ 'tablePrefix' => '', 'table' => 'article_i18n', 'schemaName' => $dbName, - ), - 'conditions' => array( - 'TranslatedArticle.id' => (object)array( + ], + 'conditions' => [ + 'TranslatedArticle.id' => (object)[ 'type' => 'identifier', 'value' => 'I18n__title.foreign_key', - ), + ], 'I18n__title.model' => 'TranslatedArticle', 'I18n__title.field' => 'title', 'I18n__title.locale' => 'eng', - ), - ), - array( + ], + ], + [ 'type' => 'INNER', 'alias' => 'I18n__body', - 'table' => (object)array( + 'table' => (object)[ 'tablePrefix' => '', 'table' => 'article_i18n', 'schemaName' => $dbName, - ), - 'conditions' => array( - 'TranslatedArticle.id' => (object)array( + ], + 'conditions' => [ + 'TranslatedArticle.id' => (object)[ 'type' => 'identifier', 'value' => 'I18n__body.foreign_key', - ), + ], 'I18n__body.model' => 'TranslatedArticle', 'I18n__body.field' => 'body', 'I18n__body.locale' => 'eng', - ), - ), - ), + ], + ], + ], 'limit' => 2, 'offset' => null, - 'order' => array( + 'order' => [ 'TranslatedArticle.id' => 'ASC', - ), + ], 'page' => 1, 'group' => null, 'callbacks' => true, 'recursive' => 0, - ); - $query = array( - 'conditions' => array( - 'NOT' => array( + ]; + $query = [ + 'conditions' => [ + 'NOT' => [ 'I18n__title.content' => '', - ), - ), + ], + ], 'fields' => null, - 'joins' => array(), + 'joins' => [], 'limit' => 2, 'offset' => null, - 'order' => array( + 'order' => [ 'TranslatedArticle.id' => 'ASC', - ), + ], 'page' => 1, 'group' => null, 'callbacks' => true, 'recursive' => 0, - ); + ]; $TranslateBehavior = ClassRegistry::getObject('TranslateBehavior'); $result = $TranslateBehavior->beforeFind($TestModel, $query); $this->assertEquals($expected, $result); @@ -1545,76 +1545,76 @@ public function testBeforeFindCountI18nConditions() { $TestModel = new TranslatedArticle(); $TestModel->cacheQueries = false; $TestModel->locale = 'eng'; - $expected = array( - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + $expected = [ + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'fields' => 'COUNT(DISTINCT(`TranslatedArticle`.`id`)) AS count', - 'joins' => array( - array( + 'joins' => [ + [ 'type' => 'INNER', 'alias' => 'TranslateArticleModel', - 'table' => (object)array( + 'table' => (object)[ 'tablePrefix' => '', 'table' => 'article_i18n', 'schemaName' => $dbName, - ), - 'conditions' => array( - '`TranslatedArticle`.`id`' => (object)array( + ], + 'conditions' => [ + '`TranslatedArticle`.`id`' => (object)[ 'type' => 'identifier', 'value' => '`TranslateArticleModel`.`foreign_key`', - ), + ], '`TranslateArticleModel`.`model`' => 'TranslatedArticle', '`TranslateArticleModel`.`locale`' => 'eng', - ), - ), - array( + ], + ], + [ 'type' => 'INNER', 'alias' => 'I18n__title', - 'table' => (object)array( + 'table' => (object)[ 'tablePrefix' => '', 'table' => 'article_i18n', 'schemaName' => $dbName, - ), - 'conditions' => array( - 'TranslatedArticle.id' => (object)array( + ], + 'conditions' => [ + 'TranslatedArticle.id' => (object)[ 'type' => 'identifier', 'value' => 'I18n__title.foreign_key', - ), + ], 'I18n__title.model' => 'TranslatedArticle', 'I18n__title.field' => 'title', 'I18n__title.locale' => 'eng', - ), - ), - ), + ], + ], + ], 'limit' => 2, 'offset' => null, - 'order' => array( + 'order' => [ 0 => false, - ), + ], 'page' => 1, 'group' => null, 'callbacks' => true, 'recursive' => 0, - ); - $query = array( - 'conditions' => array( - 'NOT' => array( + ]; + $query = [ + 'conditions' => [ + 'NOT' => [ 'I18n__title.content' => '', - ) - ), + ] + ], 'fields' => 'COUNT(*) AS `count`', - 'joins' => array(), + 'joins' => [], 'limit' => 2, 'offset' => null, - 'order' => array( + 'order' => [ 0 => false - ), + ], 'page' => 1, 'group' => null, 'callbacks' => true, 'recursive' => 0, - ); + ]; $TranslateBehavior = ClassRegistry::getObject('TranslateBehavior'); $result = $TranslateBehavior->beforeFind($TestModel, $query); $this->assertEquals($expected, $result); diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorAfterTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorAfterTest.php index e107de9a28..539c799379 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorAfterTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorAfterTest.php @@ -19,7 +19,7 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); -require_once dirname(dirname(__FILE__)) . DS . 'models.php'; +require_once dirname(__FILE__, 2) . DS . 'models.php'; /** * TreeBehaviorAfterTest class @@ -40,19 +40,19 @@ class TreeBehaviorAfterTest extends CakeTestCase { * * @var array */ - public $settings = array( + public $settings = [ 'modelClass' => 'AfterTree', 'leftField' => 'lft', 'rightField' => 'rght', 'parentField' => 'parent_id' - ); + ]; /** * fixtures property * * @var array */ - public $fixtures = array('core.after_tree'); + public $fixtures = ['core.after_tree']; /** * Tests the afterSave callback in the model @@ -63,12 +63,12 @@ public function testAftersaveCallback() { $this->Tree = new AfterTree(); $this->Tree->order = null; - $expected = array('AfterTree' => array('name' => 'Six and One Half Changed in AfterTree::afterSave() but not in database', 'parent_id' => 6, 'lft' => 11, 'rght' => 12)); - $result = $this->Tree->save(array('AfterTree' => array('name' => 'Six and One Half', 'parent_id' => 6))); + $expected = ['AfterTree' => ['name' => 'Six and One Half Changed in AfterTree::afterSave() but not in database', 'parent_id' => 6, 'lft' => 11, 'rght' => 12]]; + $result = $this->Tree->save(['AfterTree' => ['name' => 'Six and One Half', 'parent_id' => 6]]); $expected['AfterTree']['id'] = $this->Tree->id; $this->assertEquals($expected, $result); - $expected = array('AfterTree' => array('name' => 'Six and One Half', 'parent_id' => 6, 'lft' => 11, 'rght' => 12, 'id' => 8)); + $expected = ['AfterTree' => ['name' => 'Six and One Half', 'parent_id' => 6, 'lft' => 11, 'rght' => 12, 'id' => 8]]; $result = $this->Tree->find('all'); $this->assertEquals($expected, $result[7]); } diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php index d7d8aadddc..5c1d2687f4 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorNumberTest.php @@ -21,7 +21,7 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); -require_once dirname(dirname(__FILE__)) . DS . 'models.php'; +require_once dirname(__FILE__, 2) . DS . 'models.php'; /** * TreeBehaviorNumberTest class @@ -42,20 +42,20 @@ class TreeBehaviorNumberTest extends CakeTestCase { * * @var array */ - public $settings = array( + public $settings = [ 'modelClass' => 'NumberTree', 'leftField' => 'lft', 'rightField' => 'rght', 'parentField' => 'parent_id', 'level' => 'level' - ); + ]; /** * fixtures property * * @var array */ - public $fixtures = array('core.number_tree', 'core.person'); + public $fixtures = ['core.number_tree', 'core.person']; /** * testInitialize method @@ -141,7 +141,7 @@ public function testDetectInvalidParent() { $result = $this->Tree->findByName('1.1'); // Bypass behavior and any other logic - $this->Tree->updateAll(array($parentField => null), array('id' => $result[$modelClass]['id'])); + $this->Tree->updateAll([$parentField => null], ['id' => $result[$modelClass]['id']]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -164,7 +164,7 @@ public function testDetectNoneExistentParent() { $this->Tree->initialize(2, 2); $result = $this->Tree->findByName('1.1'); - $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); + $this->Tree->updateAll([$parentField => 999999], ['id' => $result[$modelClass]['id']]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -187,22 +187,22 @@ public function testRecoverUsingParentMode() { $this->Tree->Behaviors->disable('Tree'); $this->Tree->create(); - $this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0]); $node1 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0]); $node11 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0]); $node12 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0]); $this->Tree->create(); - $this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0]); $this->Tree->Behaviors->enable('Tree'); @@ -215,19 +215,19 @@ public function testRecoverUsingParentMode() { $result = $this->Tree->verify(); $this->assertTrue($result); - $result = $this->Tree->find('first', array( - 'fields' => array('name', $parentField, $leftField, $rightField), - 'conditions' => array('name' => 'Main'), + $result = $this->Tree->find('first', [ + 'fields' => ['name', $parentField, $leftField, $rightField], + 'conditions' => ['name' => 'Main'], 'recursive' => -1 - )); - $expected = array( - $modelClass => array( + ]); + $expected = [ + $modelClass => [ 'name' => 'Main', $parentField => null, $leftField => 1, $rightField => 10 - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -242,36 +242,36 @@ public function testRecoverUsingParentModeAndDelete() { $this->Tree->Behaviors->disable('Tree'); $this->Tree->create(); - $this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0]); $node1 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0]); $node11 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0]); $node12 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0]); $this->Tree->create(); - $this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0]); $this->Tree->create(); - $this->Tree->save(array('name' => 'Lost', $parentField => 9, $leftField => 0, $rightField => 0)); + $this->Tree->save(['name' => 'Lost', $parentField => 9, $leftField => 0, $rightField => 0]); $this->Tree->Behaviors->enable('Tree'); - $this->Tree->bindModel(array('belongsTo' => array('Parent' => array( + $this->Tree->bindModel(['belongsTo' => ['Parent' => [ 'className' => $this->Tree->name, 'foreignKey' => $parentField - )))); - $this->Tree->bindModel(array('hasMany' => array('Child' => array( + ]]]); + $this->Tree->bindModel(['hasMany' => ['Child' => [ 'className' => $this->Tree->name, 'foreignKey' => $parentField - )))); + ]]]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -288,19 +288,19 @@ public function testRecoverUsingParentModeAndDelete() { $count = $this->Tree->find('count'); $this->assertEquals(5, $count); - $result = $this->Tree->find('first', array( - 'fields' => array('name', $parentField, $leftField, $rightField), - 'conditions' => array('name' => 'Main'), + $result = $this->Tree->find('first', [ + 'fields' => ['name', $parentField, $leftField, $rightField], + 'conditions' => ['name' => 'Main'], 'recursive' => -1 - )); - $expected = array( - $modelClass => array( + ]); + $expected = [ + $modelClass => [ 'name' => 'Main', $parentField => null, $leftField => 1, $rightField => 10 - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -315,7 +315,7 @@ public function testRecoverFromMissingParent() { $this->Tree->initialize(2, 2); $result = $this->Tree->findByName('1.1'); - $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); + $this->Tree->updateAll([$parentField => 999999], ['id' => $result[$modelClass]['id']]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -337,7 +337,7 @@ public function testDetectInvalidParents() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $this->Tree->updateAll(array($parentField => null)); + $this->Tree->updateAll([$parentField => null]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -359,7 +359,7 @@ public function testDetectInvalidLftsRghts() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $this->Tree->updateAll(array($leftField => 0, $rightField => 0)); + $this->Tree->updateAll([$leftField => 0, $rightField => 0]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -381,11 +381,11 @@ public function testDetectEqualLftsRghts() { $this->Tree->initialize(1, 3); $result = $this->Tree->findByName('1.1'); - $this->Tree->updateAll(array($rightField => $result[$modelClass][$leftField]), array('id' => $result[$modelClass]['id'])); - $this->Tree->updateAll(array($leftField => $this->Tree->escapeField($leftField) . ' -1'), - array($leftField . ' >' => $result[$modelClass][$leftField])); - $this->Tree->updateAll(array($rightField => $this->Tree->escapeField($rightField) . ' -1'), - array($rightField . ' >' => $result[$modelClass][$leftField])); + $this->Tree->updateAll([$rightField => $result[$modelClass][$leftField]], ['id' => $result[$modelClass]['id']]); + $this->Tree->updateAll([$leftField => $this->Tree->escapeField($leftField) . ' -1'], + [$leftField . ' >' => $result[$modelClass][$leftField]]); + $this->Tree->updateAll([$rightField => $this->Tree->escapeField($rightField) . ' -1'], + [$rightField . ' >' => $result[$modelClass][$leftField]]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -408,9 +408,9 @@ public function testAddOrphan() { $this->Tree->initialize(2, 2); $this->Tree->create(); - $this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null))); - $result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc')); - $expected = array($modelClass => array('name' => 'testAddOrphan', $parentField => null)); + $this->Tree->save([$modelClass => ['name' => 'testAddOrphan', $parentField => null]]); + $result = $this->Tree->find('first', ['fields' => ['name', $parentField], 'order' => $modelClass . '.' . $leftField . ' desc']); + $expected = [$modelClass => ['name' => 'testAddOrphan', $parentField => null]]; $this->assertEquals($expected, $result); $validTree = $this->Tree->verify(); @@ -427,21 +427,21 @@ public function testAddMiddle() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1']]); $initialCount = $this->Tree->find('count'); $this->Tree->create(); - $result = $this->Tree->save(array($modelClass => array('name' => 'testAddMiddle', $parentField => $data[$modelClass]['id']))); - $expected = array_merge(array($modelClass => array('name' => 'testAddMiddle', $parentField => '2')), $result); + $result = $this->Tree->save([$modelClass => ['name' => 'testAddMiddle', $parentField => $data[$modelClass]['id']]]); + $expected = array_merge([$modelClass => ['name' => 'testAddMiddle', $parentField => '2']], $result); $this->assertSame($expected, $result); $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount + 1, $laterCount); - $children = $this->Tree->children($data[$modelClass]['id'], true, array('name')); - $expected = array(array($modelClass => array('name' => '1.1.1')), - array($modelClass => array('name' => '1.1.2')), - array($modelClass => array('name' => 'testAddMiddle'))); + $children = $this->Tree->children($data[$modelClass]['id'], true, ['name']); + $expected = [[$modelClass => ['name' => '1.1.1']], + [$modelClass => ['name' => '1.1.2']], + [$modelClass => ['name' => 'testAddMiddle']]]; $this->assertSame($expected, $children); $validTree = $this->Tree->verify(); @@ -458,19 +458,19 @@ public function testAddWithPreSpecifiedId() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array( - 'fields' => array('id'), - 'conditions' => array($modelClass . '.name' => '1.1') - )); + $data = $this->Tree->find('first', [ + 'fields' => ['id'], + 'conditions' => [$modelClass . '.name' => '1.1'] + ]); $this->Tree->create(); - $result = $this->Tree->save(array($modelClass => array( + $result = $this->Tree->save([$modelClass => [ 'id' => 100, 'name' => 'testAddMiddle', - $parentField => $data[$modelClass]['id']) - )); + $parentField => $data[$modelClass]['id']] + ]); $expected = array_merge( - array($modelClass => array('id' => 100, 'name' => 'testAddMiddle', $parentField => '2')), + [$modelClass => ['id' => 100, 'name' => 'testAddMiddle', $parentField => '2']], $result ); $this->assertSame($expected, $result); @@ -493,7 +493,7 @@ public function testAddInvalid() { //$this->expectError('Trying to save a node under a none-existant node in TreeBehavior::beforeSave'); $this->Tree->create(); - $saveSuccess = $this->Tree->save(array($modelClass => array('name' => 'testAddInvalid', $parentField => 99999))); + $saveSuccess = $this->Tree->save([$modelClass => ['name' => 'testAddInvalid', $parentField => 99999]]); $this->assertFalse($saveSuccess); $laterCount = $this->Tree->find('count'); @@ -514,9 +514,9 @@ public function testAddNotIndexedByModel() { $this->Tree->initialize(2, 2); $this->Tree->create(); - $this->Tree->save(array('name' => 'testAddNotIndexed', $parentField => null)); - $result = $this->Tree->find('first', array('fields' => array('name', $parentField), 'order' => $modelClass . '.' . $leftField . ' desc')); - $expected = array($modelClass => array('name' => 'testAddNotIndexed', $parentField => null)); + $this->Tree->save(['name' => 'testAddNotIndexed', $parentField => null]); + $result = $this->Tree->find('first', ['fields' => ['name', $parentField], 'order' => $modelClass . '.' . $leftField . ' desc']); + $expected = [$modelClass => ['name' => 'testAddNotIndexed', $parentField => null]]; $this->assertEquals($expected, $result); $validTree = $this->Tree->verify(); @@ -534,16 +534,16 @@ public function testMovePromote() { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $parent = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $parentId = $parent[$modelClass]['id']; - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1.1']]); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parentId); - $direct = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField)); - $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)), - array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)), - array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13))); + $direct = $this->Tree->children($parentId, true, ['id', 'name', $parentField, $leftField, $rightField]); + $expected = [[$modelClass => ['id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5]], + [$modelClass => ['id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11]], + [$modelClass => ['id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13]]]; $this->assertEquals($expected, $direct); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); @@ -580,18 +580,18 @@ public function testMoveWithWhitelist() { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $parent = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $parentId = $parent[$modelClass]['id']; - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1.1']]); $this->Tree->id = $data[$modelClass]['id']; - $this->Tree->whitelist = array($parentField, 'name', 'description'); + $this->Tree->whitelist = [$parentField, 'name', 'description']; $this->Tree->saveField($parentField, $parentId); - $result = $this->Tree->children($parentId, true, array('id', 'name', $parentField, $leftField, $rightField)); - $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5)), - array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11)), - array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13))); + $result = $this->Tree->children($parentId, true, ['id', 'name', $parentField, $leftField, $rightField]); + $expected = [[$modelClass => ['id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 5]], + [$modelClass => ['id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 6, $rightField => 11]], + [$modelClass => ['id' => 3, 'name' => '1.1.1', $parentField => 1, $leftField => 12, $rightField => 13]]]; $this->assertEquals($expected, $result); $this->assertTrue($this->Tree->verify()); } @@ -606,11 +606,11 @@ public function testInsertWithWhitelist() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $this->Tree->whitelist = array('name', $parentField); + $this->Tree->whitelist = ['name', $parentField]; $this->Tree->create(); - $this->Tree->save(array($modelClass => array('name' => 'testAddOrphan', $parentField => null))); - $result = $this->Tree->findByName('testAddOrphan', array('name', $parentField, $leftField, $rightField)); - $expected = array('name' => 'testAddOrphan', $parentField => null, $leftField => '15', $rightField => 16); + $this->Tree->save([$modelClass => ['name' => 'testAddOrphan', $parentField => null]]); + $result = $this->Tree->findByName('testAddOrphan', ['name', $parentField, $leftField, $rightField]); + $expected = ['name' => 'testAddOrphan', $parentField => null, $leftField => '15', $rightField => 16]; $this->assertEquals($expected, $result[$modelClass]); $this->assertTrue($this->Tree->verify()); } @@ -626,17 +626,17 @@ public function testMoveBefore() { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1'))); + $parent = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1.1']]); $parentId = $parent[$modelClass]['id']; - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.2']]); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parentId); - $result = $this->Tree->children($parentId, true, array('name')); - $expected = array(array($modelClass => array('name' => '1.1.1')), - array($modelClass => array('name' => '1.1.2')), - array($modelClass => array('name' => '1.2'))); + $result = $this->Tree->children($parentId, true, ['name']); + $expected = [[$modelClass => ['name' => '1.1.1']], + [$modelClass => ['name' => '1.1.2']], + [$modelClass => ['name' => '1.2']]]; $this->assertEquals($expected, $result); $validTree = $this->Tree->verify(); @@ -654,17 +654,17 @@ public function testMoveAfter() { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2'))); + $parent = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1.2']]); $parentId = $parent[$modelClass]['id']; - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1']]); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parentId); - $result = $this->Tree->children($parentId, true, array('name')); - $expected = array(array($modelClass => array('name' => '1.2.1')), - array($modelClass => array('name' => '1.2.2')), - array($modelClass => array('name' => '1.1'))); + $result = $this->Tree->children($parentId, true, ['name']); + $expected = [[$modelClass => ['name' => '1.2.1']], + [$modelClass => ['name' => '1.2.2']], + [$modelClass => ['name' => '1.1']]]; $this->assertEquals($expected, $result); $validTree = $this->Tree->verify(); @@ -682,10 +682,10 @@ public function testMoveDemoteInvalid() { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $parent = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $parentId = $parent[$modelClass]['id']; - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1.1']]); $expected = $this->Tree->find('all'); $before = $this->Tree->read(null, $data[$modelClass]['id']); @@ -762,14 +762,14 @@ public function testMoveUpSuccess() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.2']]); $this->Tree->moveUp($data[$modelClass]['id']); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array(array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1.1'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [[$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1.1']]]; $this->assertSame($expected, $result); } @@ -783,15 +783,15 @@ public function testMoveUpFail() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.1'))); + $data = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1.1']]); $this->Tree->moveUp($data[$modelClass]['id']); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array(array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1.2'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [[$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1.2']]]; $this->assertSame($expected, $result); } @@ -805,23 +805,23 @@ public function testMoveUp2() { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.5']]); $this->Tree->moveUp($data[$modelClass]['id'], 2); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array( - array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1.5')), - array($modelClass => array('name' => '1.3')), - array($modelClass => array('name' => '1.4')), - array($modelClass => array('name' => '1.6')), - array($modelClass => array('name' => '1.7')), - array($modelClass => array('name' => '1.8')), - array($modelClass => array('name' => '1.9')), - array($modelClass => array('name' => '1.10'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [ + [$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1.5']], + [$modelClass => ['name' => '1.3']], + [$modelClass => ['name' => '1.4']], + [$modelClass => ['name' => '1.6']], + [$modelClass => ['name' => '1.7']], + [$modelClass => ['name' => '1.8']], + [$modelClass => ['name' => '1.9']], + [$modelClass => ['name' => '1.10']]]; $this->assertSame($expected, $result); } @@ -835,23 +835,23 @@ public function testMoveUpFirst() { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.5']]); $this->Tree->moveUp($data[$modelClass]['id'], true); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array( - array($modelClass => array('name' => '1.5')), - array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1.3')), - array($modelClass => array('name' => '1.4')), - array($modelClass => array('name' => '1.6')), - array($modelClass => array('name' => '1.7')), - array($modelClass => array('name' => '1.8')), - array($modelClass => array('name' => '1.9')), - array($modelClass => array('name' => '1.10'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [ + [$modelClass => ['name' => '1.5']], + [$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1.3']], + [$modelClass => ['name' => '1.4']], + [$modelClass => ['name' => '1.6']], + [$modelClass => ['name' => '1.7']], + [$modelClass => ['name' => '1.8']], + [$modelClass => ['name' => '1.9']], + [$modelClass => ['name' => '1.10']]]; $this->assertSame($expected, $result); } @@ -865,14 +865,14 @@ public function testMoveDownSuccess() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1']]); $this->Tree->moveDown($data[$modelClass]['id']); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array(array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1.1'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [[$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1.1']]]; $this->assertSame($expected, $result); } @@ -886,14 +886,14 @@ public function testMoveDownFail() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2'))); + $data = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1.2']]); $this->Tree->moveDown($data[$modelClass]['id']); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array(array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1.2'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [[$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1.2']]]; $this->assertSame($expected, $result); } @@ -907,23 +907,23 @@ public function testMoveDownLast() { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.5']]); $this->Tree->moveDown($data[$modelClass]['id'], true); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array( - array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1.3')), - array($modelClass => array('name' => '1.4')), - array($modelClass => array('name' => '1.6')), - array($modelClass => array('name' => '1.7')), - array($modelClass => array('name' => '1.8')), - array($modelClass => array('name' => '1.9')), - array($modelClass => array('name' => '1.10')), - array($modelClass => array('name' => '1.5'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [ + [$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1.3']], + [$modelClass => ['name' => '1.4']], + [$modelClass => ['name' => '1.6']], + [$modelClass => ['name' => '1.7']], + [$modelClass => ['name' => '1.8']], + [$modelClass => ['name' => '1.9']], + [$modelClass => ['name' => '1.10']], + [$modelClass => ['name' => '1.5']]]; $this->assertSame($expected, $result); } @@ -937,23 +937,23 @@ public function testMoveDown2() { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.5']]); $this->Tree->moveDown($data[$modelClass]['id'], 2); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array( - array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1.3')), - array($modelClass => array('name' => '1.4')), - array($modelClass => array('name' => '1.6')), - array($modelClass => array('name' => '1.7')), - array($modelClass => array('name' => '1.5')), - array($modelClass => array('name' => '1.8')), - array($modelClass => array('name' => '1.9')), - array($modelClass => array('name' => '1.10'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [ + [$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1.3']], + [$modelClass => ['name' => '1.4']], + [$modelClass => ['name' => '1.6']], + [$modelClass => ['name' => '1.7']], + [$modelClass => ['name' => '1.5']], + [$modelClass => ['name' => '1.8']], + [$modelClass => ['name' => '1.9']], + [$modelClass => ['name' => '1.10']]]; $this->assertSame($expected, $result); } @@ -967,23 +967,23 @@ public function testSaveNoMove() { $this->Tree = new $modelClass(); $this->Tree->initialize(1, 10); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.5'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.5']]); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField('name', 'renamed'); - $parent = $this->Tree->findByName('1. Root', array('id')); + $parent = $this->Tree->findByName('1. Root', ['id']); $this->Tree->id = $parent[$modelClass]['id']; - $result = $this->Tree->children(null, true, array('name')); - $expected = array( - array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1.3')), - array($modelClass => array('name' => '1.4')), - array($modelClass => array('name' => 'renamed')), - array($modelClass => array('name' => '1.6')), - array($modelClass => array('name' => '1.7')), - array($modelClass => array('name' => '1.8')), - array($modelClass => array('name' => '1.9')), - array($modelClass => array('name' => '1.10'))); + $result = $this->Tree->children(null, true, ['name']); + $expected = [ + [$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1.3']], + [$modelClass => ['name' => '1.4']], + [$modelClass => ['name' => 'renamed']], + [$modelClass => ['name' => '1.6']], + [$modelClass => ['name' => '1.7']], + [$modelClass => ['name' => '1.8']], + [$modelClass => ['name' => '1.9']], + [$modelClass => ['name' => '1.10']]]; $this->assertSame($expected, $result); } @@ -996,18 +996,18 @@ public function testMoveToRootAndMoveUp() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(1, 1); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1']]); $this->Tree->id = $data[$modelClass]['id']; - $this->Tree->save(array($parentField => null)); + $this->Tree->save([$parentField => null]); $result = $this->Tree->verify(); $this->assertTrue($result); $this->Tree->moveUp(); - $result = $this->Tree->find('all', array('fields' => 'name', 'order' => $modelClass . '.' . $leftField . ' ASC')); - $expected = array(array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1. Root'))); + $result = $this->Tree->find('all', ['fields' => 'name', 'order' => $modelClass . '.' . $leftField . ' ASC']); + $expected = [[$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1. Root']]]; $this->assertSame($expected, $result); } @@ -1075,15 +1075,15 @@ public function testRemove() { $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount, $laterCount); - $children = $this->Tree->children($result[$modelClass][$parentField], true, array('name')); - $expected = array(array($modelClass => array('name' => '1.1.1')), - array($modelClass => array('name' => '1.1.2')), - array($modelClass => array('name' => '1.2'))); + $children = $this->Tree->children($result[$modelClass][$parentField], true, ['name']); + $expected = [[$modelClass => ['name' => '1.1.1']], + [$modelClass => ['name' => '1.1.2']], + [$modelClass => ['name' => '1.2']]]; $this->assertEquals($expected, $children); - $topNodes = $this->Tree->children(false, true, array('name')); - $expected = array(array($modelClass => array('name' => '1. Root')), - array($modelClass => array('name' => '1.1'))); + $topNodes = $this->Tree->children(false, true, ['name']); + $expected = [[$modelClass => ['name' => '1. Root']], + [$modelClass => ['name' => '1.1']]]; $this->assertEquals($expected, $topNodes); $validTree = $this->Tree->verify(); @@ -1112,10 +1112,10 @@ public function testRemoveLastTopParent() { $this->assertEquals($initialCount, $laterCount); $this->assertEquals($initialTopNodes, $laterTopNodes); - $topNodes = $this->Tree->children(false, true, array('name')); - $expected = array(array($modelClass => array('name' => '1.1')), - array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1. Root'))); + $topNodes = $this->Tree->children(false, true, ['name']); + $expected = [[$modelClass => ['name' => '1.1']], + [$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1. Root']]]; $this->assertEquals($expected, $topNodes); @@ -1140,8 +1140,8 @@ public function testRemoveNoChildren() { $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount, $laterCount); - $nodes = $this->Tree->find('list', array('order' => $leftField)); - $expected = array( + $nodes = $this->Tree->find('list', ['order' => $leftField]); + $expected = [ 1 => '1. Root', 2 => '1.1', 4 => '1.1.2', @@ -1149,7 +1149,7 @@ public function testRemoveNoChildren() { 6 => '1.2.1', 7 => '1.2.2', 3 => '1.1.1', - ); + ]; $this->assertEquals($expected, $nodes); @@ -1175,16 +1175,16 @@ public function testRemoveAndDelete() { $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount - 1, $laterCount); - $children = $this->Tree->children($result[$modelClass][$parentField], true, array('name'), $leftField . ' asc'); - $expected = array( - array($modelClass => array('name' => '1.1.1')), - array($modelClass => array('name' => '1.1.2')), - array($modelClass => array('name' => '1.2')) - ); + $children = $this->Tree->children($result[$modelClass][$parentField], true, ['name'], $leftField . ' asc'); + $expected = [ + [$modelClass => ['name' => '1.1.1']], + [$modelClass => ['name' => '1.1.2']], + [$modelClass => ['name' => '1.2']] + ]; $this->assertEquals($expected, $children); - $topNodes = $this->Tree->children(false, true, array('name')); - $expected = array(array($modelClass => array('name' => '1. Root'))); + $topNodes = $this->Tree->children(false, true, ['name']); + $expected = [[$modelClass => ['name' => '1. Root']]]; $this->assertEquals($expected, $topNodes); $validTree = $this->Tree->verify(); @@ -1208,15 +1208,15 @@ public function testRemoveAndDeleteNoChildren() { $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount - 1, $laterCount); - $nodes = $this->Tree->find('list', array('order' => $leftField)); - $expected = array( + $nodes = $this->Tree->find('list', ['order' => $leftField]); + $expected = [ 1 => '1. Root', 2 => '1.1', 4 => '1.1.2', 5 => '1.2', 6 => '1.2.1', 7 => '1.2.2', - ); + ]; $this->assertEquals($expected, $nodes); $validTree = $this->Tree->verify(); @@ -1233,24 +1233,24 @@ public function testChildren() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $data = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $this->Tree->id = $data[$modelClass]['id']; - $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField)); - $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)), - array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13))); + $direct = $this->Tree->children(null, true, ['id', 'name', $parentField, $leftField, $rightField]); + $expected = [[$modelClass => ['id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7]], + [$modelClass => ['id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13]]]; $this->assertEquals($expected, $direct); - $total = $this->Tree->children(null, null, array('id', 'name', $parentField, $leftField, $rightField)); - $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)), - array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4)), - array($modelClass => array('id' => 4, 'name' => '1.1.2', $parentField => 2, $leftField => 5, $rightField => 6)), - array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13)), - array($modelClass => array('id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)), - array($modelClass => array('id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12))); + $total = $this->Tree->children(null, null, ['id', 'name', $parentField, $leftField, $rightField]); + $expected = [[$modelClass => ['id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7]], + [$modelClass => ['id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4]], + [$modelClass => ['id' => 4, 'name' => '1.1.2', $parentField => 2, $leftField => 5, $rightField => 6]], + [$modelClass => ['id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13]], + [$modelClass => ['id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10]], + [$modelClass => ['id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12]]]; $this->assertEquals($expected, $total); - $this->assertEquals(array(), $this->Tree->children(10000)); + $this->assertEquals([], $this->Tree->children(10000)); } /** @@ -1263,7 +1263,7 @@ public function testCountChildren() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $data = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $this->Tree->id = $data[$modelClass]['id']; $direct = $this->Tree->childCount(null, true); @@ -1273,7 +1273,7 @@ public function testCountChildren() { $this->assertEquals(6, $total); $this->Tree->read(null, $data[$modelClass]['id']); - $id = $this->Tree->field('id', array($modelClass . '.name' => '1.2')); + $id = $this->Tree->field('id', [$modelClass . '.name' => '1.2']); $total = $this->Tree->childCount($id); $this->assertEquals(2, $total); } @@ -1288,11 +1288,11 @@ public function testGetParentNode() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2'))); + $data = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1.2.2']]); $this->Tree->id = $data[$modelClass]['id']; - $result = $this->Tree->getParentNode(null, array('name')); - $expected = array($modelClass => array('name' => '1.2')); + $result = $this->Tree->getParentNode(null, ['name']); + $expected = [$modelClass => ['name' => '1.2']]; $this->assertSame($expected, $result); } @@ -1306,13 +1306,13 @@ public function testGetPath() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1.2.2'))); + $data = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1.2.2']]); $this->Tree->id = $data[$modelClass]['id']; - $result = $this->Tree->getPath(null, array('name')); - $expected = array(array($modelClass => array('name' => '1. Root')), - array($modelClass => array('name' => '1.2')), - array($modelClass => array('name' => '1.2.2'))); + $result = $this->Tree->getPath(null, ['name']); + $expected = [[$modelClass => ['name' => '1. Root']], + [$modelClass => ['name' => '1.2']], + [$modelClass => ['name' => '1.2.2']]]; $this->assertSame($expected, $result); } @@ -1324,27 +1324,27 @@ public function testGetPath() { public function testNoAmbiguousColumn() { extract($this->settings); $this->Tree = new $modelClass(); - $this->Tree->bindModel(array('belongsTo' => array('Dummy' => - array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); + $this->Tree->bindModel(['belongsTo' => ['Dummy' => + ['className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => ['Dummy.id' => null]]]], false); $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $data = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $this->Tree->id = $data[$modelClass]['id']; - $direct = $this->Tree->children(null, true, array('id', 'name', $parentField, $leftField, $rightField)); - $expected = array(array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)), - array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13))); + $direct = $this->Tree->children(null, true, ['id', 'name', $parentField, $leftField, $rightField]); + $expected = [[$modelClass => ['id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7]], + [$modelClass => ['id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13]]]; $this->assertEquals($expected, $direct); - $total = $this->Tree->children(null, null, array('id', 'name', $parentField, $leftField, $rightField)); - $expected = array( - array($modelClass => array('id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7)), - array($modelClass => array('id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4)), - array($modelClass => array('id' => 4, 'name' => '1.1.2', $parentField => 2, $leftField => 5, $rightField => 6)), - array($modelClass => array('id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13)), - array($modelClass => array('id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10)), - array($modelClass => array('id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12)) - ); + $total = $this->Tree->children(null, null, ['id', 'name', $parentField, $leftField, $rightField]); + $expected = [ + [$modelClass => ['id' => 2, 'name' => '1.1', $parentField => 1, $leftField => 2, $rightField => 7]], + [$modelClass => ['id' => 3, 'name' => '1.1.1', $parentField => 2, $leftField => 3, $rightField => 4]], + [$modelClass => ['id' => 4, 'name' => '1.1.2', $parentField => 2, $leftField => 5, $rightField => 6]], + [$modelClass => ['id' => 5, 'name' => '1.2', $parentField => 1, $leftField => 8, $rightField => 13]], + [$modelClass => ['id' => 6, 'name' => '1.2.1', $parentField => 5, $leftField => 9, $rightField => 10]], + [$modelClass => ['id' => 7, 'name' => '1.2.2', $parentField => 5, $leftField => 11, $rightField => 12]] + ]; $this->assertEquals($expected, $total); } @@ -1357,23 +1357,23 @@ public function testReorderTree() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(3, 3); - $nodes = $this->Tree->find('list', array('order' => $leftField)); + $nodes = $this->Tree->find('list', ['order' => $leftField]); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1']]); $this->Tree->moveDown($data[$modelClass]['id']); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.2.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.2.1']]); $this->Tree->moveDown($data[$modelClass]['id']); - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.3.2.2'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.3.2.2']]); $this->Tree->moveDown($data[$modelClass]['id']); - $unsortedNodes = $this->Tree->find('list', array('order' => $leftField)); + $unsortedNodes = $this->Tree->find('list', ['order' => $leftField]); $this->assertEquals($nodes, $unsortedNodes); $this->assertNotEquals(array_keys($nodes), array_keys($unsortedNodes)); $this->Tree->reorder(); - $sortedNodes = $this->Tree->find('list', array('order' => $leftField)); + $sortedNodes = $this->Tree->find('list', ['order' => $leftField]); $this->assertSame($nodes, $sortedNodes); } @@ -1391,7 +1391,7 @@ public function testReorderBigTreeWithQueryCaching() { $original = $this->Tree->cacheQueries; $this->Tree->cacheQueries = true; - $this->Tree->reorder(array('field' => 'name', 'direction' => 'DESC')); + $this->Tree->reorder(['field' => 'name', 'direction' => 'DESC']); $this->assertTrue($this->Tree->cacheQueries, 'cacheQueries was not restored after reorder(). %s'); $this->Tree->cacheQueries = $original; } @@ -1404,12 +1404,12 @@ public function testReorderBigTreeWithQueryCaching() { public function testGenerateTreeListWithSelfJoin() { extract($this->settings); $this->Tree = new $modelClass(); - $this->Tree->bindModel(array('belongsTo' => array('Dummy' => - array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); + $this->Tree->bindModel(['belongsTo' => ['Dummy' => + ['className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => ['Dummy.id' => null]]]], false); $this->Tree->initialize(2, 2); $result = $this->Tree->generateTreeList(); - $expected = array(1 => '1. Root', 2 => '_1.1', 3 => '__1.1.1', 4 => '__1.1.2', 5 => '_1.2', 6 => '__1.2.1', 7 => '__1.2.2'); + $expected = [1 => '1. Root', 2 => '_1.1', 3 => '__1.1.1', 4 => '__1.1.2', 5 => '_1.2', 6 => '__1.2.1', 7 => '__1.2.2']; $this->assertSame($expected, $result); } @@ -1426,7 +1426,7 @@ public function testGenerateTreeListFormatting() { $result = $this->Tree->generateTreeList( null, "{n}.$modelClass.id", - array('%s - %s', "{n}.$modelClass.id", "{n}.$modelClass.name") + ['%s - %s', "{n}.$modelClass.id", "{n}.$modelClass.name"] ); $this->assertEquals('1 - 1. Root', $result[1]); $this->assertEquals('_2 - 1.1', $result[2]); @@ -1443,13 +1443,13 @@ public function testFormatTreeList() { $this->Tree = new $modelClass(); $this->Tree->initialize(2, 2); - $options = array('order' => array('lft' => 'asc')); + $options = ['order' => ['lft' => 'asc']]; $records = $this->Tree->find('all', $options); - $options = array( + $options = [ 'keyPath' => "{n}.$modelClass.id", - 'valuePath' => array('%s - %s', "{n}.$modelClass.id", "{n}.$modelClass.name"), - 'spacer' => '--'); + 'valuePath' => ['%s - %s', "{n}.$modelClass.id", "{n}.$modelClass.name"], + 'spacer' => '--']; $result = $this->Tree->formatTreeList($records, $options); $this->assertEquals('1 - 1. Root', $result[1]); $this->assertEquals('--2 - 1.1', $result[2]); @@ -1465,9 +1465,9 @@ public function testArraySyntax() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->initialize(3, 3); - $this->assertSame($this->Tree->childCount(2), $this->Tree->childCount(array('id' => 2))); - $this->assertSame($this->Tree->getParentNode(2), $this->Tree->getParentNode(array('id' => 2))); - $this->assertSame($this->Tree->getPath(4), $this->Tree->getPath(array('id' => 4))); + $this->assertSame($this->Tree->childCount(2), $this->Tree->childCount(['id' => 2])); + $this->assertSame($this->Tree->getParentNode(2), $this->Tree->getParentNode(['id' => 2])); + $this->assertSame($this->Tree->getPath(4), $this->Tree->getPath(['id' => 4])); } /** @@ -1478,84 +1478,84 @@ public function testArraySyntax() { public function testFindThreaded() { $Model = new Person(); $Model->recursive = -1; - $Model->Behaviors->load('Tree', array('parent' => 'mother_id')); + $Model->Behaviors->load('Tree', ['parent' => 'mother_id']); $result = $Model->find('threaded'); - $expected = array( - array( - 'Person' => array( + $expected = [ + [ + 'Person' => [ 'id' => '4', 'name' => 'mother - grand mother', 'mother_id' => '0', 'father_id' => '0' - ), - 'children' => array( - array( - 'Person' => array( + ], + 'children' => [ + [ + 'Person' => [ 'id' => '2', 'name' => 'mother', 'mother_id' => '4', 'father_id' => '5' - ), - 'children' => array( - array( - 'Person' => array( + ], + 'children' => [ + [ + 'Person' => [ 'id' => '1', 'name' => 'person', 'mother_id' => '2', 'father_id' => '3' - ), - 'children' => array() - ) - ) - ) - ) - ), - array( - 'Person' => array( + ], + 'children' => [] + ] + ] + ] + ] + ], + [ + 'Person' => [ 'id' => '5', 'name' => 'mother - grand father', 'mother_id' => '0', 'father_id' => '0' - ), - 'children' => array() - ), - array( - 'Person' => array( + ], + 'children' => [] + ], + [ + 'Person' => [ 'id' => '6', 'name' => 'father - grand mother', 'mother_id' => '0', 'father_id' => '0' - ), - 'children' => array( - array( - 'Person' => array( + ], + 'children' => [ + [ + 'Person' => [ 'id' => '3', 'name' => 'father', 'mother_id' => '6', 'father_id' => '7' - ), - 'children' => array() - ) - ) - ), - array( - 'Person' => array( + ], + 'children' => [] + ] + ] + ], + [ + 'Person' => [ 'id' => '7', 'name' => 'father - grand father', 'mother_id' => '0', 'father_id' => '0' - ), - 'children' => array() - ) - ); + ], + 'children' => [] + ] + ]; $this->assertEquals($expected, $result); } public function testLevel() { extract($this->settings); $this->Tree = new $modelClass(); - $this->Tree->Behaviors->attach('Tree', array('level' => 'level')); + $this->Tree->Behaviors->attach('Tree', ['level' => 'level']); $this->Tree->initialize(2, 2); $result = $this->Tree->findByName('1. Root'); @@ -1571,25 +1571,25 @@ public function testLevel() { $this->assertEquals(2, $result[$modelClass][$level]); // Save with parent_id not set - $this->Tree->save(array('id' => $result[$modelClass]['id'], 'name' => 'foo')); + $this->Tree->save(['id' => $result[$modelClass]['id'], 'name' => 'foo']); $result = $this->Tree->findByName('foo'); $this->assertEquals(2, $result[$modelClass][$level]); // Save with parent_id not changed - $this->Tree->save(array( + $this->Tree->save([ 'id' => $result[$modelClass]['id'], 'parent_id' => $result[$modelClass]['parent_id'], 'name' => 'foo2' - )); + ]); $result = $this->Tree->findByName('foo2'); $this->assertEquals(2, $result[$modelClass][$level]); // Save with parent_id changed $result = $this->Tree->findByName('1.1'); - $this->Tree->save(array( + $this->Tree->save([ 'id' => $result[$modelClass]['id'], 'parent_id' => '' - )); + ]); $result = $this->Tree->findByName('1.1'); $this->assertEquals(0, $result[$modelClass][$level]); @@ -1598,10 +1598,10 @@ public function testLevel() { $parent = $this->Tree->findByName('1.1.2'); $result = $this->Tree->findByName('1.2'); - $this->Tree->save(array( + $this->Tree->save([ 'id' => $result[$modelClass]['id'], 'parent_id' => $parent[$modelClass]['id'] - )); + ]); $result = $this->Tree->findByName('1.2'); $this->assertEquals(2, $result[$modelClass][$level]); diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php index 22f3aeda9b..812012259e 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorScopedTest.php @@ -21,7 +21,7 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); -require_once dirname(dirname(__FILE__)) . DS . 'models.php'; +require_once dirname(__FILE__, 2) . DS . 'models.php'; /** * TreeBehaviorScopedTest class @@ -42,19 +42,19 @@ class TreeBehaviorScopedTest extends CakeTestCase { * * @var array */ - public $settings = array( + public $settings = [ 'modelClass' => 'FlagTree', 'leftField' => 'lft', 'rightField' => 'rght', 'parentField' => 'parent_id' - ); + ]; /** * fixtures property * * @var array */ - public $fixtures = array('core.flag_tree', 'core.ad', 'core.campaign', 'core.translate', 'core.number_tree_two'); + public $fixtures = ['core.flag_tree', 'core.ad', 'core.campaign', 'core.translate', 'core.number_tree_two']; /** * testStringScope method @@ -72,21 +72,21 @@ public function testStringScope() { $this->Tree->saveField('flag', 1); $result = $this->Tree->children(); - $expected = array( - array('FlagTree' => array('id' => '3', 'name' => '1.1.1', 'parent_id' => '2', 'lft' => '3', 'rght' => '4', 'flag' => '0')), - array('FlagTree' => array('id' => '4', 'name' => '1.1.2', 'parent_id' => '2', 'lft' => '5', 'rght' => '6', 'flag' => '0')), - array('FlagTree' => array('id' => '5', 'name' => '1.1.3', 'parent_id' => '2', 'lft' => '7', 'rght' => '8', 'flag' => '0')) - ); + $expected = [ + ['FlagTree' => ['id' => '3', 'name' => '1.1.1', 'parent_id' => '2', 'lft' => '3', 'rght' => '4', 'flag' => '0']], + ['FlagTree' => ['id' => '4', 'name' => '1.1.2', 'parent_id' => '2', 'lft' => '5', 'rght' => '6', 'flag' => '0']], + ['FlagTree' => ['id' => '5', 'name' => '1.1.3', 'parent_id' => '2', 'lft' => '7', 'rght' => '8', 'flag' => '0']] + ]; $this->assertEquals($expected, $result); - $this->Tree->Behaviors->load('Tree', array('scope' => 'FlagTree.flag = 1')); - $this->assertEquals(array(), $this->Tree->children()); + $this->Tree->Behaviors->load('Tree', ['scope' => 'FlagTree.flag = 1']); + $this->assertEquals([], $this->Tree->children()); $this->Tree->id = 1; - $this->Tree->Behaviors->load('Tree', array('scope' => 'FlagTree.flag = 1')); + $this->Tree->Behaviors->load('Tree', ['scope' => 'FlagTree.flag = 1']); $result = $this->Tree->children(); - $expected = array(array('FlagTree' => array('id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1'))); + $expected = [['FlagTree' => ['id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1']]]; $this->assertEquals($expected, $result); $this->assertTrue($this->Tree->delete()); @@ -109,21 +109,21 @@ public function testArrayScope() { $this->Tree->saveField('flag', 1); $result = $this->Tree->children(); - $expected = array( - array('FlagTree' => array('id' => '3', 'name' => '1.1.1', 'parent_id' => '2', 'lft' => '3', 'rght' => '4', 'flag' => '0')), - array('FlagTree' => array('id' => '4', 'name' => '1.1.2', 'parent_id' => '2', 'lft' => '5', 'rght' => '6', 'flag' => '0')), - array('FlagTree' => array('id' => '5', 'name' => '1.1.3', 'parent_id' => '2', 'lft' => '7', 'rght' => '8', 'flag' => '0')) - ); + $expected = [ + ['FlagTree' => ['id' => '3', 'name' => '1.1.1', 'parent_id' => '2', 'lft' => '3', 'rght' => '4', 'flag' => '0']], + ['FlagTree' => ['id' => '4', 'name' => '1.1.2', 'parent_id' => '2', 'lft' => '5', 'rght' => '6', 'flag' => '0']], + ['FlagTree' => ['id' => '5', 'name' => '1.1.3', 'parent_id' => '2', 'lft' => '7', 'rght' => '8', 'flag' => '0']] + ]; $this->assertEquals($expected, $result); - $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); - $this->assertEquals(array(), $this->Tree->children()); + $this->Tree->Behaviors->load('Tree', ['scope' => ['FlagTree.flag' => 1]]); + $this->assertEquals([], $this->Tree->children()); $this->Tree->id = 1; - $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', ['scope' => ['FlagTree.flag' => 1]]); $result = $this->Tree->children(); - $expected = array(array('FlagTree' => array('id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1'))); + $expected = [['FlagTree' => ['id' => '2', 'name' => '1.1', 'parent_id' => '1', 'lft' => '2', 'rght' => '9', 'flag' => '1']]]; $this->assertEquals($expected, $result); $this->assertTrue($this->Tree->delete()); @@ -141,13 +141,13 @@ public function testArrayScope() { public function testSaveWithParentAndInvalidScope() { $this->Tree = new FlagTree(); $this->Tree->order = null; - $data = $this->Tree->create(array( + $data = $this->Tree->create([ 'name' => 'Flag', - )); + ]); $tree = $this->Tree->save($data); - $this->Tree->Behaviors->load('Tree', array( - 'scope' => array('FlagTree.flag' => 100) - )); + $this->Tree->Behaviors->load('Tree', [ + 'scope' => ['FlagTree.flag' => 100] + ]); $tree['FlagTree']['parent_id'] = 1; $result = $this->Tree->save($tree); $this->assertFalse($result); @@ -161,13 +161,13 @@ public function testSaveWithParentAndInvalidScope() { public function testMoveUpWithScope() { $this->Ad = new Ad(); $this->Ad->order = null; - $this->Ad->Behaviors->load('Tree', array('scope' => 'Campaign')); + $this->Ad->Behaviors->load('Tree', ['scope' => 'Campaign']); $this->Ad->moveUp(6); $this->Ad->id = 4; $result = $this->Ad->children(); - $this->assertEquals(array(6, 5), Hash::extract($result, '{n}.Ad.id')); - $this->assertEquals(array(2, 2), Hash::extract($result, '{n}.Campaign.id')); + $this->assertEquals([6, 5], Hash::extract($result, '{n}.Ad.id')); + $this->assertEquals([2, 2], Hash::extract($result, '{n}.Campaign.id')); } /** @@ -178,13 +178,13 @@ public function testMoveUpWithScope() { public function testMoveDownWithScope() { $this->Ad = new Ad(); $this->Ad->order = null; - $this->Ad->Behaviors->load('Tree', array('scope' => 'Campaign')); + $this->Ad->Behaviors->load('Tree', ['scope' => 'Campaign']); $this->Ad->moveDown(6); $this->Ad->id = 4; $result = $this->Ad->children(); - $this->assertEquals(array(5, 6), Hash::extract($result, '{n}.Ad.id')); - $this->assertEquals(array(2, 2), Hash::extract($result, '{n}.Campaign.id')); + $this->assertEquals([5, 6], Hash::extract($result, '{n}.Ad.id')); + $this->assertEquals([2, 2], Hash::extract($result, '{n}.Campaign.id')); } /** @@ -197,20 +197,20 @@ public function testTranslatingTree() { $this->Tree = new FlagTree(); $this->Tree->order = null; $this->Tree->cacheQueries = false; - $this->Tree->Behaviors->load('Translate', array('title')); + $this->Tree->Behaviors->load('Translate', ['title']); //Save $this->Tree->create(); $this->Tree->locale = 'eng'; - $data = array('FlagTree' => array( + $data = ['FlagTree' => [ 'title' => 'name #1', 'name' => 'test', 'locale' => 'eng', 'parent_id' => null, - )); + ]]; $this->Tree->save($data); $result = $this->Tree->find('all'); - $expected = array(array('FlagTree' => array( + $expected = [['FlagTree' => [ 'id' => 1, 'title' => 'name #1', 'name' => 'test', @@ -219,7 +219,7 @@ public function testTranslatingTree() { 'rght' => 2, 'flag' => 0, 'locale' => 'eng', - ))); + ]]]; $this->assertEquals($expected, $result); // update existing record, same locale @@ -228,7 +228,7 @@ public function testTranslatingTree() { $this->Tree->id = 1; $this->Tree->save($data); $result = $this->Tree->find('all'); - $expected = array(array('FlagTree' => array( + $expected = [['FlagTree' => [ 'id' => 1, 'title' => 'Named 2', 'name' => 'test', @@ -237,27 +237,27 @@ public function testTranslatingTree() { 'rght' => 2, 'flag' => 0, 'locale' => 'eng', - ))); + ]]]; $this->assertEquals($expected, $result); // update different locale, same record $this->Tree->create(); $this->Tree->locale = 'deu'; $this->Tree->id = 1; - $data = array('FlagTree' => array( + $data = ['FlagTree' => [ 'id' => 1, 'parent_id' => null, 'title' => 'namen #1', 'name' => 'test', 'locale' => 'deu', - )); + ]]; $this->Tree->save($data); $this->Tree->locale = 'deu'; $result = $this->Tree->find('all'); - $expected = array( - array( - 'FlagTree' => array( + $expected = [ + [ + 'FlagTree' => [ 'id' => 1, 'title' => 'namen #1', 'name' => 'test', @@ -266,29 +266,29 @@ public function testTranslatingTree() { 'rght' => 2, 'flag' => 0, 'locale' => 'deu', - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); // Save with bindTranslation $this->Tree->locale = 'eng'; - $data = array( - 'title' => array('eng' => 'New title', 'spa' => 'Nuevo leyenda'), + $data = [ + 'title' => ['eng' => 'New title', 'spa' => 'Nuevo leyenda'], 'name' => 'test', 'parent_id' => null - ); + ]; $this->Tree->create($data); $this->Tree->save(); $this->Tree->unbindTranslation(); - $translations = array('title' => 'Title'); + $translations = ['title' => 'Title']; $this->Tree->bindTranslation($translations, false); - $this->Tree->locale = array('eng', 'spa'); + $this->Tree->locale = ['eng', 'spa']; $result = $this->Tree->read(); - $expected = array( - 'FlagTree' => array( + $expected = [ + 'FlagTree' => [ 'id' => 2, 'parent_id' => null, 'locale' => 'eng', @@ -297,12 +297,12 @@ public function testTranslatingTree() { 'flag' => 0, 'lft' => 3, 'rght' => 4 - ), - 'Title' => array( - array('id' => 21, 'locale' => 'eng', 'model' => 'FlagTree', 'foreign_key' => 2, 'field' => 'title', 'content' => 'New title'), - array('id' => 22, 'locale' => 'spa', 'model' => 'FlagTree', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Nuevo leyenda') - ), - ); + ], + 'Title' => [ + ['id' => 21, 'locale' => 'eng', 'model' => 'FlagTree', 'foreign_key' => 2, 'field' => 'title', 'content' => 'New title'], + ['id' => 22, 'locale' => 'spa', 'model' => 'FlagTree', 'foreign_key' => 2, 'field' => 'title', 'content' => 'Nuevo leyenda'] + ], + ]; $this->assertEquals($expected, $result); } @@ -322,45 +322,45 @@ public function testAliasesWithScopeInTwoTreeAssociations() { $record = $this->Tree->find('first'); - $this->Tree->bindModel(array( - 'hasMany' => array( - 'SecondTree' => array( + $this->Tree->bindModel([ + 'hasMany' => [ + 'SecondTree' => [ 'className' => 'NumberTreeTwo', 'foreignKey' => 'number_tree_id' - ) - ) - )); - $this->TreeTwo->bindModel(array( - 'belongsTo' => array( - 'FirstTree' => array( + ] + ] + ]); + $this->TreeTwo->bindModel([ + 'belongsTo' => [ + 'FirstTree' => [ 'className' => $modelClass, 'foreignKey' => 'number_tree_id' - ) - ) - )); - $this->TreeTwo->Behaviors->load('Tree', array( + ] + ] + ]); + $this->TreeTwo->Behaviors->load('Tree', [ 'scope' => 'FirstTree' - )); + ]); - $data = array( - 'NumberTreeTwo' => array( + $data = [ + 'NumberTreeTwo' => [ 'name' => 'First', 'number_tree_id' => $record['FlagTree']['id'] - ) - ); + ] + ]; $this->TreeTwo->create(); $result = $this->TreeTwo->save($data); $this->assertFalse(empty($result)); $result = $this->TreeTwo->find('first'); - $expected = array('NumberTreeTwo' => array( + $expected = ['NumberTreeTwo' => [ 'id' => 1, 'name' => 'First', 'number_tree_id' => $record['FlagTree']['id'], 'parent_id' => null, 'lft' => 1, 'rght' => 2 - )); + ]]; $this->assertEquals($expected, $result); } @@ -380,26 +380,26 @@ public function testGenerateTreeListWithScope() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', ['scope' => ['FlagTree.flag' => 1]]); $result = $this->Tree->generateTreeList(); - $expected = array( + $expected = [ 1 => '1. Root', 2 => '_1.1' - ); + ]; $this->assertEquals($expected, $result); // As string. - $this->Tree->Behaviors->load('Tree', array('scope' => 'FlagTree.flag = 1')); + $this->Tree->Behaviors->load('Tree', ['scope' => 'FlagTree.flag = 1']); $result = $this->Tree->generateTreeList(); $this->assertEquals($expected, $result); // Merging conditions. - $result = $this->Tree->generateTreeList(array('FlagTree.id >' => 1)); - $expected = array( + $result = $this->Tree->generateTreeList(['FlagTree.id >' => 1]); + $expected = [ 2 => '1.1' - ); + ]; $this->assertEquals($expected, $result); } @@ -414,26 +414,26 @@ public function testRecoverUsingParentMode() { $this->Tree->order = null; $this->Tree->initialize(2, 3); - $this->Tree->Behaviors->load('Tree', array('scope' => 'FlagTree.flag = 1')); + $this->Tree->Behaviors->load('Tree', ['scope' => 'FlagTree.flag = 1']); $this->Tree->Behaviors->disable('Tree'); $this->Tree->create(); - $this->Tree->save(array('name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0, 'flag' => 1)); + $this->Tree->save(['name' => 'Main', $parentField => null, $leftField => 0, $rightField => 0, 'flag' => 1]); $node1 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0, 'flag' => 1)); + $this->Tree->save(['name' => 'About Us', $parentField => $node1, $leftField => 0, $rightField => 0, 'flag' => 1]); $node11 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0, 'flag' => 1)); + $this->Tree->save(['name' => 'Programs', $parentField => $node1, $leftField => 0, $rightField => 0, 'flag' => 1]); $node12 = $this->Tree->id; $this->Tree->create(); - $this->Tree->save(array('name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0, 'flag' => 1)); + $this->Tree->save(['name' => 'Mission and History', $parentField => $node11, $leftField => 0, $rightField => 0, 'flag' => 1]); $this->Tree->create(); - $this->Tree->save(array('name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0, 'flag' => 1)); + $this->Tree->save(['name' => 'Overview', $parentField => $node12, $leftField => 0, $rightField => 0, 'flag' => 1]); $this->Tree->Behaviors->enable('Tree'); @@ -446,20 +446,20 @@ public function testRecoverUsingParentMode() { $result = $this->Tree->verify(); $this->assertTrue($result); - $result = $this->Tree->find('first', array( - 'fields' => array('name', $parentField, $leftField, $rightField, 'flag'), - 'conditions' => array('name' => 'Main'), + $result = $this->Tree->find('first', [ + 'fields' => ['name', $parentField, $leftField, $rightField, 'flag'], + 'conditions' => ['name' => 'Main'], 'recursive' => -1 - )); - $expected = array( - $modelClass => array( + ]); + $expected = [ + $modelClass => [ 'name' => 'Main', $parentField => null, $leftField => 1, $rightField => 10, 'flag' => 1 - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -479,10 +479,10 @@ public function testRecoverFromMissingParent() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', ['scope' => ['FlagTree.flag' => 1]]); $result = $this->Tree->findByName('1.1'); - $this->Tree->updateAll(array($parentField => 999999), array('id' => $result[$modelClass]['id'])); + $this->Tree->updateAll([$parentField => 999999], ['id' => $result[$modelClass]['id']]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -510,9 +510,9 @@ public function testDetectInvalidParents() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', ['scope' => ['FlagTree.flag' => 1]]); - $this->Tree->updateAll(array($parentField => null)); + $this->Tree->updateAll([$parentField => null]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -540,9 +540,9 @@ public function testDetectInvalidLftsRghts() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', ['scope' => ['FlagTree.flag' => 1]]); - $this->Tree->updateAll(array($leftField => 0, $rightField => 0)); + $this->Tree->updateAll([$leftField => 0, $rightField => 0]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); @@ -569,14 +569,14 @@ public function testDetectEqualLftsRghts() { $this->Tree->id = 2; $this->Tree->saveField('flag', 1); - $this->Tree->Behaviors->load('Tree', array('scope' => array('FlagTree.flag' => 1))); + $this->Tree->Behaviors->load('Tree', ['scope' => ['FlagTree.flag' => 1]]); $result = $this->Tree->findByName('1.1'); - $this->Tree->updateAll(array($rightField => $result[$modelClass][$leftField]), array('id' => $result[$modelClass]['id'])); - $this->Tree->updateAll(array($leftField => $this->Tree->escapeField($leftField) . ' -1'), - array($leftField . ' >' => $result[$modelClass][$leftField])); - $this->Tree->updateAll(array($rightField => $this->Tree->escapeField($rightField) . ' -1'), - array($rightField . ' >' => $result[$modelClass][$leftField])); + $this->Tree->updateAll([$rightField => $result[$modelClass][$leftField]], ['id' => $result[$modelClass]['id']]); + $this->Tree->updateAll([$leftField => $this->Tree->escapeField($leftField) . ' -1'], + [$leftField . ' >' => $result[$modelClass][$leftField]]); + $this->Tree->updateAll([$rightField => $this->Tree->escapeField($rightField) . ' -1'], + [$rightField . ' >' => $result[$modelClass][$leftField]]); $result = $this->Tree->verify(); $this->assertNotSame(true, $result); diff --git a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php index cfa2559af9..89e5dca6fe 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TreeBehaviorUuidTest.php @@ -22,7 +22,7 @@ App::uses('AppModel', 'Model'); App::uses('CakeText', 'Utility'); -require_once dirname(dirname(__FILE__)) . DS . 'models.php'; +require_once dirname(__FILE__, 2) . DS . 'models.php'; /** * TreeBehaviorUuidTest class @@ -43,19 +43,19 @@ class TreeBehaviorUuidTest extends CakeTestCase { * * @var array */ - public $settings = array( + public $settings = [ 'modelClass' => 'UuidTree', 'leftField' => 'lft', 'rightField' => 'rght', 'parentField' => 'parent_id' - ); + ]; /** * fixtures property * * @var array */ - public $fixtures = array('core.uuid_tree'); + public $fixtures = ['core.uuid_tree']; /** * testAddWithPreSpecifiedId method @@ -68,20 +68,20 @@ public function testAddWithPreSpecifiedId() { $this->Tree->order = null; $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array( - 'fields' => array('id'), - 'conditions' => array($modelClass . '.name' => '1.1') - )); + $data = $this->Tree->find('first', [ + 'fields' => ['id'], + 'conditions' => [$modelClass . '.name' => '1.1'] + ]); $id = CakeText::uuid(); $this->Tree->create(); - $result = $this->Tree->save(array($modelClass => array( + $result = $this->Tree->save([$modelClass => [ 'id' => $id, 'name' => 'testAddMiddle', - $parentField => $data[$modelClass]['id']) - )); + $parentField => $data[$modelClass]['id']] + ]); $expected = array_merge( - array($modelClass => array('id' => $id, 'name' => 'testAddMiddle', $parentField => '2')), + [$modelClass => ['id' => $id, 'name' => 'testAddMiddle', $parentField => '2']], $result ); $this->assertSame($expected, $result); @@ -101,16 +101,16 @@ public function testMovePromote() { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $parent = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $parentId = $parent[$modelClass]['id']; - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1.1']]); $this->Tree->id = $data[$modelClass]['id']; $this->Tree->saveField($parentField, $parentId); - $direct = $this->Tree->children($parentId, true, array('name', $leftField, $rightField)); - $expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)), - array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)), - array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13))); + $direct = $this->Tree->children($parentId, true, ['name', $leftField, $rightField]); + $expected = [[$modelClass => ['name' => '1.1', $leftField => 2, $rightField => 5]], + [$modelClass => ['name' => '1.2', $leftField => 6, $rightField => 11]], + [$modelClass => ['name' => '1.1.1', $leftField => 12, $rightField => 13]]]; $this->assertEquals($expected, $direct); $validTree = $this->Tree->verify(); $this->assertTrue($validTree); @@ -128,18 +128,18 @@ public function testMoveWithWhitelist() { $this->Tree->initialize(2, 2); $this->Tree->id = null; - $parent = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $parent = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $parentId = $parent[$modelClass]['id']; - $data = $this->Tree->find('first', array('fields' => array('id'), 'conditions' => array($modelClass . '.name' => '1.1.1'))); + $data = $this->Tree->find('first', ['fields' => ['id'], 'conditions' => [$modelClass . '.name' => '1.1.1']]); $this->Tree->id = $data[$modelClass]['id']; - $this->Tree->whitelist = array($parentField, 'name', 'description'); + $this->Tree->whitelist = [$parentField, 'name', 'description']; $this->Tree->saveField($parentField, $parentId); - $result = $this->Tree->children($parentId, true, array('name', $leftField, $rightField)); - $expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 5)), - array($modelClass => array('name' => '1.2', $leftField => 6, $rightField => 11)), - array($modelClass => array('name' => '1.1.1', $leftField => 12, $rightField => 13))); + $result = $this->Tree->children($parentId, true, ['name', $leftField, $rightField]); + $expected = [[$modelClass => ['name' => '1.1', $leftField => 2, $rightField => 5]], + [$modelClass => ['name' => '1.2', $leftField => 6, $rightField => 11]], + [$modelClass => ['name' => '1.1.1', $leftField => 12, $rightField => 13]]]; $this->assertEquals($expected, $result); $this->assertTrue($this->Tree->verify()); } @@ -162,8 +162,8 @@ public function testRemoveNoChildren() { $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount, $laterCount); - $nodes = $this->Tree->find('list', array('order' => $leftField)); - $expected = array( + $nodes = $this->Tree->find('list', ['order' => $leftField]); + $expected = [ '1. Root', '1.1', '1.1.2', @@ -171,7 +171,7 @@ public function testRemoveNoChildren() { '1.2.1', '1.2.2', '1.1.1', - ); + ]; $this->assertEquals($expected, array_values($nodes)); @@ -197,15 +197,15 @@ public function testRemoveAndDeleteNoChildren() { $laterCount = $this->Tree->find('count'); $this->assertEquals($initialCount - 1, $laterCount); - $nodes = $this->Tree->find('list', array('order' => $leftField)); - $expected = array( + $nodes = $this->Tree->find('list', ['order' => $leftField]); + $expected = [ '1. Root', '1.1', '1.1.2', '1.2', '1.2.1', '1.2.2', - ); + ]; $this->assertEquals($expected, array_values($nodes)); $validTree = $this->Tree->verify(); @@ -223,21 +223,21 @@ public function testChildren() { $this->Tree->order = null; $this->Tree->initialize(2, 2); - $data = $this->Tree->find('first', array('conditions' => array($modelClass . '.name' => '1. Root'))); + $data = $this->Tree->find('first', ['conditions' => [$modelClass . '.name' => '1. Root']]); $this->Tree->id = $data[$modelClass]['id']; - $direct = $this->Tree->children(null, true, array('name', $leftField, $rightField)); - $expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 7)), - array($modelClass => array('name' => '1.2', $leftField => 8, $rightField => 13))); + $direct = $this->Tree->children(null, true, ['name', $leftField, $rightField]); + $expected = [[$modelClass => ['name' => '1.1', $leftField => 2, $rightField => 7]], + [$modelClass => ['name' => '1.2', $leftField => 8, $rightField => 13]]]; $this->assertEquals($expected, $direct); - $total = $this->Tree->children(null, null, array('name', $leftField, $rightField)); - $expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 7)), - array($modelClass => array('name' => '1.1.1', $leftField => 3, $rightField => 4)), - array($modelClass => array('name' => '1.1.2', $leftField => 5, $rightField => 6)), - array($modelClass => array('name' => '1.2', $leftField => 8, $rightField => 13)), - array($modelClass => array('name' => '1.2.1', $leftField => 9, $rightField => 10)), - array($modelClass => array('name' => '1.2.2', $leftField => 11, $rightField => 12))); + $total = $this->Tree->children(null, null, ['name', $leftField, $rightField]); + $expected = [[$modelClass => ['name' => '1.1', $leftField => 2, $rightField => 7]], + [$modelClass => ['name' => '1.1.1', $leftField => 3, $rightField => 4]], + [$modelClass => ['name' => '1.1.2', $leftField => 5, $rightField => 6]], + [$modelClass => ['name' => '1.2', $leftField => 8, $rightField => 13]], + [$modelClass => ['name' => '1.2.1', $leftField => 9, $rightField => 10]], + [$modelClass => ['name' => '1.2.2', $leftField => 11, $rightField => 12]]]; $this->assertEquals($expected, $total); } @@ -252,29 +252,29 @@ public function testNoAmbiguousColumn() { $this->Tree->order = null; $this->Tree->initialize(2, 2); - $this->Tree->bindModel(array('belongsTo' => array('Dummy' => - array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); + $this->Tree->bindModel(['belongsTo' => ['Dummy' => + ['className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => ['Dummy.id' => null]]]], false); - $data = $this->Tree->find('first', array( - 'conditions' => array($modelClass . '.name' => '1. Root'), + $data = $this->Tree->find('first', [ + 'conditions' => [$modelClass . '.name' => '1. Root'], 'recursive' => -1 - )); + ]); $this->Tree->id = $data[$modelClass]['id']; - $direct = $this->Tree->children(null, true, array('name', $leftField, $rightField)); - $expected = array(array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 7)), - array($modelClass => array('name' => '1.2', $leftField => 8, $rightField => 13))); + $direct = $this->Tree->children(null, true, ['name', $leftField, $rightField]); + $expected = [[$modelClass => ['name' => '1.1', $leftField => 2, $rightField => 7]], + [$modelClass => ['name' => '1.2', $leftField => 8, $rightField => 13]]]; $this->assertEquals($expected, $direct); - $total = $this->Tree->children(null, null, array('name', $leftField, $rightField)); - $expected = array( - array($modelClass => array('name' => '1.1', $leftField => 2, $rightField => 7)), - array($modelClass => array('name' => '1.1.1', $leftField => 3, $rightField => 4)), - array($modelClass => array('name' => '1.1.2', $leftField => 5, $rightField => 6)), - array($modelClass => array('name' => '1.2', $leftField => 8, $rightField => 13)), - array($modelClass => array('name' => '1.2.1', $leftField => 9, $rightField => 10)), - array($modelClass => array('name' => '1.2.2', $leftField => 11, $rightField => 12)) - ); + $total = $this->Tree->children(null, null, ['name', $leftField, $rightField]); + $expected = [ + [$modelClass => ['name' => '1.1', $leftField => 2, $rightField => 7]], + [$modelClass => ['name' => '1.1.1', $leftField => 3, $rightField => 4]], + [$modelClass => ['name' => '1.1.2', $leftField => 5, $rightField => 6]], + [$modelClass => ['name' => '1.2', $leftField => 8, $rightField => 13]], + [$modelClass => ['name' => '1.2.1', $leftField => 9, $rightField => 10]], + [$modelClass => ['name' => '1.2.2', $leftField => 11, $rightField => 12]] + ]; $this->assertEquals($expected, $total); } @@ -287,12 +287,12 @@ public function testGenerateTreeListWithSelfJoin() { extract($this->settings); $this->Tree = new $modelClass(); $this->Tree->order = null; - $this->Tree->bindModel(array('belongsTo' => array('Dummy' => - array('className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => array('Dummy.id' => null)))), false); + $this->Tree->bindModel(['belongsTo' => ['Dummy' => + ['className' => $modelClass, 'foreignKey' => $parentField, 'conditions' => ['Dummy.id' => null]]]], false); $this->Tree->initialize(2, 2); $result = $this->Tree->generateTreeList(); - $expected = array('1. Root', '_1.1', '__1.1.1', '__1.1.2', '_1.2', '__1.2.1', '__1.2.2'); + $expected = ['1. Root', '_1.1', '__1.1.1', '__1.1.2', '_1.2', '__1.2.1', '__1.2.2']; $this->assertSame($expected, array_values($result)); } } diff --git a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php index a4ada23e53..d04382d35e 100644 --- a/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php +++ b/lib/Cake/Test/Case/Model/BehaviorCollectionTest.php @@ -20,7 +20,7 @@ App::uses('AppModel', 'Model'); -require_once dirname(__FILE__) . DS . 'models.php'; +require_once __DIR__ . DS . 'models.php'; /** * TestBehavior class @@ -34,7 +34,7 @@ class TestBehavior extends ModelBehavior { * * @var array */ - public $mapMethods = array('/test(\w+)/' => 'testMethod', '/look for\s+(.+)/' => 'speakEnglish'); + public $mapMethods = ['/test(\w+)/' => 'testMethod', '/look for\s+(.+)/' => 'speakEnglish']; /** * setup method @@ -43,12 +43,12 @@ class TestBehavior extends ModelBehavior { * @param array $config * @return void */ - public function setup(Model $model, $config = array()) { + public function setup(Model $model, $config = []) { parent::setup($model, $config); if (isset($config['mangle'])) { $config['mangle'] .= ' mangled'; } - $this->settings[$model->alias] = array_merge(array('beforeFind' => 'on', 'afterFind' => 'off'), $config); + $this->settings[$model->alias] = array_merge(['beforeFind' => 'on', 'afterFind' => 'off'], $config); } /** @@ -69,7 +69,7 @@ public function beforeFind(Model $model, $query) { case 'test': return null; case 'modify': - $query['fields'] = array($model->alias . '.id', $model->alias . '.name', $model->alias . '.mytime'); + $query['fields'] = [$model->alias . '.id', $model->alias . '.name', $model->alias . '.mytime']; $query['recursive'] = -1; return $query; } @@ -90,7 +90,7 @@ public function afterFind(Model $model, $results, $primary = false) { } switch ($settings['afterFind']) { case 'on': - return array(); + return []; case 'test': return true; case 'test2': @@ -108,7 +108,7 @@ public function afterFind(Model $model, $results, $primary = false) { * @return mixed False if the operation should abort. Any other result will continue. * @see Model::save() */ - public function beforeSave(Model $model, $options = array()) { + public function beforeSave(Model $model, $options = []) { $settings = $this->settings[$model->alias]; if (!isset($settings['beforeSave']) || $settings['beforeSave'] === 'off') { return parent::beforeSave($model, $options); @@ -132,7 +132,7 @@ public function beforeSave(Model $model, $options = array()) { * @param array $options Options passed from Model::save(). * @return void */ - public function afterSave(Model $model, $created, $options = array()) { + public function afterSave(Model $model, $created, $options = []) { $settings = $this->settings[$model->alias]; if (!isset($settings['afterSave']) || $settings['afterSave'] === 'off') { return parent::afterSave($model, $created, $options); @@ -164,7 +164,7 @@ public function afterSave(Model $model, $created, $options = array()) { * @return bool * @see Model::save() */ - public function beforeValidate(Model $model, $options = array()) { + public function beforeValidate(Model $model, $options = []) { $settings = $this->settings[$model->alias]; if (!isset($settings['validate']) || $settings['validate'] === 'off') { return parent::beforeValidate($model, $options); @@ -176,7 +176,7 @@ public function beforeValidate(Model $model, $options = array()) { case 'test': return null; case 'whitelist': - $this->_addToWhitelist($model, array('name')); + $this->_addToWhitelist($model, ['name']); return true; case 'stop': $model->invalidate('name'); @@ -200,7 +200,7 @@ public function afterValidate(Model $model) { case 'on': return false; case 'test': - $model->data = array('foo'); + $model->data = ['foo']; return true; } } @@ -271,10 +271,10 @@ public function onError(Model $model, $error) { */ public function beforeTest(Model $model) { if (!isset($model->beforeTestResult)) { - $model->beforeTestResult = array(); + $model->beforeTestResult = []; } - $model->beforeTestResult[] = strtolower(get_class($this)); - return strtolower(get_class($this)); + $model->beforeTestResult[] = strtolower(static::class); + return strtolower(static::class); } /** @@ -338,7 +338,7 @@ public function speakEnglish(Model $model, $method, $query) { */ class Test2Behavior extends TestBehavior { - public $mapMethods = array('/mappingRobot(\w+)/' => 'mapped'); + public $mapMethods = ['/mappingRobot(\w+)/' => 'mapped']; public function resolveMethod(Model $model, $stuff) { } @@ -365,7 +365,7 @@ class Test4Behavior extends ModelBehavior { public function setup(Model $model, $config = null) { $model->bindModel( - array('hasMany' => array('Comment')) + ['hasMany' => ['Comment']] ); } @@ -380,7 +380,7 @@ class Test5Behavior extends ModelBehavior { public function setup(Model $model, $config = null) { $model->bindModel( - array('belongsTo' => array('User')) + ['belongsTo' => ['User']] ); } @@ -395,7 +395,7 @@ class Test6Behavior extends ModelBehavior { public function setup(Model $model, $config = null) { $model->bindModel( - array('hasAndBelongsToMany' => array('Tag')) + ['hasAndBelongsToMany' => ['Tag']] ); } @@ -410,7 +410,7 @@ class Test7Behavior extends ModelBehavior { public function setup(Model $model, $config = null) { $model->bindModel( - array('hasOne' => array('Attachment')) + ['hasOne' => ['Attachment']] ); } @@ -427,8 +427,8 @@ class TestAliasBehavior extends TestBehavior { */ class FirstBehavior extends ModelBehavior { - public function beforeFind(Model $model, $query = array()) { - $model->called[] = get_class($this); + public function beforeFind(Model $model, $query = []) { + $model->called[] = static::class; return $query; } @@ -451,7 +451,7 @@ class ThirdBehavior extends FirstBehavior { */ class Orangutan extends Monkey { - public $called = array(); + public $called = []; } @@ -467,11 +467,11 @@ class BehaviorCollectionTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.apple', 'core.sample', 'core.article', 'core.user', 'core.comment', 'core.attachment', 'core.tag', 'core.articles_tag', 'core.translate', 'core.device' - ); + ]; /** * Test load() with enabled => false @@ -480,9 +480,9 @@ class BehaviorCollectionTest extends CakeTestCase { */ public function testLoadDisabled() { $Apple = new Apple(); - $this->assertSame(array(), $Apple->Behaviors->loaded()); + $this->assertSame([], $Apple->Behaviors->loaded()); - $Apple->Behaviors->load('Translate', array('enabled' => false)); + $Apple->Behaviors->load('Translate', ['enabled' => false]); $this->assertTrue($Apple->Behaviors->loaded('Translate')); $this->assertFalse($Apple->Behaviors->enabled('Translate')); } @@ -494,10 +494,10 @@ public function testLoadDisabled() { */ public function testLoadAlias() { $Apple = new Apple(); - $this->assertSame(array(), $Apple->Behaviors->loaded()); + $this->assertSame([], $Apple->Behaviors->loaded()); - $Apple->Behaviors->load('Test', array('className' => 'TestAlias', 'somesetting' => true)); - $this->assertSame(array('Test'), $Apple->Behaviors->loaded()); + $Apple->Behaviors->load('Test', ['className' => 'TestAlias', 'somesetting' => true]); + $this->assertSame(['Test'], $Apple->Behaviors->loaded()); $this->assertInstanceOf('TestAliasBehavior', $Apple->Behaviors->Test); $this->assertTrue($Apple->Behaviors->Test->settings['Apple']['somesetting']); @@ -505,13 +505,13 @@ public function testLoadAlias() { $this->assertEquals('working', $Apple->testMethod(true)); $this->assertEquals('working', $Apple->Behaviors->dispatchMethod($Apple, 'testMethod')); - App::build(array('Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS))); + App::build(['Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS]]); CakePlugin::load('TestPlugin'); - $this->assertTrue($Apple->Behaviors->load('SomeOther', array('className' => 'TestPlugin.TestPluginPersisterOne'))); + $this->assertTrue($Apple->Behaviors->load('SomeOther', ['className' => 'TestPlugin.TestPluginPersisterOne'])); $this->assertInstanceOf('TestPluginPersisterOneBehavior', $Apple->Behaviors->SomeOther); $result = $Apple->Behaviors->loaded(); - $this->assertEquals(array('Test', 'SomeOther'), $result, 'loaded() results are wrong.'); + $this->assertEquals(['Test', 'SomeOther'], $result, 'loaded() results are wrong.'); App::build(); CakePlugin::unload(); } @@ -523,61 +523,61 @@ public function testLoadAlias() { */ public function testBehaviorBinding() { $Apple = new Apple(); - $this->assertSame(array(), $Apple->Behaviors->loaded()); + $this->assertSame([], $Apple->Behaviors->loaded()); - $Apple->Behaviors->load('Test', array('key' => 'value')); - $this->assertSame(array('Test'), $Apple->Behaviors->loaded()); - $this->assertEquals('testbehavior', strtolower(get_class($Apple->Behaviors->Test))); - $expected = array('beforeFind' => 'on', 'afterFind' => 'off', 'key' => 'value'); + $Apple->Behaviors->load('Test', ['key' => 'value']); + $this->assertSame(['Test'], $Apple->Behaviors->loaded()); + $this->assertEquals('testbehavior', strtolower($Apple->Behaviors->Test::class)); + $expected = ['beforeFind' => 'on', 'afterFind' => 'off', 'key' => 'value']; $this->assertEquals($expected, $Apple->Behaviors->Test->settings['Apple']); - $this->assertEquals(array('priority', 'Apple'), array_keys($Apple->Behaviors->Test->settings)); + $this->assertEquals(['priority', 'Apple'], array_keys($Apple->Behaviors->Test->settings)); - $this->assertSame($Apple->Sample->Behaviors->loaded(), array()); - $Apple->Sample->Behaviors->load('Test', array('key2' => 'value2')); - $this->assertSame($Apple->Sample->Behaviors->loaded(), array('Test')); - $this->assertEquals(array('beforeFind' => 'on', 'afterFind' => 'off', 'key2' => 'value2'), $Apple->Sample->Behaviors->Test->settings['Sample']); + $this->assertSame($Apple->Sample->Behaviors->loaded(), []); + $Apple->Sample->Behaviors->load('Test', ['key2' => 'value2']); + $this->assertSame($Apple->Sample->Behaviors->loaded(), ['Test']); + $this->assertEquals(['beforeFind' => 'on', 'afterFind' => 'off', 'key2' => 'value2'], $Apple->Sample->Behaviors->Test->settings['Sample']); - $this->assertEquals(array('priority', 'Apple', 'Sample'), array_keys($Apple->Behaviors->Test->settings)); + $this->assertEquals(['priority', 'Apple', 'Sample'], array_keys($Apple->Behaviors->Test->settings)); $this->assertSame( $Apple->Sample->Behaviors->Test->settings, $Apple->Behaviors->Test->settings ); $this->assertNotSame($Apple->Behaviors->Test->settings['Apple'], $Apple->Sample->Behaviors->Test->settings['Sample']); - $Apple->Behaviors->load('Test', array('key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); - $Apple->Sample->Behaviors->load('Test', array('key' => 'value', 'key3' => 'value3', 'beforeFind' => 'off')); - $this->assertEquals(array('beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'value', 'key2' => 'value2', 'key3' => 'value3'), $Apple->Behaviors->Test->settings['Apple']); + $Apple->Behaviors->load('Test', ['key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off']); + $Apple->Sample->Behaviors->load('Test', ['key' => 'value', 'key3' => 'value3', 'beforeFind' => 'off']); + $this->assertEquals(['beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'value', 'key2' => 'value2', 'key3' => 'value3'], $Apple->Behaviors->Test->settings['Apple']); $this->assertEquals($Apple->Behaviors->Test->settings['Apple'], $Apple->Sample->Behaviors->Test->settings['Sample']); $this->assertFalse(isset($Apple->Child->Behaviors->Test)); - $Apple->Child->Behaviors->load('Test', array('key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); + $Apple->Child->Behaviors->load('Test', ['key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off']); $this->assertEquals($Apple->Child->Behaviors->Test->settings['Child'], $Apple->Sample->Behaviors->Test->settings['Sample']); $this->assertFalse(isset($Apple->Parent->Behaviors->Test)); - $Apple->Parent->Behaviors->load('Test', array('key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off')); + $Apple->Parent->Behaviors->load('Test', ['key' => 'value', 'key2' => 'value2', 'key3' => 'value3', 'beforeFind' => 'off']); $this->assertEquals($Apple->Parent->Behaviors->Test->settings['Parent'], $Apple->Sample->Behaviors->Test->settings['Sample']); - $Apple->Parent->Behaviors->load('Test', array('key' => 'value', 'key2' => 'value', 'key3' => 'value', 'beforeFind' => 'off')); + $Apple->Parent->Behaviors->load('Test', ['key' => 'value', 'key2' => 'value', 'key3' => 'value', 'beforeFind' => 'off']); $this->assertNotEquals($Apple->Parent->Behaviors->Test->settings['Parent'], $Apple->Sample->Behaviors->Test->settings['Sample']); - $Apple->Behaviors->load('Plugin.Test', array('key' => 'new value')); - $expected = array( + $Apple->Behaviors->load('Plugin.Test', ['key' => 'new value']); + $expected = [ 'beforeFind' => 'off', 'afterFind' => 'off', 'key' => 'new value', 'key2' => 'value2', 'key3' => 'value3' - ); + ]; $this->assertEquals($expected, $Apple->Behaviors->Test->settings['Apple']); $current = $Apple->Behaviors->Test->settings['Apple']; - $expected = array_merge($current, array('mangle' => 'trigger mangled')); - $Apple->Behaviors->load('Test', array('mangle' => 'trigger')); + $expected = array_merge($current, ['mangle' => 'trigger mangled']); + $Apple->Behaviors->load('Test', ['mangle' => 'trigger']); $this->assertEquals($expected, $Apple->Behaviors->Test->settings['Apple']); $Apple->Behaviors->load('Test'); - $expected = array_merge($current, array('mangle' => 'trigger mangled mangled')); + $expected = array_merge($current, ['mangle' => 'trigger mangled mangled']); $this->assertEquals($expected, $Apple->Behaviors->Test->settings['Apple']); - $Apple->Behaviors->load('Test', array('mangle' => 'trigger')); - $expected = array_merge($current, array('mangle' => 'trigger mangled')); + $Apple->Behaviors->load('Test', ['mangle' => 'trigger']); + $expected = array_merge($current, ['mangle' => 'trigger mangled']); $this->assertEquals($expected, $Apple->Behaviors->Test->settings['Apple']); } @@ -590,17 +590,17 @@ public function testDetachWithPluginNames() { $Apple = new Apple(); $Apple->Behaviors->load('Plugin.Test'); $this->assertTrue(isset($Apple->Behaviors->Test), 'Missing behavior'); - $this->assertEquals(array('Test'), $Apple->Behaviors->loaded()); + $this->assertEquals(['Test'], $Apple->Behaviors->loaded()); $Apple->Behaviors->unload('Plugin.Test'); - $this->assertEquals(array(), $Apple->Behaviors->loaded()); + $this->assertEquals([], $Apple->Behaviors->loaded()); $Apple->Behaviors->load('Plugin.Test'); $this->assertTrue(isset($Apple->Behaviors->Test), 'Missing behavior'); - $this->assertEquals(array('Test'), $Apple->Behaviors->loaded()); + $this->assertEquals(['Test'], $Apple->Behaviors->loaded()); $Apple->Behaviors->unload('Test'); - $this->assertEquals(array(), $Apple->Behaviors->loaded()); + $this->assertEquals([], $Apple->Behaviors->loaded()); } /** @@ -621,31 +621,31 @@ public function testInvalidBehaviorCausingCakeError() { */ public function testBehaviorToggling() { $Apple = new Apple(); - $this->assertSame($Apple->Behaviors->enabled(), array()); + $this->assertSame($Apple->Behaviors->enabled(), []); - $Apple->Behaviors->init('Apple', array('Test' => array('key' => 'value'))); - $this->assertSame($Apple->Behaviors->enabled(), array('Test')); + $Apple->Behaviors->init('Apple', ['Test' => ['key' => 'value']]); + $this->assertSame($Apple->Behaviors->enabled(), ['Test']); $Apple->Behaviors->disable('Test'); - $this->assertSame(array('Test'), $Apple->Behaviors->loaded()); - $this->assertSame($Apple->Behaviors->enabled(), array()); + $this->assertSame(['Test'], $Apple->Behaviors->loaded()); + $this->assertSame($Apple->Behaviors->enabled(), []); $Apple->Sample->Behaviors->load('Test'); $this->assertTrue($Apple->Sample->Behaviors->enabled('Test')); - $this->assertSame($Apple->Behaviors->enabled(), array()); + $this->assertSame($Apple->Behaviors->enabled(), []); $Apple->Behaviors->enable('Test'); $this->assertTrue($Apple->Behaviors->loaded('Test')); - $this->assertSame($Apple->Behaviors->enabled(), array('Test')); + $this->assertSame($Apple->Behaviors->enabled(), ['Test']); $Apple->Behaviors->disable('Test'); - $this->assertSame($Apple->Behaviors->enabled(), array()); - $Apple->Behaviors->load('Test', array('enabled' => true)); - $this->assertSame($Apple->Behaviors->enabled(), array('Test')); - $Apple->Behaviors->load('Test', array('enabled' => false)); - $this->assertSame($Apple->Behaviors->enabled(), array()); + $this->assertSame($Apple->Behaviors->enabled(), []); + $Apple->Behaviors->load('Test', ['enabled' => true]); + $this->assertSame($Apple->Behaviors->enabled(), ['Test']); + $Apple->Behaviors->load('Test', ['enabled' => false]); + $this->assertSame($Apple->Behaviors->enabled(), []); $Apple->Behaviors->unload('Test'); - $this->assertSame($Apple->Behaviors->enabled(), array()); + $this->assertSame($Apple->Behaviors->enabled(), []); } /** @@ -662,47 +662,47 @@ public function testBehaviorFindCallbacks() { $Apple->Behaviors->load('Test'); $this->assertNull($Apple->find('all')); - $Apple->Behaviors->load('Test', array('beforeFind' => 'off')); + $Apple->Behaviors->load('Test', ['beforeFind' => 'off']); $this->assertSame($expected, $Apple->find('all')); - $Apple->Behaviors->load('Test', array('beforeFind' => 'test')); + $Apple->Behaviors->load('Test', ['beforeFind' => 'test']); $this->assertSame($expected, $Apple->find('all')); - $Apple->Behaviors->load('Test', array('beforeFind' => 'modify')); - $expected2 = array( - array('Apple' => array('id' => '1', 'name' => 'Red Apple 1', 'mytime' => '22:57:17')), - array('Apple' => array('id' => '2', 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')), - array('Apple' => array('id' => '3', 'name' => 'green blue', 'mytime' => '22:57:17')) - ); - $result = $Apple->find('all', array('conditions' => array('Apple.id <' => '4'))); + $Apple->Behaviors->load('Test', ['beforeFind' => 'modify']); + $expected2 = [ + ['Apple' => ['id' => '1', 'name' => 'Red Apple 1', 'mytime' => '22:57:17']], + ['Apple' => ['id' => '2', 'name' => 'Bright Red Apple', 'mytime' => '22:57:17']], + ['Apple' => ['id' => '3', 'name' => 'green blue', 'mytime' => '22:57:17']] + ]; + $result = $Apple->find('all', ['conditions' => ['Apple.id <' => '4']]); $this->assertEquals($expected2, $result); $Apple->Behaviors->disable('Test'); $result = $Apple->find('all'); $this->assertEquals($expected, $result); - $Apple->Behaviors->load('Test', array('beforeFind' => 'off', 'afterFind' => 'on')); - $this->assertSame($Apple->find('all'), array()); + $Apple->Behaviors->load('Test', ['beforeFind' => 'off', 'afterFind' => 'on']); + $this->assertSame($Apple->find('all'), []); - $Apple->Behaviors->load('Test', array('afterFind' => 'off')); + $Apple->Behaviors->load('Test', ['afterFind' => 'off']); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Behaviors->load('Test', array('afterFind' => 'test')); + $Apple->Behaviors->load('Test', ['afterFind' => 'test']); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Behaviors->load('Test', array('afterFind' => 'test2')); + $Apple->Behaviors->load('Test', ['afterFind' => 'test2']); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Behaviors->load('Test', array('afterFind' => 'modify')); - $expected = array( - array('id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'), - array('id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'), - array('id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'), - array('id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'), - array('id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'), - array('id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'), - array('id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17') - ); + $Apple->Behaviors->load('Test', ['afterFind' => 'modify']); + $expected = [ + ['id' => '1', 'apple_id' => '2', 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'], + ['id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', 'name' => 'Bright Red Apple', 'created' => '2006-11-22 10:43:13', 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17'], + ['id' => '3', 'apple_id' => '2', 'color' => 'blue green', 'name' => 'green blue', 'created' => '2006-12-25 05:13:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17'], + ['id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', 'name' => 'Test Name', 'created' => '2006-12-25 05:23:36', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17'], + ['id' => '5', 'apple_id' => '5', 'color' => 'Green', 'name' => 'Blue Green', 'created' => '2006-12-25 05:24:06', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17'], + ['id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', 'name' => 'My new apple', 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17'], + ['id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', 'name' => 'Some odd color', 'created' => '2006-12-25 05:34:21', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17'] + ]; $this->assertEquals($expected, $Apple->find('all')); } @@ -713,37 +713,37 @@ public function testBehaviorFindCallbacks() { */ public function testBehaviorHasManyFindCallbacks() { $Apple = new Apple(); - $Apple->unbindModel(array('hasOne' => array('Sample'), 'belongsTo' => array('Parent')), false); + $Apple->unbindModel(['hasOne' => ['Sample'], 'belongsTo' => ['Parent']], false); $expected = $Apple->find('all'); - $Apple->unbindModel(array('hasMany' => array('Child'))); + $Apple->unbindModel(['hasMany' => ['Child']]); $wellBehaved = $Apple->find('all'); - $Apple->Child->Behaviors->load('Test', array('afterFind' => 'modify')); - $Apple->unbindModel(array('hasMany' => array('Child'))); + $Apple->Child->Behaviors->load('Test', ['afterFind' => 'modify']); + $Apple->unbindModel(['hasMany' => ['Child']]); $this->assertSame($Apple->find('all'), $wellBehaved); - $Apple->Child->Behaviors->load('Test', array('before' => 'off')); + $Apple->Child->Behaviors->load('Test', ['before' => 'off']); $this->assertSame($expected, $Apple->find('all')); - $Apple->Child->Behaviors->load('Test', array('before' => 'test')); + $Apple->Child->Behaviors->load('Test', ['before' => 'test']); $this->assertSame($expected, $Apple->find('all')); - $Apple->Child->Behaviors->load('Test', array('before' => 'modify')); - $result = $Apple->find('all', array('fields' => array('Apple.id'), 'conditions' => array('Apple.id <' => '4'))); + $Apple->Child->Behaviors->load('Test', ['before' => 'modify']); + $result = $Apple->find('all', ['fields' => ['Apple.id'], 'conditions' => ['Apple.id <' => '4']]); $Apple->Child->Behaviors->disable('Test'); $result = $Apple->find('all'); $this->assertEquals($expected, $result); - $Apple->Child->Behaviors->load('Test', array('before' => 'off', 'after' => 'on')); + $Apple->Child->Behaviors->load('Test', ['before' => 'off', 'after' => 'on']); - $Apple->Child->Behaviors->load('Test', array('after' => 'off')); + $Apple->Child->Behaviors->load('Test', ['after' => 'off']); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Child->Behaviors->load('Test', array('after' => 'test')); + $Apple->Child->Behaviors->load('Test', ['after' => 'test']); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Child->Behaviors->load('Test', array('after' => 'test2')); + $Apple->Child->Behaviors->load('Test', ['after' => 'test2']); $this->assertEquals($expected, $Apple->find('all')); } @@ -754,32 +754,32 @@ public function testBehaviorHasManyFindCallbacks() { */ public function testBehaviorHasOneFindCallbacks() { $Apple = new Apple(); - $Apple->unbindModel(array('hasMany' => array('Child'), 'belongsTo' => array('Parent')), false); + $Apple->unbindModel(['hasMany' => ['Child'], 'belongsTo' => ['Parent']], false); $expected = $Apple->find('all'); - $Apple->unbindModel(array('hasOne' => array('Sample'))); + $Apple->unbindModel(['hasOne' => ['Sample']]); $wellBehaved = $Apple->find('all'); $Apple->Sample->Behaviors->load('Test'); - $Apple->unbindModel(array('hasOne' => array('Sample'))); + $Apple->unbindModel(['hasOne' => ['Sample']]); $this->assertSame($Apple->find('all'), $wellBehaved); - $Apple->Sample->Behaviors->load('Test', array('before' => 'off')); + $Apple->Sample->Behaviors->load('Test', ['before' => 'off']); $this->assertSame($expected, $Apple->find('all')); - $Apple->Sample->Behaviors->load('Test', array('before' => 'test')); + $Apple->Sample->Behaviors->load('Test', ['before' => 'test']); $this->assertSame($expected, $Apple->find('all')); $Apple->Sample->Behaviors->disable('Test'); $result = $Apple->find('all'); $this->assertEquals($expected, $result); - $Apple->Sample->Behaviors->load('Test', array('after' => 'off')); + $Apple->Sample->Behaviors->load('Test', ['after' => 'off']); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Sample->Behaviors->load('Test', array('after' => 'test')); + $Apple->Sample->Behaviors->load('Test', ['after' => 'test']); $this->assertEquals($expected, $Apple->find('all')); - $Apple->Sample->Behaviors->load('Test', array('after' => 'test2')); + $Apple->Sample->Behaviors->load('Test', ['after' => 'test2']); $this->assertEquals($expected, $Apple->find('all')); } @@ -791,53 +791,53 @@ public function testBehaviorHasOneFindCallbacks() { public function testBehaviorBelongsToFindCallbacks() { $this->skipIf($this->db instanceof Sqlserver, 'This test is not compatible with SQL Server.'); - $conditions = array('order' => 'Apple.id ASC'); + $conditions = ['order' => 'Apple.id ASC']; $Apple = new Apple(); - $Apple->unbindModel(array('hasMany' => array('Child'), 'hasOne' => array('Sample')), false); + $Apple->unbindModel(['hasMany' => ['Child'], 'hasOne' => ['Sample']], false); $expected = $Apple->find('all', $conditions); - $Apple->unbindModel(array('belongsTo' => array('Parent'))); + $Apple->unbindModel(['belongsTo' => ['Parent']]); $wellBehaved = $Apple->find('all', $conditions); $Apple->Parent->Behaviors->load('Test'); - $Apple->unbindModel(array('belongsTo' => array('Parent'))); + $Apple->unbindModel(['belongsTo' => ['Parent']]); $this->assertSame($Apple->find('all', $conditions), $wellBehaved); - $Apple->Parent->Behaviors->load('Test', array('before' => 'off')); + $Apple->Parent->Behaviors->load('Test', ['before' => 'off']); $this->assertSame($expected, $Apple->find('all', $conditions)); - $Apple->Parent->Behaviors->load('Test', array('before' => 'test')); + $Apple->Parent->Behaviors->load('Test', ['before' => 'test']); $this->assertSame($expected, $Apple->find('all', $conditions)); - $Apple->Parent->Behaviors->load('Test', array('before' => 'modify')); - $expected2 = array( - array( - 'Apple' => array('id' => 1), - 'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')), - array( - 'Apple' => array('id' => 2), - 'Parent' => array('id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17')), - array( - 'Apple' => array('id' => 3), - 'Parent' => array('id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17')) - ); - $result2 = $Apple->find('all', array( - 'fields' => array('Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'), - 'conditions' => array('Apple.id <' => '4'), + $Apple->Parent->Behaviors->load('Test', ['before' => 'modify']); + $expected2 = [ + [ + 'Apple' => ['id' => 1], + 'Parent' => ['id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17']], + [ + 'Apple' => ['id' => 2], + 'Parent' => ['id' => 1, 'name' => 'Red Apple 1', 'mytime' => '22:57:17']], + [ + 'Apple' => ['id' => 3], + 'Parent' => ['id' => 2, 'name' => 'Bright Red Apple', 'mytime' => '22:57:17']] + ]; + $result2 = $Apple->find('all', [ + 'fields' => ['Apple.id', 'Parent.id', 'Parent.name', 'Parent.mytime'], + 'conditions' => ['Apple.id <' => '4'], 'order' => 'Apple.id ASC', - )); + ]); $this->assertEquals($expected2, $result2); $Apple->Parent->Behaviors->disable('Test'); $result = $Apple->find('all', $conditions); $this->assertEquals($expected, $result); - $Apple->Parent->Behaviors->load('Test', array('after' => 'off')); + $Apple->Parent->Behaviors->load('Test', ['after' => 'off']); $this->assertEquals($expected, $Apple->find('all', $conditions)); - $Apple->Parent->Behaviors->load('Test', array('after' => 'test')); + $Apple->Parent->Behaviors->load('Test', ['after' => 'test']); $this->assertEquals($expected, $Apple->find('all', $conditions)); - $Apple->Parent->Behaviors->load('Test', array('after' => 'test2')); + $Apple->Parent->Behaviors->load('Test', ['after' => 'test2']); $this->assertEquals($expected, $Apple->find('all', $conditions)); } @@ -848,27 +848,27 @@ public function testBehaviorBelongsToFindCallbacks() { */ public function testBehaviorSaveCallbacks() { $Sample = new Sample(); - $record = array('Sample' => array('apple_id' => 6, 'name' => 'sample99')); + $record = ['Sample' => ['apple_id' => 6, 'name' => 'sample99']]; - $Sample->Behaviors->load('Test', array('beforeSave' => 'on')); + $Sample->Behaviors->load('Test', ['beforeSave' => 'on']); $Sample->create(); $this->assertSame(false, $Sample->save($record)); - $Sample->Behaviors->load('Test', array('beforeSave' => 'off')); + $Sample->Behaviors->load('Test', ['beforeSave' => 'off']); $Sample->create(); $result = $Sample->save($record); $expected = $record; $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->load('Test', array('beforeSave' => 'test')); + $Sample->Behaviors->load('Test', ['beforeSave' => 'test']); $Sample->create(); $result = $Sample->save($record); $expected = $record; $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->load('Test', array('beforeSave' => 'modify')); + $Sample->Behaviors->load('Test', ['beforeSave' => 'modify']); $expected = Hash::insert($record, 'Sample.name', 'sample99 modified before'); $Sample->create(); $result = $Sample->save($record); @@ -878,21 +878,21 @@ public function testBehaviorSaveCallbacks() { $Sample->Behaviors->disable('Test'); $this->assertSame($record, $Sample->save($record)); - $Sample->Behaviors->load('Test', array('beforeSave' => 'off', 'afterSave' => 'on')); - $expected = Hash::merge($record, array('Sample' => array('aftersave' => 'modified after on create'))); + $Sample->Behaviors->load('Test', ['beforeSave' => 'off', 'afterSave' => 'on']); + $expected = Hash::merge($record, ['Sample' => ['aftersave' => 'modified after on create']]); $Sample->create(); $result = $Sample->save($record); $expected['Sample']['id'] = $Sample->id; $this->assertEquals($expected, $result); - $Sample->Behaviors->load('Test', array('beforeSave' => 'modify', 'afterSave' => 'modify')); - $expected = Hash::merge($record, array('Sample' => array('name' => 'sample99 modified before modified after on create'))); + $Sample->Behaviors->load('Test', ['beforeSave' => 'modify', 'afterSave' => 'modify']); + $expected = Hash::merge($record, ['Sample' => ['name' => 'sample99 modified before modified after on create']]); $Sample->create(); $result = $Sample->save($record); $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->load('Test', array('beforeSave' => 'off', 'afterSave' => 'test')); + $Sample->Behaviors->load('Test', ['beforeSave' => 'off', 'afterSave' => 'test']); $Sample->create(); $expected = $record; unset($expected['Sample']['name']); @@ -900,24 +900,24 @@ public function testBehaviorSaveCallbacks() { $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->load('Test', array('afterSave' => 'test2')); + $Sample->Behaviors->load('Test', ['afterSave' => 'test2']); $Sample->create(); $expected = $record; $result = $Sample->save($record); $expected['Sample']['id'] = $Sample->id; $this->assertSame($expected, $result); - $Sample->Behaviors->load('Test', array('beforeFind' => 'off', 'afterFind' => 'off')); + $Sample->Behaviors->load('Test', ['beforeFind' => 'off', 'afterFind' => 'off']); $Sample->recursive = -1; $record2 = $Sample->read(null, 1); - $Sample->Behaviors->load('Test', array('afterSave' => 'on')); - $expected = Hash::merge($record2, array('Sample' => array('aftersave' => 'modified after'))); + $Sample->Behaviors->load('Test', ['afterSave' => 'on']); + $expected = Hash::merge($record2, ['Sample' => ['aftersave' => 'modified after']]); $Sample->create(); $this->assertSame($expected, $Sample->save($record2)); - $Sample->Behaviors->load('Test', array('afterSave' => 'modify')); - $expected = Hash::merge($record2, array('Sample' => array('name' => 'sample1 modified after'))); + $Sample->Behaviors->load('Test', ['afterSave' => 'modify']); + $expected = Hash::merge($record2, ['Sample' => ['name' => 'sample1 modified after']]); $Sample->create(); $this->assertSame($expected, $Sample->save($record2)); } @@ -930,13 +930,13 @@ public function testBehaviorSaveCallbacks() { public function testBehaviorDeleteCallbacks() { $Apple = new Apple(); - $Apple->Behaviors->load('Test', array('beforeFind' => 'off', 'beforeDelete' => 'off')); + $Apple->Behaviors->load('Test', ['beforeFind' => 'off', 'beforeDelete' => 'off']); $this->assertTrue($Apple->delete(6)); - $Apple->Behaviors->load('Test', array('beforeDelete' => 'on')); + $Apple->Behaviors->load('Test', ['beforeDelete' => 'on']); $this->assertFalse($Apple->delete(4)); - $Apple->Behaviors->load('Test', array('beforeDelete' => 'test2')); + $Apple->Behaviors->load('Test', ['beforeDelete' => 'test2']); ob_start(); $results = $Apple->delete(4); @@ -948,7 +948,7 @@ public function testBehaviorDeleteCallbacks() { $this->assertSame(trim(ob_get_clean()), 'beforeDelete success'); $this->assertTrue($results); - $Apple->Behaviors->load('Test', array('beforeDelete' => 'off', 'afterDelete' => 'on')); + $Apple->Behaviors->load('Test', ['beforeDelete' => 'off', 'afterDelete' => 'on']); ob_start(); $results = $Apple->delete(2, false); $this->assertSame(trim(ob_get_clean()), 'afterDelete success'); @@ -963,7 +963,7 @@ public function testBehaviorDeleteCallbacks() { public function testBehaviorOnErrorCallback() { $Apple = new Apple(); - $Apple->Behaviors->load('Test', array('beforeFind' => 'off', 'onError' => 'on')); + $Apple->Behaviors->load('Test', ['beforeFind' => 'off', 'onError' => 'on']); ob_start(); $Apple->Behaviors->Test->onError($Apple, ''); $this->assertSame(trim(ob_get_clean()), 'onError trigger success'); @@ -980,21 +980,21 @@ public function testBehaviorValidateCallback() { $Apple->Behaviors->load('Test'); $this->assertTrue($Apple->validates()); - $Apple->Behaviors->load('Test', array('validate' => 'on')); + $Apple->Behaviors->load('Test', ['validate' => 'on']); $this->assertFalse($Apple->validates()); - $this->assertSame($Apple->validationErrors, array('name' => array(true))); + $this->assertSame($Apple->validationErrors, ['name' => [true]]); - $Apple->Behaviors->load('Test', array('validate' => 'stop')); + $Apple->Behaviors->load('Test', ['validate' => 'stop']); $this->assertFalse($Apple->validates()); - $this->assertSame($Apple->validationErrors, array('name' => array(true, true))); + $this->assertSame($Apple->validationErrors, ['name' => [true, true]]); - $Apple->Behaviors->load('Test', array('validate' => 'whitelist')); + $Apple->Behaviors->load('Test', ['validate' => 'whitelist']); $Apple->validates(); - $this->assertSame($Apple->whitelist, array()); + $this->assertSame($Apple->whitelist, []); - $Apple->whitelist = array('unknown'); + $Apple->whitelist = ['unknown']; $Apple->validates(); - $this->assertSame($Apple->whitelist, array('unknown', 'name')); + $this->assertSame($Apple->whitelist, ['unknown', 'name']); } /** @@ -1008,14 +1008,14 @@ public function testBehaviorValidateAfterCallback() { $Apple->Behaviors->load('Test'); $this->assertTrue($Apple->validates()); - $Apple->Behaviors->load('Test', array('afterValidate' => 'on')); + $Apple->Behaviors->load('Test', ['afterValidate' => 'on']); $this->assertTrue($Apple->validates()); - $this->assertSame($Apple->validationErrors, array()); + $this->assertSame($Apple->validationErrors, []); - $Apple->Behaviors->load('Test', array('afterValidate' => 'test')); - $Apple->data = array('bar'); + $Apple->Behaviors->load('Test', ['afterValidate' => 'test']); + $Apple->data = ['bar']; $Apple->validates(); - $this->assertEquals(array('foo'), $Apple->data); + $this->assertEquals(['foo'], $Apple->data); } /** @@ -1028,11 +1028,11 @@ public function testBehaviorValidateMethods() { $Apple->Behaviors->load('Test'); $Apple->validate['color'] = 'validateField'; - $result = $Apple->save(array('name' => 'Genetically Modified Apple', 'color' => 'Orange')); - $this->assertEquals(array('name', 'color', 'modified', 'created', 'id'), array_keys($result['Apple'])); + $result = $Apple->save(['name' => 'Genetically Modified Apple', 'color' => 'Orange']); + $this->assertEquals(['name', 'color', 'modified', 'created', 'id'], array_keys($result['Apple'])); $Apple->create(); - $result = $Apple->save(array('name' => 'Regular Apple', 'color' => 'Red')); + $result = $Apple->save(['name' => 'Regular Apple', 'color' => 'Red']); $this->assertFalse($result); } @@ -1050,7 +1050,7 @@ public function testBehaviorMethodDispatching() { $this->assertEquals($expected, $Apple->Behaviors->dispatchMethod($Apple, 'testMethod')); $result = $Apple->Behaviors->dispatchMethod($Apple, 'wtf'); - $this->assertEquals(array('unhandled'), $result); + $this->assertEquals(['unhandled'], $result); $result = $Apple->{'look for the remote'}('in the couch'); $expected = "Item.name = 'the remote' AND Location.name = 'the couch'"; @@ -1085,7 +1085,7 @@ public function testBehaviorMethodDispatchingWithData() { public function testBindModelCallsInBehaviors() { // hasMany $Article = new Article(); - $Article->unbindModel(array('hasMany' => array('Comment'))); + $Article->unbindModel(['hasMany' => ['Comment']]); $result = $Article->find('first'); $this->assertFalse(array_key_exists('Comment', $result)); @@ -1094,7 +1094,7 @@ public function testBindModelCallsInBehaviors() { $this->assertTrue(array_key_exists('Comment', $result)); // belongsTo - $Article->unbindModel(array('belongsTo' => array('User'))); + $Article->unbindModel(['belongsTo' => ['User']]); $result = $Article->find('first'); $this->assertFalse(array_key_exists('User', $result)); @@ -1103,7 +1103,7 @@ public function testBindModelCallsInBehaviors() { $this->assertTrue(array_key_exists('User', $result)); // hasAndBelongsToMany - $Article->unbindModel(array('hasAndBelongsToMany' => array('Tag'))); + $Article->unbindModel(['hasAndBelongsToMany' => ['Tag']]); $result = $Article->find('first'); $this->assertFalse(array_key_exists('Tag', $result)); @@ -1113,7 +1113,7 @@ public function testBindModelCallsInBehaviors() { // hasOne $Comment = new Comment(); - $Comment->unbindModel(array('hasOne' => array('Attachment'))); + $Comment->unbindModel(['hasOne' => ['Attachment']]); $result = $Comment->find('first'); $this->assertFalse(array_key_exists('Attachment', $result)); @@ -1129,12 +1129,12 @@ public function testBindModelCallsInBehaviors() { */ public function testBehaviorAttachAndDetach() { $Sample = new Sample(); - $Sample->actsAs = array('Test3' => array('bar'), 'Test2' => array('foo', 'bar')); + $Sample->actsAs = ['Test3' => ['bar'], 'Test2' => ['foo', 'bar']]; $Sample->Behaviors->init($Sample->alias, $Sample->actsAs); $Sample->Behaviors->load('Test2'); $Sample->Behaviors->unload('Test3'); - $Sample->Behaviors->trigger('beforeTest', array(&$Sample)); + $Sample->Behaviors->trigger('beforeTest', [&$Sample]); } /** @@ -1145,7 +1145,7 @@ public function testBehaviorAttachAndDetach() { public function testHasMethodBasic() { new Sample(); $Collection = new BehaviorCollection(); - $Collection->init('Sample', array('Test', 'Test2')); + $Collection->init('Sample', ['Test', 'Test2']); $this->assertTrue($Collection->hasMethod('testMethod')); $this->assertTrue($Collection->hasMethod('resolveMethod')); @@ -1161,7 +1161,7 @@ public function testHasMethodBasic() { public function testHasMethodMappedMethods() { new Sample(); $Collection = new BehaviorCollection(); - $Collection->init('Sample', array('Test', 'Test2')); + $Collection->init('Sample', ['Test', 'Test2']); $this->assertTrue($Collection->hasMethod('look for the remote in the couch')); $this->assertTrue($Collection->hasMethod('mappingRobotOnTheRoof')); @@ -1175,18 +1175,18 @@ public function testHasMethodMappedMethods() { public function testHasMethodAsCallback() { new Sample(); $Collection = new BehaviorCollection(); - $Collection->init('Sample', array('Test', 'Test2')); + $Collection->init('Sample', ['Test', 'Test2']); $result = $Collection->hasMethod('testMethod', true); - $expected = array('Test', 'testMethod'); + $expected = ['Test', 'testMethod']; $this->assertEquals($expected, $result); $result = $Collection->hasMethod('resolveMethod', true); - $expected = array('Test2', 'resolveMethod'); + $expected = ['Test2', 'resolveMethod']; $this->assertEquals($expected, $result); $result = $Collection->hasMethod('mappingRobotOnTheRoof', true); - $expected = array('Test2', 'mapped', 'mappingRobotOnTheRoof'); + $expected = ['Test2', 'mapped', 'mappingRobotOnTheRoof']; $this->assertEquals($expected, $result); } @@ -1197,71 +1197,71 @@ public function testHasMethodAsCallback() { */ public function testBehaviorOrderCallbacks() { $model = ClassRegistry::init('Orangutan'); - $model->Behaviors->init('Orangutan', array( - 'Second' => array('priority' => 9), + $model->Behaviors->init('Orangutan', [ + 'Second' => ['priority' => 9], 'Third', - 'First' => array('priority' => 8), - )); + 'First' => ['priority' => 8], + ]); $this->assertEmpty($model->called); $model->find('first'); - $expected = array( + $expected = [ 'FirstBehavior', 'SecondBehavior', 'ThirdBehavior', - ); + ]; $this->assertEquals($expected, $model->called); - $model->called = array(); - $model->Behaviors->load('Third', array('priority' => 1)); + $model->called = []; + $model->Behaviors->load('Third', ['priority' => 1]); $model->find('first'); - $expected = array( + $expected = [ 'ThirdBehavior', 'FirstBehavior', 'SecondBehavior' - ); + ]; $this->assertEquals($expected, $model->called); - $model->called = array(); + $model->called = []; $model->Behaviors->load('First'); $model->find('first'); - $expected = array( + $expected = [ 'ThirdBehavior', 'SecondBehavior', 'FirstBehavior' - ); + ]; $this->assertEquals($expected, $model->called); - $model->called = array(); + $model->called = []; $model->Behaviors->unload('Third'); $model->find('first'); - $expected = array( + $expected = [ 'SecondBehavior', 'FirstBehavior' - ); + ]; $this->assertEquals($expected, $model->called); - $model->called = array(); + $model->called = []; $model->Behaviors->disable('Second'); $model->find('first'); - $expected = array( + $expected = [ 'FirstBehavior' - ); + ]; $this->assertEquals($expected, $model->called); - $model->called = array(); + $model->called = []; $model->Behaviors->enable('Second'); $model->find('first'); - $expected = array( + $expected = [ 'SecondBehavior', 'FirstBehavior' - ); + ]; $this->assertEquals($expected, $model->called); } diff --git a/lib/Cake/Test/Case/Model/CakeSchemaTest.php b/lib/Cake/Test/Case/Model/CakeSchemaTest.php index ac3e5490e7..3d062f9952 100644 --- a/lib/Cake/Test/Case/Model/CakeSchemaTest.php +++ b/lib/Cake/Test/Case/Model/CakeSchemaTest.php @@ -38,48 +38,48 @@ class MyAppSchema extends CakeSchema { * * @var array */ - public $comments = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'user_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => false, 'length' => 100), - 'comment' => array('type' => 'text', 'null' => false, 'default' => null), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - ); + public $comments = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'post_id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'user_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => false, 'length' => 100], + 'comment' => ['type' => 'text', 'null' => false, 'default' => null], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + ]; /** * posts property * * @var array */ - public $posts = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => true, 'default' => ''), - 'title' => array('type' => 'string', 'null' => false, 'default' => 'Title'), - 'body' => array('type' => 'text', 'null' => true, 'default' => null), - 'summary' => array('type' => 'text', 'null' => true), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'status' => array( + public $posts = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => true, 'default' => ''], + 'title' => ['type' => 'string', 'null' => false, 'default' => 'Title'], + 'body' => ['type' => 'text', 'null' => true, 'default' => null], + 'summary' => ['type' => 'text', 'null' => true], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'status' => [ 'type' => 'enum(\'active\',\'deleted\')', 'null' => false, 'default' => 'active', 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8', - ), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - ); + ], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + ]; /** * _foo property * * @var array */ - protected $_foo = array('bar'); + protected $_foo = ['bar']; /** * getVar method @@ -115,78 +115,78 @@ class TestAppSchema extends CakeSchema { * * @var array */ - public $comments = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'article_id' => array('type' => 'integer', 'null' => false), - 'user_id' => array('type' => 'integer', 'null' => false), - 'comment' => array('type' => 'text', 'null' => true, 'default' => null), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - 'tableParameters' => array(), - ); + public $comments = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'article_id' => ['type' => 'integer', 'null' => false], + 'user_id' => ['type' => 'integer', 'null' => false], + 'comment' => ['type' => 'text', 'null' => true, 'default' => null], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + 'tableParameters' => [], + ]; /** * posts property * * @var array */ - public $posts = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => false), - 'body' => array('type' => 'text', 'null' => true, 'default' => null), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - 'tableParameters' => array(), - ); + public $posts = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => false], + 'body' => ['type' => 'text', 'null' => true, 'default' => null], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + 'tableParameters' => [], + ]; /** * posts_tags property * * @var array */ - public $posts_tags = array( - 'post_id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'), - 'tag_id' => array('type' => 'string', 'null' => false, 'key' => 'primary'), - 'indexes' => array('posts_tag' => array('column' => array('tag_id', 'post_id'), 'unique' => 1)), - 'tableParameters' => array() - ); + public $posts_tags = [ + 'post_id' => ['type' => 'integer', 'null' => false, 'key' => 'primary'], + 'tag_id' => ['type' => 'string', 'null' => false, 'key' => 'primary'], + 'indexes' => ['posts_tag' => ['column' => ['tag_id', 'post_id'], 'unique' => 1]], + 'tableParameters' => [] + ]; /** * tags property * * @var array */ - public $tags = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'tag' => array('type' => 'string', 'null' => false), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - 'tableParameters' => array() - ); + public $tags = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'tag' => ['type' => 'string', 'null' => false], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + 'tableParameters' => [] + ]; /** * datatypes property * * @var array */ - public $datatypes = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'float_field' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => ''), - 'decimal_field' => array('type' => 'decimal', 'length' => '6,3', 'default' => '0.000'), - 'huge_int' => array('type' => 'biginteger'), - 'normal_int' => array('type' => 'integer'), - 'small_int' => array('type' => 'smallinteger'), - 'tiny_int' => array('type' => 'tinyinteger'), - 'bool' => array('type' => 'boolean', 'null' => false, 'default' => false), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - 'tableParameters' => array() - ); + public $datatypes = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'float_field' => ['type' => 'float', 'null' => false, 'length' => '5,2', 'default' => ''], + 'decimal_field' => ['type' => 'decimal', 'length' => '6,3', 'default' => '0.000'], + 'huge_int' => ['type' => 'biginteger'], + 'normal_int' => ['type' => 'integer'], + 'small_int' => ['type' => 'smallinteger'], + 'tiny_int' => ['type' => 'tinyinteger'], + 'bool' => ['type' => 'boolean', 'null' => false, 'default' => false], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + 'tableParameters' => [] + ]; /** * setup method @@ -227,14 +227,14 @@ class SchemaPost extends CakeTestModel { * * @var array */ - public $hasMany = array('SchemaComment'); + public $hasMany = ['SchemaComment']; /** * hasAndBelongsToMany property * * @var array */ - public $hasAndBelongsToMany = array('SchemaTag'); + public $hasAndBelongsToMany = ['SchemaTag']; } /** @@ -256,7 +256,7 @@ class SchemaComment extends CakeTestModel { * * @var array */ - public $belongsTo = array('SchemaPost'); + public $belongsTo = ['SchemaPost']; } /** @@ -278,7 +278,7 @@ class SchemaTag extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('SchemaPost'); + public $hasAndBelongsToMany = ['SchemaPost']; } /** @@ -357,20 +357,20 @@ class SchemaCrossDatabaseFixture extends CakeTestFixture { * * @var array */ - public $fields = array( - 'id' => array('type' => 'integer', 'key' => 'primary'), + public $fields = [ + 'id' => ['type' => 'integer', 'key' => 'primary'], 'name' => 'string' - ); + ]; /** * records property * * @var array */ - public $records = array( - array('id' => 1, 'name' => 'First'), - array('id' => 2, 'name' => 'Second'), - ); + public $records = [ + ['id' => 1, 'name' => 'First'], + ['id' => 2, 'name' => 'Second'], + ]; } /** @@ -399,11 +399,11 @@ class NonConventionalPrimaryKeyFixture extends CakeTestFixture { * * @var array */ - public $fields = array( - 'version_id' => array('type' => 'integer', 'key' => 'primary'), - 'id' => array('type' => 'integer'), + public $fields = [ + 'version_id' => ['type' => 'integer', 'key' => 'primary'], + 'id' => ['type' => 'integer'], 'name' => 'string' - ); + ]; } /** @@ -440,12 +440,12 @@ class CakeSchemaTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.post', 'core.tag', 'core.posts_tag', 'core.test_plugin_comment', 'core.datatype', 'core.auth_user', 'core.author', 'core.test_plugin_article', 'core.user', 'core.comment', 'core.prefix_test' - ); + ]; /** * setUp method @@ -488,14 +488,14 @@ public function testSchemaName() { * @return void */ public function testSchemaRead() { - $read = $this->Schema->read(array( + $read = $this->Schema->read([ 'connection' => 'test', 'name' => 'TestApp', - 'models' => array('SchemaPost', 'SchemaComment', 'SchemaTag', 'SchemaDatatype') - )); + 'models' => ['SchemaPost', 'SchemaComment', 'SchemaTag', 'SchemaDatatype'] + ]); unset($read['tables']['missing']); - $expected = array('comments', 'datatypes', 'posts', 'posts_tags', 'tags'); + $expected = ['comments', 'datatypes', 'posts', 'posts_tags', 'tags']; foreach ($expected as $table) { $this->assertTrue(isset($read['tables'][$table]), 'Missing table ' . $table); } @@ -524,14 +524,14 @@ public function testSchemaRead() { $config = $db->config; $config['prefix'] = 'schema_test_prefix_'; ConnectionManager::create('schema_prefix', $config); - $read = $this->Schema->read(array('connection' => 'schema_prefix', 'models' => false)); + $read = $this->Schema->read(['connection' => 'schema_prefix', 'models' => false]); $this->assertTrue(empty($read['tables'])); - $read = $this->Schema->read(array( + $read = $this->Schema->read([ 'connection' => 'test', 'name' => 'TestApp', - 'models' => array('SchemaComment', 'SchemaTag', 'SchemaPost') - )); + 'models' => ['SchemaComment', 'SchemaTag', 'SchemaPost'] + ]); $this->assertFalse(isset($read['tables']['missing']['posts_tags']), 'Join table marked as missing'); } @@ -545,11 +545,11 @@ public function testSchemaReadWithAppModel() { ConnectionManager::drop('default'); ConnectionManager::create('default', $connections['test']); try { - $this->Schema->read(array( + $this->Schema->read([ 'connection' => 'default', 'name' => 'TestApp', - 'models' => array('AppModel') - )); + 'models' => ['AppModel'] + ]); } catch(MissingTableException $mte) { ConnectionManager::drop('default'); $this->fail($mte->getMessage()); @@ -569,11 +569,11 @@ public function testSchemaReadWithOddTablePrefix() { $SchemaPost = ClassRegistry::init('SchemaPost'); $SchemaPost->tablePrefix = 'po'; $SchemaPost->useTable = 'sts'; - $read = $this->Schema->read(array( + $read = $this->Schema->read([ 'connection' => 'test', 'name' => 'TestApp', - 'models' => array('SchemaPost') - )); + 'models' => ['SchemaPost'] + ]); $this->assertFalse(isset($read['tables']['missing']['posts']), 'Posts table was not read from tablePrefix'); } @@ -588,11 +588,11 @@ public function testSchemaReadWithTablePrefix() { $this->skipIf(!empty($config['prefix']), 'This test can not be executed with datasource prefix set.'); $Schema = new CakeSchema(); - $read = $Schema->read(array( + $read = $Schema->read([ 'connection' => 'test', 'name' => 'TestApp', - 'models' => array('SchemaPrefixAuthUser') - )); + 'models' => ['SchemaPrefixAuthUser'] + ]); unset($read['tables']['missing']); $this->assertTrue(isset($read['tables']['auth_users']), 'auth_users key missing %s'); } @@ -611,15 +611,15 @@ public function testSchemaReadWithConfigPrefix() { $config['prefix'] = 'schema_test_prefix_'; ConnectionManager::create('schema_prefix', $config); - $read = $this->Schema->read(array('connection' => 'schema_prefix', 'models' => false)); + $read = $this->Schema->read(['connection' => 'schema_prefix', 'models' => false]); $this->assertTrue(empty($read['tables'])); $config['prefix'] = 'prefix_'; ConnectionManager::create('schema_prefix2', $config); - $read = $this->Schema->read(array( + $read = $this->Schema->read([ 'connection' => 'schema_prefix2', 'name' => 'TestApp', - 'models' => false)); + 'models' => false]); $this->assertTrue(isset($read['tables']['prefix_tests'])); } @@ -630,18 +630,18 @@ public function testSchemaReadWithConfigPrefix() { */ public function testSchemaReadWithPlugins() { App::objects('model', null, false); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); $Schema = new CakeSchema(); $Schema->plugin = 'TestPlugin'; - $read = $Schema->read(array( + $read = $Schema->read([ 'connection' => 'test', 'name' => 'TestApp', 'models' => true - )); + ]); unset($read['tables']['missing']); $this->assertTrue(isset($read['tables']['auth_users'])); $this->assertTrue(isset($read['tables']['authors'])); @@ -671,20 +671,20 @@ public function testSchemaReadWithCrossDatabase() { $fixture->create($db); $fixture->insert($db); - $read = $this->Schema->read(array( + $read = $this->Schema->read([ 'connection' => 'test', 'name' => 'TestApp', - 'models' => array('SchemaCrossDatabase', 'SchemaPost') - )); + 'models' => ['SchemaCrossDatabase', 'SchemaPost'] + ]); $this->assertTrue(isset($read['tables']['posts'])); $this->assertFalse(isset($read['tables']['cross_database']), 'Cross database should not appear'); $this->assertFalse(isset($read['tables']['missing']['cross_database']), 'Cross database should not appear'); - $read = $this->Schema->read(array( + $read = $this->Schema->read([ 'connection' => 'test2', 'name' => 'TestApp', - 'models' => array('SchemaCrossDatabase', 'SchemaPost') - )); + 'models' => ['SchemaCrossDatabase', 'SchemaPost'] + ]); $this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear'); $this->assertFalse(isset($read['tables']['posts']), 'Posts should not appear'); $this->assertTrue(isset($read['tables']['cross_database'])); @@ -702,11 +702,11 @@ public function testSchemaReadWithNonConventionalPrimaryKey() { $fixture = new NonConventionalPrimaryKeyFixture(); $fixture->create($db); - $read = $this->Schema->read(array( + $read = $this->Schema->read([ 'connection' => 'test', 'name' => 'TestApp', 'models' => false - )); + ]); $fixture->drop($db); $this->assertArrayHasKey('non_conventional', $read['tables']); @@ -725,32 +725,32 @@ public function testSchemaReadWithNonConventionalPrimaryKey() { * @return void */ public function testGenerateTable() { - $posts = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => false), - 'body' => array('type' => 'text', 'null' => true, 'default' => null), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => true)), - ); + $posts = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => false], + 'body' => ['type' => 'text', 'null' => true, 'default' => null], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => true]], + ]; $result = $this->Schema->generateTable('posts', $posts); $this->assertMatchesRegularExpression('/public \$posts/', $result); - $posts = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => false), - 'body' => array('type' => 'text', 'null' => true, 'default' => null), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true), - 'MyFtIndex' => array('column' => array('title', 'body'), 'type' => 'fulltext') - ) - ); + $posts = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => false], + 'body' => ['type' => 'text', 'null' => true, 'default' => null], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'N', 'length' => 1], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true], + 'MyFtIndex' => ['column' => ['title', 'body'], 'type' => 'fulltext'] + ] + ]; $result = $this->Schema->generateTable('fields', $posts); $this->assertMatchesRegularExpression('/public \$fields/', $result); $this->assertMatchesRegularExpression('/\'type\' \=\> \'fulltext\'/', $result); @@ -765,7 +765,7 @@ public function testGenerateInvalidTable() { $invalidTableName = 'invalid name !@#$%^&*()'; $expectedException = "Invalid table name '{$invalidTableName}'"; try{ - $this->Schema->generateTable($invalidTableName, array()); + $this->Schema->generateTable($invalidTableName, []); $this->fail("Expected exception \"{$expectedException}\" not thrown"); } catch (Exception $e) { $this->assertEquals($expectedException, $e->getMessage()); @@ -778,11 +778,11 @@ public function testGenerateInvalidTable() { * @return void */ public function testSchemaWrite() { - $write = $this->Schema->write(array( + $write = $this->Schema->write([ 'name' => 'MyOtherApp', 'tables' => $this->Schema->tables, 'path' => TMP . 'tests' - )); + ]); $file = file_get_contents(TMP . 'tests' . DS . 'schema.php'); $this->assertEquals($write, $file); @@ -799,83 +799,83 @@ public function testSchemaWrite() { public function testSchemaComparison() { $New = new MyAppSchema(); $compare = $New->compare($this->Schema); - $expected = array( - 'comments' => array( - 'add' => array( - 'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'after' => 'id'), - 'title' => array('type' => 'string', 'null' => false, 'length' => 100, 'after' => 'user_id'), - ), - 'drop' => array( - 'article_id' => array('type' => 'integer', 'null' => false), - 'tableParameters' => array(), - ), - 'change' => array( - 'comment' => array('type' => 'text', 'null' => false, 'default' => null), - ) - ), - 'posts' => array( - 'add' => array( - 'summary' => array('type' => 'text', 'null' => true, 'after' => 'body'), - 'status' => array( + $expected = [ + 'comments' => [ + 'add' => [ + 'post_id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'after' => 'id'], + 'title' => ['type' => 'string', 'null' => false, 'length' => 100, 'after' => 'user_id'], + ], + 'drop' => [ + 'article_id' => ['type' => 'integer', 'null' => false], + 'tableParameters' => [], + ], + 'change' => [ + 'comment' => ['type' => 'text', 'null' => false, 'default' => null], + ] + ], + 'posts' => [ + 'add' => [ + 'summary' => ['type' => 'text', 'null' => true, 'after' => 'body'], + 'status' => [ 'type' => 'enum(\'active\',\'deleted\')', 'null' => false, 'default' => 'active', 'collate' => 'utf8_unicode_ci', 'charset' => 'utf8', 'after' => 'updated', - ), - ), - 'drop' => array( - 'tableParameters' => array(), - ), - 'change' => array( - 'author_id' => array('type' => 'integer', 'null' => true, 'default' => ''), - 'title' => array('type' => 'string', 'null' => false, 'default' => 'Title'), - 'published' => array('type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1) - ) - ), - ); + ], + ], + 'drop' => [ + 'tableParameters' => [], + ], + 'change' => [ + 'author_id' => ['type' => 'integer', 'null' => true, 'default' => ''], + 'title' => ['type' => 'string', 'null' => false, 'default' => 'Title'], + 'published' => ['type' => 'string', 'null' => true, 'default' => 'Y', 'length' => 1] + ] + ], + ]; $this->assertEquals($expected, $compare); $this->assertNull($New->getVar('comments')); - $this->assertEquals(array('bar'), $New->getVar('_foo')); - - $tables = array( - 'missing' => array( - 'categories' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'modified' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'name' => array('type' => 'string', 'null' => false, 'default' => null, 'length' => 100), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM') - ) - ), - 'ratings' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'), - 'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => null), - 'model' => array('type' => 'varchar', 'null' => false, 'default' => null), - 'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => null), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'modified' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM') - ) - ); + $this->assertEquals(['bar'], $New->getVar('_foo')); + + $tables = [ + 'missing' => [ + 'categories' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'], + 'created' => ['type' => 'datetime', 'null' => false, 'default' => null], + 'modified' => ['type' => 'datetime', 'null' => false, 'default' => null], + 'name' => ['type' => 'string', 'null' => false, 'default' => null, 'length' => 100], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1]], + 'tableParameters' => ['charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM'] + ] + ], + 'ratings' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'], + 'foreign_key' => ['type' => 'integer', 'null' => false, 'default' => null], + 'model' => ['type' => 'varchar', 'null' => false, 'default' => null], + 'value' => ['type' => 'float', 'null' => false, 'length' => '5,2', 'default' => null], + 'created' => ['type' => 'datetime', 'null' => false, 'default' => null], + 'modified' => ['type' => 'datetime', 'null' => false, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1]], + 'tableParameters' => ['charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM'] + ] + ]; $compare = $New->compare($this->Schema, $tables); - $expected = array( - 'ratings' => array( - 'create' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'), - 'foreign_key' => array('type' => 'integer', 'null' => false, 'default' => null), - 'model' => array('type' => 'varchar', 'null' => false, 'default' => null), - 'value' => array('type' => 'float', 'null' => false, 'length' => '5,2', 'default' => null), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'modified' => array('type' => 'datetime', 'null' => false, 'default' => null), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)), - 'tableParameters' => array('charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM') - ) - ) - ); + $expected = [ + 'ratings' => [ + 'create' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'], + 'foreign_key' => ['type' => 'integer', 'null' => false, 'default' => null], + 'model' => ['type' => 'varchar', 'null' => false, 'default' => null], + 'value' => ['type' => 'float', 'null' => false, 'length' => '5,2', 'default' => null], + 'created' => ['type' => 'datetime', 'null' => false, 'default' => null], + 'modified' => ['type' => 'datetime', 'null' => false, 'default' => null], + 'indexes' => ['PRIMARY' => ['column' => 'id', 'unique' => 1]], + 'tableParameters' => ['charset' => 'latin1', 'collate' => 'latin1_swedish_ci', 'engine' => 'MyISAM'] + ] + ] + ]; $this->assertEquals($expected, $compare); } @@ -885,26 +885,26 @@ public function testSchemaComparison() { * @return void */ public function testCompareEmptyStringAndNull() { - $One = new CakeSchema(array( - 'posts' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => false, 'default' => '') - ) - )); - $Two = new CakeSchema(array( - 'posts' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => false, 'default' => null) - ) - )); + $One = new CakeSchema([ + 'posts' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'], + 'name' => ['type' => 'string', 'null' => false, 'default' => ''] + ] + ]); + $Two = new CakeSchema([ + 'posts' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary'], + 'name' => ['type' => 'string', 'null' => false, 'default' => null] + ] + ]); $compare = $One->compare($Two); - $expected = array( - 'posts' => array( - 'change' => array( - 'name' => array('type' => 'string', 'null' => false, 'default' => null) - ) - ) - ); + $expected = [ + 'posts' => [ + 'change' => [ + 'name' => ['type' => 'string', 'null' => false, 'default' => null] + ] + ] + ]; $this->assertEquals($expected, $compare); } @@ -914,88 +914,88 @@ public function testCompareEmptyStringAndNull() { * @return void */ public function testTableParametersAndIndexComparison() { - $old = array( - 'posts' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => false), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true) - ), - 'tableParameters' => array( + $old = [ + 'posts' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => false], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true] + ], + 'tableParameters' => [ 'charset' => 'latin1', 'collate' => 'latin1_general_ci' - ) - ), - 'comments' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'comment' => array('type' => 'text'), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true), - 'post_id' => array('column' => 'post_id'), - ), - 'tableParameters' => array( + ] + ], + 'comments' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'post_id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'comment' => ['type' => 'text'], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true], + 'post_id' => ['column' => 'post_id'], + ], + 'tableParameters' => [ 'engine' => 'InnoDB', 'charset' => 'latin1', 'collate' => 'latin1_general_ci' - ) - ) - ); - $new = array( - 'posts' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => false), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true), - 'author_id' => array('column' => 'author_id'), - ), - 'tableParameters' => array( + ] + ] + ]; + $new = [ + 'posts' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => false], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true], + 'author_id' => ['column' => 'author_id'], + ], + 'tableParameters' => [ 'charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'MyISAM' - ) - ), - 'comments' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'post_id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'comment' => array('type' => 'text'), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true), - ), - 'tableParameters' => array( + ] + ], + 'comments' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'post_id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'comment' => ['type' => 'text'], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true], + ], + 'tableParameters' => [ 'charset' => 'utf8', 'collate' => 'utf8_general_ci' - ) - ) - ); + ] + ] + ]; $compare = $this->Schema->compare($old, $new); - $expected = array( - 'posts' => array( - 'add' => array( - 'indexes' => array('author_id' => array('column' => 'author_id')), - ), - 'change' => array( - 'tableParameters' => array( + $expected = [ + 'posts' => [ + 'add' => [ + 'indexes' => ['author_id' => ['column' => 'author_id']], + ], + 'change' => [ + 'tableParameters' => [ 'charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'MyISAM' - ) - ) - ), - 'comments' => array( - 'drop' => array( - 'indexes' => array('post_id' => array('column' => 'post_id')), - ), - 'change' => array( - 'tableParameters' => array( + ] + ] + ], + 'comments' => [ + 'drop' => [ + 'indexes' => ['post_id' => ['column' => 'post_id']], + ], + 'change' => [ + 'tableParameters' => [ 'charset' => 'utf8', 'collate' => 'utf8_general_ci', - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, $compare); } @@ -1005,45 +1005,45 @@ public function testTableParametersAndIndexComparison() { * @return void */ public function testCompareVarcharToDatetime() { - $old = array( - 'posts' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => true, 'length' => 45), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true) - ), - 'tableParameters' => array( + $old = [ + 'posts' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => true, 'length' => 45], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true] + ], + 'tableParameters' => [ 'charset' => 'latin1', 'collate' => 'latin1_general_ci' - ) - ), - ); - $new = array( - 'posts' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'datetime', 'null' => false), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true) - ), - 'tableParameters' => array( + ] + ], + ]; + $new = [ + 'posts' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'datetime', 'null' => false], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true] + ], + 'tableParameters' => [ 'charset' => 'latin1', 'collate' => 'latin1_general_ci' - ) - ), - ); + ] + ], + ]; $compare = $this->Schema->compare($old, $new); - $expected = array( - 'posts' => array( - 'change' => array( - 'title' => array( + $expected = [ + 'posts' => [ + 'change' => [ + 'title' => [ 'type' => 'datetime', 'null' => false, - ) - ) - ), - ); + ] + ] + ], + ]; $this->assertEquals($expected, $compare, 'Invalid SQL, datetime does not have length'); } @@ -1053,54 +1053,54 @@ public function testCompareVarcharToDatetime() { * @return void */ public function testCompareLimitToDefault() { - $old = array( - 'posts' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 1, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false, 'limit' => 5), - 'title' => array('type' => 'string', 'null' => true, 'length' => 45), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true) - ), - 'tableParameters' => array( + $old = [ + 'posts' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 1, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false, 'limit' => 5], + 'title' => ['type' => 'string', 'null' => true, 'length' => 45], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true] + ], + 'tableParameters' => [ 'charset' => 'latin1', 'collate' => 'latin1_general_ci' - ) - ), - ); - $new = array( - 'posts' => array( - 'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'varchar', 'null' => true), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => true) - ), - 'tableParameters' => array( + ] + ], + ]; + $new = [ + 'posts' => [ + 'id' => ['type' => 'integer', 'null' => false, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'varchar', 'null' => true], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => true] + ], + 'tableParameters' => [ 'charset' => 'latin1', 'collate' => 'latin1_general_ci' - ) - ), - ); + ] + ], + ]; $compare = $this->Schema->compare($old, $new); - $expected = array( - 'posts' => array( - 'change' => array( - 'id' => array( + $expected = [ + 'posts' => [ + 'change' => [ + 'id' => [ 'type' => 'integer', 'null' => false, 'key' => 'primary' - ), - 'author_id' => array( + ], + 'author_id' => [ 'type' => 'integer', 'null' => false, - ), - 'title' => array( + ], + 'title' => [ 'type' => 'varchar', 'null' => true, - ) - ) - ), - ); + ] + ] + ], + ]; $this->assertEquals($expected, $compare, 'Invalid SQL, field length change not detected'); } @@ -1110,7 +1110,7 @@ public function testCompareLimitToDefault() { * @return void */ public function testSchemaLoading() { - $Other = $this->Schema->load(array('name' => 'MyOtherApp', 'path' => TMP . 'tests')); + $Other = $this->Schema->load(['name' => 'MyOtherApp', 'path' => TMP . 'tests']); $this->assertEquals('MyOtherApp', $Other->name); $this->assertEquals($Other->tables, $this->Schema->tables); } @@ -1121,13 +1121,13 @@ public function testSchemaLoading() { * @return void */ public function testSchemaLoadingFromPlugin() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); - $Other = $this->Schema->load(array('name' => 'TestPluginApp', 'plugin' => 'TestPlugin')); + $Other = $this->Schema->load(['name' => 'TestPluginApp', 'plugin' => 'TestPlugin']); $this->assertEquals('TestPluginApp', $Other->name); - $this->assertEquals(array('test_plugin_acos'), array_keys($Other->tables)); + $this->assertEquals(['test_plugin_acos'], array_keys($Other->tables)); App::build(); } @@ -1141,14 +1141,14 @@ public function testSchemaCreateTable() { $db = ConnectionManager::getDataSource('test'); $db->cacheSources = false; - $Schema = new CakeSchema(array( + $Schema = new CakeSchema([ 'connection' => 'test', - 'testdescribes' => array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'int_null' => array('type' => 'integer', 'null' => true), - 'int_not_null' => array('type' => 'integer', 'null' => false), - ), - )); + 'testdescribes' => [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'int_null' => ['type' => 'integer', 'null' => true], + 'int_not_null' => ['type' => 'integer', 'null' => false], + ], + ]); $sql = $db->createSchema($Schema); $col = $Schema->tables['testdescribes']['int_null']; diff --git a/lib/Cake/Test/Case/Model/ConnectionManagerTest.php b/lib/Cake/Test/Case/Model/ConnectionManagerTest.php index 39fc5beb49..9531741522 100644 --- a/lib/Cake/Test/Case/Model/ConnectionManagerTest.php +++ b/lib/Cake/Test/Case/Model/ConnectionManagerTest.php @@ -43,7 +43,7 @@ public function testEnumConnectionObjects() { $sources = ConnectionManager::enumConnectionObjects(); $this->assertTrue(count($sources) >= 1); - $connections = array('default', 'test', 'test'); + $connections = ['default', 'test', 'test']; $this->assertTrue(count(array_intersect(array_keys($sources), $connections)) >= 1); } @@ -53,14 +53,14 @@ public function testEnumConnectionObjects() { * @return void */ public function testGetDataSource() { - App::build(array( - 'Model/Datasource' => array( + App::build([ + 'Model/Datasource' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS . 'Datasource' . DS - ) - )); + ] + ]); $name = 'test_get_datasource'; - $config = array('datasource' => 'Test2Source'); + $config = ['datasource' => 'Test2Source']; ConnectionManager::create($name, $config); $connections = ConnectionManager::enumConnectionObjects(); @@ -87,12 +87,12 @@ public function testGetDataSourceException() { * @return void */ public function testGetPluginDataSource() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $name = 'test_source'; - $config = array('datasource' => 'TestPlugin.TestSource'); + $config = ['datasource' => 'TestPlugin.TestSource']; $connection = ConnectionManager::create($name, $config); $this->assertTrue(class_exists('TestSource')); @@ -108,12 +108,12 @@ public function testGetPluginDataSource() { * @return void */ public function testGetPluginDataSourceAndPluginDriver() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); $name = 'test_plugin_source_and_driver'; - $config = array('datasource' => 'TestPlugin.Database/TestDriver'); + $config = ['datasource' => 'TestPlugin.Database/TestDriver']; $connection = ConnectionManager::create($name, $config); @@ -131,12 +131,12 @@ public function testGetPluginDataSourceAndPluginDriver() { * @return void */ public function testGetLocalDataSourceAndPluginDriver() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); $name = 'test_local_source_and_plugin_driver'; - $config = array('datasource' => 'TestPlugin.Database/DboDummy'); + $config = ['datasource' => 'TestPlugin.Database/DboDummy']; $connection = ConnectionManager::create($name, $config); @@ -153,15 +153,15 @@ public function testGetLocalDataSourceAndPluginDriver() { * @return void */ public function testGetPluginDataSourceAndLocalDriver() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Model/Datasource/Database' => array( + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Model/Datasource/Database' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS . 'Datasource' . DS . 'Database' . DS - ) - )); + ] + ]); $name = 'test_plugin_source_and_local_driver'; - $config = array('datasource' => 'Database/TestLocalDriver'); + $config = ['datasource' => 'Database/TestLocalDriver']; $connection = ConnectionManager::create($name, $config); @@ -206,11 +206,11 @@ public function testGetSourceName() { * @return void */ public function testLoadDataSource() { - $connections = array( - array('classname' => 'Mysql', 'filename' => 'Mysql', 'package' => 'Database'), - array('classname' => 'Postgres', 'filename' => 'Postgres', 'package' => 'Database'), - array('classname' => 'Sqlite', 'filename' => 'Sqlite', 'package' => 'Database'), - ); + $connections = [ + ['classname' => 'Mysql', 'filename' => 'Mysql', 'package' => 'Database'], + ['classname' => 'Postgres', 'filename' => 'Postgres', 'package' => 'Database'], + ['classname' => 'Sqlite', 'filename' => 'Sqlite', 'package' => 'Database'], + ]; foreach ($connections as $connection) { $exists = class_exists($connection['classname']); @@ -226,7 +226,7 @@ public function testLoadDataSource() { */ public function testLoadDataSourceException() { $this->expectException(MissingDatasourceException::class); - $connection = array('classname' => 'NonExistentDataSource', 'filename' => 'non_existent'); + $connection = ['classname' => 'NonExistentDataSource', 'filename' => 'non_existent']; ConnectionManager::loadDataSource($connection); } @@ -251,13 +251,13 @@ public function testCreateDataSourceWithIntegrationTests() { $this->assertEquals($name, $connection->configKeyName); $this->assertEquals($name, ConnectionManager::getSourceName($connection)); - $source = ConnectionManager::create(null, array()); + $source = ConnectionManager::create(null, []); $this->assertEquals(null, $source); - $source = ConnectionManager::create('another_test', array()); + $source = ConnectionManager::create('another_test', []); $this->assertEquals(null, $source); - $config = array('classname' => 'DboMysql', 'filename' => 'dbo' . DS . 'dbo_mysql'); + $config = ['classname' => 'DboMysql', 'filename' => 'dbo' . DS . 'dbo_mysql']; $source = ConnectionManager::create(null, $config); $this->assertEquals(null, $source); } @@ -268,56 +268,56 @@ public function testCreateDataSourceWithIntegrationTests() { * @return void */ public function testConnectionData() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Model/Datasource' => array( + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Model/Datasource' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS . 'Datasource' . DS - ) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); - $expected = array( + ] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); + $expected = [ 'datasource' => 'Test2Source' - ); + ]; - ConnectionManager::create('connection1', array('datasource' => 'Test2Source')); + ConnectionManager::create('connection1', ['datasource' => 'Test2Source']); $connections = ConnectionManager::enumConnectionObjects(); $this->assertEquals($expected, $connections['connection1']); ConnectionManager::drop('connection1'); - ConnectionManager::create('connection2', array('datasource' => 'Test2Source')); + ConnectionManager::create('connection2', ['datasource' => 'Test2Source']); $connections = ConnectionManager::enumConnectionObjects(); $this->assertEquals($expected, $connections['connection2']); ConnectionManager::drop('connection2'); - ConnectionManager::create('connection3', array('datasource' => 'TestPlugin.TestSource')); + ConnectionManager::create('connection3', ['datasource' => 'TestPlugin.TestSource']); $connections = ConnectionManager::enumConnectionObjects(); $expected['datasource'] = 'TestPlugin.TestSource'; $this->assertEquals($expected, $connections['connection3']); ConnectionManager::drop('connection3'); - ConnectionManager::create('connection4', array('datasource' => 'TestPlugin.TestSource')); + ConnectionManager::create('connection4', ['datasource' => 'TestPlugin.TestSource']); $connections = ConnectionManager::enumConnectionObjects(); $this->assertEquals($expected, $connections['connection4']); ConnectionManager::drop('connection4'); - ConnectionManager::create('connection5', array('datasource' => 'Test2OtherSource')); + ConnectionManager::create('connection5', ['datasource' => 'Test2OtherSource']); $connections = ConnectionManager::enumConnectionObjects(); $expected['datasource'] = 'Test2OtherSource'; $this->assertEquals($expected, $connections['connection5']); ConnectionManager::drop('connection5'); - ConnectionManager::create('connection6', array('datasource' => 'Test2OtherSource')); + ConnectionManager::create('connection6', ['datasource' => 'Test2OtherSource']); $connections = ConnectionManager::enumConnectionObjects(); $this->assertEquals($expected, $connections['connection6']); ConnectionManager::drop('connection6'); - ConnectionManager::create('connection7', array('datasource' => 'TestPlugin.TestOtherSource')); + ConnectionManager::create('connection7', ['datasource' => 'TestPlugin.TestOtherSource']); $connections = ConnectionManager::enumConnectionObjects(); $expected['datasource'] = 'TestPlugin.TestOtherSource'; $this->assertEquals($expected, $connections['connection7']); ConnectionManager::drop('connection7'); - ConnectionManager::create('connection8', array('datasource' => 'TestPlugin.TestOtherSource')); + ConnectionManager::create('connection8', ['datasource' => 'TestPlugin.TestOtherSource']); $connections = ConnectionManager::enumConnectionObjects(); $this->assertEquals($expected, $connections['connection8']); ConnectionManager::drop('connection8'); @@ -329,14 +329,14 @@ public function testConnectionData() { * @return void */ public function testDrop() { - App::build(array( - 'Model/Datasource' => array( + App::build([ + 'Model/Datasource' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS . 'Datasource' . DS - ) - )); - ConnectionManager::create('droppable', array('datasource' => 'Test2Source')); + ] + ]); + ConnectionManager::create('droppable', ['datasource' => 'Test2Source']); $connections = ConnectionManager::enumConnectionObjects(); - $this->assertEquals(array('datasource' => 'Test2Source'), $connections['droppable']); + $this->assertEquals(['datasource' => 'Test2Source'], $connections['droppable']); $this->assertTrue(ConnectionManager::drop('droppable')); $connections = ConnectionManager::enumConnectionObjects(); diff --git a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php index 98e54a0912..d4d0ee5ebf 100644 --- a/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php @@ -77,7 +77,7 @@ class CakeSessionTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.session'); + public $fixtures = ['core.session']; /** * setup before class. @@ -107,13 +107,13 @@ public static function teardownAfterClass() : void { */ public function setUp() : void { parent::setUp(); - Configure::write('Session', array( + Configure::write('Session', [ 'defaults' => 'php', 'cookie' => 'cakephp', 'timeout' => 120, 'cookieTimeout' => 120, - 'ini' => array(), - )); + 'ini' => [], + ]); } /** @@ -137,15 +137,15 @@ public function tearDown() : void { public function testSessionConfigIniSetting() { $_SESSION = null; - Configure::write('Session', array( + Configure::write('Session', [ 'cookie' => 'test', 'checkAgent' => false, 'timeout' => 86400, - 'ini' => array( + 'ini' => [ 'session.referer_check' => 'example.com', 'session.use_trans_sid' => false - ) - )); + ] + ]); TestCakeSession::start(); $this->assertEquals('', ini_get('session.use_trans_sid'), 'Ini value is incorrect'); $this->assertEquals('example.com', ini_get('session.referer_check'), 'Ini value is incorrect'); @@ -257,12 +257,12 @@ public function testSimpleRead() { $result = TestCakeSession::read('testing'); $this->assertEquals('1,2,3', $result); - TestCakeSession::write('testing', array('1' => 'one', '2' => 'two', '3' => 'three')); + TestCakeSession::write('testing', ['1' => 'one', '2' => 'two', '3' => 'three']); $result = TestCakeSession::read('testing.1'); $this->assertEquals('one', $result); $result = TestCakeSession::read('testing'); - $this->assertEquals(array('1' => 'one', '2' => 'two', '3' => 'three'), $result); + $this->assertEquals(['1' => 'one', '2' => 'two', '3' => 'three'], $result); $result = TestCakeSession::read(); $this->assertTrue(isset($result['testing'])); @@ -289,15 +289,15 @@ public function testReadyEmpty() { * @return void */ public function testWriteArray() { - $result = TestCakeSession::write(array( + $result = TestCakeSession::write([ 'one' => 1, 'two' => 2, - 'three' => array('something'), + 'three' => ['something'], 'null' => null - )); + ]); $this->assertTrue($result); $this->assertEquals(1, TestCakeSession::read('one')); - $this->assertEquals(array('something'), TestCakeSession::read('three')); + $this->assertEquals(['something'], TestCakeSession::read('three')); $this->assertEquals(null, TestCakeSession::read('null')); } @@ -321,9 +321,9 @@ public function testWriteOverwriteStringValue() { TestCakeSession::write('Some.string', 'value'); $this->assertEquals('value', TestCakeSession::read('Some.string')); - TestCakeSession::write('Some.string.array', array('values')); + TestCakeSession::write('Some.string.array', ['values']); $this->assertEquals( - array('values'), + ['values'], TestCakeSession::read('Some.string.array') ); } @@ -335,7 +335,7 @@ public function testWriteOverwriteStringValue() { */ public function testConsume() { TestCakeSession::write('Some.string', 'value'); - TestCakeSession::write('Some.array', array('key1' => 'value1', 'key2' => 'value2')); + TestCakeSession::write('Some.array', ['key1' => 'value1', 'key2' => 'value2']); $this->assertEquals('value', TestCakeSession::read('Some.string')); $value = TestCakeSession::consume('Some.string'); $this->assertEquals('value', $value); @@ -345,7 +345,7 @@ public function testConsume() { $value = TestCakeSession::consume(null); $this->assertNull($value); $value = TestCakeSession::consume('Some.array'); - $expected = array('key1' => 'value1', 'key2' => 'value2'); + $expected = ['key1' => 'value1', 'key2' => 'value2']; $this->assertEquals($expected, $value); $this->assertFalse(TestCakeSession::check('Some.array')); } @@ -429,7 +429,7 @@ public function testClear() { TestCakeSession::clear(false); $this->assertNull(TestCakeSession::read('Some')); - TestCakeSession::write('Some.string.array', array('values')); + TestCakeSession::write('Some.string.array', ['values']); TestCakeSession::clear(false); $this->assertFalse(TestCakeSession::read()); } @@ -612,18 +612,18 @@ public function testReadAndWriteWithCakeStorage() { * @return void */ public function testUsingAppLibsHandler() { - App::build(array( - 'Model/Datasource/Session' => array( + App::build([ + 'Model/Datasource/Session' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS . 'Datasource' . DS . 'Session' . DS - ), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - Configure::write('Session', array( + ], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + Configure::write('Session', [ 'defaults' => 'cake', - 'handler' => array( + 'handler' => [ 'engine' => 'TestAppLibSession' - ) - )); + ] + ]); TestCakeSession::start(); $this->assertTrue(TestCakeSession::started()); @@ -640,17 +640,17 @@ public function testUsingAppLibsHandler() { * @return void */ public function testUsingPluginHandler() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); - Configure::write('Session', array( + Configure::write('Session', [ 'defaults' => 'cake', - 'handler' => array( + 'handler' => [ 'engine' => 'TestPlugin.TestPluginSession' - ) - )); + ] + ]); TestCakeSession::start(); $this->assertTrue(TestCakeSession::started()); @@ -707,10 +707,10 @@ public function testReadAndWriteWithCustomCacheConfig() { Configure::write('Session.handler.engine', 'TestCacheSession'); Configure::write('Session.handler.config', 'session_test'); - Cache::config('session_test', array( + Cache::config('session_test', [ 'engine' => 'File', 'prefix' => 'session_test_', - )); + ]); TestCakeSession::init(); TestCakeSession::start(); @@ -769,9 +769,9 @@ public function testReadAndWriteWithDatabaseStorage() { TestCakeSession::destroy(); $this->assertNull(TestCakeSession::read('SessionTestCase')); - Configure::write('Session', array( + Configure::write('Session', [ 'defaults' => 'php' - )); + ]); TestCakeSession::init(); } @@ -814,10 +814,10 @@ public function testSessionTimeout() { */ public function testCookieTimeoutFallback() { $_SESSION = null; - Configure::write('Session', array( + Configure::write('Session', [ 'defaults' => 'cake', 'timeout' => 400, - )); + ]); TestCakeSession::start(); $this->assertEquals(400, Configure::read('Session.cookieTimeout')); $this->assertEquals(400, Configure::read('Session.timeout')); @@ -825,11 +825,11 @@ public function testCookieTimeoutFallback() { $this->assertEquals(400 * 60, ini_get('session.gc_maxlifetime')); $_SESSION = null; - Configure::write('Session', array( + Configure::write('Session', [ 'defaults' => 'cake', 'timeout' => 400, 'cookieTimeout' => 600 - )); + ]); TestCakeSession::start(); $this->assertEquals(600, Configure::read('Session.cookieTimeout')); $this->assertEquals(400, Configure::read('Session.timeout')); diff --git a/lib/Cake/Test/Case/Model/Datasource/DataSourceTest.php b/lib/Cake/Test/Case/Model/Datasource/DataSourceTest.php index 846be3d87b..95d93083c7 100644 --- a/lib/Cake/Test/Case/Model/Datasource/DataSourceTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/DataSourceTest.php @@ -30,36 +30,36 @@ class TestSource extends DataSource { * _schema * @var type */ - protected $_schema = array( - 'id' => array( + protected $_schema = [ + 'id' => [ 'type' => 'integer', 'null' => false, 'key' => 'primary', 'length' => 11, - ), - 'text' => array( + ], + 'text' => [ 'type' => 'string', 'null' => true, 'length' => 140, - ), - 'status' => array( + ], + 'status' => [ 'type' => 'string', 'null' => true, 'length' => 140, - ), - 'customField' => array( + ], + 'customField' => [ 'type' => 'string', 'null' => true, 'length' => 255, - ), - ); + ], + ]; /** * listSources * * @return bool */ - public function listSources() { + public function listSources($data = \null) { return null; } @@ -82,7 +82,7 @@ public function describe(Model $Model) { * @param type $params * @return array */ - public function calculate(Model $Model, $func, $params = array()) { + public function calculate(Model $Model, $func, $params = []) { return $func; } @@ -111,16 +111,16 @@ public function setUp() : void { parent::setUp(); $this->Source = $this->getMock( 'TestSource', - array('create', 'read', 'update', 'delete') + ['create', 'read', 'update', 'delete'] ); - ConnectionManager::create($this->sourceName, array( - 'datasource' => get_class($this->Source), + ConnectionManager::create($this->sourceName, [ + 'datasource' => $this->Source::class, 'apiKey' => '1234abcd', - )); + ]); $this->Model = $this->getMock( 'Model', - array('getDataSource'), - array(array('ds' => $this->sourceName)) + ['getDataSource'], + [['ds' => $this->sourceName]] ); $this->Model->expects($this->any()) ->method('getDataSource') @@ -144,16 +144,16 @@ public function tearDown() : void { * @return void */ public function testCreate() { - $data = array( - $this->Model->alias => array( + $data = [ + $this->Model->alias => [ 'text' => 'This is a test', 'status' => 'Test status', - 'customField' => array( + 'customField' => [ 'array', 'field', 'type', 'for', 'custom', 'datasources', - ), - ), - ); + ], + ], + ]; $this->Source->expects($this->once()) ->method('create') ->with( @@ -170,28 +170,28 @@ public function testCreate() { * @return void */ public function testRead() { - $expected = array( - 'conditions' => array('status' => 'test'), + $expected = [ + 'conditions' => ['status' => 'test'], 'fields' => null, - 'joins' => array(), + 'joins' => [], 'limit' => 10, 'offset' => null, - 'order' => array(array('status')), + 'order' => [['status']], 'page' => 1, 'group' => null, 'callbacks' => true, - ); + ]; $this->Source->expects($this->once()) ->method('read') ->with( $this->anything(), $this->equalTo($expected) ); - $this->Model->find('all', array( - 'conditions' => array('status' => 'test'), + $this->Model->find('all', [ + 'conditions' => ['status' => 'test'], 'limit' => 10, - 'order' => array('status'), - )); + 'order' => ['status'], + ]); } /** @@ -200,22 +200,22 @@ public function testRead() { * @return void */ public function testUpdate() { - $data = array( - $this->Model->alias => array( + $data = [ + $this->Model->alias => [ 'id' => 1, 'text' => 'This is a test', 'status' => 'Test status', - 'customField' => array( + 'customField' => [ 'array', 'field', 'type', 'for', 'custom', 'datasources', - ), - ), - ); + ], + ], + ]; $this->Source->expects($this->any()) ->method('read') - ->will($this->returnValue(array( - array($this->Model->alias => array('count' => 1)) - ))); + ->will($this->returnValue([ + [$this->Model->alias => ['count' => 1]] + ])); $this->Source->expects($this->once()) ->method('update') ->with( @@ -234,14 +234,14 @@ public function testUpdate() { public function testDelete() { $this->Source->expects($this->any()) ->method('read') - ->will($this->returnValue(array( - array($this->Model->alias => array('count' => 1)) - ))); + ->will($this->returnValue([ + [$this->Model->alias => ['count' => 1]] + ])); $this->Source->expects($this->once()) ->method('delete') ->with( $this->equalTo($this->Model), - $this->equalTo(array($this->Model->alias . '.id' => 1)) + $this->equalTo([$this->Model->alias . '.id' => 1]) ); $this->Model->delete(1); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php index ed44627dae..b9712428af 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php @@ -21,7 +21,7 @@ App::uses('Mysql', 'Model/Datasource/Database'); App::uses('CakeSchema', 'Model'); -require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php'; +require_once dirname(__FILE__, 3) . DS . 'models.php'; /** * DboMysqlTest class @@ -42,11 +42,11 @@ class MysqlTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.apple', 'core.article', 'core.articles_tag', 'core.attachment', 'core.comment', 'core.sample', 'core.tag', 'core.user', 'core.post', 'core.author', 'core.data_test', 'core.binary_test', 'core.inno', 'core.unsigned' - ); + ]; /** * The Dbo instance to be tested @@ -91,7 +91,7 @@ public function tearDown() : void { */ public function testQuoting() { $result = $this->Dbo->fields($this->model); - $expected = array( + $expected = [ '`MysqlTestModel`.`id`', '`MysqlTestModel`.`client_id`', '`MysqlTestModel`.`name`', @@ -110,7 +110,7 @@ public function testQuoting() { '`MysqlTestModel`.`last_login`', '`MysqlTestModel`.`created`', '`MysqlTestModel`.`updated`' - ); + ]; $this->assertEquals($expected, $result); $expected = 1.2; @@ -203,27 +203,27 @@ public function testTinyintCasting() { $tableName = 'tinyint_' . uniqid(); $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), tiny_int tinyint(2), primary key(id));'); - $this->model = new CakeTestModel(array( + $this->model = new CakeTestModel([ 'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test' - )); + ]); $result = $this->model->schema(); $this->assertEquals('boolean', $result['bool']['type']); $this->assertEquals('tinyinteger', $result['tiny_int']['type']); - $this->assertTrue((bool)$this->model->save(array('bool' => 5, 'tiny_int' => 5))); + $this->assertTrue((bool)$this->model->save(['bool' => 5, 'tiny_int' => 5])); $result = $this->model->find('first'); $this->assertTrue($result['Tinyint']['bool']); $this->assertEquals($result['Tinyint']['tiny_int'], '5'); $this->model->deleteAll(true); - $this->assertTrue((bool)$this->model->save(array('bool' => 0, 'tiny_int' => 100))); + $this->assertTrue((bool)$this->model->save(['bool' => 0, 'tiny_int' => 100])); $result = $this->model->find('first'); $this->assertFalse($result['Tinyint']['bool']); $this->assertEquals($result['Tinyint']['tiny_int'], '100'); $this->model->deleteAll(true); - $this->assertTrue((bool)$this->model->save(array('bool' => true, 'tiny_int' => 0))); + $this->assertTrue((bool)$this->model->save(['bool' => true, 'tiny_int' => 0])); $result = $this->model->find('first'); $this->assertTrue($result['Tinyint']['bool']); $this->assertEquals($result['Tinyint']['tiny_int'], '0'); @@ -242,11 +242,11 @@ public function testLastAffected() { $tableName = 'tinyint_' . uniqid(); $this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); - $this->model = new CakeTestModel(array( + $this->model = new CakeTestModel([ 'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test' - )); + ]); - $this->assertTrue((bool)$this->model->save(array('bool' => 5, 'small_int' => 5))); + $this->assertTrue((bool)$this->model->save(['bool' => 5, 'small_int' => 5])); $this->assertEquals(1, $this->model->find('count')); $this->model->deleteAll(true); $result = $this->Dbo->lastAffected(); @@ -267,91 +267,91 @@ public function testIndexDetection() { $name = $this->Dbo->fullTableName('simple'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); - $expected = array('PRIMARY' => array('column' => 'id', 'unique' => 1)); - $result = $this->Dbo->index('simple', false); + $expected = ['PRIMARY' => ['column' => 'id', 'unique' => 1]]; + $result = $this->Dbo->index('simple'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); $name = $this->Dbo->fullTableName('bigint'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id bigint(20) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));'); - $expected = array('PRIMARY' => array('column' => 'id', 'unique' => 1)); - $result = $this->Dbo->index('bigint', false); + $expected = ['PRIMARY' => ['column' => 'id', 'unique' => 1]]; + $result = $this->Dbo->index('bigint'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); $name = $this->Dbo->fullTableName('with_a_key'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - ); - $result = $this->Dbo->index('with_a_key', false); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'pointless_bool' => ['column' => 'bool', 'unique' => 0], + ]; + $result = $this->Dbo->index('with_a_key'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); $name = $this->Dbo->fullTableName('with_two_keys'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), - ); - $result = $this->Dbo->index('with_two_keys', false); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'pointless_bool' => ['column' => 'bool', 'unique' => 0], + 'pointless_small_int' => ['column' => 'small_int', 'unique' => 0], + ]; + $result = $this->Dbo->index('with_two_keys'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); $name = $this->Dbo->fullTableName('with_compound_keys'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), - 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), - ); - $result = $this->Dbo->index('with_compound_keys', false); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'pointless_bool' => ['column' => 'bool', 'unique' => 0], + 'pointless_small_int' => ['column' => 'small_int', 'unique' => 0], + 'one_way' => ['column' => ['bool', 'small_int'], 'unique' => 0], + ]; + $result = $this->Dbo->index('with_compound_keys'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); $name = $this->Dbo->fullTableName('with_multiple_compound_keys'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ), KEY `other_way` ( `small_int`, `bool` ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), - 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), - 'other_way' => array('column' => array('small_int', 'bool'), 'unique' => 0), - ); - $result = $this->Dbo->index('with_multiple_compound_keys', false); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'pointless_bool' => ['column' => 'bool', 'unique' => 0], + 'pointless_small_int' => ['column' => 'small_int', 'unique' => 0], + 'one_way' => ['column' => ['bool', 'small_int'], 'unique' => 0], + 'other_way' => ['column' => ['small_int', 'bool'], 'unique' => 0], + ]; + $result = $this->Dbo->index('with_multiple_compound_keys'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); $name = $this->Dbo->fullTableName('with_fulltext'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, name varchar(255), description text, primary key(id), FULLTEXT KEY `MyFtIndex` ( `name`, `description` )) ENGINE=MyISAM;'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'MyFtIndex' => array('column' => array('name', 'description'), 'type' => 'fulltext') - ); - $result = $this->Dbo->index('with_fulltext', false); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'MyFtIndex' => ['column' => ['name', 'description'], 'type' => 'fulltext'] + ]; + $result = $this->Dbo->index('with_fulltext'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); $name = $this->Dbo->fullTableName('with_text_index'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, text_field text, primary key(id), KEY `text_index` ( `text_field`(20) ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'text_index' => array('column' => 'text_field', 'unique' => 0, 'length' => array('text_field' => 20)), - ); - $result = $this->Dbo->index('with_text_index', false); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'text_index' => ['column' => 'text_field', 'unique' => 0, 'length' => ['text_field' => 20]], + ]; + $result = $this->Dbo->index('with_text_index'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); $name = $this->Dbo->fullTableName('with_compound_text_index'); $this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, text_field1 text, text_field2 text, primary key(id), KEY `text_index` ( `text_field1`(20), `text_field2`(20) ));'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'text_index' => array('column' => array('text_field1', 'text_field2'), 'unique' => 0, 'length' => array('text_field1' => 20, 'text_field2' => 20)), - ); - $result = $this->Dbo->index('with_compound_text_index', false); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'text_index' => ['column' => ['text_field1', 'text_field2'], 'unique' => 0, 'length' => ['text_field1' => 20, 'text_field2' => 20]], + ]; + $result = $this->Dbo->index('with_compound_text_index'); $this->Dbo->rawQuery('DROP TABLE ' . $name); $this->assertEquals($expected, $result); } @@ -366,9 +366,9 @@ public function testIndexDetection() { public function testIndexOnMySQL4Output() { $name = $this->Dbo->fullTableName('simple'); - $mockDbo = $this->getMock('Mysql', array('connect', '_execute', 'getVersion')); - $columnData = array( - array('0' => array( + $mockDbo = $this->getMock('Mysql', ['connect', '_execute', 'getVersion']); + $columnData = [ + ['0' => [ 'Table' => 'with_compound_keys', 'Non_unique' => '0', 'Key_name' => 'PRIMARY', @@ -381,8 +381,8 @@ public function testIndexOnMySQL4Output() { 'Null' => '', 'Index_type' => 'BTREE', 'Comment' => '' - )), - array('0' => array( + ]], + ['0' => [ 'Table' => 'with_compound_keys', 'Non_unique' => '1', 'Key_name' => 'pointless_bool', @@ -395,8 +395,8 @@ public function testIndexOnMySQL4Output() { 'Null' => 'YES', 'Index_type' => 'BTREE', 'Comment' => '' - )), - array('0' => array( + ]], + ['0' => [ 'Table' => 'with_compound_keys', 'Non_unique' => '1', 'Key_name' => 'pointless_small_int', @@ -409,8 +409,8 @@ public function testIndexOnMySQL4Output() { 'Null' => 'YES', 'Index_type' => 'BTREE', 'Comment' => '' - )), - array('0' => array( + ]], + ['0' => [ 'Table' => 'with_compound_keys', 'Non_unique' => '1', 'Key_name' => 'one_way', @@ -423,8 +423,8 @@ public function testIndexOnMySQL4Output() { 'Null' => 'YES', 'Index_type' => 'BTREE', 'Comment' => '' - )), - array('0' => array( + ]], + ['0' => [ 'Table' => 'with_compound_keys', 'Non_unique' => '1', 'Key_name' => 'one_way', @@ -437,11 +437,11 @@ public function testIndexOnMySQL4Output() { 'Null' => 'YES', 'Index_type' => 'BTREE', 'Comment' => '' - )) - ); + ]] + ]; $mockDbo->expects($this->once())->method('getVersion')->will($this->returnValue('4.1')); - $resultMock = $this->getMock('PDOStatement', array('fetch', 'closeCursor')); + $resultMock = $this->getMock('PDOStatement', ['fetch', 'closeCursor']); $mockDbo->expects($this->once()) ->method('_execute') ->with('SHOW INDEX FROM ' . $name) @@ -452,12 +452,12 @@ public function testIndexOnMySQL4Output() { } $result = $mockDbo->index($name, false); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'pointless_small_int' => array('column' => 'small_int', 'unique' => 0), - 'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0), - ); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'pointless_bool' => ['column' => 'bool', 'unique' => 0], + 'pointless_small_int' => ['column' => 'small_int', 'unique' => 0], + 'one_way' => ['column' => ['bool', 'small_int'], 'unique' => 0], + ]; $this->assertEquals($expected, $result); } @@ -542,15 +542,15 @@ public function testAlterSchemaIndexes() { $this->Dbo->cacheSources = $this->Dbo->testing = false; $table = $this->Dbo->fullTableName('altertest'); - $schemaA = new CakeSchema(array( + $schemaA = new CakeSchema([ 'name' => 'AlterTest1', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'group1' => array('type' => 'integer', 'null' => true), - 'group2' => array('type' => 'integer', 'null' => true) - ))); + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + 'group1' => ['type' => 'integer', 'null' => true], + 'group2' => ['type' => 'integer', 'null' => true] + ]]); $result = $this->Dbo->createSchema($schemaA); $this->assertStringContainsString('`id` int(11) DEFAULT 0 NOT NULL,', $result); $this->assertStringContainsString('`name` varchar(50) NOT NULL,', $result); @@ -561,20 +561,20 @@ public function testAlterSchemaIndexes() { $query = $this->Dbo->getConnection()->prepare($result); $this->assertEquals($query->queryString, $result); - $schemaB = new CakeSchema(array( + $schemaB = new CakeSchema([ 'name' => 'AlterTest2', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'group1' => array('type' => 'integer', 'null' => true), - 'group2' => array('type' => 'integer', 'null' => true), - 'indexes' => array( - 'name_idx' => array('column' => 'name', 'unique' => 0), - 'group_idx' => array('column' => 'group1', 'unique' => 0), - 'compound_idx' => array('column' => array('group1', 'group2'), 'unique' => 0), - 'PRIMARY' => array('column' => 'id', 'unique' => 1)) - ))); + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + 'group1' => ['type' => 'integer', 'null' => true], + 'group2' => ['type' => 'integer', 'null' => true], + 'indexes' => [ + 'name_idx' => ['column' => 'name', 'unique' => 0], + 'group_idx' => ['column' => 'group1', 'unique' => 0], + 'compound_idx' => ['column' => ['group1', 'group2'], 'unique' => 0], + 'PRIMARY' => ['column' => 'id', 'unique' => 1]] + ]]); $result = $this->Dbo->alterSchema($schemaB->compare($schemaA)); $this->assertStringContainsString("ALTER TABLE $table", $result); @@ -588,20 +588,20 @@ public function testAlterSchemaIndexes() { $this->assertEquals($query->queryString, $result); // Change three indexes, delete one and add another one - $schemaC = new CakeSchema(array( + $schemaC = new CakeSchema([ 'name' => 'AlterTest3', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'group1' => array('type' => 'integer', 'null' => true), - 'group2' => array('type' => 'integer', 'null' => true), - 'indexes' => array( - 'name_idx' => array('column' => 'name', 'unique' => 1), - 'group_idx' => array('column' => 'group2', 'unique' => 0), - 'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => 0), - 'id_name_idx' => array('column' => array('id', 'name'), 'unique' => 0)) - ))); + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + 'group1' => ['type' => 'integer', 'null' => true], + 'group2' => ['type' => 'integer', 'null' => true], + 'indexes' => [ + 'name_idx' => ['column' => 'name', 'unique' => 1], + 'group_idx' => ['column' => 'group2', 'unique' => 0], + 'compound_idx' => ['column' => ['group2', 'group1'], 'unique' => 0], + 'id_name_idx' => ['column' => ['id', 'name'], 'unique' => 0]] + ]]); $result = $this->Dbo->alterSchema($schemaC->compare($schemaB)); $this->assertStringContainsString("ALTER TABLE $table", $result); @@ -618,7 +618,7 @@ public function testAlterSchemaIndexes() { $this->assertEquals($query->queryString, $result); // Compare us to ourself. - $this->assertEquals(array(), $schemaC->compare($schemaC)); + $this->assertEquals([], $schemaC->compare($schemaC)); // Drop the indexes $result = $this->Dbo->alterSchema($schemaA->compare($schemaC)); @@ -643,7 +643,7 @@ public function testBlobSaving() { $this->Dbo->cacheSources = false; $data = file_get_contents(CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif'); - $model = new CakeTestModel(array('name' => 'BinaryTest', 'ds' => 'test')); + $model = new CakeTestModel(['name' => 'BinaryTest', 'ds' => 'test']); $model->save(compact('data')); $result = $model->find('first'); @@ -658,34 +658,34 @@ public function testBlobSaving() { public function testAlteringTableParameters() { $this->Dbo->cacheSources = $this->Dbo->testing = false; - $schemaA = new CakeSchema(array( + $schemaA = new CakeSchema([ 'name' => 'AlterTest1', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'tableParameters' => array( + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + 'tableParameters' => [ 'charset' => 'latin1', 'collate' => 'latin1_general_ci', 'engine' => 'MyISAM' - ) - ) - )); + ] + ] + ]); $this->Dbo->rawQuery($this->Dbo->createSchema($schemaA)); - $schemaB = new CakeSchema(array( + $schemaB = new CakeSchema([ 'name' => 'AlterTest1', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'tableParameters' => array( + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + 'tableParameters' => [ 'charset' => 'utf8', 'collate' => 'utf8_general_ci', 'engine' => 'InnoDB', 'comment' => 'Newly table added comment.', - ) - ) - )); + ] + ] + ]); $result = $this->Dbo->alterSchema($schemaB->compare($schemaA)); $this->assertStringContainsString('DEFAULT CHARSET=utf8', $result); $this->assertStringContainsString('ENGINE=InnoDB', $result); @@ -707,30 +707,30 @@ public function testAlteringTableParameters() { * @return void */ public function testAlteringTwoTables() { - $schema1 = new CakeSchema(array( + $schema1 = new CakeSchema([ 'name' => 'AlterTest1', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - ), - 'other_table' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - ) - )); - $schema2 = new CakeSchema(array( + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + ], + 'other_table' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + ] + ]); + $schema2 = new CakeSchema([ 'name' => 'AlterTest1', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50), - ), - 'other_table' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50), - ) - )); + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'field_two' => ['type' => 'string', 'null' => false, 'length' => 50], + ], + 'other_table' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'field_two' => ['type' => 'string', 'null' => false, 'length' => 50], + ] + ]); $result = $this->Dbo->alterSchema($schema2->compare($schema1)); $this->assertEquals(2, substr_count($result, 'field_two'), 'Too many fields'); } @@ -747,22 +747,22 @@ public function testReadTableParameters() { $this->Dbo->rawQuery('CREATE TABLE ' . $table . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'); $result = $this->Dbo->readTableParameters($this->Dbo->fullTableName($tableName, false, false)); $this->Dbo->rawQuery('DROP TABLE ' . $table); - $expected = array( + $expected = [ 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci', - 'engine' => 'InnoDB'); + 'engine' => 'InnoDB']; $this->assertEquals($expected, $result); $table = $this->Dbo->fullTableName($tableName); $this->Dbo->rawQuery('CREATE TABLE ' . $table . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci COMMENT=\'Table\'\'s comment\';'); $result = $this->Dbo->readTableParameters($this->Dbo->fullTableName($tableName, false, false)); $this->Dbo->rawQuery('DROP TABLE ' . $table); - $expected = array( + $expected = [ 'charset' => 'cp1250', 'collate' => 'cp1250_general_ci', 'engine' => 'MyISAM', 'comment' => 'Table\'s comment', - ); + ]; $this->assertEquals($expected, $result); } @@ -773,15 +773,15 @@ public function testReadTableParameters() { */ public function testBuildTableParameters() { $this->Dbo->cacheSources = $this->Dbo->testing = false; - $data = array( + $data = [ 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci', - 'engine' => 'InnoDB'); + 'engine' => 'InnoDB']; $result = $this->Dbo->buildTableParameters($data); - $expected = array( + $expected = [ 'DEFAULT CHARSET=utf8', 'COLLATE=utf8_unicode_ci', - 'ENGINE=InnoDB'); + 'ENGINE=InnoDB']; $this->assertEquals($expected, $result); } @@ -804,20 +804,20 @@ public function testGetCharsetName() { * @return void */ public function testGetCharsetNameCaching() { - $db = $this->getMock('Mysql', array('connect', '_execute', 'getVersion')); + $db = $this->getMock('Mysql', ['connect', '_execute', 'getVersion']); $queryResult = $this->getMock('PDOStatement'); $db->expects($this->exactly(2))->method('getVersion')->will($this->returnValue('5.1')); $db->expects($this->exactly(1)) ->method('_execute') - ->with('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?', array('utf8_unicode_ci')) + ->with('SELECT CHARACTER_SET_NAME FROM INFORMATION_SCHEMA.COLLATIONS WHERE COLLATION_NAME = ?', ['utf8_unicode_ci']) ->will($this->returnValue($queryResult)); $queryResult->expects($this->once()) ->method('fetch') ->with(PDO::FETCH_ASSOC) - ->will($this->returnValue(array('CHARACTER_SET_NAME' => 'utf8'))); + ->will($this->returnValue(['CHARACTER_SET_NAME' => 'utf8'])); $result = $db->getCharsetName('utf8_unicode_ci'); $this->assertEquals('utf8', $result); @@ -833,15 +833,15 @@ public function testGetCharsetNameCaching() { */ public function testVirtualFieldSeparators() { $this->loadFixtures('BinaryTest'); - $model = new CakeTestModel(array('table' => 'binary_tests', 'ds' => 'test', 'name' => 'BinaryTest')); - $model->virtualFields = array( + $model = new CakeTestModel(['table' => 'binary_tests', 'ds' => 'test', 'name' => 'BinaryTest']); + $model->virtualFields = [ 'other__field' => 'SUM(id)' - ); + ]; $this->Dbo->virtualFieldSeparator = '_$_'; - $result = $this->Dbo->fields($model, null, array('data', 'other__field')); + $result = $this->Dbo->fields($model, null, ['data', 'other__field']); - $expected = array('`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`'); + $expected = ['`BinaryTest`.`data`', '(SUM(id)) AS `BinaryTest_$_other__field`']; $this->assertEquals($expected, $result); } @@ -881,20 +881,20 @@ public function testDescribeHandleCurrentTimestamp() { ); SQL; $this->Dbo->execute($sql); - $model = new Model(array( + $model = new Model([ 'table' => 'timestamp_default_values', 'ds' => 'test', 'alias' => 'TimestampDefaultValue' - )); + ]); $result = $this->Dbo->describe($model); $this->Dbo->execute('DROP TABLE ' . $name); $this->assertNull($result['limit_date']['default']); - $schema = new CakeSchema(array( + $schema = new CakeSchema([ 'connection' => 'test', 'testdescribes' => $result - )); + ]); $result = $this->Dbo->createSchema($schema); $this->assertStringContainsString('`limit_date` timestamp NOT NULL,', $result); } @@ -919,20 +919,20 @@ public function testDescribeHandleCurrentTimestampDatetime() { ); SQL; $this->Dbo->execute($sql); - $model = new Model(array( + $model = new Model([ 'table' => 'timestamp_default_values', 'ds' => 'test', 'alias' => 'TimestampDefaultValue' - )); + ]); $result = $this->Dbo->describe($model); $this->Dbo->execute('DROP TABLE ' . $name); $this->assertNull($result['limit_date']['default']); - $schema = new CakeSchema(array( + $schema = new CakeSchema([ 'connection' => 'test', 'testdescribes' => $result - )); + ]); $result = $this->Dbo->createSchema($schema); $this->assertStringContainsString('`limit_date` datetime NOT NULL,', $result); } @@ -943,27 +943,27 @@ public function testDescribeHandleCurrentTimestampDatetime() { * @return void */ public function testDescribeGettingFieldParameters() { - $schema = new CakeSchema(array( + $schema = new CakeSchema([ 'connection' => 'test', - 'testdescribes' => array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'stringy' => array( + 'testdescribes' => [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'stringy' => [ 'type' => 'string', 'null' => true, 'charset' => 'cp1250', 'collate' => 'cp1250_general_ci', - ), - 'other_col' => array( + ], + 'other_col' => [ 'type' => 'string', 'null' => false, 'charset' => 'latin1', 'comment' => 'Test Comment' - ) - ) - )); + ] + ] + ]); $this->Dbo->execute($this->Dbo->createSchema($schema)); - $model = new CakeTestModel(array('table' => 'testdescribes', 'name' => 'Testdescribes')); + $model = new CakeTestModel(['table' => 'testdescribes', 'name' => 'Testdescribes']); $result = $model->getDataSource()->describe($model); $this->Dbo->execute($this->Dbo->dropSchema($schema)); @@ -978,33 +978,33 @@ public function testDescribeGettingFieldParameters() { * @return void */ public function testTwoColumnsWithPrimaryKey() { - $schema = new CakeSchema(array( + $schema = new CakeSchema([ 'connection' => 'test', - 'roles_users' => array( - 'role_id' => array( + 'roles_users' => [ + 'role_id' => [ 'type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary' - ), - 'user_id' => array( + ], + 'user_id' => [ 'type' => 'integer', 'null' => false, 'default' => null, 'key' => 'primary' - ), - 'indexes' => array( - 'user_role_index' => array( - 'column' => array('role_id', 'user_id'), + ], + 'indexes' => [ + 'user_role_index' => [ + 'column' => ['role_id', 'user_id'], 'unique' => 1 - ), - 'user_index' => array( + ], + 'user_index' => [ 'column' => 'user_id', 'unique' => 0 - ) - ), - ) - )); + ] + ], + ] + ]); $result = $this->Dbo->createSchema($schema); $this->assertStringContainsString('`role_id` int(11) NOT NULL,', $result); @@ -1018,40 +1018,40 @@ public function testTwoColumnsWithPrimaryKey() { */ public function testCreateSchemaAutoPrimaryKey() { $schema = new CakeSchema(); - $schema->tables = array( - 'no_indexes' => array( - 'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'), - 'data' => array('type' => 'integer', 'null' => false), - 'indexes' => array(), - ) - ); + $schema->tables = [ + 'no_indexes' => [ + 'id' => ['type' => 'integer', 'null' => false, 'key' => 'primary'], + 'data' => ['type' => 'integer', 'null' => false], + 'indexes' => [], + ] + ]; $result = $this->Dbo->createSchema($schema, 'no_indexes'); $this->assertStringContainsString('PRIMARY KEY (`id`)', $result); $this->assertStringNotContainsString('UNIQUE KEY', $result); - $schema->tables = array( - 'primary_index' => array( - 'id' => array('type' => 'integer', 'null' => false), - 'data' => array('type' => 'integer', 'null' => false), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'some_index' => array('column' => 'data', 'unique' => 1) - ), - ) - ); + $schema->tables = [ + 'primary_index' => [ + 'id' => ['type' => 'integer', 'null' => false], + 'data' => ['type' => 'integer', 'null' => false], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'some_index' => ['column' => 'data', 'unique' => 1] + ], + ] + ]; $result = $this->Dbo->createSchema($schema, 'primary_index'); $this->assertStringContainsString('PRIMARY KEY (`id`)', $result); $this->assertStringContainsString('UNIQUE KEY `some_index` (`data`)', $result); - $schema->tables = array( - 'primary_flag_has_index' => array( - 'id' => array('type' => 'integer', 'null' => false, 'key' => 'primary'), - 'data' => array('type' => 'integer', 'null' => false), - 'indexes' => array( - 'some_index' => array('column' => 'data', 'unique' => 1) - ), - ) - ); + $schema->tables = [ + 'primary_flag_has_index' => [ + 'id' => ['type' => 'integer', 'null' => false, 'key' => 'primary'], + 'data' => ['type' => 'integer', 'null' => false], + 'indexes' => [ + 'some_index' => ['column' => 'data', 'unique' => 1] + ], + ] + ]; $result = $this->Dbo->createSchema($schema, 'primary_flag_has_index'); $this->assertStringContainsString('PRIMARY KEY (`id`)', $result); $this->assertStringContainsString('UNIQUE KEY `some_index` (`data`)', $result); @@ -1062,7 +1062,7 @@ public function testCreateSchemaAutoPrimaryKey() { * @return void */ public function testListSources() { - $db = $this->getMock('Mysql', array('connect', '_execute')); + $db = $this->getMock('Mysql', ['connect', '_execute']); $queryResult = $this->getMock('PDOStatement'); $db->expects($this->once()) ->method('_execute') @@ -1070,16 +1070,16 @@ public function testListSources() { ->will($this->returnValue($queryResult)); $queryResult->expects($this->at(0)) ->method('fetch') - ->will($this->returnValue(array('cake_table'))); + ->will($this->returnValue(['cake_table'])); $queryResult->expects($this->at(1)) ->method('fetch') - ->will($this->returnValue(array('another_table'))); + ->will($this->returnValue(['another_table'])); $queryResult->expects($this->at(2)) ->method('fetch') ->will($this->returnValue(null)); $tables = $db->listSources(); - $this->assertEquals(array('cake_table', 'another_table'), $tables); + $this->assertEquals(['cake_table', 'another_table'], $tables); } /** @@ -1091,7 +1091,7 @@ public function testListDetailedSourcesNamed() { $this->loadFixtures('Apple'); $result = $this->Dbo->listDetailedSources('imaginary'); - $this->assertEquals(array(), $result, 'Should be empty when table does not exist.'); + $this->assertEquals([], $result, 'Should be empty when table does not exist.'); $result = $this->Dbo->listDetailedSources(); $tableName = $this->Dbo->fullTableName('apples', false, false); @@ -1112,12 +1112,12 @@ public function testGetVersion() { * @return void */ public function testGetEncoding() { - $db = $this->getMock('Mysql', array('connect', '_execute')); + $db = $this->getMock('Mysql', ['connect', '_execute']); $queryResult = $this->getMock('PDOStatement'); $db->expects($this->once()) ->method('_execute') - ->with('SHOW VARIABLES LIKE ?', array('character_set_client')) + ->with('SHOW VARIABLES LIKE ?', ['character_set_client']) ->will($this->returnValue($queryResult)); $result = new StdClass; $result->Value = 'utf-8'; @@ -1136,10 +1136,10 @@ public function testGetEncoding() { */ public function testFieldDoubleEscaping() { $db = $this->Dbo->config['database']; - $test = $this->getMock('Mysql', array('connect', '_execute', 'execute')); + $test = $this->getMock('Mysql', ['connect', '_execute', 'execute']); $test->config['database'] = $db; - $this->Model = $this->getMock('Article2', array('getDataSource')); + $this->Model = $this->getMock('Article2', ['getDataSource']); $this->Model->alias = 'Article'; $this->Model->expects($this->any()) ->method('getDataSource') @@ -1147,31 +1147,31 @@ public function testFieldDoubleEscaping() { $this->assertEquals('`Article`.`id`', $this->Model->escapeField()); $result = $test->fields($this->Model, null, $this->Model->escapeField()); - $this->assertEquals(array('`Article`.`id`'), $result); + $this->assertEquals(['`Article`.`id`'], $result); $test->expects($this->at(0))->method('execute') ->with('SELECT `Article`.`id` FROM ' . $test->fullTableName('articles') . ' AS `Article` WHERE 1 = 1'); - $result = $test->read($this->Model, array( + $result = $test->read($this->Model, [ 'fields' => $this->Model->escapeField(), 'conditions' => null, 'recursive' => -1 - )); + ]); $test->startQuote = '['; $test->endQuote = ']'; $this->assertEquals('[Article].[id]', $this->Model->escapeField()); $result = $test->fields($this->Model, null, $this->Model->escapeField()); - $this->assertEquals(array('[Article].[id]'), $result); + $this->assertEquals(['[Article].[id]'], $result); $test->expects($this->at(0))->method('execute') ->with('SELECT [Article].[id] FROM ' . $test->fullTableName('articles') . ' AS [Article] WHERE 1 = 1'); - $result = $test->read($this->Model, array( + $result = $test->read($this->Model, [ 'fields' => $this->Model->escapeField(), 'conditions' => null, 'recursive' => -1 - )); + ]); } /** @@ -1180,7 +1180,7 @@ public function testFieldDoubleEscaping() { * @return void */ public function testGenerateAssociationQuerySelfJoin() { - $this->Dbo = $this->getMock('Mysql', array('connect', '_execute', 'execute')); + $this->Dbo = $this->getMock('Mysql', ['connect', '_execute', 'execute']); $this->startTime = microtime(true); $this->Model = new Article2(); $this->_buildRelatedModels($this->Model); @@ -1188,7 +1188,7 @@ public function testGenerateAssociationQuerySelfJoin() { $this->Model->Category2->ChildCat = new Category2(); $this->Model->Category2->ParentCat = new Category2(); - $queryData = array(); + $queryData = []; foreach ($this->Model->Category2->associations() as $type) { foreach ($this->Model->Category2->{$type} as $assoc => $assocData) { @@ -1217,8 +1217,8 @@ public function testGenerateAssociationQuerySelfJoin() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'belongsTo', 'model' => 'TestModel4Parent'); - $queryData = array(); + $binding = ['type' => 'belongsTo', 'model' => 'TestModel4Parent']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1226,9 +1226,9 @@ public function testGenerateAssociationQuerySelfJoin() { $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external']); $this->assertTrue($result); - $expected = array( - 'conditions' => array(), - 'fields' => array( + $expected = [ + 'conditions' => [], + 'fields' => [ '`TestModel4`.`id`', '`TestModel4`.`name`', '`TestModel4`.`created`', @@ -1237,23 +1237,23 @@ public function testGenerateAssociationQuerySelfJoin() { '`TestModel4Parent`.`name`', '`TestModel4Parent`.`created`', '`TestModel4Parent`.`updated`' - ), - 'joins' => array( - array( + ], + 'joins' => [ + [ 'table' => $this->Dbo->fullTableName($this->Model), 'alias' => 'TestModel4Parent', 'type' => 'LEFT', 'conditions' => '`TestModel4`.`parent_id` = `TestModel4Parent`.`id`' - ) - ), - 'order' => array(), - 'limit' => array(), - 'offset' => array(), - 'group' => array(), + ] + ], + 'order' => [], + 'limit' => [], + 'offset' => [], + 'group' => [], 'having' => null, 'lock' => null, 'callbacks' => null - ); + ]; $queryData['joins'][0]['table'] = $this->Dbo->fullTableName($queryData['joins'][0]['table']); $this->assertEquals($expected, $queryData); @@ -1308,7 +1308,7 @@ protected function &_prepareAssociationQuery(Model $model, &$queryData, $binding $external = isset($assocData['external']); $queryData = $this->_scrubQueryData($queryData); - $result = array_merge(array('linkModel' => &$linkModel), compact('type', 'assoc', 'assocData', 'external')); + $result = array_merge(['linkModel' => &$linkModel], compact('type', 'assoc', 'assocData', 'external')); return $result; } @@ -1321,7 +1321,7 @@ protected function &_prepareAssociationQuery(Model $model, &$queryData, $binding protected function _scrubQueryData($data) { static $base = null; if ($base === null) { - $base = array_fill_keys(array('conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'), array()); + $base = array_fill_keys(['conditions', 'fields', 'joins', 'order', 'limit', 'offset', 'group'], []); $base['callbacks'] = null; } return (array)$data + $base; @@ -1334,15 +1334,15 @@ protected function _scrubQueryData($data) { */ public function testReadCustomJoinsAfterGeneratedJoins() { $db = $this->Dbo->config['database']; - $test = $this->getMock('Mysql', array('connect', '_execute', 'execute')); + $test = $this->getMock('Mysql', ['connect', '_execute', 'execute']); $test->config['database'] = $db; - $this->Model = $this->getMock('TestModel9', array('getDataSource')); + $this->Model = $this->getMock('TestModel9', ['getDataSource']); $this->Model->expects($this->any()) ->method('getDataSource') ->will($this->returnValue($test)); - $this->Model->TestModel8 = $this->getMock('TestModel8', array('getDataSource')); + $this->Model->TestModel8 = $this->getMock('TestModel8', ['getDataSource']); $this->Model->TestModel8->expects($this->any()) ->method('getDataSource') ->will($this->returnValue($test)); @@ -1357,17 +1357,17 @@ public function testReadCustomJoinsAfterGeneratedJoins() { $test->expects($this->at(0))->method('execute') ->with($this->stringContains($search)); - $test->read($this->Model, array( - 'joins' => array( - array( + $test->read($this->Model, [ + 'joins' => [ + [ 'table' => 'users', 'alias' => 'User', 'type' => 'LEFT', - 'conditions' => array('TestModel9.id = User.test_id') - ) - ), + 'conditions' => ['TestModel9.id = User.test_id'] + ] + ], 'recursive' => 1 - )); + ]); } /** @@ -1377,15 +1377,15 @@ public function testReadCustomJoinsAfterGeneratedJoins() { */ public function testGenerateInnerJoinAssociationQuery() { $db = $this->Dbo->config['database']; - $test = $this->getMock('Mysql', array('connect', '_execute', 'execute')); + $test = $this->getMock('Mysql', ['connect', '_execute', 'execute']); $test->config['database'] = $db; - $this->Model = $this->getMock('TestModel9', array('getDataSource')); + $this->Model = $this->getMock('TestModel9', ['getDataSource']); $this->Model->expects($this->any()) ->method('getDataSource') ->will($this->returnValue($test)); - $this->Model->TestModel8 = $this->getMock('TestModel8', array('getDataSource')); + $this->Model->TestModel8 = $this->getMock('TestModel8', ['getDataSource']); $this->Model->TestModel8->expects($this->any()) ->method('getDataSource') ->will($this->returnValue($test)); @@ -1398,9 +1398,9 @@ public function testGenerateInnerJoinAssociationQuery() { $test->expects($this->at(1))->method('execute') ->with($this->stringContains('TestModel9` INNER JOIN ' . $testModel8Table)); - $test->read($this->Model, array('recursive' => 1)); + $test->read($this->Model, ['recursive' => 1]); $this->Model->belongsTo['TestModel8']['type'] = 'INNER'; - $test->read($this->Model, array('recursive' => 1)); + $test->read($this->Model, ['recursive' => 1]); } /** @@ -1413,8 +1413,8 @@ public function testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBindin $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasOne', 'model' => 'TestModel9'); - $queryData = array(); + $binding = ['type' => 'hasOne', 'model' => 'TestModel9']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external']); @@ -1437,8 +1437,8 @@ public function testGenerateAssociationQuerySelfJoinWithConditionsInBelongsToBin $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'belongsTo', 'model' => 'TestModel8'); - $queryData = array(); + $binding = ['type' => 'belongsTo', 'model' => 'TestModel8']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); $result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external']); @@ -1461,8 +1461,8 @@ public function testGenerateAssociationQuerySelfJoinWithConditions() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'belongsTo', 'model' => 'TestModel4Parent'); - $queryData = array('conditions' => array('TestModel4Parent.name !=' => 'mariano')); + $binding = ['type' => 'belongsTo', 'model' => 'TestModel4Parent']; + $queryData = ['conditions' => ['TestModel4Parent.name !=' => 'mariano']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1478,19 +1478,19 @@ public function testGenerateAssociationQuerySelfJoinWithConditions() { $this->Featured2 = new Featured2(); $this->Featured2->schema(); - $this->Featured2->bindModel(array( - 'belongsTo' => array( - 'ArticleFeatured2' => array( + $this->Featured2->bindModel([ + 'belongsTo' => [ + 'ArticleFeatured2' => [ 'conditions' => 'ArticleFeatured2.published = \'Y\'', 'fields' => 'id, title, user_id, published' - ) - ) - )); + ] + ] + ]); $this->_buildRelatedModels($this->Featured2); - $binding = array('type' => 'belongsTo', 'model' => 'ArticleFeatured2'); - $queryData = array('conditions' => array()); + $binding = ['type' => 'belongsTo', 'model' => 'ArticleFeatured2']; + $queryData = ['conditions' => []]; $params = &$this->_prepareAssociationQuery($this->Featured2, $queryData, $binding); @@ -1518,9 +1518,9 @@ public function testGenerateAssociationQueryHasOne() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasOne', 'model' => 'TestModel5'); + $binding = ['type' => 'hasOne', 'model' => 'TestModel5']; - $queryData = array(); + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1549,9 +1549,9 @@ public function testGenerateAssociationQueryHasOneWithConditions() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasOne', 'model' => 'TestModel5'); + $binding = ['type' => 'hasOne', 'model' => 'TestModel5']; - $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); + $queryData = ['conditions' => ['TestModel5.name !=' => 'mariano']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1576,8 +1576,8 @@ public function testGenerateAssociationQueryBelongsTo() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'belongsTo', 'model' => 'TestModel4'); - $queryData = array(); + $binding = ['type' => 'belongsTo', 'model' => 'TestModel4']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1606,8 +1606,8 @@ public function testGenerateAssociationQueryBelongsToWithConditions() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'belongsTo', 'model' => 'TestModel4'); - $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); + $binding = ['type' => 'belongsTo', 'model' => 'TestModel4']; + $queryData = ['conditions' => ['TestModel5.name !=' => 'mariano']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1636,8 +1636,8 @@ public function testGenerateAssociationQueryHasMany() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array(); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1665,8 +1665,8 @@ public function testGenerateAssociationQueryHasManyWithLimit() { $this->Model->hasMany['TestModel6']['limit'] = 2; - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array(); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1700,8 +1700,8 @@ public function testGenerateAssociationQueryHasManyWithConditions() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('conditions' => array('TestModel5.name !=' => 'mariano')); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = ['conditions' => ['TestModel5.name !=' => 'mariano']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1731,8 +1731,8 @@ public function testGenerateAssociationQueryHasManyWithOffsetAndLimit() { $this->Model->hasMany['TestModel6']['offset'] = 2; $this->Model->hasMany['TestModel6']['limit'] = 5; - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array(); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1766,7 +1766,7 @@ public function testGenerateAssociationQueryHasManyWithPageAndLimit() { $this->Model->hasMany['TestModel6']['page'] = 2; $this->Model->hasMany['TestModel6']['limit'] = 5; - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1794,8 +1794,8 @@ public function testGenerateAssociationQueryHasManyWithFields() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`name`')); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = ['fields' => ['`TestModel5`.`name`']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1809,8 +1809,8 @@ public function testGenerateAssociationQueryHasManyWithFields() { $this->assertMatchesRegularExpression('/\s+FROM\s+\S+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); $this->assertMatchesRegularExpression('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`id`, `TestModel5`.`name`')); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = ['fields' => ['`TestModel5`.`id`, `TestModel5`.`name`']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1824,8 +1824,8 @@ public function testGenerateAssociationQueryHasManyWithFields() { $this->assertMatchesRegularExpression('/\s+FROM\s+\S+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); $this->assertMatchesRegularExpression('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`name`', '`TestModel5`.`created`')); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = ['fields' => ['`TestModel5`.`name`', '`TestModel5`.`created`']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1839,10 +1839,10 @@ public function testGenerateAssociationQueryHasManyWithFields() { $this->assertMatchesRegularExpression('/\s+FROM\s+\S+`test_model5` AS `TestModel5`\s+WHERE\s+/', $result); $this->assertMatchesRegularExpression('/\s+WHERE\s+(?:\()?1\s+=\s+1(?:\))?\s*$/', $result); - $this->Model->hasMany['TestModel6']['fields'] = array('name'); + $this->Model->hasMany['TestModel6']['fields'] = ['name']; - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = ['fields' => ['`TestModel5`.`id`', '`TestModel5`.`name`']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1858,10 +1858,10 @@ public function testGenerateAssociationQueryHasManyWithFields() { unset($this->Model->hasMany['TestModel6']['fields']); - $this->Model->hasMany['TestModel6']['fields'] = array('id', 'name'); + $this->Model->hasMany['TestModel6']['fields'] = ['id', 'name']; - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = ['fields' => ['`TestModel5`.`id`', '`TestModel5`.`name`']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1877,10 +1877,10 @@ public function testGenerateAssociationQueryHasManyWithFields() { unset($this->Model->hasMany['TestModel6']['fields']); - $this->Model->hasMany['TestModel6']['fields'] = array('test_model5_id', 'name'); + $this->Model->hasMany['TestModel6']['fields'] = ['test_model5_id', 'name']; - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('`TestModel5`.`id`', '`TestModel5`.`name`')); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = ['fields' => ['`TestModel5`.`id`', '`TestModel5`.`name`']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1907,8 +1907,8 @@ public function testGenerateAssociationQueryHasManyAndAggregateFunction() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasMany', 'model' => 'TestModel6'); - $queryData = array('fields' => array('MIN(`TestModel5`.`test_model4_id`)')); + $binding = ['type' => 'hasMany', 'model' => 'TestModel6']; + $queryData = ['fields' => ['MIN(`TestModel5`.`test_model4_id`)']]; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); $this->Model->recursive = 0; @@ -1926,8 +1926,8 @@ public function testGenerateAssociationQueryHasAndBelongsToMany() { $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7'); - $queryData = array(); + $binding = ['type' => 'hasAndBelongsToMany', 'model' => 'TestModel7']; + $queryData = []; $params = $this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1955,8 +1955,8 @@ public function testGenerateAssociationQueryHasAndBelongsToManyWithConditions() $this->Model->schema(); $this->_buildRelatedModels($this->Model); - $binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7'); - $queryData = array('conditions' => array('TestModel4.name !=' => 'mariano')); + $binding = ['type' => 'hasAndBelongsToMany', 'model' => 'TestModel7']; + $queryData = ['conditions' => ['TestModel4.name !=' => 'mariano']]; $params = $this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -1986,8 +1986,8 @@ public function testGenerateAssociationQueryHasAndBelongsToManyWithOffsetAndLimi $this->Model->hasAndBelongsToMany['TestModel7']['offset'] = 2; $this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5; - $binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7'); - $queryData = array(); + $binding = ['type' => 'hasAndBelongsToMany', 'model' => 'TestModel7']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -2020,8 +2020,8 @@ public function testGenerateAssociationQueryHasAndBelongsToManyWithPageAndLimit( $this->Model->hasAndBelongsToMany['TestModel7']['page'] = 2; $this->Model->hasAndBelongsToMany['TestModel7']['limit'] = 5; - $binding = array('type' => 'hasAndBelongsToMany', 'model' => 'TestModel7'); - $queryData = array(); + $binding = ['type' => 'hasAndBelongsToMany', 'model' => 'TestModel7']; + $queryData = []; $params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding); @@ -2047,7 +2047,7 @@ public function testGenerateAssociationQueryHasAndBelongsToManyWithPageAndLimit( public function testSelectDistict() { $this->Model = new TestModel4(); $result = $this->Dbo->fields($this->Model, 'Vendor', "DISTINCT Vendor.id, Vendor.name"); - $expected = array('DISTINCT `Vendor`.`id`', '`Vendor`.`name`'); + $expected = ['DISTINCT `Vendor`.`id`', '`Vendor`.`name`']; $this->assertEquals($expected, $result); } @@ -2090,7 +2090,7 @@ public function testStringConditionsParsing() { $expected = " WHERE score BETWEEN 90.1 AND 95.7"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('score' => array(2 => 1, 2, 10))); + $result = $this->Dbo->conditions(['score' => [2 => 1, 2, 10]]); $expected = " WHERE `score` IN (1, 2, 10)"; $this->assertEquals($expected, $result); @@ -2153,22 +2153,22 @@ public function testStringConditionsParsing() { $this->assertEquals($expected, $result); $letter = $letter = 'd.a'; - $conditions = array('Company.name like ' => $letter . '%'); + $conditions = ['Company.name like ' => $letter . '%']; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `Company`.`name` like 'd.a%'"; $this->assertEquals($expected, $result); - $conditions = array('Artist.name' => 'JUDY and MARY'); + $conditions = ['Artist.name' => 'JUDY and MARY']; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `Artist`.`name` = 'JUDY and MARY'"; $this->assertEquals($expected, $result); - $conditions = array('Artist.name' => 'JUDY AND MARY'); + $conditions = ['Artist.name' => 'JUDY AND MARY']; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `Artist`.`name` = 'JUDY AND MARY'"; $this->assertEquals($expected, $result); - $conditions = array('Company.name similar to ' => 'a word'); + $conditions = ['Company.name similar to ' => 'a word']; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `Company`.`name` similar to 'a word'"; $this->assertEquals($expected, $result); @@ -2271,46 +2271,46 @@ public function testParenthesisInStringConditions() { * @return void */ public function testParenthesisInArrayConditions() { - $result = $this->Dbo->conditions(array('Member.name' => '(lu')); + $result = $this->Dbo->conditions(['Member.name' => '(lu']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(lu\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => ')lu')); + $result = $this->Dbo->conditions(['Member.name' => ')lu']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\)lu\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => 'va(lu')); + $result = $this->Dbo->conditions(['Member.name' => 'va(lu']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => 'va)lu')); + $result = $this->Dbo->conditions(['Member.name' => 'va)lu']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\)lu\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => 'va(lu)')); + $result = $this->Dbo->conditions(['Member.name' => 'va(lu)']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => 'va(lu)e')); + $result = $this->Dbo->conditions(['Member.name' => 'va(lu)e']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'va\(lu\)e\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => '(mariano)')); + $result = $this->Dbo->conditions(['Member.name' => '(mariano)']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => '(mariano)iglesias')); + $result = $this->Dbo->conditions(['Member.name' => '(mariano)iglesias']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\)iglesias\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => '(mariano) iglesias')); + $result = $this->Dbo->conditions(['Member.name' => '(mariano) iglesias']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano\) iglesias\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => '(mariano word) iglesias')); + $result = $this->Dbo->conditions(['Member.name' => '(mariano word) iglesias']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano word\) iglesias\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => '(mariano.iglesias)')); + $result = $this->Dbo->conditions(['Member.name' => '(mariano.iglesias)']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\)\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => 'Mariano Iglesias (mariano.iglesias)')); + $result = $this->Dbo->conditions(['Member.name' => 'Mariano Iglesias (mariano.iglesias)']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\)\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => 'Mariano Iglesias (mariano.iglesias) CakePHP')); + $result = $this->Dbo->conditions(['Member.name' => 'Mariano Iglesias (mariano.iglesias) CakePHP']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'Mariano Iglesias \(mariano.iglesias\) CakePHP\'$/', $result); - $result = $this->Dbo->conditions(array('Member.name' => '(mariano.iglesias) CakePHP')); + $result = $this->Dbo->conditions(['Member.name' => '(mariano.iglesias) CakePHP']); $this->assertMatchesRegularExpression('/^\s+WHERE\s+`Member`.`name`\s+=\s+\'\(mariano.iglesias\) CakePHP\'$/', $result); } @@ -2321,251 +2321,251 @@ public function testParenthesisInArrayConditions() { */ public function testArrayConditionsParsing() { $this->loadFixtures('Post', 'Author'); - $result = $this->Dbo->conditions(array('Stereo.type' => 'in dash speakers')); + $result = $this->Dbo->conditions(['Stereo.type' => 'in dash speakers']); $this->assertMatchesRegularExpression("/^\s+WHERE\s+`Stereo`.`type`\s+=\s+'in dash speakers'/", $result); - $result = $this->Dbo->conditions(array('Candy.name LIKE' => 'a', 'HardCandy.name LIKE' => 'c')); + $result = $this->Dbo->conditions(['Candy.name LIKE' => 'a', 'HardCandy.name LIKE' => 'c']); $this->assertMatchesRegularExpression("/^\s+WHERE\s+`Candy`.`name` LIKE\s+'a'\s+AND\s+`HardCandy`.`name`\s+LIKE\s+'c'/", $result); - $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'a', 'Candy.name LIKE' => 'c')); + $result = $this->Dbo->conditions(['HardCandy.name LIKE' => 'a', 'Candy.name LIKE' => 'c']); $expected = " WHERE `HardCandy`.`name` LIKE 'a' AND `Candy`.`name` LIKE 'c'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'a%', 'Candy.name LIKE' => '%c%')); + $result = $this->Dbo->conditions(['HardCandy.name LIKE' => 'a%', 'Candy.name LIKE' => '%c%']); $expected = " WHERE `HardCandy`.`name` LIKE 'a%' AND `Candy`.`name` LIKE '%c%'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('HardCandy.name LIKE' => 'to be or%', 'Candy.name LIKE' => '%not to be%')); + $result = $this->Dbo->conditions(['HardCandy.name LIKE' => 'to be or%', 'Candy.name LIKE' => '%not to be%']); $expected = " WHERE `HardCandy`.`name` LIKE 'to be or%' AND `Candy`.`name` LIKE '%not to be%'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array( + $result = $this->Dbo->conditions([ "Person.name || ' ' || Person.surname ILIKE" => '%mark%' - )); + ]); $expected = " WHERE `Person`.`name` || ' ' || `Person`.`surname` ILIKE '%mark%'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('score BETWEEN ? AND ?' => array(90.1, 95.7))); + $result = $this->Dbo->conditions(['score BETWEEN ? AND ?' => [90.1, 95.7]]); $expected = " WHERE `score` BETWEEN 90.1 AND 95.7"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Post.title' => 1.1)); + $result = $this->Dbo->conditions(['Post.title' => 1.1]); $expected = " WHERE `Post`.`title` = 1.1"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Post.title' => 1.1), true, true, new Post()); + $result = $this->Dbo->conditions(['Post.title' => 1.1], true, true, new Post()); $expected = " WHERE `Post`.`title` = '1.1'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('SUM(Post.comments_count) >' => '500')); + $result = $this->Dbo->conditions(['SUM(Post.comments_count) >' => '500']); $expected = " WHERE SUM(`Post`.`comments_count`) > '500'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('MAX(Post.rating) >' => '50')); + $result = $this->Dbo->conditions(['MAX(Post.rating) >' => '50']); $expected = " WHERE MAX(`Post`.`rating`) > '50'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('lower(Article.title)' => 'secrets')); + $result = $this->Dbo->conditions(['lower(Article.title)' => 'secrets']); $expected = " WHERE lower(`Article`.`title`) = 'secrets'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('title LIKE' => '%hello')); + $result = $this->Dbo->conditions(['title LIKE' => '%hello']); $expected = " WHERE `title` LIKE '%hello'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Post.name' => 'mad(g)ik')); + $result = $this->Dbo->conditions(['Post.name' => 'mad(g)ik']); $expected = " WHERE `Post`.`name` = 'mad(g)ik'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('score' => array(1, 2, 10))); + $result = $this->Dbo->conditions(['score' => [1, 2, 10]]); $expected = " WHERE `score` IN (1, 2, 10)"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('score' => array())); + $result = $this->Dbo->conditions(['score' => []]); $expected = " WHERE `score` IS NULL"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('score !=' => array())); + $result = $this->Dbo->conditions(['score !=' => []]); $expected = " WHERE `score` IS NOT NULL"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('score !=' => '20')); + $result = $this->Dbo->conditions(['score !=' => '20']); $expected = " WHERE `score` != '20'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('score >' => '20')); + $result = $this->Dbo->conditions(['score >' => '20']); $expected = " WHERE `score` > '20'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('client_id >' => '20'), true, true, new TestModel()); + $result = $this->Dbo->conditions(['client_id >' => '20'], true, true, new TestModel()); $expected = " WHERE `client_id` > 20"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('OR' => array( - array('User.user' => 'mariano'), - array('User.user' => 'nate') - ))); + $result = $this->Dbo->conditions(['OR' => [ + ['User.user' => 'mariano'], + ['User.user' => 'nate'] + ]]); $expected = " WHERE ((`User`.`user` = 'mariano') OR (`User`.`user` = 'nate'))"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('User.user RLIKE' => 'mariano|nate')); + $result = $this->Dbo->conditions(['User.user RLIKE' => 'mariano|nate']); $expected = " WHERE `User`.`user` RLIKE 'mariano|nate'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('or' => array( - 'score BETWEEN ? AND ?' => array('4', '5'), 'rating >' => '20' - ))); + $result = $this->Dbo->conditions(['or' => [ + 'score BETWEEN ? AND ?' => ['4', '5'], 'rating >' => '20' + ]]); $expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`rating` > '20'))"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('or' => array( - 'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20') - ))); + $result = $this->Dbo->conditions(['or' => [ + 'score BETWEEN ? AND ?' => ['4', '5'], ['score >' => '20'] + ]]); $expected = " WHERE ((`score` BETWEEN '4' AND '5') OR (`score` > '20'))"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('and' => array( - 'score BETWEEN ? AND ?' => array('4', '5'), array('score >' => '20') - ))); + $result = $this->Dbo->conditions(['and' => [ + 'score BETWEEN ? AND ?' => ['4', '5'], ['score >' => '20'] + ]]); $expected = " WHERE ((`score` BETWEEN '4' AND '5') AND (`score` > '20'))"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array( - 'published' => 1, 'or' => array('score >' => '2', array('score >' => '20')) - )); + $result = $this->Dbo->conditions([ + 'published' => 1, 'or' => ['score >' => '2', ['score >' => '20']] + ]); $expected = " WHERE `published` = 1 AND ((`score` > '2') OR (`score` > '20'))"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array(array('Project.removed' => false))); + $result = $this->Dbo->conditions([['Project.removed' => false]]); $expected = " WHERE `Project`.`removed` = '0'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array(array('Project.removed' => true))); + $result = $this->Dbo->conditions([['Project.removed' => true]]); $expected = " WHERE `Project`.`removed` = '1'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array(array('Project.removed' => null))); + $result = $this->Dbo->conditions([['Project.removed' => null]]); $expected = " WHERE `Project`.`removed` IS NULL"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array(array('Project.removed !=' => null))); + $result = $this->Dbo->conditions([['Project.removed !=' => null]]); $expected = " WHERE `Project`.`removed` IS NOT NULL"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('(Usergroup.permissions) & 4' => 4)); + $result = $this->Dbo->conditions(['(Usergroup.permissions) & 4' => 4]); $expected = " WHERE (`Usergroup`.`permissions`) & 4 = 4"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('((Usergroup.permissions) & 4)' => 4)); + $result = $this->Dbo->conditions(['((Usergroup.permissions) & 4)' => 4]); $expected = " WHERE ((`Usergroup`.`permissions`) & 4) = 4"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Post.modified >=' => 'DATE_SUB(NOW(), INTERVAL 7 DAY)')); + $result = $this->Dbo->conditions(['Post.modified >=' => 'DATE_SUB(NOW(), INTERVAL 7 DAY)']); $expected = " WHERE `Post`.`modified` >= 'DATE_SUB(NOW(), INTERVAL 7 DAY)'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Post.modified >= DATE_SUB(NOW(), INTERVAL 7 DAY)')); + $result = $this->Dbo->conditions(['Post.modified >= DATE_SUB(NOW(), INTERVAL 7 DAY)']); $expected = " WHERE `Post`.`modified` >= DATE_SUB(NOW(), INTERVAL 7 DAY)"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array( - 'NOT' => array('Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => array(912, 999)), - 'Enrollment.yearcompleted >' => '0') + $result = $this->Dbo->conditions([ + 'NOT' => ['Course.id' => null, 'Course.vet' => 'N', 'level_of_education_id' => [912, 999]], + 'Enrollment.yearcompleted >' => '0'] ); $this->assertMatchesRegularExpression('/^\s*WHERE\s+\(NOT\s+\(`Course`\.`id` IS NULL\)\s+AND NOT\s+\(`Course`\.`vet`\s+=\s+\'N\'\)\s+AND NOT\s+\(`level_of_education_id` IN \(912, 999\)\)\)\s+AND\s+`Enrollment`\.`yearcompleted`\s+>\s+\'0\'\s*$/', $result); - $result = $this->Dbo->conditions(array('id <>' => '8')); + $result = $this->Dbo->conditions(['id <>' => '8']); $this->assertMatchesRegularExpression('/^\s*WHERE\s+`id`\s+<>\s+\'8\'\s*$/', $result); - $result = $this->Dbo->conditions(array('TestModel.field =' => 'gribe$@()lu')); + $result = $this->Dbo->conditions(['TestModel.field =' => 'gribe$@()lu']); $expected = " WHERE `TestModel`.`field` = 'gribe$@()lu'"; $this->assertEquals($expected, $result); - $conditions['NOT'] = array('Listing.expiration BETWEEN ? AND ?' => array("1", "100")); - $conditions[0]['OR'] = array( + $conditions['NOT'] = ['Listing.expiration BETWEEN ? AND ?' => ["1", "100"]]; + $conditions[0]['OR'] = [ "Listing.title LIKE" => "%term%", "Listing.description LIKE" => "%term%" - ); - $conditions[1]['OR'] = array( + ]; + $conditions[1]['OR'] = [ "Listing.title LIKE" => "%term_2%", "Listing.description LIKE" => "%term_2%" - ); + ]; $result = $this->Dbo->conditions($conditions); $expected = " WHERE NOT (`Listing`.`expiration` BETWEEN '1' AND '100') AND" . " ((`Listing`.`title` LIKE '%term%') OR (`Listing`.`description` LIKE '%term%')) AND" . " ((`Listing`.`title` LIKE '%term_2%') OR (`Listing`.`description` LIKE '%term_2%'))"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('MD5(CONCAT(Reg.email,Reg.id))' => 'blah')); + $result = $this->Dbo->conditions(['MD5(CONCAT(Reg.email,Reg.id))' => 'blah']); $expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) = 'blah'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array( - 'MD5(CONCAT(Reg.email,Reg.id))' => array('blah', 'blahblah') - )); + $result = $this->Dbo->conditions([ + 'MD5(CONCAT(Reg.email,Reg.id))' => ['blah', 'blahblah'] + ]); $expected = " WHERE MD5(CONCAT(`Reg`.`email`,`Reg`.`id`)) IN ('blah', 'blahblah')"; $this->assertEquals($expected, $result); - $conditions = array('id' => array(2, 5, 6, 9, 12, 45, 78, 43, 76)); + $conditions = ['id' => [2, 5, 6, 9, 12, 45, 78, 43, 76]]; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `id` IN (2, 5, 6, 9, 12, 45, 78, 43, 76)"; $this->assertEquals($expected, $result); - $conditions = array('`Correction`.`source` collate utf8_bin' => array('kiwi', 'pear')); + $conditions = ['`Correction`.`source` collate utf8_bin' => ['kiwi', 'pear']]; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `Correction`.`source` collate utf8_bin IN ('kiwi', 'pear')"; $this->assertEquals($expected, $result); - $conditions = array('title' => 'user(s)'); + $conditions = ['title' => 'user(s)']; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `title` = 'user(s)'"; $this->assertEquals($expected, $result); - $conditions = array('title' => 'user(s) data'); + $conditions = ['title' => 'user(s) data']; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `title` = 'user(s) data'"; $this->assertEquals($expected, $result); - $conditions = array('title' => 'user(s,arg) data'); + $conditions = ['title' => 'user(s,arg) data']; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `title` = 'user(s,arg) data'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array("Book.book_name" => 'Java(TM)')); + $result = $this->Dbo->conditions(["Book.book_name" => 'Java(TM)']); $expected = " WHERE `Book`.`book_name` = 'Java(TM)'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array("Book.book_name" => 'Java(TM) ')); + $result = $this->Dbo->conditions(["Book.book_name" => 'Java(TM) ']); $expected = " WHERE `Book`.`book_name` = 'Java(TM) '"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array("Book.id" => 0)); + $result = $this->Dbo->conditions(["Book.id" => 0]); $expected = " WHERE `Book`.`id` = 0"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array("Book.id" => null)); + $result = $this->Dbo->conditions(["Book.id" => null]); $expected = " WHERE `Book`.`id` IS NULL"; $this->assertEquals($expected, $result); - $conditions = array('MysqlModel.id' => ''); + $conditions = ['MysqlModel.id' => '']; $result = $this->Dbo->conditions($conditions, true, true, $this->model); $expected = " WHERE `MysqlModel`.`id` IS NULL"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Listing.beds >=' => 0)); + $result = $this->Dbo->conditions(['Listing.beds >=' => 0]); $expected = " WHERE `Listing`.`beds` >= 0"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array( - 'ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN ? AND ?' => array(65, 90) - )); + $result = $this->Dbo->conditions([ + 'ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN ? AND ?' => [65, 90] + ]); $expected = ' WHERE ASCII(SUBSTRING(keyword, 1, 1)) BETWEEN 65 AND 90'; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('or' => array( + $result = $this->Dbo->conditions(['or' => [ '? BETWEEN Model.field1 AND Model.field2' => '2009-03-04' - ))); + ]]); $expected = " WHERE '2009-03-04' BETWEEN Model.field1 AND Model.field2"; $this->assertEquals($expected, $result); } @@ -2576,15 +2576,15 @@ public function testArrayConditionsParsing() { * @return void */ public function testConditionsWithReplacements() { - $result = $this->Dbo->conditions(array( - 'score BETWEEN :0 AND :1' => array(90.1, 95.7) - )); + $result = $this->Dbo->conditions([ + 'score BETWEEN :0 AND :1' => [90.1, 95.7] + ]); $expected = " WHERE `score` BETWEEN 90.1 AND 95.7"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array( - 'score BETWEEN ? AND ?' => array(90.1, 95.7) - )); + $result = $this->Dbo->conditions([ + 'score BETWEEN ? AND ?' => [90.1, 95.7] + ]); $expected = " WHERE `score` BETWEEN 90.1 AND 95.7"; $this->assertEquals($expected, $result); } @@ -2595,12 +2595,12 @@ public function testConditionsWithReplacements() { * @return void */ public function testArrayConditionsOneElement() { - $conditions = array('id' => array(1)); + $conditions = ['id' => [1]]; $result = $this->Dbo->conditions($conditions); $expected = " WHERE id = (1)"; $this->assertEquals($expected, $result); - $conditions = array('id NOT' => array(1)); + $conditions = ['id NOT' => [1]]; $result = $this->Dbo->conditions($conditions); $expected = " WHERE NOT (id = (1))"; $this->assertEquals($expected, $result); @@ -2612,21 +2612,21 @@ public function testArrayConditionsOneElement() { * @return void */ public function testArrayConditionsParsingComplexKeys() { - $result = $this->Dbo->conditions(array( + $result = $this->Dbo->conditions([ 'CAST(Book.created AS DATE)' => '2008-08-02' - )); + ]); $expected = " WHERE CAST(`Book`.`created` AS DATE) = '2008-08-02'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array( + $result = $this->Dbo->conditions([ 'CAST(Book.created AS DATE) <=' => '2008-08-02' - )); + ]); $expected = " WHERE CAST(`Book`.`created` AS DATE) <= '2008-08-02'"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array( + $result = $this->Dbo->conditions([ '(Stats.clicks * 100) / Stats.views >' => 50 - )); + ]); $expected = " WHERE (`Stats`.`clicks` * 100) / `Stats`.`views` > 50"; $this->assertEquals($expected, $result); } @@ -2638,16 +2638,16 @@ public function testArrayConditionsParsingComplexKeys() { */ public function testMixedConditionsParsing() { $conditions[] = 'User.first_name = \'Firstname\''; - $conditions[] = array('User.last_name' => 'Lastname'); + $conditions[] = ['User.last_name' => 'Lastname']; $result = $this->Dbo->conditions($conditions); $expected = " WHERE `User`.`first_name` = 'Firstname' AND `User`.`last_name` = 'Lastname'"; $this->assertEquals($expected, $result); - $conditions = array( + $conditions = [ 'Thread.project_id' => 5, 'Thread.buyer_id' => 14, '1=1 GROUP BY Thread.project_id' - ); + ]; $result = $this->Dbo->conditions($conditions); $this->assertMatchesRegularExpression('/^\s*WHERE\s+`Thread`.`project_id`\s*=\s*5\s+AND\s+`Thread`.`buyer_id`\s*=\s*14\s+AND\s+1\s*=\s*1\s+GROUP BY `Thread`.`project_id`$/', $result); } @@ -2658,10 +2658,10 @@ public function testMixedConditionsParsing() { * @return void */ public function testConditionsOptionalArguments() { - $result = $this->Dbo->conditions(array('Member.name' => 'Mariano'), true, false); + $result = $this->Dbo->conditions(['Member.name' => 'Mariano'], true, false); $this->assertMatchesRegularExpression('/^\s*`Member`.`name`\s*=\s*\'Mariano\'\s*$/', $result); - $result = $this->Dbo->conditions(array(), true, false); + $result = $this->Dbo->conditions([], true, false); $this->assertMatchesRegularExpression('/^\s*1\s*=\s*1\s*$/', $result); } @@ -2673,27 +2673,27 @@ public function testConditionsOptionalArguments() { public function testConditionsWithModel() { $this->Model = new Article2(); - $result = $this->Dbo->conditions(array('Article2.viewed >=' => 0), true, true, $this->Model); + $result = $this->Dbo->conditions(['Article2.viewed >=' => 0], true, true, $this->Model); $expected = " WHERE `Article2`.`viewed` >= 0"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Article2.viewed >=' => '0'), true, true, $this->Model); + $result = $this->Dbo->conditions(['Article2.viewed >=' => '0'], true, true, $this->Model); $expected = " WHERE `Article2`.`viewed` >= 0"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Article2.viewed >=' => '1'), true, true, $this->Model); + $result = $this->Dbo->conditions(['Article2.viewed >=' => '1'], true, true, $this->Model); $expected = " WHERE `Article2`.`viewed` >= 1"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array(0, 10)), true, true, $this->Model); + $result = $this->Dbo->conditions(['Article2.rate_sum BETWEEN ? AND ?' => [0, 10]], true, true, $this->Model); $expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('0', '10')), true, true, $this->Model); + $result = $this->Dbo->conditions(['Article2.rate_sum BETWEEN ? AND ?' => ['0', '10']], true, true, $this->Model); $expected = " WHERE `Article2`.`rate_sum` BETWEEN 0 AND 10"; $this->assertEquals($expected, $result); - $result = $this->Dbo->conditions(array('Article2.rate_sum BETWEEN ? AND ?' => array('1', '10')), true, true, $this->Model); + $result = $this->Dbo->conditions(['Article2.rate_sum BETWEEN ? AND ?' => ['1', '10']], true, true, $this->Model); $expected = " WHERE `Article2`.`rate_sum` BETWEEN 1 AND 10"; $this->assertEquals($expected, $result); } @@ -2706,120 +2706,120 @@ public function testConditionsWithModel() { public function testFieldParsing() { $this->Model = new TestModel(); $result = $this->Dbo->fields($this->Model, 'Vendor', "Vendor.id, COUNT(Model.vendor_id) AS `Vendor`.`count`"); - $expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`'); + $expected = ['`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`']; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, 'Vendor', "`Vendor`.`id`, COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`"); - $expected = array('`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`'); + $expected = ['`Vendor`.`id`', 'COUNT(`Model`.`vendor_id`) AS `Vendor`.`count`']; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, 'Post', "CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name, Node.created"); - $expected = array("CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", "`Node`.`created`"); + $expected = ["CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", "`Node`.`created`"]; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, null, 'round( (3.55441 * fooField), 3 ) AS test'); - $this->assertEquals(array('round( (3.55441 * fooField), 3 ) AS test'), $result); + $this->assertEquals(['round( (3.55441 * fooField), 3 ) AS test'], $result); $result = $this->Dbo->fields($this->Model, null, 'ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating'); - $this->assertEquals(array('ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating'), $result); + $this->assertEquals(['ROUND(`Rating`.`rate_total` / `Rating`.`rate_count`,2) AS rating'], $result); $result = $this->Dbo->fields($this->Model, null, 'ROUND(Rating.rate_total / Rating.rate_count,2) AS rating'); - $this->assertEquals(array('ROUND(Rating.rate_total / Rating.rate_count,2) AS rating'), $result); + $this->assertEquals(['ROUND(Rating.rate_total / Rating.rate_count,2) AS rating'], $result); $result = $this->Dbo->fields($this->Model, 'Post', "Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name"); - $expected = array("`Node`.`created`", "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name"); + $expected = ["`Node`.`created`", "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name"]; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, 'Post', "2.2,COUNT(*), SUM(Something.else) as sum, Node.created, CONCAT(REPEAT(' ', COUNT(Parent.name) - 1), Node.name) AS name,Post.title,Post.1,1.1"); - $expected = array( + $expected = [ '2.2', 'COUNT(*)', 'SUM(`Something`.`else`) as sum', '`Node`.`created`', "CONCAT(REPEAT(' ', COUNT(`Parent`.`name`) - 1), Node.name) AS name", '`Post`.`title`', '`Post`.`1`', '1.1' - ); + ]; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, null, "(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"); - $expected = array("(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"); + $expected = ["(`Provider`.`star_total` / `Provider`.`total_ratings`) as `rating`"]; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, 'Post'); - $expected = array( + $expected = [ '`Post`.`id`', '`Post`.`client_id`', '`Post`.`name`', '`Post`.`login`', '`Post`.`passwd`', '`Post`.`addr_1`', '`Post`.`addr_2`', '`Post`.`zip_code`', '`Post`.`city`', '`Post`.`country`', '`Post`.`phone`', '`Post`.`fax`', '`Post`.`url`', '`Post`.`email`', '`Post`.`comments`', '`Post`.`last_login`', '`Post`.`created`', '`Post`.`updated`' - ); + ]; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, 'Other'); - $expected = array( + $expected = [ '`Other`.`id`', '`Other`.`client_id`', '`Other`.`name`', '`Other`.`login`', '`Other`.`passwd`', '`Other`.`addr_1`', '`Other`.`addr_2`', '`Other`.`zip_code`', '`Other`.`city`', '`Other`.`country`', '`Other`.`phone`', '`Other`.`fax`', '`Other`.`url`', '`Other`.`email`', '`Other`.`comments`', '`Other`.`last_login`', '`Other`.`created`', '`Other`.`updated`' - ); + ]; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->Model, null, array(), false); - $expected = array('id', 'client_id', 'name', 'login', 'passwd', 'addr_1', 'addr_2', 'zip_code', 'city', 'country', 'phone', 'fax', 'url', 'email', 'comments', 'last_login', 'created', 'updated'); + $result = $this->Dbo->fields($this->Model, null, [], false); + $expected = ['id', 'client_id', 'name', 'login', 'passwd', 'addr_1', 'addr_2', 'zip_code', 'city', 'country', 'phone', 'fax', 'url', 'email', 'comments', 'last_login', 'created', 'updated']; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, null, 'COUNT(*)'); - $expected = array('COUNT(*)'); + $expected = ['COUNT(*)']; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, null, 'SUM(Thread.unread_buyer) AS ' . $this->Dbo->name('sum_unread_buyer')); - $expected = array('SUM(`Thread`.`unread_buyer`) AS `sum_unread_buyer`'); + $expected = ['SUM(`Thread`.`unread_buyer`) AS `sum_unread_buyer`']; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, null, 'name, count(*)'); - $expected = array('`TestModel`.`name`', 'count(*)'); + $expected = ['`TestModel`.`name`', 'count(*)']; $this->assertEquals($expected, $result); $result = $this->Dbo->fields($this->Model, null, 'count(*), name'); - $expected = array('count(*)', '`TestModel`.`name`'); + $expected = ['count(*)', '`TestModel`.`name`']; $this->assertEquals($expected, $result); $result = $this->Dbo->fields( $this->Model, null, 'field1, field2, field3, count(*), name' ); - $expected = array( + $expected = [ '`TestModel`.`field1`', '`TestModel`.`field2`', '`TestModel`.`field3`', 'count(*)', '`TestModel`.`name`' - ); + ]; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->Model, null, array('dayofyear(now())')); - $expected = array('dayofyear(now())'); + $result = $this->Dbo->fields($this->Model, null, ['dayofyear(now())']); + $expected = ['dayofyear(now())']; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->Model, null, array('MAX(Model.field) As Max')); - $expected = array('MAX(`Model`.`field`) As Max'); + $result = $this->Dbo->fields($this->Model, null, ['MAX(Model.field) As Max']); + $expected = ['MAX(`Model`.`field`) As Max']; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->Model, null, array('Model.field AS AnotherName')); - $expected = array('`Model`.`field` AS `AnotherName`'); + $result = $this->Dbo->fields($this->Model, null, ['Model.field AS AnotherName']); + $expected = ['`Model`.`field` AS `AnotherName`']; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->Model, null, array('field AS AnotherName')); - $expected = array('`field` AS `AnotherName`'); + $result = $this->Dbo->fields($this->Model, null, ['field AS AnotherName']); + $expected = ['`field` AS `AnotherName`']; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->Model, null, array( + $result = $this->Dbo->fields($this->Model, null, [ 'TestModel.field AS AnotherName' - )); - $expected = array('`TestModel`.`field` AS `AnotherName`'); + ]); + $expected = ['`TestModel`.`field` AS `AnotherName`']; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->Model, 'Foo', array( + $result = $this->Dbo->fields($this->Model, 'Foo', [ 'id', 'title', '(user_count + discussion_count + post_count) AS score' - )); - $expected = array( + ]); + $expected = [ '`Foo`.`id`', '`Foo`.`title`', '(user_count + discussion_count + post_count) AS score' - ); + ]; $this->assertEquals($expected, $result); } @@ -2831,11 +2831,11 @@ public function testFieldParsing() { public function testFieldsWithExpression() { $this->Model = new TestModel; $expression = $this->Dbo->expression("CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col"); - $result = $this->Dbo->fields($this->Model, null, array("id", $expression)); - $expected = array( + $result = $this->Dbo->fields($this->Model, null, ["id", $expression]); + $expected = [ '`TestModel`.`id`', "CASE Sample.id WHEN 1 THEN 'Id One' ELSE 'Other Id' END AS case_col" - ); + ]; $this->assertEquals($expected, $result); } @@ -2845,22 +2845,22 @@ public function testFieldsWithExpression() { * @return void */ public function testRenderStatement() { - $result = $this->Dbo->renderStatement('select', array( + $result = $this->Dbo->renderStatement('select', [ 'fields' => 'id', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '', 'joins' => '', 'order' => '', 'limit' => '', 'group' => '' - )); + ]); $this->assertMatchesRegularExpression('/^\s*SELECT\s+id\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result); - $result = $this->Dbo->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '')); + $result = $this->Dbo->renderStatement('update', ['fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '']); $this->assertMatchesRegularExpression('/^\s*UPDATE\s+table\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result); - $result = $this->Dbo->renderStatement('update', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => '')); + $result = $this->Dbo->renderStatement('update', ['fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => '']); $this->assertMatchesRegularExpression('/^\s*UPDATE\s+table\s+AS\s+alias\s+SET\s+value=2\s+WHERE\s+1=1\s*$/', $result); - $result = $this->Dbo->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '')); + $result = $this->Dbo->renderStatement('delete', ['fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => '']); $this->assertMatchesRegularExpression('/^\s*DELETE\s+FROM\s+table\s+WHERE\s+1=1\s*$/', $result); - $result = $this->Dbo->renderStatement('delete', array('fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => '')); + $result = $this->Dbo->renderStatement('delete', ['fields' => 'value=2', 'table' => 'table', 'conditions' => 'WHERE 1=1', 'alias' => 'alias', 'joins' => '']); $this->assertMatchesRegularExpression('/^\s*DELETE\s+alias\s+FROM\s+table\s+AS\s+alias\s+WHERE\s+1=1\s*$/', $result); } @@ -2871,7 +2871,7 @@ public function testRenderStatement() { */ public function testSchema() { $Schema = new CakeSchema(); - $Schema->tables = array('table' => array(), 'anotherTable' => array()); + $Schema->tables = ['table' => [], 'anotherTable' => []]; $result = $this->Dbo->dropSchema($Schema, 'non_existing'); $this->assertTrue(empty($result)); @@ -2891,7 +2891,7 @@ public function testDropSchemaNoSchema() { try { $this->Dbo->dropSchema(null); $this->fail('No exception'); - } catch (TypeError $e) { + } catch (TypeError) { throw new \PHPUnit\Framework\Error('Raised an error', 100); } } @@ -2912,32 +2912,32 @@ public function testOrderParsing() { $result = $this->Dbo->order("title desc, id desc"); $this->assertMatchesRegularExpression('/^\s*ORDER BY\s+`title`\s+desc,\s+`id`\s+desc\s*$/', $result); - $result = $this->Dbo->order(array("title desc, id desc")); + $result = $this->Dbo->order(["title desc, id desc"]); $this->assertMatchesRegularExpression('/^\s*ORDER BY\s+`title`\s+desc,\s+`id`\s+desc\s*$/', $result); - $result = $this->Dbo->order(array("title", "id")); + $result = $this->Dbo->order(["title", "id"]); $this->assertMatchesRegularExpression('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); - $result = $this->Dbo->order(array(array('title'), array('id'))); + $result = $this->Dbo->order([['title'], ['id']]); $this->assertMatchesRegularExpression('/^\s*ORDER BY\s+`title`\s+ASC,\s+`id`\s+ASC\s*$/', $result); - $result = $this->Dbo->order(array("Post.title" => 'asc', "Post.id" => 'desc')); + $result = $this->Dbo->order(["Post.title" => 'asc', "Post.id" => 'desc']); $this->assertMatchesRegularExpression('/^\s*ORDER BY\s+`Post`.`title`\s+asc,\s+`Post`.`id`\s+desc\s*$/', $result); - $result = $this->Dbo->order(array(array("Post.title" => 'asc', "Post.id" => 'desc'))); + $result = $this->Dbo->order([["Post.title" => 'asc', "Post.id" => 'desc']]); $this->assertMatchesRegularExpression('/^\s*ORDER BY\s+`Post`.`title`\s+asc,\s+`Post`.`id`\s+desc\s*$/', $result); - $result = $this->Dbo->order(array("title")); + $result = $this->Dbo->order(["title"]); $this->assertMatchesRegularExpression('/^\s*ORDER BY\s+`title`\s+ASC\s*$/', $result); - $result = $this->Dbo->order(array(array("title"))); + $result = $this->Dbo->order([["title"]]); $this->assertMatchesRegularExpression('/^\s*ORDER BY\s+`title`\s+ASC\s*$/', $result); $result = $this->Dbo->order("Dealer.id = 7 desc, Dealer.id = 3 desc, Dealer.title asc"); $expected = " ORDER BY `Dealer`.`id` = 7 desc, `Dealer`.`id` = 3 desc, `Dealer`.`title` asc"; $this->assertEquals($expected, $result); - $result = $this->Dbo->order(array("Page.name" => "='test' DESC")); + $result = $this->Dbo->order(["Page.name" => "='test' DESC"]); $this->assertMatchesRegularExpression("/^\s*ORDER BY\s+`Page`\.`name`\s*='test'\s+DESC\s*$/", $result); $result = $this->Dbo->order("Page.name = 'view' DESC"); @@ -2966,7 +2966,7 @@ public function testOrderParsing() { $expected = ' ORDER BY 3963.191 * id ASC'; $this->assertEquals($expected, $result); - $result = $this->Dbo->order(array('Property.sale_price IS NULL')); + $result = $this->Dbo->order(['Property.sale_price IS NULL']); $expected = ' ORDER BY `Property`.`sale_price` IS NULL ASC'; $this->assertEquals($expected, $result); } @@ -2977,7 +2977,7 @@ public function testOrderParsing() { * @return void */ public function testComplexSortExpression() { - $result = $this->Dbo->order(array('(Model.field > 100) DESC', 'Model.field ASC')); + $result = $this->Dbo->order(['(Model.field > 100) DESC', 'Model.field ASC']); $this->assertMatchesRegularExpression("/^\s*ORDER BY\s+\(`Model`\.`field`\s+>\s+100\)\s+DESC,\s+`Model`\.`field`\s+ASC\s*$/", $result); } @@ -2991,32 +2991,32 @@ public function testCalculations() { $result = $this->Dbo->calculate($this->Model, 'count'); $this->assertEquals('COUNT(*) AS `count`', $result); - $result = $this->Dbo->calculate($this->Model, 'count', array('id')); + $result = $this->Dbo->calculate($this->Model, 'count', ['id']); $this->assertEquals('COUNT(`id`) AS `count`', $result); $result = $this->Dbo->calculate( $this->Model, 'count', - array($this->Dbo->expression('DISTINCT id')) + [$this->Dbo->expression('DISTINCT id')] ); $this->assertEquals('COUNT(DISTINCT id) AS `count`', $result); - $result = $this->Dbo->calculate($this->Model, 'count', array('id', 'id_count')); + $result = $this->Dbo->calculate($this->Model, 'count', ['id', 'id_count']); $this->assertEquals('COUNT(`id`) AS `id_count`', $result); - $result = $this->Dbo->calculate($this->Model, 'count', array('Model.id', 'id_count')); + $result = $this->Dbo->calculate($this->Model, 'count', ['Model.id', 'id_count']); $this->assertEquals('COUNT(`Model`.`id`) AS `id_count`', $result); - $result = $this->Dbo->calculate($this->Model, 'max', array('id')); + $result = $this->Dbo->calculate($this->Model, 'max', ['id']); $this->assertEquals('MAX(`id`) AS `id`', $result); - $result = $this->Dbo->calculate($this->Model, 'max', array('Model.id', 'id')); + $result = $this->Dbo->calculate($this->Model, 'max', ['Model.id', 'id']); $this->assertEquals('MAX(`Model`.`id`) AS `id`', $result); - $result = $this->Dbo->calculate($this->Model, 'max', array('`Model`.`id`', 'id')); + $result = $this->Dbo->calculate($this->Model, 'max', ['`Model`.`id`', 'id']); $this->assertEquals('MAX(`Model`.`id`) AS `id`', $result); - $result = $this->Dbo->calculate($this->Model, 'min', array('`Model`.`id`', 'id')); + $result = $this->Dbo->calculate($this->Model, 'min', ['`Model`.`id`', 'id']); $this->assertEquals('MIN(`Model`.`id`) AS `id`', $result); $result = $this->Dbo->calculate($this->Model, 'min', 'left'); @@ -3083,46 +3083,46 @@ public function testLengthSet() { * @return void */ public function testBuildIndex() { - $data = array( - 'PRIMARY' => array('column' => 'id') - ); + $data = [ + 'PRIMARY' => ['column' => 'id'] + ]; $result = $this->Dbo->buildIndex($data); - $expected = array('PRIMARY KEY (`id`)'); + $expected = ['PRIMARY KEY (`id`)']; $this->assertSame($expected, $result); - $data = array( - 'MyIndex' => array('column' => 'id', 'unique' => true) - ); + $data = [ + 'MyIndex' => ['column' => 'id', 'unique' => true] + ]; $result = $this->Dbo->buildIndex($data); - $expected = array('UNIQUE KEY `MyIndex` (`id`)'); + $expected = ['UNIQUE KEY `MyIndex` (`id`)']; $this->assertEquals($expected, $result); - $data = array( - 'MyIndex' => array('column' => array('id', 'name'), 'unique' => true) - ); + $data = [ + 'MyIndex' => ['column' => ['id', 'name'], 'unique' => true] + ]; $result = $this->Dbo->buildIndex($data); - $expected = array('UNIQUE KEY `MyIndex` (`id`, `name`)'); + $expected = ['UNIQUE KEY `MyIndex` (`id`, `name`)']; $this->assertEquals($expected, $result); - $data = array( - 'MyFtIndex' => array('column' => array('name', 'description'), 'type' => 'fulltext') - ); + $data = [ + 'MyFtIndex' => ['column' => ['name', 'description'], 'type' => 'fulltext'] + ]; $result = $this->Dbo->buildIndex($data); - $expected = array('FULLTEXT KEY `MyFtIndex` (`name`, `description`)'); + $expected = ['FULLTEXT KEY `MyFtIndex` (`name`, `description`)']; $this->assertEquals($expected, $result); - $data = array( - 'MyTextIndex' => array('column' => 'text_field', 'length' => array('text_field' => 20)) - ); + $data = [ + 'MyTextIndex' => ['column' => 'text_field', 'length' => ['text_field' => 20]] + ]; $result = $this->Dbo->buildIndex($data); - $expected = array('KEY `MyTextIndex` (`text_field`(20))'); + $expected = ['KEY `MyTextIndex` (`text_field`(20))']; $this->assertEquals($expected, $result); - $data = array( - 'MyMultiTextIndex' => array('column' => array('text_field1', 'text_field2'), 'length' => array('text_field1' => 20, 'text_field2' => 20)) - ); + $data = [ + 'MyMultiTextIndex' => ['column' => ['text_field1', 'text_field2'], 'length' => ['text_field1' => 20, 'text_field2' => 20]] + ]; $result = $this->Dbo->buildIndex($data); - $expected = array('KEY `MyMultiTextIndex` (`text_field1`(20), `text_field2`(20))'); + $expected = ['KEY `MyMultiTextIndex` (`text_field1`(20), `text_field2`(20))']; $this->assertEquals($expected, $result); } @@ -3132,98 +3132,98 @@ public function testBuildIndex() { * @return void */ public function testBuildColumn() { - $data = array( + $data = [ 'name' => 'testName', 'type' => 'string', 'length' => 255, 'default', 'null' => true, 'key' - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '`testName` varchar(255) DEFAULT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'int_field', 'type' => 'integer', 'default' => '', 'null' => false, - ); + ]; $restore = $this->Dbo->columns; - $this->Dbo->columns = array('integer' => array('name' => 'int', 'limit' => '11', 'formatter' => 'intval'), ); + $this->Dbo->columns = ['integer' => ['name' => 'int', 'limit' => '11', 'formatter' => 'intval'], ]; $result = $this->Dbo->buildColumn($data); $expected = '`int_field` int(11) NOT NULL'; $this->assertEquals($expected, $result); - $this->Dbo->fieldParameters['param'] = array( + $this->Dbo->fieldParameters['param'] = [ 'value' => 'COLLATE', 'quote' => false, 'join' => ' ', 'column' => 'Collate', 'position' => 'beforeDefault', - 'options' => array('GOOD', 'OK') - ); - $data = array( + 'options' => ['GOOD', 'OK'] + ]; + $data = [ 'name' => 'int_field', 'type' => 'integer', 'default' => '', 'null' => false, 'param' => 'BAD' - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '`int_field` int(11) NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'int_field', 'type' => 'integer', 'default' => '', 'null' => false, 'param' => 'GOOD' - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '`int_field` int(11) COLLATE GOOD NOT NULL'; $this->assertEquals($expected, $result); $this->Dbo->columns = $restore; - $data = array( + $data = [ 'name' => 'created', 'type' => 'timestamp', 'default' => 'current_timestamp', 'null' => false, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'created', 'type' => 'timestamp', 'default' => 'CURRENT_TIMESTAMP', 'null' => true, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '`created` timestamp DEFAULT CURRENT_TIMESTAMP'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'modified', 'type' => 'timestamp', 'null' => true, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '`modified` timestamp NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'modified', 'type' => 'timestamp', 'default' => null, 'null' => true, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '`modified` timestamp NULL'; $this->assertEquals($expected, $result); @@ -3236,13 +3236,13 @@ public function testBuildColumn() { */ public function testBuildColumnBadType() { $this->expectWarning(); - $data = array( + $data = [ 'name' => 'testName', 'type' => 'varchar(255)', 'default', 'null' => true, 'key' - ); + ]; $this->Dbo->buildColumn($data); } @@ -3267,114 +3267,114 @@ public function testBuildColumnUnsigned($data, $expected) { * @return array */ public function buildColumnUnsignedProvider() { - return array( + return [ // unsigned int - array( - array( + [ + [ 'name' => 'testName', 'type' => 'integer', 'length' => 11, 'unsigned' => true - ), + ], '`testName` int(11) UNSIGNED' - ), + ], // unsigned bigint - array( - array( + [ + [ 'name' => 'testName', 'type' => 'biginteger', 'length' => 20, 'unsigned' => true - ), + ], '`testName` bigint(20) UNSIGNED' - ), + ], // unsigned float - array( - array( + [ + [ 'name' => 'testName', 'type' => 'float', 'unsigned' => true - ), + ], '`testName` float UNSIGNED' - ), + ], // varchar - array( - array( + [ + [ 'name' => 'testName', 'type' => 'string', 'length' => 255, 'unsigned' => true - ), + ], '`testName` varchar(255)' - ), + ], // date unsigned - array( - array( + [ + [ 'name' => 'testName', 'type' => 'date', 'unsigned' => true - ), + ], '`testName` date' - ), + ], // date - array( - array( + [ + [ 'name' => 'testName', 'type' => 'date', 'unsigned' => false - ), + ], '`testName` date' - ), + ], // integer with length - array( - array( + [ + [ 'name' => 'testName', 'type' => 'integer', 'length' => 11, 'unsigned' => false - ), + ], '`testName` int(11)' - ), + ], // unsigned decimal - array( - array( + [ + [ 'name' => 'testName', 'type' => 'decimal', 'unsigned' => true - ), + ], '`testName` decimal UNSIGNED' - ), + ], // decimal with default - array( - array( + [ + [ 'name' => 'testName', 'type' => 'decimal', 'unsigned' => true, 'default' => 1 - ), + ], '`testName` decimal UNSIGNED DEFAULT 1' - ), + ], // smallinteger - array( - array( + [ + [ 'name' => 'testName', 'type' => 'smallinteger', 'length' => 6, 'unsigned' => true - ), + ], '`testName` smallint(6) UNSIGNED' - ), + ], // tinyinteger - array( - array( + [ + [ 'name' => 'testName', 'type' => 'tinyinteger', 'length' => 4, 'unsigned' => true - ), + ], '`testName` tinyint(4) UNSIGNED' - ) - ); + ] + ]; } /** @@ -3404,10 +3404,10 @@ public function testSchemaUnsigned() { */ public function testHasAny() { $db = $this->Dbo->config['database']; - $this->Dbo = $this->getMock('Mysql', array('connect', '_execute', 'execute', 'value')); + $this->Dbo = $this->getMock('Mysql', ['connect', '_execute', 'execute', 'value']); $this->Dbo->config['database'] = $db; - $this->Model = $this->getMock('TestModel', array('getDataSource')); + $this->Model = $this->getMock('TestModel', ['getDataSource']); $this->Model->expects($this->any()) ->method('getDataSource') ->will($this->returnValue($this->Dbo)); @@ -3422,8 +3422,8 @@ public function testHasAny() { $this->Dbo->expects($this->at(2))->method('execute') ->with('SELECT COUNT(`TestModel`.`id`) AS count FROM ' . $modelTable . ' AS `TestModel` WHERE 1 = 1'); - $this->Dbo->hasAny($this->Model, array('TestModel.name' => 'harry')); - $this->Dbo->hasAny($this->Model, array()); + $this->Dbo->hasAny($this->Model, ['TestModel.name' => 'harry']); + $this->Dbo->hasAny($this->Model, []); } /** @@ -3436,14 +3436,14 @@ public function testVirtualFields() { $this->Dbo->virtualFieldSeparator = '__'; $Article = ClassRegistry::init('Article'); $commentsTable = $this->Dbo->fullTableName('comments', false, false); - $Article->virtualFields = array( + $Article->virtualFields = [ 'this_moment' => 'NOW()', 'two' => '1 + 1', 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentsTable . ' WHERE Article.id = ' . $commentsTable . '.article_id' - ); + ]; $result = $this->Dbo->fields($Article); - $expected = array( + $expected = [ '`Article`.`id`', '`Article`.`user_id`', '`Article`.`title`', @@ -3454,47 +3454,47 @@ public function testVirtualFields() { '(NOW()) AS `Article__this_moment`', '(1 + 1) AS `Article__two`', "(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) AS `Article__comment_count`" - ); + ]; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($Article, null, array('this_moment', 'title')); - $expected = array( + $result = $this->Dbo->fields($Article, null, ['this_moment', 'title']); + $expected = [ '`Article`.`title`', '(NOW()) AS `Article__this_moment`', - ); + ]; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($Article, null, array('Article.title', 'Article.this_moment')); - $expected = array( + $result = $this->Dbo->fields($Article, null, ['Article.title', 'Article.this_moment']); + $expected = [ '`Article`.`title`', '(NOW()) AS `Article__this_moment`', - ); + ]; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($Article, null, array('Article.this_moment', 'Article.title')); - $expected = array( + $result = $this->Dbo->fields($Article, null, ['Article.this_moment', 'Article.title']); + $expected = [ '`Article`.`title`', '(NOW()) AS `Article__this_moment`', - ); + ]; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($Article, null, array('Article.*')); - $expected = array( + $result = $this->Dbo->fields($Article, null, ['Article.*']); + $expected = [ '`Article`.*', '(NOW()) AS `Article__this_moment`', '(1 + 1) AS `Article__two`', "(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) AS `Article__comment_count`" - ); + ]; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($Article, null, array('*')); - $expected = array( + $result = $this->Dbo->fields($Article, null, ['*']); + $expected = [ '*', '(NOW()) AS `Article__this_moment`', '(1 + 1) AS `Article__two`', "(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) AS `Article__comment_count`" - ); + ]; $this->assertEquals($expected, $result); } @@ -3508,11 +3508,11 @@ public function testVirtualFieldsWithSubquery() { $this->Dbo->virtualFieldSeparator = '__'; $Article = ClassRegistry::init('Article'); $commentsTable = $this->Dbo->fullTableName('comments', false, false); - $Article->Comment->virtualFields = array( + $Article->Comment->virtualFields = [ 'extra' => 'SELECT id FROM ' . $commentsTable . ' WHERE id = (SELECT 1)', - ); - $conditions = array('Article.id' => array(1, 2)); - $contain = array('Comment.extra'); + ]; + $conditions = ['Article.id' => [1, 2]]; + $contain = ['Comment.extra']; $test = ConnectionManager::getDatasource('test'); $test->getLog(); @@ -3536,28 +3536,28 @@ public function testVirtualFieldsInConditions() { $Article = ClassRegistry::init('Article'); $commentsTable = $this->Dbo->fullTableName('comments', false, false); - $Article->virtualFields = array( + $Article->virtualFields = [ 'this_moment' => 'NOW()', 'two' => '1 + 1', 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentsTable . ' WHERE Article.id = ' . $commentsTable . '.article_id' - ); - $conditions = array('two' => 2); + ]; + $conditions = ['two' => 2]; $result = $this->Dbo->conditions($conditions, true, false, $Article); $expected = '(1 + 1) = 2'; $this->assertEquals($expected, $result); - $conditions = array('this_moment BETWEEN ? AND ?' => array(1, 2)); + $conditions = ['this_moment BETWEEN ? AND ?' => [1, 2]]; $expected = 'NOW() BETWEEN 1 AND 2'; $result = $this->Dbo->conditions($conditions, true, false, $Article); $this->assertEquals($expected, $result); - $conditions = array('comment_count >' => 5); + $conditions = ['comment_count >' => 5]; $expected = "(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) > 5"; $result = $this->Dbo->conditions($conditions, true, false, $Article); $this->assertEquals($expected, $result); - $conditions = array('NOT' => array('two' => 2)); + $conditions = ['NOT' => ['two' => 2]]; $result = $this->Dbo->conditions($conditions, true, false, $Article); $expected = 'NOT ((1 + 1) = 2)'; $this->assertEquals($expected, $result); @@ -3569,16 +3569,16 @@ public function testVirtualFieldsInConditions() { * @return void */ public function testConditionsWithComplexVirtualFields() { - $Article = ClassRegistry::init('Article', 'Comment', 'Tag'); - $Article->virtualFields = array( + $Article = ClassRegistry::init('Article', 'Comment'); + $Article->virtualFields = [ 'distance' => 'ACOS(SIN(20 * PI() / 180) * SIN(Article.latitude * PI() / 180) + COS(20 * PI() / 180) * COS(Article.latitude * PI() / 180) * COS((50 - Article.longitude) * PI() / 180) ) * 180 / PI() * 60 * 1.1515 * 1.609344' - ); - $conditions = array('distance >=' => 20); + ]; + $conditions = ['distance >=' => 20]; $result = $this->Dbo->conditions($conditions, true, true, $Article); $this->assertMatchesRegularExpression('/\) >= 20/', $result); @@ -3594,18 +3594,18 @@ public function testConditionsWithComplexVirtualFields() { public function testVirtualFieldsInCalculate() { $Article = ClassRegistry::init('Article'); $commentsTable = $this->Dbo->fullTableName('comments', false, false); - $Article->virtualFields = array( + $Article->virtualFields = [ 'this_moment' => 'NOW()', 'two' => '1 + 1', 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentsTable . ' WHERE Article.id = ' . $commentsTable . '.article_id' - ); + ]; - $result = $this->Dbo->calculate($Article, 'count', array('this_moment')); + $result = $this->Dbo->calculate($Article, 'count', ['this_moment']); $expected = 'COUNT(NOW()) AS `count`'; $this->assertEquals($expected, $result); - $result = $this->Dbo->calculate($Article, 'max', array('comment_count')); + $result = $this->Dbo->calculate($Article, 'max', ['comment_count']); $expected = "MAX(SELECT COUNT(*) FROM $commentsTable WHERE `Article`.`id` = `$commentsTable`.`article_id`) AS `comment_count`"; $this->assertEquals($expected, $result); } @@ -3618,12 +3618,12 @@ public function testVirtualFieldsInCalculate() { public function testReadVirtualFieldsWithNewLines() { $Article = new Article(); $Article->recursive = 1; - $Article->virtualFields = array( + $Article->virtualFields = [ 'test' => ' User.id + User.id ' - ); - $result = $this->Dbo->fields($Article, null, array()); + ]; + $result = $this->Dbo->fields($Article, null, []); $result = $this->Dbo->fields($Article, $Article->alias, $result); $this->assertMatchesRegularExpression('/[`\"]User[`\"]\.[`\"]id[`\"] \+ [`\"]User[`\"]\.[`\"]id[`\"]/', $result[7]); } @@ -3635,9 +3635,9 @@ public function testReadVirtualFieldsWithNewLines() { */ public function testVirtualFieldsInGroup() { $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( + $Article->virtualFields = [ 'this_year' => 'YEAR(Article.created)' - ); + ]; $result = $this->Dbo->group('this_year', $Article); @@ -3652,16 +3652,16 @@ public function testVirtualFieldsInGroup() { */ public function testFieldsWithComplexVirtualFields() { $Article = new Article(); - $Article->virtualFields = array( + $Article->virtualFields = [ 'distance' => 'ACOS(SIN(20 * PI() / 180) * SIN(Article.latitude * PI() / 180) + COS(20 * PI() / 180) * COS(Article.latitude * PI() / 180) * COS((50 - Article.longitude) * PI() / 180) ) * 180 / PI() * 60 * 1.1515 * 1.609344' - ); + ]; - $fields = array('id', 'distance'); + $fields = ['id', 'distance']; $result = $this->Dbo->fields($Article, null, $fields); $qs = $this->Dbo->startQuote; $qe = $this->Dbo->endQuote; @@ -3681,7 +3681,7 @@ public function testExecute() { $query = 'SELECT * FROM ' . $this->Dbo->fullTableName('articles') . ' WHERE 1 = 1'; $this->Dbo->took = null; $this->Dbo->affected = null; - $result = $this->Dbo->execute($query, array('log' => false)); + $result = $this->Dbo->execute($query, ['log' => false]); $this->assertNotNull($result, 'No query performed! %s'); $this->assertNull($this->Dbo->took, 'Stats were set %s'); $this->assertNull($this->Dbo->affected, 'Stats were set %s'); @@ -3701,18 +3701,18 @@ public function testVirtualFieldsFetch() { $this->loadFixtures('Article', 'Comment'); $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( + $Article->virtualFields = [ 'comment_count' => 'SELECT COUNT(*) FROM ' . $this->Dbo->fullTableName('comments') . ' WHERE Article.id = ' . $this->Dbo->fullTableName('comments') . '.article_id' - ); + ]; - $conditions = array('comment_count >' => 2); - $query = 'SELECT ' . implode(',', $this->Dbo->fields($Article, null, array('id', 'comment_count'))) . + $conditions = ['comment_count >' => 2]; + $query = 'SELECT ' . implode(',', $this->Dbo->fields($Article, null, ['id', 'comment_count'])) . ' FROM ' . $this->Dbo->fullTableName($Article) . ' Article ' . $this->Dbo->conditions($conditions, true, true, $Article); $result = $this->Dbo->fetchAll($query); - $expected = array(array( - 'Article' => array('id' => 1, 'comment_count' => 4) - )); + $expected = [[ + 'Article' => ['id' => 1, 'comment_count' => 4] + ]]; $this->assertEquals($expected, $result); } @@ -3727,23 +3727,23 @@ public function testVirtualFieldsComplexRead() { $Article = ClassRegistry::init('Article'); $commentTable = $this->Dbo->fullTableName('comments'); $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( + $Article->virtualFields = [ 'comment_count' => 'SELECT COUNT(*) FROM ' . $commentTable . ' AS Comment WHERE Article.id = Comment.article_id' - ); + ]; $result = $Article->find('all'); $this->assertTrue(count($result) > 0); $this->assertTrue($result[0]['Article']['comment_count'] > 0); $DataTest = ClassRegistry::init('DataTest'); - $DataTest->virtualFields = array( + $DataTest->virtualFields = [ 'complicated' => 'ACOS(SIN(20 * PI() / 180) * SIN(DataTest.float * PI() / 180) + COS(20 * PI() / 180) * COS(DataTest.count * PI() / 180) * COS((50 - DataTest.float) * PI() / 180) ) * 180 / PI() * 60 * 1.1515 * 1.609344' - ); + ]; $result = $DataTest->find('all'); $this->assertTrue(count($result) > 0); $this->assertTrue($result[0]['DataTest']['complicated'] > 0); @@ -3770,52 +3770,52 @@ public function testIntrospectType() { $this->assertEquals('string', $this->Dbo->introspectType('stringme')); $this->assertEquals('string', $this->Dbo->introspectType('0stringme')); - $data = array(2.2); + $data = [2.2]; $this->assertEquals('float', $this->Dbo->introspectType($data)); - $data = array('2.2'); + $data = ['2.2']; $this->assertEquals('float', $this->Dbo->introspectType($data)); - $data = array(2); + $data = [2]; $this->assertEquals('integer', $this->Dbo->introspectType($data)); - $data = array('2'); + $data = ['2']; $this->assertEquals('integer', $this->Dbo->introspectType($data)); - $data = array('string'); + $data = ['string']; $this->assertEquals('string', $this->Dbo->introspectType($data)); - $data = array(2.2, '2.2'); + $data = [2.2, '2.2']; $this->assertEquals('float', $this->Dbo->introspectType($data)); - $data = array(2, '2'); + $data = [2, '2']; $this->assertEquals('integer', $this->Dbo->introspectType($data)); - $data = array('string one', 'string two'); + $data = ['string one', 'string two']; $this->assertEquals('string', $this->Dbo->introspectType($data)); - $data = array('2.2', 3); + $data = ['2.2', 3]; $this->assertEquals('integer', $this->Dbo->introspectType($data)); - $data = array('2.2', '0stringme'); + $data = ['2.2', '0stringme']; $this->assertEquals('string', $this->Dbo->introspectType($data)); - $data = array(2.2, 3); + $data = [2.2, 3]; $this->assertEquals('integer', $this->Dbo->introspectType($data)); - $data = array(2.2, '0stringme'); + $data = [2.2, '0stringme']; $this->assertEquals('string', $this->Dbo->introspectType($data)); - $data = array(2, 'stringme'); + $data = [2, 'stringme']; $this->assertEquals('string', $this->Dbo->introspectType($data)); - $data = array(2, '2.2', 'stringgme'); + $data = [2, '2.2', 'stringgme']; $this->assertEquals('string', $this->Dbo->introspectType($data)); - $data = array(2, '2.2'); + $data = [2, '2.2']; $this->assertEquals('integer', $this->Dbo->introspectType($data)); - $data = array(2, 2.2); + $data = [2, 2.2]; $this->assertEquals('integer', $this->Dbo->introspectType($data)); // null @@ -3929,53 +3929,53 @@ public function testRealQueries() { $this->assertTrue(!empty($result)); $result = $this->Dbo->fetchRow($result); - $expected = array($this->Dbo->fullTableName('apples', false, false) => array( + $expected = [$this->Dbo->fullTableName('apples', false, false) => [ 'color' => 'Red 1', 'name' => 'Red Apple 1' - )); + ]]; $this->assertEquals($expected, $result); $result = $this->Dbo->fetchAll('SELECT name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id'); - $expected = array( - array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Red Apple 1')), - array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Bright Red Apple')), - array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'green blue')), - array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Test Name')), - array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Blue Green')), - array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'My new apple')), - array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Some odd color')) - ); + $expected = [ + [$this->Dbo->fullTableName('apples', false, false) => ['name' => 'Red Apple 1']], + [$this->Dbo->fullTableName('apples', false, false) => ['name' => 'Bright Red Apple']], + [$this->Dbo->fullTableName('apples', false, false) => ['name' => 'green blue']], + [$this->Dbo->fullTableName('apples', false, false) => ['name' => 'Test Name']], + [$this->Dbo->fullTableName('apples', false, false) => ['name' => 'Blue Green']], + [$this->Dbo->fullTableName('apples', false, false) => ['name' => 'My new apple']], + [$this->Dbo->fullTableName('apples', false, false) => ['name' => 'Some odd color']] + ]; $this->assertEquals($expected, $result); $result = $this->Dbo->field($this->Dbo->fullTableName('apples', false, false), 'SELECT color, name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id'); - $expected = array( + $expected = [ 'color' => 'Red 1', 'name' => 'Red Apple 1' - ); + ]; $this->assertEquals($expected, $result); - $Apple->unbindModel(array(), false); - $result = $this->Dbo->read($Apple, array( - 'fields' => array($Apple->escapeField('name')), + $Apple->unbindModel([], false); + $result = $this->Dbo->read($Apple, [ + 'fields' => [$Apple->escapeField('name')], 'conditions' => null, 'recursive' => -1 - )); - $expected = array( - array('Apple' => array('name' => 'Red Apple 1')), - array('Apple' => array('name' => 'Bright Red Apple')), - array('Apple' => array('name' => 'green blue')), - array('Apple' => array('name' => 'Test Name')), - array('Apple' => array('name' => 'Blue Green')), - array('Apple' => array('name' => 'My new apple')), - array('Apple' => array('name' => 'Some odd color')) - ); - $this->assertEquals($expected, $result); - - $result = $this->Dbo->read($Article, array( - 'fields' => array('id', 'user_id', 'title'), + ]); + $expected = [ + ['Apple' => ['name' => 'Red Apple 1']], + ['Apple' => ['name' => 'Bright Red Apple']], + ['Apple' => ['name' => 'green blue']], + ['Apple' => ['name' => 'Test Name']], + ['Apple' => ['name' => 'Blue Green']], + ['Apple' => ['name' => 'My new apple']], + ['Apple' => ['name' => 'Some odd color']] + ]; + $this->assertEquals($expected, $result); + + $result = $this->Dbo->read($Article, [ + 'fields' => ['id', 'user_id', 'title'], 'conditions' => null, 'recursive' => 1 - )); + ]); $this->assertTrue(Set::matches('/Article[id=1]', $result)); $this->assertTrue(Set::matches('/Comment[id=1]', $result)); @@ -3988,13 +3988,13 @@ public function testRealQueries() { */ public function testExceptionOnBrokenConnection() { $this->expectException(MissingConnectionException::class); - new Mysql(array( + new Mysql([ 'driver' => 'mysql', 'host' => 'imaginary_host', 'login' => 'mark', 'password' => 'inyurdatabase', 'database' => 'imaginary' - )); + ]); } /** @@ -4007,7 +4007,7 @@ public function testUpdateStatements() { $test = ConnectionManager::getDatasource('test'); $db = $test->config['database']; - $this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config)); + $this->Dbo = $this->getMock('Mysql', ['execute'], [$test->config]); $this->Dbo->expects($this->at(0))->method('execute') ->with("UPDATE `$db`.`articles` SET `field1` = 'value1' WHERE 1 = 1"); @@ -4024,9 +4024,9 @@ public function testUpdateStatements() { $Article = new Article(); - $this->Dbo->update($Article, array('field1'), array('value1')); - $this->Dbo->update($Article, array('field1'), array('2'), '2=2'); - $this->Dbo->update($Article, array('field1'), array("'value'"), array('index' => 'val')); + $this->Dbo->update($Article, ['field1'], ['value1']); + $this->Dbo->update($Article, ['field1'], ['2'], '2=2'); + $this->Dbo->update($Article, ['field1'], ["'value'"], ['index' => 'val']); } /** @@ -4039,7 +4039,7 @@ public function testDeleteStatements() { $test = ConnectionManager::getDatasource('test'); $db = $test->config['database']; - $this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config)); + $this->Dbo = $this->getMock('Mysql', ['execute'], [$test->config]); $this->Dbo->expects($this->at(0))->method('execute') ->with("DELETE FROM `$db`.`articles` WHERE 1 = 1"); @@ -4070,7 +4070,7 @@ public function testDeleteNoComplexCondition() { $test = ConnectionManager::getDatasource('test'); $db = $test->config['database']; - $this->Dbo = $this->getMock('Mysql', array('execute'), array($test->config)); + $this->Dbo = $this->getMock('Mysql', ['execute'], [$test->config]); $this->Dbo->expects($this->at(0))->method('execute') ->with("DELETE `Article` FROM `$db`.`articles` AS `Article` WHERE `id` = 1"); @@ -4080,9 +4080,9 @@ public function testDeleteNoComplexCondition() { $Article = new Article(); - $conditions = array('id' => 1); + $conditions = ['id' => 1]; $this->Dbo->delete($Article, $conditions); - $conditions = array('NOT' => array('id' => 1)); + $conditions = ['NOT' => ['id' => 1]]; $this->Dbo->delete($Article, $conditions); } @@ -4097,7 +4097,7 @@ public function testTruncateStatements() { $schema = $db->config['database']; $Article = new Article(); - $this->Dbo = $this->getMock('Mysql', array('execute'), array($db->config)); + $this->Dbo = $this->getMock('Mysql', ['execute'], [$db->config]); $this->Dbo->expects($this->at(0))->method('execute') ->with("TRUNCATE TABLE `$schema`.`articles`"); @@ -4134,7 +4134,7 @@ public function testNestedTransaction() { $this->loadFixtures('Inno'); $model = ClassRegistry::init('Inno'); - $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array(); + $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = []; $model->cacheQueries = false; $this->Dbo->cacheMethods = false; @@ -4199,8 +4199,8 @@ public function testInsertMultiId() { $Article = ClassRegistry::init('Article'); $db = $Article->getDatasource(); $datetime = date('Y-m-d H:i:s'); - $data = array( - array( + $data = [ + [ 'user_id' => 1, 'title' => 'test', 'body' => 'test', @@ -4208,8 +4208,8 @@ public function testInsertMultiId() { 'created' => $datetime, 'updated' => $datetime, 'id' => 100, - ), - array( + ], + [ 'user_id' => 1, 'title' => 'test 101', 'body' => 'test 101', @@ -4217,13 +4217,13 @@ public function testInsertMultiId() { 'created' => $datetime, 'updated' => $datetime, 'id' => 101, - ) - ); + ] + ]; $result = $db->insertMulti('articles', array_keys($data[0]), $data); $this->assertTrue($result, 'Data was saved'); - $data = array( - array( + $data = [ + [ 'id' => 102, 'user_id' => 1, 'title' => 'test', @@ -4231,8 +4231,8 @@ public function testInsertMultiId() { 'published' => 'N', 'created' => $datetime, 'updated' => $datetime, - ), - array( + ], + [ 'id' => 103, 'user_id' => 1, 'title' => 'test 101', @@ -4240,8 +4240,8 @@ public function testInsertMultiId() { 'published' => 'N', 'created' => $datetime, 'updated' => $datetime, - ) - ); + ] + ]; $result = $db->insertMulti('articles', array_keys($data[0]), $data); $this->assertTrue($result, 'Data was saved'); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php index ed499e077d..80e42ce6a3 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/PostgresTest.php @@ -19,7 +19,7 @@ App::uses('AppModel', 'Model'); App::uses('Postgres', 'Model/Datasource/Database'); -require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php'; +require_once dirname(__FILE__, 3) . DS . 'models.php'; /** * DboPostgresTestDb class @@ -33,7 +33,7 @@ class DboPostgresTestDb extends Postgres { * * @var array */ - public $simulated = array(); + public $simulated = []; /** * execute method @@ -41,7 +41,7 @@ class DboPostgresTestDb extends Postgres { * @param mixed $sql * @return void */ - protected function _execute($sql, $params = array(), $prepareOptions = array()) { + protected function _execute($sql, $params = [], $prepareOptions = []) { $this->simulated[] = $sql; return null; } @@ -76,11 +76,11 @@ class PostgresTestModel extends Model { * * @var array */ - public $belongsTo = array( - 'PostgresClientTestModel' => array( + public $belongsTo = [ + 'PostgresClientTestModel' => [ 'foreignKey' => 'client_id' - ) - ); + ] + ]; /** * find method @@ -114,27 +114,27 @@ public function findAll($conditions = null, $fields = null, $order = null, $recu * @return void */ public function schema($field = false) { - return array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), - 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''), - 'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null), - 'some_uuid' => array('type' => 'uuid', 'null' => '1', 'default' => null), - ); + return [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'client_id' => ['type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'login' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'passwd' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'addr_1' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'addr_2' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'], + 'zip_code' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'city' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'country' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'phone' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'fax' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'url' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'comments' => ['type' => 'text', 'null' => '1', 'default' => '', 'length' => ''], + 'last_login' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null], + 'some_uuid' => ['type' => 'uuid', 'null' => '1', 'default' => null], + ]; } } @@ -159,13 +159,13 @@ class PostgresClientTestModel extends Model { * @return void */ public function schema($field = false) { - return array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'created' => array('type' => 'datetime', 'null' => true, 'default' => null, 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => true, 'default' => null, 'length' => null) - ); + return [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'created' => ['type' => 'datetime', 'null' => true, 'default' => null, 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => true, 'default' => null, 'length' => null] + ]; } } @@ -190,10 +190,10 @@ class PostgresTest extends CakeTestCase { * * @var object */ - public $fixtures = array('core.user', 'core.binary_test', 'core.comment', 'core.article', + public $fixtures = ['core.user', 'core.binary_test', 'core.comment', 'core.article', 'core.tag', 'core.articles_tag', 'core.attachment', 'core.person', 'core.post', 'core.author', 'core.datatype', - ); + ]; /** * Actual DB connection used in testing @@ -252,7 +252,7 @@ public function tearDown() : void { * @return void */ public function testFieldQuoting() { - $fields = array( + $fields = [ '"PostgresTestModel"."id" AS "PostgresTestModel__id"', '"PostgresTestModel"."client_id" AS "PostgresTestModel__client_id"', '"PostgresTestModel"."name" AS "PostgresTestModel__name"', @@ -272,7 +272,7 @@ public function testFieldQuoting() { '"PostgresTestModel"."created" AS "PostgresTestModel__created"', '"PostgresTestModel"."updated" AS "PostgresTestModel__updated"', '"PostgresTestModel"."some_uuid" AS "PostgresTestModel__some_uuid"' - ); + ]; $result = $this->Dbo->fields($this->model); $expected = $fields; @@ -282,19 +282,19 @@ public function testFieldQuoting() { $expected = $fields; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name')); - $expected = array_merge($fields, array( + $result = $this->Dbo->fields($this->model, null, ['*', 'AnotherModel.id', 'AnotherModel.name']); + $expected = array_merge($fields, [ '"AnotherModel"."id" AS "AnotherModel__id"', - '"AnotherModel"."name" AS "AnotherModel__name"')); + '"AnotherModel"."name" AS "AnotherModel__name"']); $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($this->model, null, array('*', 'PostgresClientTestModel.*')); - $expected = array_merge($fields, array( + $result = $this->Dbo->fields($this->model, null, ['*', 'PostgresClientTestModel.*']); + $expected = array_merge($fields, [ '"PostgresClientTestModel"."id" AS "PostgresClientTestModel__id"', '"PostgresClientTestModel"."name" AS "PostgresClientTestModel__name"', '"PostgresClientTestModel"."email" AS "PostgresClientTestModel__email"', '"PostgresClientTestModel"."created" AS "PostgresClientTestModel__created"', - '"PostgresClientTestModel"."updated" AS "PostgresClientTestModel__updated"')); + '"PostgresClientTestModel"."updated" AS "PostgresClientTestModel__updated"']); $this->assertEquals($expected, $result); } @@ -350,7 +350,7 @@ public function testValueQuoting() { $this->assertEquals("'TRUE'", $this->Dbo->value(1, 'boolean')); $this->assertEquals("'TRUE'", $this->Dbo->value('1', 'boolean')); $this->assertEquals("NULL", $this->Dbo->value(null, 'boolean')); - $this->assertEquals("NULL", $this->Dbo->value(array())); + $this->assertEquals("NULL", $this->Dbo->value([])); $this->assertEquals("'550e8400-e29b-41d4-a716-446655440000'", $this->Dbo->value('550e8400-e29b-41d4-a716-446655440000', 'uuid')); $this->assertEquals("NULL", $this->Dbo->value(null, 'uuid')); } @@ -420,7 +420,7 @@ public function testBooleanNormalization() { public function testBooleanDefaultFalseInSchema() { $this->loadFixtures('Datatype'); - $model = new Model(array('name' => 'Datatype', 'table' => 'datatypes', 'ds' => 'test')); + $model = new Model(['name' => 'Datatype', 'table' => 'datatypes', 'ds' => 'test']); $model->create(); $this->assertSame(false, $model->data['Datatype']['bool']); } @@ -453,11 +453,11 @@ public function testLastInsertIdMultipleInsert() { * @return void */ public function testColumnUseLength() { - $result = array('name' => 'foo', 'type' => 'string', 'length' => 100, 'default' => 'FOO'); + $result = ['name' => 'foo', 'type' => 'string', 'length' => 100, 'default' => 'FOO']; $expected = '"foo" varchar(100) DEFAULT \'FOO\''; $this->assertEquals($expected, $this->Dbo->buildColumn($result)); - $result = array('name' => 'foo', 'type' => 'text', 'length' => 100, 'default' => 'FOO'); + $result = ['name' => 'foo', 'type' => 'text', 'length' => 100, 'default' => 'FOO']; $expected = '"foo" text DEFAULT \'FOO\''; $this->assertEquals($expected, $this->Dbo->buildColumn($result)); } @@ -488,7 +488,7 @@ public function testBinaryDataIntegrity() { ªºnh˚ºO^∏…®[Ó“‚ÅfıÌ≥∫F!Eœ(π∑T6`¬tΩÆ0ì»rTÎ`»Ñ« ]≈åp˝)=¿Ô0∆öVÂmˇˆ„ø~¯ÁÔ∏b*fc»‡Îı„Ú}∆tœs∂Y∫ÜaÆ˙X∏~<ÿ·Ù vé1‹p¿TD∆ÔîÄ“úhˆ*Ú€îe)K –p¨ÚJ3Ÿ∞ã>ÊuNê°“√Ü ‹Ê9iÙ0˙AAEÍ ˙`∂£\'ûce•åƒX›ŸÁ´1SK{qdá"tÏ[wQ#SµBe∞∑µó…ÌV`B"Ñ≥„!è_Óφ-º*ºú¿Ë0ˆeê∂´ë+HFj…‡zvHÓN|ÔL÷ûñ3õÜ$z%sá…pÎóV38âs Çoµ•ß3†<9B·¨û~¢3)ÂxóÿÁCÕòÆ ∫Í=»ÿSπS;∆~±êÆTEp∑óÈ÷ÀuìDHÈ $ÉõæÜjû§"≤ÃONM®RËíRr{õS ∏Ê™op±W;ÂUÔ P∫kÔˇflTæ∑óflË” ÆC©Ô[≥◊HÁ˚¨hê"ÆbF?ú%h˙ˇ4xèÕ(ó2ÙáíM])Ñd|=fë-cI0ñL¢kÖêk‰Rƒ«ıÄWñ8mO3∏&√æËX¯Hó—ì]yF2»–˜ádàà‡‹Çο„≥7mªHAS∑¶.;Œx(1} _kd©.fidç48M\'àáªCp^Krí<ɉXÓıïl!Ì$N<ı∞B»G]…∂Ó¯>˛ÔbõÒπÀ•:ôO@È$pÖu‹Ê´-QqV ?V≥JÆÍqÛX8(lπï@zgÖ}Fe<ˇ‡Sñ“ÿ˜ê?6‡L∫Oß~µ –?ËeäÚ®YîÕ =Ü=¢DÁu*GvBk;)L¬N«î:flö∂≠ÇΩq„Ñm하Ë∂‚"û≥§:±≤i^ΩÑ!)Wıyŧô á„RÄ÷Òôc’≠—s™rı‚Pdêãh˘ßHVç5fifiÈF€çÌÛuçÖ/M=gëµ±ÿGû1coÔuñæ‘z®. õ∑7ÉÏÜÆ,°’H†ÍÉÌ∂7e º® íˆ⁄◊øNWK”ÂYµ‚ñé;µ¶gV-fl>µtË¥áßN2 ¯¶BaP-)eW.àôt^∏1›C∑Ö?L„&”5’4jvã–ªZ ÷+4% ´0l…»ú^°´© ûiπ∑é®óܱÒÿ‰ïˆÌ–dˆ◊Æ19rQ=Í|ı•rMæ¬;ò‰Y‰é9.” ‹˝V«ã¯∏,+ë®j*¡·/'; - $model = new AppModel(array('name' => 'BinaryTest', 'ds' => 'test')); + $model = new AppModel(['name' => 'BinaryTest', 'ds' => 'test']); $model->save(compact('data')); $result = $model->find('first'); @@ -501,13 +501,13 @@ public function testBinaryDataIntegrity() { * @return void */ public function testRegexpOperatorConditionsParsing() { - $this->assertSame(' WHERE "name" ~ \'[a-z_]+\'', $this->Dbo->conditions(array('name ~' => '[a-z_]+'))); - $this->assertSame(' WHERE "name" ~* \'[a-z_]+\'', $this->Dbo->conditions(array('name ~*' => '[a-z_]+'))); - $this->assertSame(' WHERE "name" !~ \'[a-z_]+\'', $this->Dbo->conditions(array('name !~' => '[a-z_]+'))); - $this->assertSame(' WHERE "name" !~* \'[a-z_]+\'', $this->Dbo->conditions(array('name !~*' => '[a-z_]+'))); + $this->assertSame(' WHERE "name" ~ \'[a-z_]+\'', $this->Dbo->conditions(['name ~' => '[a-z_]+'])); + $this->assertSame(' WHERE "name" ~* \'[a-z_]+\'', $this->Dbo->conditions(['name ~*' => '[a-z_]+'])); + $this->assertSame(' WHERE "name" !~ \'[a-z_]+\'', $this->Dbo->conditions(['name !~' => '[a-z_]+'])); + $this->assertSame(' WHERE "name" !~* \'[a-z_]+\'', $this->Dbo->conditions(['name !~*' => '[a-z_]+'])); $this->assertSame( ' WHERE EXTRACT( \'YEAR\' FROM "User"."birthday" ) = 2015', - $this->Dbo->conditions(array('EXTRACT( \'YEAR\' FROM User.birthday )' => 2015)) + $this->Dbo->conditions(['EXTRACT( \'YEAR\' FROM User.birthday )' => 2015]) ); } @@ -518,26 +518,26 @@ public function testRegexpOperatorConditionsParsing() { */ public function testSchemaIndexSyntax() { $schema = new CakeSchema(); - $schema->tables = array('i18n' => array( - 'id' => array( + $schema->tables = ['i18n' => [ + 'id' => [ 'type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary' - ), - 'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'), - 'model' => array('type' => 'string', 'null' => false, 'key' => 'index'), - 'foreign_key' => array( + ], + 'locale' => ['type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'], + 'model' => ['type' => 'string', 'null' => false, 'key' => 'index'], + 'foreign_key' => [ 'type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index' - ), - 'field' => array('type' => 'string', 'null' => false, 'key' => 'index'), - 'content' => array('type' => 'text', 'null' => true, 'default' => null), - 'indexes' => array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'locale' => array('column' => 'locale', 'unique' => 0), - 'model' => array('column' => 'model', 'unique' => 0), - 'row_id' => array('column' => 'foreign_key', 'unique' => 0), - 'field' => array('column' => 'field', 'unique' => 0) - ) - )); + ], + 'field' => ['type' => 'string', 'null' => false, 'key' => 'index'], + 'content' => ['type' => 'text', 'null' => true, 'default' => null], + 'indexes' => [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'locale' => ['column' => 'locale', 'unique' => 0], + 'model' => ['column' => 'model', 'unique' => 0], + 'row_id' => ['column' => 'foreign_key', 'unique' => 0], + 'field' => ['column' => 'field', 'unique' => 0] + ] + ]]; $result = $this->Dbo->createSchema($schema); $this->assertDoesNotMatchRegularExpression('/^CREATE INDEX(.+);,$/', $result); @@ -565,15 +565,15 @@ public function testCakeSchema() { CONSTRAINT test_data_types_pkey PRIMARY KEY (id) )'); - $schema = new CakeSchema(array('connection' => 'test')); - $result = $schema->read(array( + $schema = new CakeSchema(['connection' => 'test']); + $result = $schema->read([ 'connection' => 'test', - 'models' => array('DatatypeTest') - )); + 'models' => ['DatatypeTest'] + ]); - $schema->tables = array( + $schema->tables = [ 'datatype_tests' => $result['tables']['missing']['datatype_tests'] - ); + ]; $result = $db1->createSchema($schema, 'datatype_tests'); $this->assertDoesNotMatchRegularExpression('/timestamp DEFAULT/', $result); @@ -584,11 +584,11 @@ public function testCakeSchema() { $db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests')); $db1->query($result); - $result2 = $schema->read(array( + $result2 = $schema->read([ 'connection' => 'test', - 'models' => array('DatatypeTest') - )); - $schema->tables = array('datatype_tests' => $result2['tables']['missing']['datatype_tests']); + 'models' => ['DatatypeTest'] + ]); + $schema->tables = ['datatype_tests' => $result2['tables']['missing']['datatype_tests']]; $result2 = $db1->createSchema($schema, 'datatype_tests'); $this->assertEquals($result, $result2); @@ -612,14 +612,14 @@ public function testCakeSchemaBigserial() { PRIMARY KEY ("id") )'); - $schema = new CakeSchema(array('connection' => 'test')); - $result = $schema->read(array( + $schema = new CakeSchema(['connection' => 'test']); + $result = $schema->read([ 'connection' => 'test', - 'models' => array('BigserialTest') - )); - $schema->tables = array( + 'models' => ['BigserialTest'] + ]); + $schema->tables = [ 'bigserial_tests' => $result['tables']['missing']['bigserial_tests'] - ); + ]; $result = $db1->createSchema($schema, 'bigserial_tests'); $this->assertStringContainsString('"id" bigserial NOT NULL,', $result); @@ -637,11 +637,11 @@ public function testIndexGeneration() { $this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )'); $this->Dbo->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")'); $this->Dbo->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")'); - $expected = array( - 'PRIMARY' => array('unique' => true, 'column' => 'id'), - 'pointless_bool' => array('unique' => false, 'column' => 'bool'), - 'char_index' => array('unique' => true, 'column' => 'small_char'), - ); + $expected = [ + 'PRIMARY' => ['unique' => true, 'column' => 'id'], + 'pointless_bool' => ['unique' => false, 'column' => 'bool'], + 'char_index' => ['unique' => true, 'column' => 'small_char'], + ]; $result = $this->Dbo->index($name); $this->Dbo->query('DROP TABLE ' . $name); $this->assertEquals($expected, $result); @@ -649,10 +649,10 @@ public function testIndexGeneration() { $name = $this->Dbo->fullTableName('index_test_2', false, false); $this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )'); $this->Dbo->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")'); - $expected = array( - 'PRIMARY' => array('unique' => true, 'column' => 'id'), - 'multi_col' => array('unique' => true, 'column' => array('small_char', 'bool')), - ); + $expected = [ + 'PRIMARY' => ['unique' => true, 'column' => 'id'], + 'multi_col' => ['unique' => true, 'column' => ['small_char', 'bool']], + ]; $result = $this->Dbo->index($name); $this->Dbo->query('DROP TABLE ' . $name); $this->assertEquals($expected, $result); @@ -664,37 +664,37 @@ public function testIndexGeneration() { * @return void */ public function testAlterSchema() { - $Old = new CakeSchema(array( + $Old = new CakeSchema([ 'connection' => 'test', 'name' => 'AlterPosts', - 'alter_posts' => array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => true), - 'body' => array('type' => 'text'), - 'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'), - 'created' => array('type' => 'datetime'), - 'updated' => array('type' => 'datetime'), - ) - )); + 'alter_posts' => [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => true], + 'body' => ['type' => 'text'], + 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'], + 'created' => ['type' => 'datetime'], + 'updated' => ['type' => 'datetime'], + ] + ]); $this->Dbo->query($this->Dbo->createSchema($Old)); - $New = new CakeSchema(array( + $New = new CakeSchema([ 'connection' => 'test', 'name' => 'AlterPosts', - 'alter_posts' => array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => true), - 'title' => array('type' => 'string', 'null' => false, 'default' => 'my title'), - 'body' => array('type' => 'string', 'length' => 500), - 'status' => array('type' => 'integer', 'length' => 3, 'default' => 1), - 'created' => array('type' => 'datetime'), - 'updated' => array('type' => 'datetime'), - ) - )); + 'alter_posts' => [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => true], + 'title' => ['type' => 'string', 'null' => false, 'default' => 'my title'], + 'body' => ['type' => 'string', 'length' => 500], + 'status' => ['type' => 'integer', 'length' => 3, 'default' => 1], + 'created' => ['type' => 'datetime'], + 'updated' => ['type' => 'datetime'], + ] + ]); $this->Dbo->query($this->Dbo->alterSchema($New->compare($Old), 'alter_posts')); - $model = new CakeTestModel(array('table' => 'alter_posts', 'ds' => 'test')); + $model = new CakeTestModel(['table' => 'alter_posts', 'ds' => 'test']); $result = $model->schema(); $this->assertTrue(isset($result['status'])); $this->assertFalse(isset($result['published'])); @@ -703,19 +703,19 @@ public function testAlterSchema() { $this->assertEquals(true, $result['author_id']['null']); $this->assertEquals(false, $result['title']['null']); - $New = new CakeSchema(array( + $New = new CakeSchema([ 'connection' => 'test_suite', 'name' => 'AlterPosts', - 'alter_posts' => array( - 'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'), - 'author_id' => array('type' => 'integer', 'null' => false), - 'title' => array('type' => 'string', 'null' => true), - 'body' => array('type' => 'text'), - 'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'), - 'created' => array('type' => 'datetime'), - 'updated' => array('type' => 'datetime'), - ) - )); + 'alter_posts' => [ + 'id' => ['type' => 'string', 'length' => 36, 'key' => 'primary'], + 'author_id' => ['type' => 'integer', 'null' => false], + 'title' => ['type' => 'string', 'null' => true], + 'body' => ['type' => 'text'], + 'published' => ['type' => 'string', 'length' => 1, 'default' => 'N'], + 'created' => ['type' => 'datetime'], + 'updated' => ['type' => 'datetime'], + ] + ]); $result = $this->Dbo->alterSchema($New->compare($Old), 'alter_posts'); $this->assertDoesNotMatchRegularExpression('/varchar\(36\) NOT NULL/i', $result); @@ -728,21 +728,21 @@ public function testAlterSchema() { * @return void */ public function testAlterSchemaBooleanToIntegerField() { - $default = array( + $default = [ 'connection' => 'test', 'name' => 'BoolField', - 'bool_fields' => array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'name' => array('type' => 'string', 'length' => 50), - 'active' => array('type' => 'boolean', 'null' => false), - ) - ); + 'bool_fields' => [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'name' => ['type' => 'string', 'length' => 50], + 'active' => ['type' => 'boolean', 'null' => false], + ] + ]; $Old = new CakeSchema($default); $result = $this->Dbo->query($this->Dbo->createSchema($Old)); $this->assertTrue($result); $modified = $default; - $modified['bool_fields']['active'] = array('type' => 'integer', 'null' => true); + $modified['bool_fields']['active'] = ['type' => 'integer', 'null' => true]; $New = new CakeSchema($modified); $query = $this->Dbo->alterSchema($New->compare($Old)); @@ -756,33 +756,33 @@ public function testAlterSchemaBooleanToIntegerField() { * @return void */ public function testAlterSchemaTextToIntegerField() { - $default = array( + $default = [ 'connection' => 'test', 'name' => 'TextField', - 'text_fields' => array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'name' => array('type' => 'string', 'length' => 50), - 'active' => array('type' => 'text', 'null' => false), - ) - ); + 'text_fields' => [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'name' => ['type' => 'string', 'length' => 50], + 'active' => ['type' => 'text', 'null' => false], + ] + ]; $Old = new CakeSchema($default); $result = $this->Dbo->query($this->Dbo->createSchema($Old)); $this->assertTrue($result); $modified = $default; - $modified['text_fields']['active'] = array('type' => 'integer', 'null' => true); + $modified['text_fields']['active'] = ['type' => 'integer', 'null' => true]; $New = new CakeSchema($modified); $this->Dbo->query($this->Dbo->alterSchema($New->compare($Old))); $result = $this->Dbo->describe('text_fields'); $this->Dbo->query($this->Dbo->dropSchema($Old)); - $expected = array( + $expected = [ 'type' => 'integer', 'null' => true, 'default' => null, 'length' => null, - ); + ]; $this->assertEquals($expected, $result['active']); } @@ -794,55 +794,55 @@ public function testAlterSchemaTextToIntegerField() { public function testAlterIndexes() { $this->Dbo->cacheSources = false; - $schema1 = new CakeSchema(array( + $schema1 = new CakeSchema([ 'name' => 'AlterTest1', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'group1' => array('type' => 'integer', 'null' => true), - 'group2' => array('type' => 'integer', 'null' => true) - ) - )); + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + 'group1' => ['type' => 'integer', 'null' => true], + 'group2' => ['type' => 'integer', 'null' => true] + ] + ]); $this->Dbo->rawQuery($this->Dbo->createSchema($schema1)); - $schema2 = new CakeSchema(array( + $schema2 = new CakeSchema([ 'name' => 'AlterTest2', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'group1' => array('type' => 'integer', 'null' => true), - 'group2' => array('type' => 'integer', 'null' => true), - 'indexes' => array( - 'name_idx' => array('unique' => false, 'column' => 'name'), - 'group_idx' => array('unique' => false, 'column' => 'group1'), - 'compound_idx' => array('unique' => false, 'column' => array('group1', 'group2')), - 'PRIMARY' => array('unique' => true, 'column' => 'id') - ) - ) - )); + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + 'group1' => ['type' => 'integer', 'null' => true], + 'group2' => ['type' => 'integer', 'null' => true], + 'indexes' => [ + 'name_idx' => ['unique' => false, 'column' => 'name'], + 'group_idx' => ['unique' => false, 'column' => 'group1'], + 'compound_idx' => ['unique' => false, 'column' => ['group1', 'group2']], + 'PRIMARY' => ['unique' => true, 'column' => 'id'] + ] + ] + ]); $this->Dbo->query($this->Dbo->alterSchema($schema2->compare($schema1))); $indexes = $this->Dbo->index('altertest'); $this->assertEquals($schema2->tables['altertest']['indexes'], $indexes); // Change three indexes, delete one and add another one - $schema3 = new CakeSchema(array( + $schema3 = new CakeSchema([ 'name' => 'AlterTest3', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - 'group1' => array('type' => 'integer', 'null' => true), - 'group2' => array('type' => 'integer', 'null' => true), - 'indexes' => array( - 'name_idx' => array('unique' => true, 'column' => 'name'), - 'group_idx' => array('unique' => false, 'column' => 'group2'), - 'compound_idx' => array('unique' => false, 'column' => array('group2', 'group1')), - 'another_idx' => array('unique' => false, 'column' => array('group1', 'name'))) - ))); + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + 'group1' => ['type' => 'integer', 'null' => true], + 'group2' => ['type' => 'integer', 'null' => true], + 'indexes' => [ + 'name_idx' => ['unique' => true, 'column' => 'name'], + 'group_idx' => ['unique' => false, 'column' => 'group2'], + 'compound_idx' => ['unique' => false, 'column' => ['group2', 'group1']], + 'another_idx' => ['unique' => false, 'column' => ['group1', 'name']]] + ]]); $this->Dbo->query($this->Dbo->alterSchema($schema3->compare($schema2))); @@ -850,13 +850,13 @@ public function testAlterIndexes() { $this->assertEquals($schema3->tables['altertest']['indexes'], $indexes); // Compare us to ourself. - $this->assertEquals(array(), $schema3->compare($schema3)); + $this->assertEquals([], $schema3->compare($schema3)); // Drop the indexes $this->Dbo->query($this->Dbo->alterSchema($schema1->compare($schema3))); $indexes = $this->Dbo->index('altertest'); - $this->assertEquals(array(), $indexes); + $this->assertEquals([], $indexes); $this->Dbo->query($this->Dbo->dropSchema($schema1)); } @@ -867,13 +867,13 @@ public function testAlterIndexes() { * @return void */ public function testAlterSchemaRenameTo() { - $query = $this->Dbo->alterSchema(array( - 'posts' => array( - 'change' => array( - 'title' => array('name' => 'subject', 'type' => 'string', 'null' => false) - ) - ) - )); + $query = $this->Dbo->alterSchema([ + 'posts' => [ + 'change' => [ + 'title' => ['name' => 'subject', 'type' => 'string', 'null' => false] + ] + ] + ]); $this->assertStringContainsString('RENAME "title" TO "subject";', $query); $this->assertStringContainsString('ALTER COLUMN "subject" TYPE', $query); $this->assertStringNotContainsString(";\n\tALTER COLUMN \"subject\" TYPE", $query); @@ -888,12 +888,12 @@ public function testAlterSchemaRenameTo() { public function testVirtualFields() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment', 'Tag', 'ArticlesTag'); $Article = new Article; - $Article->virtualFields = array( + $Article->virtualFields = [ 'next_id' => 'Article.id + 1', 'complex' => 'Article.title || Article.body', 'functional' => 'COALESCE(User.user, Article.title)', 'subquery' => 'SELECT count(*) FROM ' . $Article->Comment->table - ); + ]; $result = $Article->find('first'); $this->assertEquals(2, $result['Article']['next_id']); $this->assertEquals($result['Article']['complex'], $result['Article']['title'] . $result['Article']['body']); @@ -909,11 +909,11 @@ public function testVirtualFields() { public function testVirtualFieldAsAConstant() { $this->loadFixtures('Article', 'Comment'); $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( + $Article->virtualFields = [ 'empty' => "NULL", 'number' => 43, 'truth' => 'TRUE' - ); + ]; $result = $Article->find('first'); $this->assertNull($result['Article']['empty']); $this->assertTrue($result['Article']['truth']); @@ -926,7 +926,7 @@ public function testVirtualFieldAsAConstant() { * @return void */ public function testOrderAdditionalParams() { - $result = $this->Dbo->order(array('title' => 'DESC NULLS FIRST', 'body' => 'DESC')); + $result = $this->Dbo->order(['title' => 'DESC NULLS FIRST', 'body' => 'DESC']); $expected = ' ORDER BY "title" DESC NULLS FIRST, "body" DESC'; $this->assertEquals($expected, $result); } @@ -940,16 +940,16 @@ public function testOrderAdditionalParams() { public function testQuoteDistinctInFunction() { $this->loadFixtures('Article'); $Article = new Article; - $result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT Article.id)')); - $expected = array('COUNT(DISTINCT "Article"."id")'); + $result = $this->Dbo->fields($Article, null, ['COUNT(DISTINCT Article.id)']); + $expected = ['COUNT(DISTINCT "Article"."id")']; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT id)')); - $expected = array('COUNT(DISTINCT "id")'); + $result = $this->Dbo->fields($Article, null, ['COUNT(DISTINCT id)']); + $expected = ['COUNT(DISTINCT "id")']; $this->assertEquals($expected, $result); - $result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT FUNC(id))')); - $expected = array('COUNT(DISTINCT FUNC("id"))'); + $result = $this->Dbo->fields($Article, null, ['COUNT(DISTINCT FUNC(id))']); + $expected = ['COUNT(DISTINCT FUNC("id"))']; $this->assertEquals($expected, $result); } @@ -961,12 +961,12 @@ public function testQuoteDistinctInFunction() { public function testUpdateAllWithNonQualifiedConditions() { $this->loadFixtures('Article'); $Article = new Article(); - $result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article')); + $result = $Article->updateAll(['title' => "'Awesome'"], ['title' => 'Third Article']); $this->assertTrue($result); - $result = $Article->find('count', array( - 'conditions' => array('Article.title' => 'Awesome') - )); + $result = $Article->find('count', [ + 'conditions' => ['Article.title' => 'Awesome'] + ]); $this->assertEquals(1, $result, 'Article count is wrong or fixture has changed.'); } @@ -976,33 +976,33 @@ public function testUpdateAllWithNonQualifiedConditions() { * @return void */ public function testAlteringTwoTables() { - $schema1 = new CakeSchema(array( + $schema1 = new CakeSchema([ 'name' => 'AlterTest1', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - ), - 'other_table' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'name' => array('type' => 'string', 'null' => false, 'length' => 50), - ) - )); - $schema2 = new CakeSchema(array( + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + ], + 'other_table' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'name' => ['type' => 'string', 'null' => false, 'length' => 50], + ] + ]); + $schema2 = new CakeSchema([ 'name' => 'AlterTest1', 'connection' => 'test', - 'altertest' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50), - ), - 'other_table' => array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => 0), - 'field_two' => array('type' => 'string', 'null' => false, 'length' => 50), - ) - )); + 'altertest' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'field_two' => ['type' => 'string', 'null' => false, 'length' => 50], + ], + 'other_table' => [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => 0], + 'field_two' => ['type' => 'string', 'null' => false, 'length' => 50], + ] + ]); $result = $this->db->alterSchema($schema2->compare($schema1)); $this->assertEquals(2, substr_count($result, 'field_two'), 'Too many fields'); - $this->assertFalse(strpos(';ALTER', $result), 'Too many semi colons'); + $this->assertFalse(strpos(';ALTER', (string) $result), 'Too many semi colons'); } /** @@ -1035,7 +1035,7 @@ public function testTruncateStatements() { $schema = $db->config['schema']; $Article = new Article(); - $this->Dbo = $this->getMock('Postgres', array('execute'), array($db->config)); + $this->Dbo = $this->getMock('Postgres', ['execute'], [$db->config]); $this->Dbo->expects($this->at(0))->method('execute') ->with("DELETE FROM \"$schema\".\"articles\""); @@ -1068,7 +1068,7 @@ public function testNestedTransaction() { $this->loadFixtures('Article'); $model = new Article(); - $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array(); + $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = []; $model->cacheQueries = false; $this->Dbo->cacheMethods = false; @@ -1095,13 +1095,13 @@ public function testResetSequence() { $model = new Article(); $table = $this->Dbo->fullTableName($model, false); - $fields = array( + $fields = [ 'id', 'user_id', 'title', 'body', 'published', - ); - $values = array( - array(1, 1, 'test', 'first post', false), - array(2, 1, 'test 2', 'second post post', false), - ); + ]; + $values = [ + [1, 1, 'test', 'first post', false], + [2, 1, 'test 2', 'second post post', false], + ]; $this->Dbo->insertMulti($table, $fields, $values); $sequence = $this->Dbo->getSequence($table); $result = $this->Dbo->rawQuery("SELECT nextval('$sequence')"); @@ -1122,7 +1122,7 @@ public function testSettings() { $config2['settings']['datestyle'] = 'sql, dmy'; ConnectionManager::create('test2', $config2); $dbo2 = new Postgres($config2, true); - $expected = array(array('r' => date('d/m/Y'))); + $expected = [['r' => date('d/m/Y')]]; $r = $dbo2->fetchRow('SELECT now()::date AS "r"'); $this->assertEquals($expected, $r); $dbo2->execute('SET DATESTYLE TO ISO'); @@ -1164,12 +1164,12 @@ public function testDescribeUuid() { $db->execute('CREATE TABLE test_uuid_describe (id UUID PRIMARY KEY, name VARCHAR(255))'); $data = $db->describe('test_uuid_describe'); - $expected = array( + $expected = [ 'type' => 'uuid', 'null' => false, 'default' => null, 'length' => 36, - ); + ]; $this->assertSame($expected, $data['id']); $db->execute('DROP TABLE test_uuid_describe'); } @@ -1183,39 +1183,39 @@ public function testDescribeTimestamp() { $this->loadFixtures('User'); $model = ClassRegistry::init('User'); $result = $this->Dbo->describe($model); - $expected = array( - 'id' => array( + $expected = [ + 'id' => [ 'type' => 'integer', 'null' => false, 'default' => null, 'length' => 11, 'key' => 'primary' - ), - 'user' => array( + ], + 'user' => [ 'type' => 'string', 'null' => true, 'default' => null, 'length' => 255 - ), - 'password' => array( + ], + 'password' => [ 'type' => 'string', 'null' => true, 'default' => null, 'length' => 255 - ), - 'created' => array( + ], + 'created' => [ 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null - ), - 'updated' => array( + ], + 'updated' => [ 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -1223,7 +1223,7 @@ public function testDescribeTimestamp() { * Test build column working for new uuid types */ public function testBuildColumnUuid() { - $column = array('name' => 'col1', 'type' => 'uuid'); + $column = ['name' => 'col1', 'type' => 'uuid']; $result = $this->Dbo2->buildColumn($column); $this->assertEquals('"col1" uuid', $result); @@ -1239,12 +1239,12 @@ public function testDescribeFunctionDefault() { $db->execute('CREATE TABLE test_function_default_describe (id integer PRIMARY KEY, year int default date_part(\'year\'::text, now()))'); $data = $db->describe('test_function_default_describe'); - $expected = array( + $expected = [ 'type' => 'integer', 'null' => true, 'default' => 'date_part(\'year\', now())', 'length' => null, - ); + ]; $this->assertSame($expected, $data['year']); $db->execute('DROP TABLE test_function_default_describe'); } diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php index 09d552e3ad..874decc5fc 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqliteTest.php @@ -20,7 +20,7 @@ App::uses('AppModel', 'Model'); App::uses('Sqlite', 'Model/Datasource/Database'); -require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php'; +require_once dirname(__FILE__, 3) . DS . 'models.php'; /** * DboSqliteTestDb class @@ -34,7 +34,7 @@ class DboSqliteTestDb extends Sqlite { * * @var array */ - public $simulated = array(); + public $simulated = []; /** * execute method @@ -42,7 +42,7 @@ class DboSqliteTestDb extends Sqlite { * @param mixed $sql * @return void */ - protected function _execute($sql, $params = array(), $prepareOptions = array()) { + protected function _execute($sql, $params = [], $prepareOptions = []) { $this->simulated[] = $sql; return null; } @@ -77,7 +77,7 @@ class SqliteTest extends CakeTestCase { * * @var object */ - public $fixtures = array('core.user', 'core.uuid', 'core.datatype'); + public $fixtures = ['core.user', 'core.uuid', 'core.datatype']; /** * Actual DB connection used in testing @@ -136,22 +136,22 @@ public function testIndex() { $this->Dbo->query('CREATE TABLE ' . $name . ' ("id" int(11) PRIMARY KEY, "bool" int(1), "small_char" varchar(50), "description" varchar(40) );'); $this->Dbo->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")'); $this->Dbo->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'pointless_bool' => array('column' => 'bool', 'unique' => 0), - 'char_index' => array('column' => 'small_char', 'unique' => 1), + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'pointless_bool' => ['column' => 'bool', 'unique' => 0], + 'char_index' => ['column' => 'small_char', 'unique' => 1], - ); + ]; $result = $this->Dbo->index($name); $this->assertEquals($expected, $result); $this->Dbo->query('DROP TABLE ' . $name); $this->Dbo->query('CREATE TABLE ' . $name . ' ("id" int(11) PRIMARY KEY, "bool" int(1), "small_char" varchar(50), "description" varchar(40) );'); $this->Dbo->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")'); - $expected = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'multi_col' => array('column' => array('small_char', 'bool'), 'unique' => 1), - ); + $expected = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'multi_col' => ['column' => ['small_char', 'bool'], 'unique' => 1], + ]; $result = $this->Dbo->index($name); $this->assertEquals($expected, $result); $this->Dbo->query('DROP TABLE ' . $name); @@ -165,28 +165,28 @@ public function testIndex() { public function testCacheKeyName() { Configure::write('Cache.disable', false); - $dbName = 'db' . rand() . '$(*%&).db'; + $dbName = 'db' . random_int(0, mt_getrandmax()) . '$(*%&).db'; $this->assertFalse(file_exists(TMP . $dbName)); try { - $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName))); - } catch (MissingConnectionException $e) { + $db = new Sqlite(array_merge($this->Dbo->config, ['database' => TMP . $dbName])); + } catch (MissingConnectionException) { // This might be caused by NTFS file systems, where '*' is a forbidden character. Repeat without this character. $dbName = str_replace('*', '', $dbName); - $db = new Sqlite(array_merge($this->Dbo->config, array('database' => TMP . $dbName))); + $db = new Sqlite(array_merge($this->Dbo->config, ['database' => TMP . $dbName])); } $this->assertTrue(file_exists(TMP . $dbName)); $db->execute("CREATE TABLE test_list (id VARCHAR(255));"); $db->cacheSources = true; - $this->assertEquals(array('test_list'), $db->listSources()); + $this->assertEquals(['test_list'], $db->listSources()); $db->cacheSources = false; $fileName = '_' . preg_replace('/[^A-Za-z0-9_\-+]/', '_', TMP . $dbName) . '_list'; $result = Cache::read($fileName, '_cake_model_'); - $this->assertEquals(array('test_list'), $result); + $this->assertEquals(['test_list'], $result); Cache::delete($fileName, '_cake_model_'); Configure::write('Cache.disable', true); @@ -198,110 +198,110 @@ public function testCacheKeyName() { * @return void */ public function testBuildColumn() { - $data = array( + $data = [ 'name' => 'int_field', 'type' => 'integer', 'null' => false, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"int_field" integer NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'name', 'type' => 'string', 'length' => 20, 'null' => false, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"name" varchar(20) NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'testName', 'type' => 'string', 'length' => 20, 'default' => null, 'null' => true, 'collate' => 'NOCASE' - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"testName" varchar(20) DEFAULT NULL COLLATE NOCASE'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'testName', 'type' => 'string', 'length' => 20, 'default' => 'test-value', 'null' => false, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"testName" varchar(20) DEFAULT \'test-value\' NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'testName', 'type' => 'integer', 'length' => 10, 'default' => 10, 'null' => false, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'testName', 'type' => 'integer', 'length' => 10, 'default' => 10, 'null' => false, 'collate' => 'BADVALUE' - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"testName" integer(10) DEFAULT 10 NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'testName', 'type' => 'smallinteger', 'length' => 6, 'default' => 6, 'null' => false, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"testName" smallint(6) DEFAULT 6 NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'testName', 'type' => 'tinyinteger', 'length' => 4, 'default' => 4, 'null' => false, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"testName" tinyint(4) DEFAULT 4 NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'huge', 'type' => 'biginteger', 'length' => 20, 'null' => false, - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"huge" bigint(20) NOT NULL'; $this->assertEquals($expected, $result); - $data = array( + $data = [ 'name' => 'id', 'type' => 'biginteger', 'length' => 20, 'null' => false, 'key' => 'primary', - ); + ]; $result = $this->Dbo->buildColumn($data); $expected = '"id" bigint(20) NOT NULL PRIMARY KEY'; $this->assertEquals($expected, $result); @@ -314,49 +314,49 @@ public function testBuildColumn() { */ public function testDescribe() { $this->loadFixtures('User'); - $Model = new Model(array( + $Model = new Model([ 'name' => 'User', 'ds' => 'test', 'table' => 'users' - )); + ]); $this->Dbo->cacheSources = true; Configure::write('Cache.disable', false); $result = $this->Dbo->describe($Model); - $expected = array( - 'id' => array( + $expected = [ + 'id' => [ 'type' => 'integer', 'key' => 'primary', 'null' => false, 'default' => null, 'length' => 11 - ), - 'user' => array( + ], + 'user' => [ 'type' => 'string', 'length' => 255, 'null' => true, 'default' => null - ), - 'password' => array( + ], + 'password' => [ 'type' => 'string', 'length' => 255, 'null' => true, 'default' => null - ), - 'created' => array( + ], + 'created' => [ 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null, - ), - 'updated' => array( + ], + 'updated' => [ 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null, - ) - ); + ] + ]; $this->assertEquals($expected, $result); $result = $this->Dbo->describe($Model->useTable); @@ -373,63 +373,63 @@ public function testDescribe() { */ public function testDatatypes() { $this->loadFixtures('Datatype'); - $Model = new Model(array( + $Model = new Model([ 'name' => 'Datatype', 'ds' => 'test', 'table' => 'datatypes' - )); + ]); $result = $this->Dbo->describe($Model); - $expected = array( - 'id' => array( + $expected = [ + 'id' => [ 'type' => 'integer', 'null' => false, 'default' => '', 'length' => 11, 'key' => 'primary', - ), - 'float_field' => array( + ], + 'float_field' => [ 'type' => 'float', 'null' => false, 'default' => '', 'length' => '5,2', - ), - 'decimal_field' => array( + ], + 'decimal_field' => [ 'type' => 'decimal', 'null' => true, 'default' => '0.000', 'length' => '6,3', - ), - 'huge_int' => array( + ], + 'huge_int' => [ 'type' => 'biginteger', 'null' => true, 'default' => null, 'length' => 20, - ), - 'normal_int' => array( + ], + 'normal_int' => [ 'type' => 'integer', 'null' => true, 'default' => null, 'length' => null - ), - 'small_int' => array( + ], + 'small_int' => [ 'type' => 'smallinteger', 'null' => true, 'default' => null, 'length' => null - ), - 'tiny_int' => array( + ], + 'tiny_int' => [ 'type' => 'tinyinteger', 'null' => true, 'default' => null, 'length' => null - ), - 'bool' => array( + ], + 'bool' => [ 'type' => 'boolean', 'null' => false, 'default' => '0', 'length' => null - ), - ); + ], + ]; $this->assertSame($expected, $result); } @@ -441,29 +441,29 @@ public function testDatatypes() { public function testDescribeWithUuidPrimaryKey() { $tableName = 'uuid_tests'; $this->Dbo->query("CREATE TABLE {$tableName} (id VARCHAR(36) PRIMARY KEY, name VARCHAR, created DATETIME, modified DATETIME)"); - $Model = new Model(array('name' => 'UuidTest', 'ds' => 'test', 'table' => 'uuid_tests')); + $Model = new Model(['name' => 'UuidTest', 'ds' => 'test', 'table' => 'uuid_tests']); $result = $this->Dbo->describe($Model); - $expected = array( + $expected = [ 'type' => 'string', 'length' => 36, 'null' => false, 'default' => null, 'key' => 'primary', - ); + ]; $this->assertEquals($expected, $result['id']); $this->Dbo->query('DROP TABLE ' . $tableName); $tableName = 'uuid_tests'; $this->Dbo->query("CREATE TABLE {$tableName} (id CHAR(36) PRIMARY KEY, name VARCHAR, created DATETIME, modified DATETIME)"); - $Model = new Model(array('name' => 'UuidTest', 'ds' => 'test', 'table' => 'uuid_tests')); + $Model = new Model(['name' => 'UuidTest', 'ds' => 'test', 'table' => 'uuid_tests']); $result = $this->Dbo->describe($Model); - $expected = array( + $expected = [ 'type' => 'string', 'length' => 36, 'null' => false, 'default' => null, 'key' => 'primary', - ); + ]; $this->assertEquals($expected, $result['id']); $this->Dbo->query('DROP TABLE ' . $tableName); } @@ -484,20 +484,20 @@ public function testDescribeHandleCurrentTimestamp() { ); SQL; $this->Dbo->execute($sql); - $model = new Model(array( + $model = new Model([ 'table' => 'timestamp_default_values', 'ds' => 'test', 'alias' => 'TimestampDefaultValue' - )); + ]); $result = $this->Dbo->describe($model); $this->Dbo->execute('DROP TABLE ' . $name); $this->assertNull($result['limit_date']['default']); - $schema = new CakeSchema(array( + $schema = new CakeSchema([ 'connection' => 'test', 'testdescribes' => $result - )); + ]); $result = $this->Dbo->createSchema($schema); $this->assertStringContainsString('"limit_date" timestamp NOT NULL', $result); } @@ -510,11 +510,11 @@ public function testDescribeHandleCurrentTimestamp() { public function testVirtualFieldWithFunction() { $this->loadFixtures('User'); $User = ClassRegistry::init('User'); - $User->virtualFields = array('name' => 'SUBSTR(User.user, 5, LENGTH(User.user) - 4)'); + $User->virtualFields = ['name' => 'SUBSTR(User.user, 5, LENGTH(User.user) - 4)']; - $result = $User->find('first', array( - 'conditions' => array('User.user' => 'garrett') - )); + $result = $User->find('first', [ + 'conditions' => ['User.user' => 'garrett'] + ]); $this->assertEquals('ett', $result['User']['name']); } @@ -528,10 +528,10 @@ public function testUuidPrimaryKeyInsertion() { $this->loadFixtures('Uuid'); $Model = ClassRegistry::init('Uuid'); - $data = array( + $data = [ 'title' => 'A UUID should work', 'count' => 10 - ); + ]; $Model->create($data); $this->assertTrue((bool)$Model->save()); $result = $Model->read(); @@ -551,7 +551,7 @@ public function testNestedTransaction() { $this->loadFixtures('User'); $model = new User(); - $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array(); + $model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = []; $model->cacheQueries = false; $this->Dbo->cacheMethods = false; @@ -612,17 +612,17 @@ public function testFetchRowColumnParsing() { 'OR "User.id" IN (5, 6, 7, 8)'; $result = $this->Dbo->fetchRow($sql); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => 4, 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23' - ), - 0 => array( + ], + 0 => [ 'two' => 2 - ) - ); + ] + ]; $this->assertEquals($expected, $result); $sql = 'SELECT "User"."id", "User"."user" ' . @@ -632,12 +632,12 @@ public function testFetchRowColumnParsing() { 'FROM "users" AS "User" WHERE "User"."id" = 3'; $result = $this->Dbo->fetchRow($sql); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => 3, 'user' => 'larry', - ), - ); + ], + ]; $this->assertEquals($expected, $result); } @@ -656,13 +656,13 @@ public function testFetchColumnRowParsingMoreComplex() { WHERE "User"."id" > 0'; $result = $this->Dbo->fetchRow($sql); - $expected = array( - '0' => array( + $expected = [ + '0' => [ 'User__count' => '4', 'User__case' => '1', 'User__bigint' => '2.5', - ), - ); + ], + ]; $this->assertEquals($expected, $result); } @@ -674,14 +674,14 @@ public function testFetchColumnRowParsingMoreComplex() { public function testBuildStatementWithoutLockingHint() { $model = new TestModel(); $sql = $this->Dbo->buildStatement( - array( - 'fields' => array('id'), + [ + 'fields' => ['id'], 'table' => 'users', 'alias' => 'User', - 'order' => array('id'), + 'order' => ['id'], 'limit' => 1, 'lock' => true, - ), + ], $model ); $expected = 'SELECT id FROM users AS "User" WHERE 1 = 1 ORDER BY "id" ASC LIMIT 1'; diff --git a/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php b/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php index 0ad014b3a2..3b3590de3f 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Database/SqlserverTest.php @@ -20,7 +20,7 @@ App::uses('AppModel', 'Model'); App::uses('Sqlserver', 'Model/Datasource/Database'); -require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php'; +require_once dirname(__FILE__, 3) . DS . 'models.php'; /** * SqlserverTestDb class @@ -34,14 +34,14 @@ class SqlserverTestDb extends Sqlserver { * * @var array */ - public $simulated = array(); + public $simulated = []; /** * execute results stack * * @var array */ - public $executeResultsStack = array(); + public $executeResultsStack = []; /** * execute method @@ -51,7 +51,7 @@ class SqlserverTestDb extends Sqlserver { * @param mixed $prepareOptions * @return mixed */ - protected function _execute($sql, $params = array(), $prepareOptions = array()) { + protected function _execute($sql, $params = [], $prepareOptions = []) { $this->simulated[] = $sql; return empty($this->executeResultsStack) ? null : array_pop($this->executeResultsStack); } @@ -63,7 +63,7 @@ protected function _execute($sql, $params = array(), $prepareOptions = array()) * @return void */ protected function _matchRecords(Model $model, $conditions = null) { - return $this->conditions(array('id' => array(1, 2))); + return $this->conditions(['id' => [1, 2]]); } /** @@ -91,7 +91,7 @@ public function getPrimaryKey($model) { * @return void */ public function clearFieldMappings() { - $this->_fieldMappings = array(); + $this->_fieldMappings = []; } /** @@ -125,37 +125,37 @@ class SqlserverTestModel extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), - 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), - 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''), - 'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'], + 'client_id' => ['type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'login' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'passwd' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'addr_1' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'addr_2' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'], + 'zip_code' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'city' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'country' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'phone' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'fax' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'url' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'comments' => ['type' => 'text', 'null' => '1', 'default' => '', 'length' => ''], + 'last_login' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; /** * belongsTo property * * @var array */ - public $belongsTo = array( - 'SqlserverClientTestModel' => array( + public $belongsTo = [ + 'SqlserverClientTestModel' => [ 'foreignKey' => 'client_id' - ) - ); + ] + ]; /** * find method @@ -191,13 +191,13 @@ class SqlserverClientTestModel extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'created' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } /** @@ -257,7 +257,7 @@ class SqlserverTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.user', 'core.category', 'core.author', 'core.post'); + public $fixtures = ['core.user', 'core.category', 'core.author', 'core.post']; /** * Sets up a Dbo class instance for testing @@ -322,7 +322,7 @@ public function testQuoting() { * @return void */ public function testFields() { - $fields = array( + $fields = [ '[SqlserverTestModel].[id] AS [SqlserverTestModel__id]', '[SqlserverTestModel].[client_id] AS [SqlserverTestModel__client_id]', '[SqlserverTestModel].[name] AS [SqlserverTestModel__name]', @@ -341,7 +341,7 @@ public function testFields() { 'CONVERT(VARCHAR(20), [SqlserverTestModel].[last_login], 20) AS [SqlserverTestModel__last_login]', '[SqlserverTestModel].[created] AS [SqlserverTestModel__created]', 'CONVERT(VARCHAR(20), [SqlserverTestModel].[updated], 20) AS [SqlserverTestModel__updated]' - ); + ]; $result = $this->db->fields($this->model); $expected = $fields; @@ -353,20 +353,20 @@ public function testFields() { $this->assertEquals($expected, $result); $this->db->clearFieldMappings(); - $result = $this->db->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name')); - $expected = array_merge($fields, array( + $result = $this->db->fields($this->model, null, ['*', 'AnotherModel.id', 'AnotherModel.name']); + $expected = array_merge($fields, [ '[AnotherModel].[id] AS [AnotherModel__id]', - '[AnotherModel].[name] AS [AnotherModel__name]')); + '[AnotherModel].[name] AS [AnotherModel__name]']); $this->assertEquals($expected, $result); $this->db->clearFieldMappings(); - $result = $this->db->fields($this->model, null, array('*', 'SqlserverClientTestModel.*')); - $expected = array_merge($fields, array( + $result = $this->db->fields($this->model, null, ['*', 'SqlserverClientTestModel.*']); + $expected = array_merge($fields, [ '[SqlserverClientTestModel].[id] AS [SqlserverClientTestModel__id]', '[SqlserverClientTestModel].[name] AS [SqlserverClientTestModel__name]', '[SqlserverClientTestModel].[email] AS [SqlserverClientTestModel__email]', 'CONVERT(VARCHAR(20), [SqlserverClientTestModel].[created], 20) AS [SqlserverClientTestModel__created]', - 'CONVERT(VARCHAR(20), [SqlserverClientTestModel].[updated], 20) AS [SqlserverClientTestModel__updated]')); + 'CONVERT(VARCHAR(20), [SqlserverClientTestModel].[updated], 20) AS [SqlserverClientTestModel__updated]']); $this->assertEquals($expected, $result); } @@ -376,16 +376,16 @@ public function testFields() { * @return void */ public function testDistinctFields() { - $result = $this->db->fields($this->model, null, array('DISTINCT Car.country_code')); - $expected = array('DISTINCT [Car].[country_code] AS [Car__country_code]'); + $result = $this->db->fields($this->model, null, ['DISTINCT Car.country_code']); + $expected = ['DISTINCT [Car].[country_code] AS [Car__country_code]']; $this->assertEquals($expected, $result); $result = $this->db->fields($this->model, null, 'DISTINCT Car.country_code'); - $expected = array('DISTINCT [Car].[country_code] AS [Car__country_code]'); + $expected = ['DISTINCT [Car].[country_code] AS [Car__country_code]']; $this->assertEquals($expected, $result); $result = $this->db->fields($this->model, null, 'COUNT(DISTINCT Car.country_code)'); - $expected = array('COUNT(DISTINCT [Car].[country_code]) AS [Car__country_code]'); + $expected = ['COUNT(DISTINCT [Car].[country_code]) AS [Car__country_code]']; $this->assertEquals($expected, $result); } @@ -395,17 +395,17 @@ public function testDistinctFields() { * @return void */ public function testDistinctWithLimit() { - $this->db->read($this->model, array( - 'fields' => array('DISTINCT SqlserverTestModel.city', 'SqlserverTestModel.country'), + $this->db->read($this->model, [ + 'fields' => ['DISTINCT SqlserverTestModel.city', 'SqlserverTestModel.country'], 'limit' => 5 - )); + ]); $result = $this->db->getLastQuery(); $this->assertMatchesRegularExpression('/^SELECT DISTINCT TOP 5/', $result); - $this->db->read($this->model, array( - 'fields' => array('DISTINCT SqlserverTestModel.city', 'SqlserverTestModel.country'), + $this->db->read($this->model, [ + 'fields' => ['DISTINCT SqlserverTestModel.city', 'SqlserverTestModel.country'], 'limit' => '5' - )); + ]); $result = $this->db->getLastQuery(); $this->assertMatchesRegularExpression('/^SELECT DISTINCT TOP 5/', $result); } @@ -416,24 +416,24 @@ public function testDistinctWithLimit() { * @return void */ public function testDescribe() { - $SqlserverTableDescription = new SqlserverTestResultIterator(array( - (object)array( + $SqlserverTableDescription = new SqlserverTestResultIterator([ + (object)[ 'Default' => '((0))', 'Field' => 'count', 'Key' => 0, 'Length' => '4', 'Null' => 'NO', 'Type' => 'integer' - ), - (object)array( + ], + (object)[ 'Default' => '', 'Field' => 'body', 'Key' => 0, 'Length' => '-1', 'Null' => 'YES', 'Type' => 'nvarchar' - ), - (object)array( + ], + (object)[ 'Default' => '', 'Field' => 'published', 'Key' => 0, @@ -441,8 +441,8 @@ public function testDescribe() { 'Length' => 8, 'Null' => 'YES', 'Size' => '' - ), - (object)array( + ], + (object)[ 'Default' => '', 'Field' => 'id', 'Key' => 1, @@ -450,8 +450,8 @@ public function testDescribe() { 'Length' => 72, 'Null' => 'NO', 'Size' => '' - ), - (object)array( + ], + (object)[ 'Default' => null, 'Field' => 'parent_id', 'Key' => '0', @@ -459,8 +459,8 @@ public function testDescribe() { 'Length' => 8, 'Null' => 'YES', 'Size' => '0', - ), - (object)array( + ], + (object)[ 'Default' => null, 'Field' => 'description', 'Key' => '0', @@ -468,50 +468,50 @@ public function testDescribe() { 'Length' => 16, 'Null' => 'YES', 'Size' => '0', - ), - )); - $this->db->executeResultsStack = array($SqlserverTableDescription); + ], + ]); + $this->db->executeResultsStack = [$SqlserverTableDescription]; $dummyModel = $this->model; $result = $this->db->describe($dummyModel); - $expected = array( - 'count' => array( + $expected = [ + 'count' => [ 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => 4 - ), - 'body' => array( + ], + 'body' => [ 'type' => 'text', 'null' => true, 'default' => null, 'length' => null - ), - 'published' => array( + ], + 'published' => [ 'type' => 'datetime', 'null' => true, 'default' => '', 'length' => null - ), - 'id' => array( + ], + 'id' => [ 'type' => 'string', 'null' => false, 'default' => '', 'length' => 36, 'key' => 'primary' - ), - 'parent_id' => array( + ], + 'parent_id' => [ 'type' => 'biginteger', 'null' => true, 'default' => null, 'length' => 8, - ), - 'description' => array( + ], + 'description' => [ 'type' => 'text', 'null' => true, 'default' => null, 'length' => null, - ) - ); + ] + ]; $this->assertEquals($expected, $result); $this->assertSame($expected['parent_id'], $result['parent_id']); } @@ -522,86 +522,86 @@ public function testDescribe() { * @return void */ public function testBuildColumn() { - $column = array('name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '8', 'key' => 'primary'); + $column = ['name' => 'id', 'type' => 'integer', 'null' => false, 'default' => '', 'length' => '8', 'key' => 'primary']; $result = $this->db->buildColumn($column); $expected = '[id] int IDENTITY (1, 1) NOT NULL'; $this->assertEquals($expected, $result); - $column = array('name' => 'client_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '11'); + $column = ['name' => 'client_id', 'type' => 'integer', 'null' => false, 'default' => '0', 'length' => '11']; $result = $this->db->buildColumn($column); $expected = '[client_id] int DEFAULT 0 NOT NULL'; $this->assertEquals($expected, $result); - $column = array('name' => 'client_id', 'type' => 'integer', 'null' => true); + $column = ['name' => 'client_id', 'type' => 'integer', 'null' => true]; $result = $this->db->buildColumn($column); $expected = '[client_id] int NULL'; $this->assertEquals($expected, $result); // 'name' => 'type' format for columns - $column = array('type' => 'integer', 'name' => 'client_id'); + $column = ['type' => 'integer', 'name' => 'client_id']; $result = $this->db->buildColumn($column); $expected = '[client_id] int NULL'; $this->assertEquals($expected, $result); - $column = array('type' => 'smallinteger', 'name' => 'client_id'); + $column = ['type' => 'smallinteger', 'name' => 'client_id']; $result = $this->db->buildColumn($column); $expected = '[client_id] smallint NULL'; $this->assertEquals($expected, $result); - $column = array('type' => 'tinyinteger', 'name' => 'client_id'); + $column = ['type' => 'tinyinteger', 'name' => 'client_id']; $result = $this->db->buildColumn($column); $expected = '[client_id] tinyint NULL'; $this->assertEquals($expected, $result); - $column = array('type' => 'string', 'name' => 'name'); + $column = ['type' => 'string', 'name' => 'name']; $result = $this->db->buildColumn($column); $expected = '[name] nvarchar(255) NULL'; $this->assertEquals($expected, $result); - $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255'); + $column = ['name' => 'name', 'type' => 'string', 'null' => false, 'default' => '', 'length' => '255']; $result = $this->db->buildColumn($column); $expected = '[name] nvarchar(255) DEFAULT \'\' NOT NULL'; $this->assertEquals($expected, $result); - $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255'); + $column = ['name' => 'name', 'type' => 'string', 'null' => false, 'length' => '255']; $result = $this->db->buildColumn($column); $expected = '[name] nvarchar(255) NOT NULL'; $this->assertEquals($expected, $result); - $column = array('name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255'); + $column = ['name' => 'name', 'type' => 'string', 'null' => false, 'default' => null, 'length' => '255']; $result = $this->db->buildColumn($column); $expected = '[name] nvarchar(255) NOT NULL'; $this->assertEquals($expected, $result); - $column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255'); + $column = ['name' => 'name', 'type' => 'string', 'null' => true, 'default' => null, 'length' => '255']; $result = $this->db->buildColumn($column); $expected = '[name] nvarchar(255) NULL'; $this->assertEquals($expected, $result); - $column = array('name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255'); + $column = ['name' => 'name', 'type' => 'string', 'null' => true, 'default' => '', 'length' => '255']; $result = $this->db->buildColumn($column); $expected = '[name] nvarchar(255) DEFAULT \'\''; $this->assertEquals($expected, $result); - $column = array('name' => 'body', 'type' => 'text'); + $column = ['name' => 'body', 'type' => 'text']; $result = $this->db->buildColumn($column); $expected = '[body] nvarchar(MAX)'; $this->assertEquals($expected, $result); - $column = array( + $column = [ 'name' => 'checked', 'type' => 'boolean', 'length' => 10, 'default' => '1' - ); + ]; $result = $this->db->buildColumn($column); $expected = "[checked] bit DEFAULT '1'"; $this->assertEquals($expected, $result); - $column = array( + $column = [ 'name' => 'huge', 'type' => 'biginteger', - ); + ]; $result = $this->db->buildColumn($column); $expected = "[huge] bigint"; $this->assertEquals($expected, $result); @@ -613,24 +613,24 @@ public function testBuildColumn() { * @return void */ public function testBuildIndex() { - $indexes = array( - 'PRIMARY' => array('column' => 'id', 'unique' => 1), - 'client_id' => array('column' => 'client_id', 'unique' => 1) - ); + $indexes = [ + 'PRIMARY' => ['column' => 'id', 'unique' => 1], + 'client_id' => ['column' => 'client_id', 'unique' => 1] + ]; $result = $this->db->buildIndex($indexes, 'items'); - $expected = array( + $expected = [ 'PRIMARY KEY ([id])', 'ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id]);' - ); + ]; $this->assertEquals($expected, $result); - $indexes = array('client_id' => array('column' => 'client_id')); + $indexes = ['client_id' => ['column' => 'client_id']]; $result = $this->db->buildIndex($indexes, 'items'); - $this->assertSame(array(), $result); + $this->assertSame([], $result); - $indexes = array('client_id' => array('column' => array('client_id', 'period_id'), 'unique' => 1)); + $indexes = ['client_id' => ['column' => ['client_id', 'period_id'], 'unique' => 1]]; $result = $this->db->buildIndex($indexes, 'items'); - $expected = array('ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id], [period_id]);'); + $expected = ['ALTER TABLE items ADD CONSTRAINT client_id UNIQUE([client_id], [period_id]);']; $this->assertEquals($expected, $result); } @@ -640,8 +640,8 @@ public function testBuildIndex() { * @return void */ public function testUpdateAllSyntax() { - $fields = array('SqlserverTestModel.client_id' => '[SqlserverTestModel].[client_id] + 1'); - $conditions = array('SqlserverTestModel.updated <' => date('2009-01-01 00:00:00')); + $fields = ['SqlserverTestModel.client_id' => '[SqlserverTestModel].[client_id] + 1']; + $conditions = ['SqlserverTestModel.updated <' => date('2009-01-01 00:00:00')]; $this->db->update($this->model, $fields, null, $conditions); $result = $this->db->getLastQuery(); @@ -675,11 +675,11 @@ public function testGetPrimaryKey() { */ public function testLimitOffsetHack() { $this->loadFixtures('Author', 'Post', 'User'); - $query = array( + $query = [ 'limit' => 2, 'page' => 1, 'order' => 'User.user ASC', - ); + ]; $User = ClassRegistry::init('User'); $results = $User->find('all', $query); @@ -687,11 +687,11 @@ public function testLimitOffsetHack() { $this->assertEquals('garrett', $results[0]['User']['user']); $this->assertEquals('larry', $results[1]['User']['user']); - $query = array( + $query = [ 'limit' => 2, 'page' => 2, 'order' => 'User.user ASC', - ); + ]; $User = ClassRegistry::init('User'); $results = $User->find('all', $query); @@ -734,27 +734,27 @@ public function testStoredProcedureReturn() { * @return void */ public function testBuildStatementWithHaving() { - $db = $this->getMock('SqlserverTestDb', array('getVersion'), array($this->Dbo->config)); + $db = $this->getMock('SqlserverTestDb', ['getVersion'], [$this->Dbo->config]); $db->expects($this->any()) ->method('getVersion') ->will($this->returnValue('11.00.0000')); - $query = array( - 'fields' => array('user_id', 'COUNT(*) AS count'), + $query = [ + 'fields' => ['user_id', 'COUNT(*) AS count'], 'table' => 'articles', 'alias' => 'Article', 'group' => 'user_id', - 'order' => array('COUNT(*)' => 'DESC'), + 'order' => ['COUNT(*)' => 'DESC'], 'limit' => 5, - 'having' => array('COUNT(*) >' => 10), - ); + 'having' => ['COUNT(*) >' => 10], + ]; $sql = $db->buildStatement($query, $this->model); $expected = 'SELECT TOP 5 user_id, COUNT(*) AS count FROM articles AS [Article] WHERE 1 = 1 GROUP BY user_id HAVING COUNT(*) > 10 ORDER BY COUNT(*) DESC'; $this->assertEquals($expected, $sql); - $sql = $db->buildStatement(array('offset' => 15) + $query, $this->model); + $sql = $db->buildStatement(['offset' => 15] + $query, $this->model); $expected = 'SELECT user_id, COUNT(*) AS count FROM articles AS [Article] WHERE 1 = 1 GROUP BY user_id HAVING COUNT(*) > 10 ORDER BY COUNT(*) DESC OFFSET 15 ROWS FETCH FIRST 5 ROWS ONLY'; $this->assertEquals($expected, $sql); } @@ -765,26 +765,26 @@ public function testBuildStatementWithHaving() { * @return void */ public function testBuildStatementWithLockingHint() { - $db = $this->getMock('SqlserverTestDb', array('getVersion'), array($this->Dbo->config)); + $db = $this->getMock('SqlserverTestDb', ['getVersion'], [$this->Dbo->config]); $db->expects($this->any()) ->method('getVersion') ->will($this->returnValue('11.00.0000')); - $query = array( - 'fields' => array('id'), + $query = [ + 'fields' => ['id'], 'table' => 'users', 'alias' => 'User', - 'order' => array('id'), + 'order' => ['id'], 'limit' => 1, 'lock' => true, - ); + ]; $sql = $db->buildStatement($query, $this->model); $expected = 'SELECT TOP 1 id FROM users AS [User] WITH (UPDLOCK) WHERE 1 = 1 ORDER BY [id] ASC'; $this->assertEquals($expected, $sql); - $sql = $db->buildStatement(array('offset' => 15) + $query, $this->model); + $sql = $db->buildStatement(['offset' => 15] + $query, $this->model); $expected = 'SELECT id FROM users AS [User] WITH (UPDLOCK) WHERE 1 = 1 ORDER BY [id] ASC OFFSET 15 ROWS FETCH FIRST 1 ROWS ONLY'; $this->assertEquals($expected, $sql); } @@ -795,27 +795,27 @@ public function testBuildStatementWithLockingHint() { * @return void */ public function testBuildStatementWithHavingForLegacyVersion() { - $db = $this->getMock('SqlserverTestDb', array('getVersion'), array($this->Dbo->config)); + $db = $this->getMock('SqlserverTestDb', ['getVersion'], [$this->Dbo->config]); $db->expects($this->any()) ->method('getVersion') ->will($this->returnValue('10.00.0000')); - $query = array( - 'fields' => array('user_id', 'COUNT(*) AS count'), + $query = [ + 'fields' => ['user_id', 'COUNT(*) AS count'], 'table' => 'articles', 'alias' => 'Article', 'group' => 'user_id', - 'order' => array('COUNT(*)' => 'DESC'), + 'order' => ['COUNT(*)' => 'DESC'], 'limit' => 5, - 'having' => array('COUNT(*) >' => 10), - ); + 'having' => ['COUNT(*) >' => 10], + ]; $sql = $db->buildStatement($query, $this->model); $expected = 'SELECT TOP 5 user_id, COUNT(*) AS count FROM articles AS [Article] WHERE 1 = 1 GROUP BY user_id HAVING COUNT(*) > 10 ORDER BY COUNT(*) DESC'; $this->assertEquals($expected, $sql); - $sql = $db->buildStatement(array('offset' => 15) + $query, $this->model); + $sql = $db->buildStatement(['offset' => 15] + $query, $this->model); $expected = <<getMock('SqlserverTestDb', array('getVersion'), array($this->Dbo->config)); + $db = $this->getMock('SqlserverTestDb', ['getVersion'], [$this->Dbo->config]); $db->expects($this->any()) ->method('getVersion') ->will($this->returnValue('10.00.0000')); - $query = array( - 'fields' => array('id'), + $query = [ + 'fields' => ['id'], 'table' => 'users', 'alias' => 'User', - 'order' => array('id'), + 'order' => ['id'], 'limit' => 1, 'lock' => true, - ); + ]; $sql = $db->buildStatement($query, $this->model); $expected = 'SELECT TOP 1 id FROM users AS [User] WITH (UPDLOCK) WHERE 1 = 1 ORDER BY [id] ASC'; $this->assertEquals($expected, $sql); - $sql = $db->buildStatement(array('offset' => 15) + $query, $this->model); + $sql = $db->buildStatement(['offset' => 15] + $query, $this->model); $expected = <<connected = true; } @@ -66,7 +66,7 @@ public function mergeAssociation(&$data, &$merge, $association, $type, $selfJoin return parent::_mergeAssociation($data, $merge, $association, $type, $selfJoin); } - public function setConfig($config = array()) { + public function setConfig($config = []) { $this->config = $config; } @@ -91,7 +91,7 @@ class DboSecondTestSource extends DboSource { public $endQuote = '_'; - public function connect($config = array()) { + public function connect($config = []) { $this->connected = true; } @@ -99,7 +99,7 @@ public function mergeAssociation(&$data, &$merge, $association, $type, $selfJoin return parent::_mergeAssociation($data, $merge, $association, $type, $selfJoin); } - public function setConfig($config = array()) { + public function setConfig($config = []) { $this->config = $config; } @@ -116,7 +116,7 @@ public function setConnection($conn) { */ class DboThirdTestSource extends DboSource { - public function connect($config = array()) { + public function connect($config = []) { $this->connected = true; } @@ -133,7 +133,7 @@ public function cacheMethodHasher($value) { */ class DboFourthTestSource extends DboSource { - public function connect($config = array()) { + public function connect($config = []) { $this->connected = true; } @@ -174,10 +174,10 @@ class DboSourceTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.apple', 'core.article', 'core.articles_tag', 'core.attachment', 'core.comment', 'core.sample', 'core.tag', 'core.user', 'core.post', 'core.author', 'core.data_test' - ); + ]; /** * setUp method @@ -220,7 +220,7 @@ public function testBooleanNullConditionsParsing() { $result = $this->testDb->conditions(null); $this->assertEquals(' WHERE 1 = 1', $result, 'null conditions failed %s'); - $result = $this->testDb->conditions(array()); + $result = $this->testDb->conditions([]); $this->assertEquals(' WHERE 1 = 1', $result, 'array() conditions failed %s'); $result = $this->testDb->conditions(''); @@ -236,10 +236,10 @@ public function testBooleanNullConditionsParsing() { * @return void */ public function testBooleanEmptyConditionsParsing() { - $result = $this->testDb->conditions(array('OR' => array())); + $result = $this->testDb->conditions(['OR' => []]); $this->assertEquals(' WHERE 1 = 1', $result, 'empty conditions failed'); - $result = $this->testDb->conditions(array('OR' => array('OR' => array()))); + $result = $this->testDb->conditions(['OR' => ['OR' => []]]); $this->assertEquals(' WHERE 1 = 1', $result, 'nested empty conditions failed'); } @@ -250,17 +250,17 @@ public function testBooleanEmptyConditionsParsing() { */ public function testColumnHyphenOperator() { //PostgreSQL style - $result = $this->testDb->conditions(array('Foo.bar->>\'fieldName\'' => 42)); + $result = $this->testDb->conditions(['Foo.bar->>\'fieldName\'' => 42]); $this->assertEquals(' WHERE `Foo`.`bar`->>\'fieldName\' = 42', $result, 'SQL JSON operator failed'); - $result = $this->testDb->conditions(array('Foo.bar->\'fieldName\'' => 42)); + $result = $this->testDb->conditions(['Foo.bar->\'fieldName\'' => 42]); $this->assertEquals(' WHERE `Foo`.`bar`->\'fieldName\' = 42', $result, 'SQL JSON operator failed'); // MYSQL style - $result = $this->testDb->conditions(array('Foo.bar->>\'$.fieldName\'' => 42)); + $result = $this->testDb->conditions(['Foo.bar->>\'$.fieldName\'' => 42]); $this->assertEquals(' WHERE `Foo`.`bar`->>\'$.fieldName\' = 42', $result, 'SQL JSON operator failed'); //Without defining table name. - $result = $this->testDb->conditions(array('bar->>\'$.fieldName\'' => 42)); + $result = $this->testDb->conditions(['bar->>\'$.fieldName\'' => 42]); $this->assertEquals(' WHERE `bar`->>\'$.fieldName\' = 42', $result, 'SQL JSON operator failed'); } @@ -282,269 +282,269 @@ public function testOrderWithExpression() { * @return void */ public function testMergeAssociations() { - $data = array('Article2' => array( + $data = ['Article2' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )); - $merge = array('Topic' => array(array( + ]]; + $merge = ['Topic' => [[ 'id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ))); - $expected = array( - 'Article2' => array( + ]]]; + $expected = [ + 'Article2' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Topic' => array( + ], + 'Topic' => [ 'id' => '1', 'topic' => 'Topic', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ); + ] + ]; $this->testDb->mergeAssociation($data, $merge, 'Topic', 'hasOne'); $this->assertEquals($expected, $data); - $data = array('Article2' => array( + $data = ['Article2' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )); - $merge = array('User2' => array(array( + ]]; + $merge = ['User2' => [[ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ))); + ]]]; - $expected = array( - 'Article2' => array( + $expected = [ + 'Article2' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User2' => array( + ], + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ); + ] + ]; $this->testDb->mergeAssociation($data, $merge, 'User2', 'belongsTo'); $this->assertEquals($expected, $data); - $data = array( - 'Article2' => array( + $data = [ + 'Article2' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ); - $merge = array(array('Comment' => false)); - $expected = array( - 'Article2' => array( + ] + ]; + $merge = [['Comment' => false]]; + $expected = [ + 'Article2' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Comment' => array() - ); + ], + 'Comment' => [] + ]; $this->testDb->mergeAssociation($data, $merge, 'Comment', 'hasMany'); $this->assertEquals($expected, $data); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ); - $merge = array( - array( - 'Comment' => array( + ] + ]; + $merge = [ + [ + 'Comment' => [ 'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( - 'Comment' => array( + ] + ], + [ + 'Comment' => [ 'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ); - $expected = array( - 'Article' => array( + ] + ] + ]; + $expected = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - array( + ], + [ 'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ); + ] + ] + ]; $this->testDb->mergeAssociation($data, $merge, 'Comment', 'hasMany'); $this->assertEquals($expected, $data); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ); - $merge = array( - array( - 'Comment' => array( + ] + ]; + $merge = [ + [ + 'Comment' => [ 'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'User2' => array( + ], + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( - 'Comment' => array( + ] + ], + [ + 'Comment' => [ 'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'User2' => array( + ], + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ); - $expected = array( - 'Article' => array( + ] + ] + ]; + $expected = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'User2' => array( + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( + ] + ], + [ 'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'User2' => array( + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ) - ); + ] + ] + ] + ]; $this->testDb->mergeAssociation($data, $merge, 'Comment', 'hasMany'); $this->assertEquals($expected, $data); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ); - $merge = array( - array( - 'Comment' => array( + ] + ]; + $merge = [ + [ + 'Comment' => [ 'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'User2' => array( + ], + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Tag' => array( - array('id' => 1, 'tag' => 'Tag 1'), - array('id' => 2, 'tag' => 'Tag 2') - ) - ), - array( - 'Comment' => array( + ], + 'Tag' => [ + ['id' => 1, 'tag' => 'Tag 1'], + ['id' => 2, 'tag' => 'Tag 2'] + ] + ], + [ + 'Comment' => [ 'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'User2' => array( + ], + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Tag' => array() - ) - ); - $expected = array( - 'Article' => array( + ], + 'Tag' => [] + ] + ]; + $expected = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'comment' => 'Comment 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'User2' => array( + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Tag' => array( - array('id' => 1, 'tag' => 'Tag 1'), - array('id' => 2, 'tag' => 'Tag 2') - ) - ), - array( + ], + 'Tag' => [ + ['id' => 1, 'tag' => 'Tag 1'], + ['id' => 2, 'tag' => 'Tag 2'] + ] + ], + [ 'id' => '2', 'comment' => 'Comment 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - 'User2' => array( + 'User2' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Tag' => array() - ) - ) - ); + ], + 'Tag' => [] + ] + ] + ]; $this->testDb->mergeAssociation($data, $merge, 'Comment', 'hasMany'); $this->assertEquals($expected, $data); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ); - $merge = array( - array( - 'Tag' => array( + ] + ]; + $merge = [ + [ + 'Tag' => [ 'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( - 'Tag' => array( + ] + ], + [ + 'Tag' => [ 'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( - 'Tag' => array( + ] + ], + [ + 'Tag' => [ 'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ); - $expected = array( - 'Article' => array( + ] + ] + ]; + $expected = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ); + ] + ] + ]; $this->testDb->mergeAssociation($data, $merge, 'Tag', 'hasAndBelongsToMany'); $this->assertEquals($expected, $data); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ); - $merge = array( - array( - 'Tag' => array( + ] + ]; + $merge = [ + [ + 'Tag' => [ 'id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( - 'Tag' => array( + ] + ], + [ + 'Tag' => [ 'id' => '2', 'tag' => 'Tag 2', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ), - array( - 'Tag' => array( + ] + ], + [ + 'Tag' => [ 'id' => '3', 'tag' => 'Tag 3', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ) - ) - ); - $expected = array( - 'Article' => array( + ] + ] + ]; + $expected = [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Tag' => array('id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31') - ); + ], + 'Tag' => ['id' => '1', 'tag' => 'Tag 1', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'] + ]; $this->testDb->mergeAssociation($data, $merge, 'Tag', 'hasOne'); $this->assertEquals($expected, $data); } @@ -555,126 +555,126 @@ public function testMergeAssociations() { * @return void */ public function testMagicMethodQuerying() { - $result = $this->db->query('findByFieldName', array('value'), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.field_name' => 'value'), + $result = $this->db->query('findByFieldName', ['value'], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.field_name' => 'value'], 'fields' => null, 'order' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); - $result = $this->db->query('findByFindBy', array('value'), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.find_by' => 'value'), + $result = $this->db->query('findByFindBy', ['value'], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.find_by' => 'value'], 'fields' => null, 'order' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); - $result = $this->db->query('findAllByFieldName', array('value'), $this->Model); - $expected = array('all', array( - 'conditions' => array('TestModel.field_name' => 'value'), + $result = $this->db->query('findAllByFieldName', ['value'], $this->Model); + $expected = ['all', [ + 'conditions' => ['TestModel.field_name' => 'value'], 'fields' => null, 'order' => null, 'limit' => null, 'page' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); - $result = $this->db->query('findAllById', array('a'), $this->Model); - $expected = array('all', array( - 'conditions' => array('TestModel.id' => 'a'), + $result = $this->db->query('findAllById', ['a'], $this->Model); + $expected = ['all', [ + 'conditions' => ['TestModel.id' => 'a'], 'fields' => null, 'order' => null, 'limit' => null, 'page' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); - $result = $this->db->query('findByFieldName', array(array('value1', 'value2', 'value3')), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.field_name' => array('value1', 'value2', 'value3')), + $result = $this->db->query('findByFieldName', [['value1', 'value2', 'value3']], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.field_name' => ['value1', 'value2', 'value3']], 'fields' => null, 'order' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); - $result = $this->db->query('findByFieldName', array(null), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.field_name' => null), + $result = $this->db->query('findByFieldName', [null], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.field_name' => null], 'fields' => null, 'order' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); - $result = $this->db->query('findByFieldName', array('= a'), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.field_name' => '= a'), + $result = $this->db->query('findByFieldName', ['= a'], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.field_name' => '= a'], 'fields' => null, 'order' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); - $result = $this->db->query('findByFieldName', array(), $this->Model); + $result = $this->db->query('findByFieldName', [], $this->Model); $expected = false; $this->assertEquals($expected, $result); // findByAnd - $result = $this->db->query('findByFieldXAndFieldY', array('x', 'y'), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.field_x' => 'x', 'TestModel.field_y' => 'y'), + $result = $this->db->query('findByFieldXAndFieldY', ['x', 'y'], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.field_x' => 'x', 'TestModel.field_y' => 'y'], 'fields' => null, 'order' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); // findByOr - $result = $this->db->query('findByFieldXOrFieldY', array('x', 'y'), $this->Model); - $expected = array('first', array( - 'conditions' => array('OR' => array('TestModel.field_x' => 'x', 'TestModel.field_y' => 'y')), + $result = $this->db->query('findByFieldXOrFieldY', ['x', 'y'], $this->Model); + $expected = ['first', [ + 'conditions' => ['OR' => ['TestModel.field_x' => 'x', 'TestModel.field_y' => 'y']], 'fields' => null, 'order' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); // findMyFancySearchBy - $result = $this->db->query('findMyFancySearchByFieldX', array('x'), $this->Model); - $expected = array('myFancySearch', array( - 'conditions' => array('TestModel.field_x' => 'x'), + $result = $this->db->query('findMyFancySearchByFieldX', ['x'], $this->Model); + $expected = ['myFancySearch', [ + 'conditions' => ['TestModel.field_x' => 'x'], 'fields' => null, 'order' => null, 'limit' => null, 'page' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); // findFirstBy - $result = $this->db->query('findFirstByFieldX', array('x'), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.field_x' => 'x'), + $result = $this->db->query('findFirstByFieldX', ['x'], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.field_x' => 'x'], 'fields' => null, 'order' => null, 'recursive' => null - )); + ]]; $this->assertEquals($expected, $result); // findBy with optional parameters - $result = $this->db->query('findByFieldX', array('x', 'y', 'priority', -1), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.field_x' => 'x'), + $result = $this->db->query('findByFieldX', ['x', 'y', 'priority', -1], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.field_x' => 'x'], 'fields' => 'y', 'order' => 'priority', 'recursive' => -1 - )); + ]]; $this->assertEquals($expected, $result); // findByAnd with optional parameters - $result = $this->db->query('findByFieldXAndFieldY', array('x', 'y', 'z', 'priority', -1), $this->Model); - $expected = array('first', array( - 'conditions' => array('TestModel.field_x' => 'x', 'TestModel.field_y' => 'y'), + $result = $this->db->query('findByFieldXAndFieldY', ['x', 'y', 'z', 'priority', -1], $this->Model); + $expected = ['first', [ + 'conditions' => ['TestModel.field_x' => 'x', 'TestModel.field_y' => 'y'], 'fields' => 'z', 'order' => 'priority', 'recursive' => -1 - )); + ]]; $this->assertEquals($expected, $result); // findAllBy with optional parameters - $result = $this->db->query('findAllByFieldX', array('x', 'y', 'priority', 10, 2, -1), $this->Model); - $expected = array('all', array( - 'conditions' => array('TestModel.field_x' => 'x'), + $result = $this->db->query('findAllByFieldX', ['x', 'y', 'priority', 10, 2, -1], $this->Model); + $expected = ['all', [ + 'conditions' => ['TestModel.field_x' => 'x'], 'fields' => 'y', 'order' => 'priority', 'limit' => 10, 'page' => 2, 'recursive' => -1 - )); + ]]; $this->assertEquals($expected, $result); // findAllByAnd with optional parameters - $result = $this->db->query('findAllByFieldXAndFieldY', array('x', 'y', 'z', 'priority', 10, 2, -1), $this->Model); - $expected = array('all', array( - 'conditions' => array('TestModel.field_x' => 'x', 'TestModel.field_y' => 'y'), + $result = $this->db->query('findAllByFieldXAndFieldY', ['x', 'y', 'z', 'priority', 10, 2, -1], $this->Model); + $expected = ['all', [ + 'conditions' => ['TestModel.field_x' => 'x', 'TestModel.field_y' => 'y'], 'fields' => 'z', 'order' => 'priority', 'limit' => 10, 'page' => 2, 'recursive' => -1 - )); + ]]; $this->assertEquals($expected, $result); } @@ -684,7 +684,7 @@ public function testMagicMethodQuerying() { */ public function testDirectCallThrowsException() { $this->expectException(PDOException::class); - $this->db->query('directCall', array(), $this->Model); + $this->db->query('directCall', [], $this->Model); } /** @@ -699,8 +699,8 @@ public function testValue() { $result = $this->db->value('{$__cakeForeignKey__$}'); $this->assertEquals('{$__cakeForeignKey__$}', $result); - $result = $this->db->value(array('first', 2, 'third')); - $expected = array('\'first\'', 2, '\'third\''); + $result = $this->db->value(['first', 2, 'third']); + $expected = ['\'first\'', 2, '\'third\'']; $this->assertEquals($expected, $result); } @@ -710,7 +710,7 @@ public function testValue() { * @return void */ public function testReconnect() { - $this->testDb->reconnect(array('prefix' => 'foo')); + $this->testDb->reconnect(['prefix' => 'foo']); $this->assertTrue($this->testDb->connected); $this->assertEquals('foo', $this->testDb->config['prefix']); } @@ -725,8 +725,8 @@ public function testName() { $expected = '`name`'; $this->assertEquals($expected, $result); - $result = $this->testDb->name(array('name', 'Model.*')); - $expected = array('`name`', '`Model`.*'); + $result = $this->testDb->name(['name', 'Model.*']); + $expected = ['`name`', '`Model`.*']; $this->assertEquals($expected, $result); $result = $this->testDb->name('MTD()'); @@ -765,12 +765,12 @@ public function testName() { $expected = '`name-with-minus`'; $this->assertEquals($expected, $result); - $result = $this->testDb->name(array('my-name', 'Foo-Model.*')); - $expected = array('`my-name`', '`Foo-Model`.*'); + $result = $this->testDb->name(['my-name', 'Foo-Model.*']); + $expected = ['`my-name`', '`Foo-Model`.*']; $this->assertEquals($expected, $result); - $result = $this->testDb->name(array('Team.P%', 'Team.G/G')); - $expected = array('`Team`.`P%`', '`Team`.`G/G`'); + $result = $this->testDb->name(['Team.P%', 'Team.G/G']); + $expected = ['`Team`.`P%`', '`Team`.`G/G`']; $this->assertEquals($expected, $result); $result = $this->testDb->name('Model.name as y'); @@ -820,7 +820,7 @@ public function testCacheMethodFilter() { $method = 'fields'; $key = '2b57253ab1fffb3e95fa4f95299220b1'; - $value = array("`Menu`.`id`", "`Menu`.`name`"); + $value = ["`Menu`.`id`", "`Menu`.`name`"]; $actual = $this->testDb->cacheMethodFilter($method, $key, $value); $this->assertTrue($actual); @@ -857,7 +857,7 @@ public function testCacheMethodFilterOverridden() { $method = 'fields'; $key = '2b57253ab1fffb3e95fa4f95299220b1'; - $value = array("`Menu`.`id`", "`Menu`.`name`"); + $value = ["`Menu`.`id`", "`Menu`.`name`"]; $actual = $testDb->cacheMethodFilter($method, $key, $value); $this->assertFalse($actual); @@ -947,7 +947,7 @@ public function testLog() { $log = $this->testDb->getLog(false, false); $result = Hash::extract($log['log'], '{n}.query'); - $expected = array('Query 1', 'Query 2'); + $expected = ['Query 1', 'Query 2']; $this->assertEquals($expected, $result); $oldDebug = Configure::read('debug'); @@ -979,12 +979,12 @@ public function testGetLog() { $this->testDb->logQuery('Query 2'); $log = $this->testDb->getLog(); - $expected = array('query' => 'Query 1', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'Query 1', 'params' => [], 'affected' => '', 'numRows' => '', 'took' => '']; $this->assertEquals($expected, $log['log'][0]); - $expected = array('query' => 'Query 2', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'Query 2', 'params' => [], 'affected' => '', 'numRows' => '', 'took' => '']; $this->assertEquals($expected, $log['log'][1]); - $expected = array('query' => 'Error 1', 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'Error 1', 'affected' => '', 'numRows' => '', 'took' => '']; } /** @@ -993,13 +993,13 @@ public function testGetLog() { * @return void */ public function testGetLogParams() { - $this->testDb->logQuery('Query 1', array(1, 2, 'abc')); - $this->testDb->logQuery('Query 2', array('field1' => 1, 'field2' => 'abc')); + $this->testDb->logQuery('Query 1', [1, 2, 'abc']); + $this->testDb->logQuery('Query 2', ['field1' => 1, 'field2' => 'abc']); $log = $this->testDb->getLog(); - $expected = array('query' => 'Query 1', 'params' => array(1, 2, 'abc'), 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'Query 1', 'params' => [1, 2, 'abc'], 'affected' => '', 'numRows' => '', 'took' => '']; $this->assertEquals($expected, $log['log'][0]); - $expected = array('query' => 'Query 2', 'params' => array('field1' => 1, 'field2' => 'abc'), 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'Query 2', 'params' => ['field1' => 1, 'field2' => 'abc'], 'affected' => '', 'numRows' => '', 'took' => '']; $this->assertEquals($expected, $log['log'][1]); } @@ -1039,18 +1039,18 @@ public function testNotNullOnEnum() { $this->assertTrue($result); $EnumTest = ClassRegistry::init('EnumTest'); - $enumResult = $EnumTest->save(array('mood' => '')); + $enumResult = $EnumTest->save(['mood' => '']); $query = "DROP TABLE {$name};"; $result = $this->db->query($query); $this->assertTrue($result); - $this->assertEquals(array( - 'EnumTest' => array( + $this->assertEquals([ + 'EnumTest' => [ 'mood' => '', 'id' => '0' - ) - ), $enumResult); + ] + ], $enumResult); } /** @@ -1073,18 +1073,18 @@ public function testIntValueAsStringOnEnum() { $this->assertTrue($result); $EnumFayaTest = ClassRegistry::init('EnumFayaTest'); - $enumResult = $EnumFayaTest->save(array('faya' => '10')); + $enumResult = $EnumFayaTest->save(['faya' => '10']); $query = "DROP TABLE {$name};"; $result = $this->db->query($query); $this->assertTrue($result); - $this->assertEquals(array( - 'EnumFayaTest' => array( + $this->assertEquals([ + 'EnumFayaTest' => [ 'faya' => '10', 'id' => '0' - ) - ), $enumResult); + ] + ], $enumResult); } /** @@ -1094,16 +1094,16 @@ public function testIntValueAsStringOnEnum() { */ public function testVirtualFieldsInOrder() { $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( + $Article->virtualFields = [ 'this_moment' => 'NOW()', 'two' => '1 + 1', - ); - $order = array('two', 'this_moment'); + ]; + $order = ['two', 'this_moment']; $result = $this->db->order($order, 'ASC', $Article); $expected = ' ORDER BY (1 + 1) ASC, (NOW()) ASC'; $this->assertEquals($expected, $result); - $order = array('Article.two', 'Article.this_moment'); + $order = ['Article.two', 'Article.this_moment']; $result = $this->db->order($order, 'ASC', $Article); $expected = ' ORDER BY (1 + 1) ASC, (NOW()) ASC'; $this->assertEquals($expected, $result); @@ -1136,9 +1136,9 @@ public function testFullTablePermutations() { $this->assertEquals($testdb->getSchemaName() . '.articles', $result); // tests for empty schemaName - $noschema = ConnectionManager::create('noschema', array( + $noschema = ConnectionManager::create('noschema', [ 'datasource' => 'DboTestSource' - )); + ]); $Article->setDataSource('noschema'); $Article->schemaName = null; $result = $noschema->fullTableName($Article, false, true); @@ -1156,9 +1156,9 @@ public function testFullTablePermutations() { */ public function testReadOnlyCallingQueryAssociationWhenDefined() { $this->loadFixtures('Article', 'User', 'ArticlesTag', 'Tag'); - ConnectionManager::create('test_no_queryAssociation', array( + ConnectionManager::create('test_no_queryAssociation', [ 'datasource' => 'MockDataSource' - )); + ]); $Article = ClassRegistry::init('Article'); $Article->Comment->useDbConfig = 'test_no_queryAssociation'; $result = $Article->find('all'); @@ -1178,43 +1178,43 @@ public function testQueryAssociationUnneededQueries() { $fullDebug = $this->db->fullDebug; $this->db->fullDebug = true; - $Comment->find('all', array('recursive' => 2)); // ensure Model descriptions are saved + $Comment->find('all', ['recursive' => 2]); // ensure Model descriptions are saved $this->db->getLog(); // case: Comment belongsTo User and Article - $Comment->unbindModel(array( - 'hasOne' => array('Attachment') - )); - $Comment->Article->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment'), - 'hasAndBelongsToMany' => array('Tag') - )); - $Comment->find('all', array('recursive' => 2)); + $Comment->unbindModel([ + 'hasOne' => ['Attachment'] + ]); + $Comment->Article->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'], + 'hasAndBelongsToMany' => ['Tag'] + ]); + $Comment->find('all', ['recursive' => 2]); $log = $this->db->getLog(); $this->assertEquals(1, count($log['log'])); // case: Comment belongsTo Article, Article belongsTo User - $Comment->unbindModel(array( - 'belongsTo' => array('User'), - 'hasOne' => array('Attachment') - )); - $Comment->Article->unbindModel(array( - 'hasMany' => array('Comment'), - 'hasAndBelongsToMany' => array('Tag'), - )); - $Comment->find('all', array('recursive' => 2)); + $Comment->unbindModel([ + 'belongsTo' => ['User'], + 'hasOne' => ['Attachment'] + ]); + $Comment->Article->unbindModel([ + 'hasMany' => ['Comment'], + 'hasAndBelongsToMany' => ['Tag'], + ]); + $Comment->find('all', ['recursive' => 2]); $log = $this->db->getLog(); $this->assertEquals(7, count($log['log'])); // case: Comment hasOne Attachment - $Comment->unbindModel(array( - 'belongsTo' => array('Article', 'User'), - )); - $Comment->Attachment->unbindModel(array( - 'belongsTo' => array('Comment'), - )); - $Comment->find('all', array('recursive' => 2)); + $Comment->unbindModel([ + 'belongsTo' => ['Article', 'User'], + ]); + $Comment->Attachment->unbindModel([ + 'belongsTo' => ['Comment'], + ]); + $Comment->find('all', ['recursive' => 2]); $log = $this->db->getLog(); $this->assertEquals(1, count($log['log'])); @@ -1231,22 +1231,22 @@ public function testGenerateAssociationQuery() { $this->loadFixtures('Article'); $Article = ClassRegistry::init('Article'); - $queryData = array( - 'conditions' => array( + $queryData = [ + 'conditions' => [ 'Article.id' => 1 - ), - 'fields' => array( + ], + 'fields' => [ 'Article.id', 'Article.title', - ), - 'joins' => array(), + ], + 'joins' => [], 'limit' => 2, 'offset' => 2, - 'order' => array('title'), + 'order' => ['title'], 'page' => 2, 'group' => null, 'callbacks' => 1 - ); + ]; $result = $this->db->generateAssociationQuery($Article, null, null, null, null, $queryData, false); $this->assertStringContainsString('SELECT', $result); @@ -1262,10 +1262,10 @@ public function testGenerateAssociationQuery() { */ public function testFieldsUsingMethodCache() { $this->testDb->cacheMethods = false; - DboTestSource::$methodCache = array(); + DboTestSource::$methodCache = []; $Article = ClassRegistry::init('Article'); - $this->testDb->fields($Article, null, array('title', 'body', 'published')); + $this->testDb->fields($Article, null, ['title', 'body', 'published']); $this->assertTrue(empty(DboTestSource::$methodCache['fields']), 'Cache not empty'); } @@ -1275,25 +1275,25 @@ public function testFieldsUsingMethodCache() { * @return void */ public function testFieldsCacheKeyWithDatasourceChange() { - ConnectionManager::create('firstschema', array( + ConnectionManager::create('firstschema', [ 'datasource' => 'DboTestSource' - )); - ConnectionManager::create('secondschema', array( + ]); + ConnectionManager::create('secondschema', [ 'datasource' => 'DboSecondTestSource' - )); + ]); Cache::delete('method_cache', '_cake_core_'); - DboTestSource::$methodCache = array(); + DboTestSource::$methodCache = []; $Article = ClassRegistry::init('Article'); $Article->setDataSource('firstschema'); $ds = $Article->getDataSource(); $ds->cacheMethods = true; - $first = $ds->fields($Article, null, array('title', 'body', 'published')); + $first = $ds->fields($Article, null, ['title', 'body', 'published']); $Article->setDataSource('secondschema'); $ds = $Article->getDataSource(); $ds->cacheMethods = true; - $second = $ds->fields($Article, null, array('title', 'body', 'published')); + $second = $ds->fields($Article, null, ['title', 'body', 'published']); $this->assertNotEquals($first, $second); $this->assertEquals(2, count(DboTestSource::$methodCache['fields'])); @@ -1309,7 +1309,7 @@ public function testFieldsCacheKeyWithSchemanameChange() { $this->markTestSkipped('Cannot run this test with SqlServer or Postgres'); } Cache::delete('method_cache', '_cake_core_'); - DboSource::$methodCache = array(); + DboSource::$methodCache = []; $Article = ClassRegistry::init('Article'); $ds = $Article->getDataSource(); @@ -1342,7 +1342,7 @@ public function testGroupNoModel() { public function testHaving() { $this->loadFixtures('User'); - $result = $this->testDb->having(array('COUNT(*) >' => 0)); + $result = $this->testDb->having(['COUNT(*) >' => 0]); $this->assertEquals(' HAVING COUNT(*) > 0', $result); $User = ClassRegistry::init('User'); @@ -1370,7 +1370,7 @@ public function testLastError() { $stmt = $this->getMock('PDOStatement'); $stmt->expects($this->any()) ->method('errorInfo') - ->will($this->returnValue(array('', 'something', 'bad'))); + ->will($this->returnValue(['', 'something', 'bad'])); $result = $this->db->lastError($stmt); $expected = 'something: bad'; @@ -1393,21 +1393,21 @@ public function testTransactionLogging() { $db->begin(); $log = $db->getLog(); - $expected = array('query' => 'BEGIN', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'BEGIN', 'params' => [], 'affected' => '', 'numRows' => '', 'took' => '']; $this->assertEquals($expected, $log['log'][0]); $db->commit(); - $expected = array('query' => 'COMMIT', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'COMMIT', 'params' => [], 'affected' => '', 'numRows' => '', 'took' => '']; $log = $db->getLog(); $this->assertEquals($expected, $log['log'][0]); $db->begin(); - $expected = array('query' => 'BEGIN', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'BEGIN', 'params' => [], 'affected' => '', 'numRows' => '', 'took' => '']; $log = $db->getLog(); $this->assertEquals($expected, $log['log'][0]); $db->rollback(); - $expected = array('query' => 'ROLLBACK', 'params' => array(), 'affected' => '', 'numRows' => '', 'took' => ''); + $expected = ['query' => 'ROLLBACK', 'params' => [], 'affected' => '', 'numRows' => '', 'took' => '']; $log = $db->getLog(); $this->assertEquals($expected, $log['log'][0]); } @@ -1493,7 +1493,7 @@ protected function _runTransactions($db) { * @return void */ public function testBuildStatementDefaults() { - $conn = $this->getMock('MockPDO', array('quote')); + $conn = $this->getMock('MockPDO', ['quote']); $conn->expects($this->any()) ->method('quote') ->will($this->returnArgument(0)); @@ -1501,14 +1501,14 @@ public function testBuildStatementDefaults() { $db->setConnection($conn); $subQuery = $db->buildStatement( - array( - 'fields' => array('DISTINCT(AssetsTag.asset_id)'), + [ + 'fields' => ['DISTINCT(AssetsTag.asset_id)'], 'table' => 'assets_tags', 'alias' => 'AssetsTag', - 'conditions' => array('Tag.name' => 'foo bar'), + 'conditions' => ['Tag.name' => 'foo bar'], 'limit' => null, 'group' => 'AssetsTag.asset_id' - ), + ], $this->Model ); $expected = 'SELECT DISTINCT(AssetsTag.asset_id) FROM assets_tags AS AssetsTag WHERE Tag.name = foo bar GROUP BY AssetsTag.asset_id'; @@ -1521,7 +1521,7 @@ public function testBuildStatementDefaults() { * @return void */ public function testBuildStatementWithHaving() { - $conn = $this->getMock('MockPDO', array('quote')); + $conn = $this->getMock('MockPDO', ['quote']); $conn->expects($this->any()) ->method('quote') ->will($this->returnArgument(0)); @@ -1529,15 +1529,15 @@ public function testBuildStatementWithHaving() { $db->setConnection($conn); $sql = $db->buildStatement( - array( - 'fields' => array('user_id', 'COUNT(*) AS count'), + [ + 'fields' => ['user_id', 'COUNT(*) AS count'], 'table' => 'articles', 'alias' => 'Article', 'group' => 'user_id', - 'order' => array('COUNT(*)' => 'DESC'), + 'order' => ['COUNT(*)' => 'DESC'], 'limit' => 5, - 'having' => array('COUNT(*) >' => 10), - ), + 'having' => ['COUNT(*) >' => 10], + ], $this->Model ); $expected = 'SELECT user_id, COUNT(*) AS count FROM articles AS Article WHERE 1 = 1 GROUP BY user_id HAVING COUNT(*) > 10 ORDER BY COUNT(*) DESC LIMIT 5'; @@ -1550,7 +1550,7 @@ public function testBuildStatementWithHaving() { * @return void */ public function testBuildStatementWithLockingHint() { - $conn = $this->getMock('MockPDO', array('quote')); + $conn = $this->getMock('MockPDO', ['quote']); $conn->expects($this->any()) ->method('quote') ->will($this->returnArgument(0)); @@ -1558,14 +1558,14 @@ public function testBuildStatementWithLockingHint() { $db->setConnection($conn); $sql = $db->buildStatement( - array( - 'fields' => array('id'), + [ + 'fields' => ['id'], 'table' => 'users', 'alias' => 'User', - 'order' => array('id'), + 'order' => ['id'], 'limit' => 1, 'lock' => true, - ), + ], $this->Model ); $expected = 'SELECT id FROM users AS User WHERE 1 = 1 ORDER BY id ASC LIMIT 1 FOR UPDATE'; @@ -1578,31 +1578,31 @@ public function testBuildStatementWithLockingHint() { * @return array */ public static function joinStatements() { - return array( - array(array( + return [ + [[ 'type' => 'CROSS', 'alias' => 'PostsTag', 'table' => 'posts_tags', - 'conditions' => array('1 = 1') - ), 'CROSS JOIN cakephp.posts_tags AS PostsTag'), - array(array( + 'conditions' => ['1 = 1'] + ], 'CROSS JOIN cakephp.posts_tags AS PostsTag'], + [[ 'type' => 'LEFT', 'alias' => 'PostsTag', 'table' => 'posts_tags', - ), 'LEFT JOIN cakephp.posts_tags AS PostsTag'), - array(array( + ], 'LEFT JOIN cakephp.posts_tags AS PostsTag'], + [[ 'type' => 'LEFT', 'alias' => 'PostsTag', 'table' => 'posts_tags', - 'conditions' => array('PostsTag.post_id = Post.id') - ), 'LEFT JOIN cakephp.posts_tags AS PostsTag ON (PostsTag.post_id = Post.id)'), - array(array( + 'conditions' => ['PostsTag.post_id = Post.id'] + ], 'LEFT JOIN cakephp.posts_tags AS PostsTag ON (PostsTag.post_id = Post.id)'], + [[ 'type' => 'LEFT', 'alias' => 'Stock', 'table' => '(SELECT Stock.article_id, sum(quantite) quantite FROM stocks AS Stock GROUP BY Stock.article_id)', 'conditions' => 'Stock.article_id = Article.id' - ), 'LEFT JOIN (SELECT Stock.article_id, sum(quantite) quantite FROM stocks AS Stock GROUP BY Stock.article_id) AS Stock ON (Stock.article_id = Article.id)') - ); + ], 'LEFT JOIN (SELECT Stock.article_id, sum(quantite) quantite FROM stocks AS Stock GROUP BY Stock.article_id) AS Stock ON (Stock.article_id = Article.id)'] + ]; } /** @@ -1613,7 +1613,7 @@ public static function joinStatements() { * @return void */ public function testBuildJoinStatement($join, $expected) { - $db = $this->getMock('DboTestSource', array('getSchemaName')); + $db = $this->getMock('DboTestSource', ['getSchemaName']); $db->expects($this->any()) ->method('getSchemaName') ->will($this->returnValue('cakephp')); @@ -1627,20 +1627,20 @@ public function testBuildJoinStatement($join, $expected) { * @return array */ public static function joinStatementsWithPrefix($schema) { - return array( - array(array( + return [ + [[ 'type' => 'LEFT', 'alias' => 'PostsTag', 'table' => 'posts_tags', - 'conditions' => array('PostsTag.post_id = Post.id') - ), 'LEFT JOIN pre_posts_tags AS PostsTag ON (PostsTag.post_id = Post.id)'), - array(array( + 'conditions' => ['PostsTag.post_id = Post.id'] + ], 'LEFT JOIN pre_posts_tags AS PostsTag ON (PostsTag.post_id = Post.id)'], + [[ 'type' => 'LEFT', 'alias' => 'Stock', 'table' => '(SELECT Stock.article_id, sum(quantite) quantite FROM stocks AS Stock GROUP BY Stock.article_id)', 'conditions' => 'Stock.article_id = Article.id' - ), 'LEFT JOIN (SELECT Stock.article_id, sum(quantite) quantite FROM stocks AS Stock GROUP BY Stock.article_id) AS Stock ON (Stock.article_id = Article.id)') - ); + ], 'LEFT JOIN (SELECT Stock.article_id, sum(quantite) quantite FROM stocks AS Stock GROUP BY Stock.article_id) AS Stock ON (Stock.article_id = Article.id)'] + ]; } /** @@ -1664,7 +1664,7 @@ public function testBuildJoinStatementWithTablePrefix($join, $expected) { */ public function testConditionKeysToString() { $Article = ClassRegistry::init('Article'); - $conn = $this->getMock('MockPDO', array('quote')); + $conn = $this->getMock('MockPDO', ['quote']); $db = new DboTestSource(); $db->setConnection($conn); @@ -1672,7 +1672,7 @@ public function testConditionKeysToString() { ->method('quote') ->will($this->returnValue('just text')); - $conditions = array('Article.name' => 'just text'); + $conditions = ['Article.name' => 'just text']; $result = $db->conditionKeysToString($conditions, true, $Article); $expected = "Article.name = just text"; $this->assertEquals($expected, $result[0]); @@ -1684,7 +1684,7 @@ public function testConditionKeysToString() { ->method('quote') ->will($this->returnValue('other text')); - $conditions = array('Article.name' => array('just text', 'other text')); + $conditions = ['Article.name' => ['just text', 'other text']]; $result = $db->conditionKeysToString($conditions, true, $Article); $expected = "Article.name IN (just text, other text)"; $this->assertEquals($expected, $result[0]); @@ -1697,10 +1697,10 @@ public function testConditionKeysToString() { */ public function testConditionKeysToStringVirtualFieldExpression() { $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( + $Article->virtualFields = [ 'extra' => $Article->getDataSource()->expression('something virtual') - ); - $conn = $this->getMock('MockPDO', array('quote')); + ]; + $conn = $this->getMock('MockPDO', ['quote']); $db = new DboTestSource(); $db->setConnection($conn); @@ -1708,7 +1708,7 @@ public function testConditionKeysToStringVirtualFieldExpression() { ->method('quote') ->will($this->returnValue('just text')); - $conditions = array('Article.extra' => 'just text'); + $conditions = ['Article.extra' => 'just text']; $result = $db->conditionKeysToString($conditions, true, $Article); $expected = "(" . $Article->virtualFields['extra']->value . ") = just text"; $this->assertEquals($expected, $result[0]); @@ -1720,7 +1720,7 @@ public function testConditionKeysToStringVirtualFieldExpression() { ->method('quote') ->will($this->returnValue('other text')); - $conditions = array('Article.extra' => array('just text', 'other text')); + $conditions = ['Article.extra' => ['just text', 'other text']]; $result = $db->conditionKeysToString($conditions, true, $Article); $expected = "(" . $Article->virtualFields['extra']->value . ") IN (just text, other text)"; $this->assertEquals($expected, $result[0]); @@ -1733,10 +1733,10 @@ public function testConditionKeysToStringVirtualFieldExpression() { */ public function testConditionKeysToStringVirtualField() { $Article = ClassRegistry::init('Article'); - $Article->virtualFields = array( + $Article->virtualFields = [ 'extra' => 'something virtual' - ); - $conn = $this->getMock('MockPDO', array('quote')); + ]; + $conn = $this->getMock('MockPDO', ['quote']); $db = new DboTestSource(); $db->setConnection($conn); @@ -1744,7 +1744,7 @@ public function testConditionKeysToStringVirtualField() { ->method('quote') ->will($this->returnValue('just text')); - $conditions = array('Article.extra' => 'just text'); + $conditions = ['Article.extra' => 'just text']; $result = $db->conditionKeysToString($conditions, true, $Article); $expected = "(" . $Article->virtualFields['extra'] . ") = just text"; $this->assertEquals($expected, $result[0]); @@ -1756,7 +1756,7 @@ public function testConditionKeysToStringVirtualField() { ->method('quote') ->will($this->returnValue('other text')); - $conditions = array('Article.extra' => array('just text', 'other text')); + $conditions = ['Article.extra' => ['just text', 'other text']]; $result = $db->conditionKeysToString($conditions, true, $Article); $expected = "(" . $Article->virtualFields['extra'] . ") IN (just text, other text)"; $this->assertEquals($expected, $result[0]); @@ -1797,8 +1797,8 @@ public function testInsertMultiId() { $Article = ClassRegistry::init('Article'); $db = $Article->getDatasource(); $datetime = date('Y-m-d H:i:s'); - $data = array( - array( + $data = [ + [ 'user_id' => 1, 'title' => 'test', 'body' => 'test', @@ -1806,8 +1806,8 @@ public function testInsertMultiId() { 'created' => $datetime, 'updated' => $datetime, 'id' => 100, - ), - array( + ], + [ 'user_id' => 1, 'title' => 'test 101', 'body' => 'test 101', @@ -1815,13 +1815,13 @@ public function testInsertMultiId() { 'created' => $datetime, 'updated' => $datetime, 'id' => 101, - ) - ); + ] + ]; $result = $db->insertMulti('articles', array_keys($data[0]), $data); $this->assertTrue($result, 'Data was saved'); - $data = array( - array( + $data = [ + [ 'id' => 102, 'user_id' => 1, 'title' => 'test', @@ -1829,8 +1829,8 @@ public function testInsertMultiId() { 'published' => 'N', 'created' => $datetime, 'updated' => $datetime, - ), - array( + ], + [ 'id' => 103, 'user_id' => 1, 'title' => 'test 101', @@ -1838,8 +1838,8 @@ public function testInsertMultiId() { 'published' => 'N', 'created' => $datetime, 'updated' => $datetime, - ) - ); + ] + ]; $result = $db->insertMulti('articles', array_keys($data[0]), $data); $this->assertTrue($result, 'Data was saved'); @@ -1858,17 +1858,17 @@ public function testDefaultConditions() { // Creates a default set of conditions from the model if $conditions is null/empty. $Article->id = 1; $result = $db->defaultConditions($Article, null); - $this->assertEquals(array('Article.id' => 1), $result); + $this->assertEquals(['Article.id' => 1], $result); // $useAlias == false $Article->id = 1; $result = $db->defaultConditions($Article, null, false); - $this->assertEquals(array($db->fullTableName($Article, false) . '.id' => 1), $result); + $this->assertEquals([$db->fullTableName($Article, false) . '.id' => 1], $result); // If conditions are supplied then they will be returned. $Article->id = 1; - $result = $db->defaultConditions($Article, array('Article.title' => 'First article')); - $this->assertEquals(array('Article.title' => 'First article'), $result); + $result = $db->defaultConditions($Article, ['Article.title' => 'First article']); + $this->assertEquals(['Article.title' => 'First article'], $result); // If a model doesn't exist and no conditions were provided either null or false will be returned based on what was input. $Article->id = 1000000; @@ -1895,13 +1895,13 @@ public function testCountAfterFindCalls() { $this->loadFixtures('Article', 'User', 'Comment', 'Attachment', 'Tag', 'ArticlesTag'); // Use alias to make testing "primary = true" easy - $Primary = $this->getMock('Comment', array('afterFind'), array(array('alias' => 'Primary')), '', true); + $Primary = $this->getMock('Comment', ['afterFind'], [['alias' => 'Primary']], '', true); - $Article = $this->getMock('Article', array('afterFind'), array(), '', true); - $User = $this->getMock('User', array('afterFind'), array(), '', true); - $Comment = $this->getMock('Comment', array('afterFind'), array(), '', true); - $Tag = $this->getMock('Tag', array('afterFind'), array(), '', true); - $Attachment = $this->getMock('Attachment', array('afterFind'), array(), '', true); + $Article = $this->getMock('Article', ['afterFind'], [], '', true); + $User = $this->getMock('User', ['afterFind'], [], '', true); + $Comment = $this->getMock('Comment', ['afterFind'], [], '', true); + $Tag = $this->getMock('Tag', ['afterFind'], [], '', true); + $Attachment = $this->getMock('Attachment', ['afterFind'], [], '', true); $Primary->Article = $Article; $Primary->Article->User = $User; @@ -1927,19 +1927,19 @@ public function testCountAfterFindCalls() { $Attachment->expects($this->once()) // Primary has 1 Attachment ->method('afterFind')->with($this->anything(), $this->isFalse())->will($this->returnArgument(0)); - $result = $Primary->find('first', array('conditions' => array('Primary.id' => 5), 'recursive' => 2)); + $result = $Primary->find('first', ['conditions' => ['Primary.id' => 5], 'recursive' => 2]); $this->assertCount(2, $result['Article']['Tag']); $this->assertCount(2, $result['Article']['Comment']); // hasMany special case // Both User and Article has many Comments - $User = $this->getMock('User', array('afterFind'), array(), '', true); - $Article = $this->getMock('Article', array('afterFind'), array(), '', true); - $Comment = $this->getMock('Comment', array('afterFind'), array(), '', true); + $User = $this->getMock('User', ['afterFind'], [], '', true); + $Article = $this->getMock('Article', ['afterFind'], [], '', true); + $Comment = $this->getMock('Comment', ['afterFind'], [], '', true); - $User->bindModel(array('hasMany' => array('Comment', 'Article'))); - $Article->unbindModel(array('belongsTo' => array('User'), 'hasAndBelongsToMany' => array('Tag'))); - $Comment->unbindModel(array('belongsTo' => array('User', 'Article'), 'hasOne' => 'Attachment')); + $User->bindModel(['hasMany' => ['Comment', 'Article']]); + $Article->unbindModel(['belongsTo' => ['User'], 'hasAndBelongsToMany' => ['Tag']]); + $Comment->unbindModel(['belongsTo' => ['User', 'Article'], 'hasOne' => 'Attachment']); $User->Comment = $Comment; $User->Article = $Article; @@ -1955,7 +1955,7 @@ public function testCountAfterFindCalls() { $Comment->expects($this->exactly(7)) // User1 has 3 Comments, Article[id=1] has 4 Comments and Article[id=3] has 0 Comments ->method('afterFind')->with($this->anything(), $this->isFalse())->will($this->returnArgument(0)); - $result = $User->find('first', array('conditions' => array('User.id' => 1), 'recursive' => 2)); + $result = $User->find('first', ['conditions' => ['User.id' => 1], 'recursive' => 2]); $this->assertCount(3, $result['Comment']); $this->assertCount(2, $result['Article']); $this->assertCount(4, $result['Article'][0]['Comment']); @@ -1970,17 +1970,17 @@ public function testCountAfterFindCalls() { public function testUseConsistentAfterFind() { $this->loadFixtures('Author', 'Post'); - $expected = array( - 'Author' => array( + $expected = [ + 'Author' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working', - ), - 'Post' => array( - array( + ], + 'Post' => [ + [ 'id' => '1', 'author_id' => '1', 'title' => 'First Post', @@ -1988,8 +1988,8 @@ public function testUseConsistentAfterFind() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - ), - array( + ], + [ 'id' => '3', 'author_id' => '1', 'title' => 'Third Post', @@ -1997,31 +1997,31 @@ public function testUseConsistentAfterFind() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - ), - ), - ); + ], + ], + ]; $Author = new Author(); - $Post = $this->getMock('Post', array('afterFind'), array(), '', true); - $Post->expects($this->at(0))->method('afterFind')->with(array(array('Post' => $expected['Post'][0])), $this->isFalse())->will($this->returnArgument(0)); - $Post->expects($this->at(1))->method('afterFind')->with(array(array('Post' => $expected['Post'][1])), $this->isFalse())->will($this->returnArgument(0)); + $Post = $this->getMock('Post', ['afterFind'], [], '', true); + $Post->expects($this->at(0))->method('afterFind')->with([['Post' => $expected['Post'][0]]], $this->isFalse())->will($this->returnArgument(0)); + $Post->expects($this->at(1))->method('afterFind')->with([['Post' => $expected['Post'][1]]], $this->isFalse())->will($this->returnArgument(0)); - $Author->bindModel(array('hasMany' => array('Post' => array('limit' => 2, 'order' => 'Post.id')))); + $Author->bindModel(['hasMany' => ['Post' => ['limit' => 2, 'order' => 'Post.id']]]); $Author->Post = $Post; - $result = $Author->find('first', array('conditions' => array('Author.id' => 1), 'recursive' => 1)); + $result = $Author->find('first', ['conditions' => ['Author.id' => 1], 'recursive' => 1]); $this->assertEquals($expected, $result); // Backward compatiblity $Author = new Author(); - $Post = $this->getMock('Post', array('afterFind'), array(), '', true); + $Post = $this->getMock('Post', ['afterFind'], [], '', true); $Post->expects($this->once())->method('afterFind')->with($expected['Post'], $this->isFalse())->will($this->returnArgument(0)); $Post->useConsistentAfterFind = false; - $Author->bindModel(array('hasMany' => array('Post' => array('limit' => 2, 'order' => 'Post.id')))); + $Author->bindModel(['hasMany' => ['Post' => ['limit' => 2, 'order' => 'Post.id']]]); $Author->Post = $Post; - $result = $Author->find('first', array('conditions' => array('Author.id' => 1), 'recursive' => 1)); + $result = $Author->find('first', ['conditions' => ['Author.id' => 1], 'recursive' => 1]); $this->assertEquals($expected, $result); } @@ -2034,15 +2034,15 @@ public function testJoinsAfterFind() { $this->loadFixtures('Article', 'User'); $User = new User(); - $User->bindModel(array('hasOne' => array('Article'))); + $User->bindModel(['hasOne' => ['Article']]); - $Article = $this->getMock('Article', array('afterFind'), array(), '', true); + $Article = $this->getMock('Article', ['afterFind'], [], '', true); $Article->expects($this->once()) ->method('afterFind') ->with( - array( - 0 => array( - 'Article' => array( + [ + 0 => [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -2050,16 +2050,16 @@ public function testJoinsAfterFind() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ) - ), + ] + ] + ], $this->isFalse() ) ->will($this->returnArgument(0)); $User->Article = $Article; - $User->find('first', array( - 'fields' => array( + $User->find('first', [ + 'fields' => [ 'Article.id', 'Article.user_id', 'Article.title', @@ -2067,21 +2067,21 @@ public function testJoinsAfterFind() { 'Article.published', 'Article.created', 'Article.updated' - ), - 'conditions' => array('User.id' => 1), + ], + 'conditions' => ['User.id' => 1], 'recursive' => -1, - 'joins' => array( - array( + 'joins' => [ + [ 'table' => 'articles', 'alias' => 'Article', 'type' => 'LEFT', - 'conditions' => array( + 'conditions' => [ 'Article.user_id = User.id' - ), - ) - ), - 'order' => array('Article.id') - )); + ], + ] + ], + 'order' => ['Article.id'] + ]); } /** @@ -2093,24 +2093,24 @@ public function testHasOneAfterFind() { $this->loadFixtures('Article', 'User', 'Comment'); $User = new User(); - $User->bindModel(array('hasOne' => array('Article'))); - - $Article = $this->getMock('Article', array('afterFind'), array(), '', true); - $Article->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment'), - 'hasAndBelongsToMany' => array('Tag') - )); - $Article->bindModel(array( - 'hasOne' => array('Comment'), - )); + $User->bindModel(['hasOne' => ['Article']]); + + $Article = $this->getMock('Article', ['afterFind'], [], '', true); + $Article->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'], + 'hasAndBelongsToMany' => ['Tag'] + ]); + $Article->bindModel([ + 'hasOne' => ['Comment'], + ]); $Article->expects($this->once()) ->method('afterFind') ->with( $this->equalTo( - array( - 0 => array( - 'Article' => array( + [ + 0 => [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -2118,7 +2118,7 @@ public function testHasOneAfterFind() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Comment' => array( + 'Comment' => [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -2126,17 +2126,17 @@ public function testHasOneAfterFind() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', - ) - ) - ) - ) + ] + ] + ] + ] ), $this->isFalse() ) ->will($this->returnArgument(0)); $User->Article = $Article; - $User->find('first', array('conditions' => array('User.id' => 1), 'recursive' => 2)); + $User->find('first', ['conditions' => ['User.id' => 1], 'recursive' => 2]); } /** @@ -2201,9 +2201,9 @@ public function testLengthEnum() { * Test find with locking hint */ public function testFindWithLockingHint() { - $db = $this->getMock('DboTestSource', array('connect', '_execute', 'execute', 'describ')); + $db = $this->getMock('DboTestSource', ['connect', '_execute', 'execute', 'describ']); - $Test = $this->getMock('Test', array('getDataSource')); + $Test = $this->getMock('Test', ['getDataSource']); $Test->expects($this->any()) ->method('getDataSource') ->will($this->returnValue($db)); @@ -2214,11 +2214,11 @@ public function testFindWithLockingHint() { ->method('execute') ->with($expected); - $Test->find('first', array( + $Test->find('first', [ 'recursive' => -1, - 'fields' => array('id'), - 'conditions' => array('id' => 1), + 'fields' => ['id'], + 'conditions' => ['id' => 1], 'lock' => true, - )); + ]); } } diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/CacheSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/CacheSessionTest.php index d3e1c6738e..744c8d437c 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/CacheSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/CacheSessionTest.php @@ -35,10 +35,10 @@ class CacheSessionTest extends CakeTestCase { * @return void */ public static function setupBeforeClass() : void { - Cache::config('session_test', array( + Cache::config('session_test', [ 'engine' => 'File', 'prefix' => 'session_test_' - )); + ]); static::$_sessionBackup = Configure::read('Session'); Configure::write('Session.handler.config', 'session_test'); diff --git a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php index 231fa3332f..284f2f45dd 100644 --- a/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php +++ b/lib/Cake/Test/Case/Model/Datasource/Session/DatabaseSessionTest.php @@ -46,7 +46,7 @@ class DatabaseSessionTest extends CakeTestCase { * * @var string */ - public $fixtures = array('core.session'); + public $fixtures = ['core.session']; /** * test case startup @@ -55,9 +55,9 @@ class DatabaseSessionTest extends CakeTestCase { */ public static function setupBeforeClass() : void { static::$_sessionBackup = Configure::read('Session'); - Configure::write('Session.handler', array( + Configure::write('Session.handler', [ 'model' => 'SessionTestModel', - )); + ]); Configure::write('Session.timeout', 100); } @@ -193,8 +193,8 @@ public function testConcurrentInsert() { $mockedModel = $this->getMockForModel( 'SessionTestModel', - array('exists'), - array('alias' => 'MockedSessionTestModel', 'table' => 'sessions') + ['exists'], + ['alias' => 'MockedSessionTestModel', 'table' => 'sessions'] ); Configure::write('Session.handler.model', 'MockedSessionTestModel'); diff --git a/lib/Cake/Test/Case/Model/ModelCrossSchemaHabtmTest.php b/lib/Cake/Test/Case/Model/ModelCrossSchemaHabtmTest.php index 0b445ab0f7..60913e2548 100644 --- a/lib/Cake/Test/Case/Model/ModelCrossSchemaHabtmTest.php +++ b/lib/Cake/Test/Case/Model/ModelCrossSchemaHabtmTest.php @@ -18,7 +18,7 @@ * @license https://opensource.org/licenses/mit-license.php MIT License */ -require_once dirname(__FILE__) . DS . 'ModelTestBase.php'; +require_once __DIR__ . DS . 'ModelTestBase.php'; /** * ModelCrossSchemaHabtmTest @@ -32,10 +32,10 @@ class ModelCrossSchemaHabtmTest extends BaseModelTest { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.player', 'core.guild', 'core.guilds_player', 'core.armor', 'core.armors_player', - ); + ]; /** * Don't drop tables if they exist @@ -104,26 +104,26 @@ public function testHabtmFind() { $this->loadFixtures('Player', 'Guild', 'GuildsPlayer'); $Player = ClassRegistry::init('Player'); - $players = $Player->find('all', array( - 'fields' => array('id', 'name'), - 'contain' => array( - 'Guild' => array( - 'conditions' => array( + $players = $Player->find('all', [ + 'fields' => ['id', 'name'], + 'contain' => [ + 'Guild' => [ + 'conditions' => [ 'Guild.name' => 'Wizards', - ), - ), - ), - )); + ], + ], + ], + ]); $this->assertEquals(4, count($players)); $wizards = Hash::extract($players, '{n}.Guild.{n}[name=Wizards]'); $this->assertEquals(1, count($wizards)); - $players = $Player->find('all', array( - 'fields' => array('id', 'name'), - 'conditions' => array( + $players = $Player->find('all', [ + 'fields' => ['id', 'name'], + 'conditions' => [ 'Player.id' => 1, - ), - )); + ], + ]); $this->assertEquals(1, count($players)); $wizards = Hash::extract($players, '{n}.Guild.{n}'); $this->assertEquals(2, count($wizards)); @@ -140,11 +140,11 @@ public function testHabtmSave() { $players = $Player->find('count'); $this->assertEquals(4, $players); - $player = $Player->create(array( + $player = $Player->create([ 'name' => 'rchavik', - )); + ]); - $results = $Player->saveAll($player, array('validate' => 'first')); + $results = $Player->saveAll($player, ['validate' => 'first']); $this->assertNotSame(false, $results); $count = $Player->find('count'); $this->assertEquals(5, $count); @@ -155,19 +155,19 @@ public function testHabtmSave() { $player = $Player->findByName('rchavik'); $this->assertEmpty($player['Guild']); - $player['Guild']['Guild'] = array(1, 2, 3); + $player['Guild']['Guild'] = [1, 2, 3]; $Player->save($player); $player = $Player->findByName('rchavik'); $this->assertEquals(3, count($player['Guild'])); - $players = $Player->find('all', array( - 'contain' => array( - 'conditions' => array( + $players = $Player->find('all', [ + 'contain' => [ + 'conditions' => [ 'Guild.name' => 'Rangers', - ), - ), - )); + ], + ], + ]); $rangers = Hash::extract($players, '{n}.Guild.{n}[name=Rangers]'); $this->assertEquals(2, count($rangers)); } @@ -189,47 +189,47 @@ public function testHabtmWithThreeDatabases() { $this->loadFixtures('Player', 'Guild', 'GuildsPlayer', 'Armor', 'ArmorsPlayer'); $Player = ClassRegistry::init('Player'); - $Player->bindModel(array( - 'hasAndBelongsToMany' => array( - 'Armor' => array( + $Player->bindModel([ + 'hasAndBelongsToMany' => [ + 'Armor' => [ 'with' => 'ArmorsPlayer', 'unique' => true, - ), - ), - ), false); + ], + ], + ], false); $this->assertEquals('test', $Player->useDbConfig); $this->assertEquals('test2', $Player->Armor->useDbConfig); $this->assertEquals('test_database_three', $Player->ArmorsPlayer->useDbConfig); $players = $Player->find('count'); $this->assertEquals(4, $players); - $spongebob = $Player->create(array( + $spongebob = $Player->create([ 'id' => 10, 'name' => 'spongebob', - )); - $spongebob['Armor'] = array('Armor' => array(1, 2, 3, 4)); + ]); + $spongebob['Armor'] = ['Armor' => [1, 2, 3, 4]]; $result = $Player->save($spongebob); - $expected = array( - 'Player' => array( + $expected = [ + 'Player' => [ 'id' => 10, 'name' => 'spongebob', - ), - 'Armor' => array( - 'Armor' => array( + ], + 'Armor' => [ + 'Armor' => [ 1, 2, 3, 4, - ), - ), - ); + ], + ], + ]; unset($result['Player']['created']); unset($result['Player']['updated']); $this->assertEquals($expected, $result); - $spongebob = $Player->find('all', array( - 'conditions' => array( + $spongebob = $Player->find('all', [ + 'conditions' => [ 'Player.id' => 10, - ) - )); + ] + ]); $spongeBobsArmors = Hash::extract($spongebob, '{n}.Armor.{n}'); $this->assertEquals(4, count($spongeBobsArmors)); } diff --git a/lib/Cake/Test/Case/Model/ModelDeleteTest.php b/lib/Cake/Test/Case/Model/ModelDeleteTest.php index cc0dbb879b..e635ecf36f 100644 --- a/lib/Cake/Test/Case/Model/ModelDeleteTest.php +++ b/lib/Cake/Test/Case/Model/ModelDeleteTest.php @@ -16,7 +16,7 @@ * @license https://opensource.org/licenses/mit-license.php MIT License */ -require_once dirname(__FILE__) . DS . 'ModelTestBase.php'; +require_once __DIR__ . DS . 'ModelTestBase.php'; /** * ModelDeleteTest @@ -34,85 +34,85 @@ public function testDeleteHabtmReferenceWithConditions() { $this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image'); $Portfolio = new Portfolio(); - $Portfolio->hasAndBelongsToMany['Item']['conditions'] = array('ItemsPortfolio.item_id >' => 1); + $Portfolio->hasAndBelongsToMany['Item']['conditions'] = ['ItemsPortfolio.item_id >' => 1]; - $result = $Portfolio->find('first', array( - 'conditions' => array('Portfolio.id' => 1) - )); - $expected = array( - array( + $result = $Portfolio->find('first', [ + 'conditions' => ['Portfolio.id' => 1] + ]); + $expected = [ + [ 'id' => 3, 'syfile_id' => 3, 'published' => false, 'name' => 'Item 3', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 3, 'item_id' => 3, 'portfolio_id' => 1 - )), - array( + ]], + [ 'id' => 4, 'syfile_id' => 4, 'published' => false, 'name' => 'Item 4', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 4, 'item_id' => 4, 'portfolio_id' => 1 - )), - array( + ]], + [ 'id' => 5, 'syfile_id' => 5, 'published' => false, 'name' => 'Item 5', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 5, 'item_id' => 5, 'portfolio_id' => 1 - ))); + ]]]; $this->assertEquals($expected, $result['Item']); - $result = $Portfolio->ItemsPortfolio->find('all', array( - 'conditions' => array('ItemsPortfolio.portfolio_id' => 1) - )); - $expected = array( - array( - 'ItemsPortfolio' => array( + $result = $Portfolio->ItemsPortfolio->find('all', [ + 'conditions' => ['ItemsPortfolio.portfolio_id' => 1] + ]); + $expected = [ + [ + 'ItemsPortfolio' => [ 'id' => 1, 'item_id' => 1, 'portfolio_id' => 1 - )), - array( - 'ItemsPortfolio' => array( + ]], + [ + 'ItemsPortfolio' => [ 'id' => 3, 'item_id' => 3, 'portfolio_id' => 1 - )), - array( - 'ItemsPortfolio' => array( + ]], + [ + 'ItemsPortfolio' => [ 'id' => 4, 'item_id' => 4, 'portfolio_id' => 1 - )), - array( - 'ItemsPortfolio' => array( + ]], + [ + 'ItemsPortfolio' => [ 'id' => 5, 'item_id' => 5, 'portfolio_id' => 1 - ))); + ]]]; $this->assertEquals($expected, $result); $Portfolio->delete(1); - $result = $Portfolio->find('first', array( - 'conditions' => array('Portfolio.id' => 1) - )); - $this->assertSame(array(), $result); + $result = $Portfolio->find('first', [ + 'conditions' => ['Portfolio.id' => 1] + ]); + $this->assertSame([], $result); - $result = $Portfolio->ItemsPortfolio->find('all', array( - 'conditions' => array('ItemsPortfolio.portfolio_id' => 1) - )); - $this->assertSame(array(), $result); + $result = $Portfolio->ItemsPortfolio->find('all', [ + 'conditions' => ['ItemsPortfolio.portfolio_id' => 1] + ]); + $this->assertSame([], $result); } /** @@ -125,21 +125,21 @@ public function testDeleteArticleBLinks() { $TestModel = new ArticleB(); $result = $TestModel->ArticlesTag->find('all'); - $expected = array( - array('ArticlesTag' => array('article_id' => '1', 'tag_id' => '1')), - array('ArticlesTag' => array('article_id' => '1', 'tag_id' => '2')), - array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')), - array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')) - ); + $expected = [ + ['ArticlesTag' => ['article_id' => '1', 'tag_id' => '1']], + ['ArticlesTag' => ['article_id' => '1', 'tag_id' => '2']], + ['ArticlesTag' => ['article_id' => '2', 'tag_id' => '1']], + ['ArticlesTag' => ['article_id' => '2', 'tag_id' => '3']] + ]; $this->assertEquals($expected, $result); $TestModel->delete(1); $result = $TestModel->ArticlesTag->find('all'); - $expected = array( - array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')), - array('ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')) - ); + $expected = [ + ['ArticlesTag' => ['article_id' => '2', 'tag_id' => '1']], + ['ArticlesTag' => ['article_id' => '2', 'tag_id' => '3']] + ]; $this->assertEquals($expected, $result); } @@ -157,26 +157,26 @@ public function testDeleteDependentWithConditions() { $Cd->delete(1); - $result = $OverallFavorite->find('all', array( - 'fields' => array('model_type', 'model_id', 'priority') - )); - $expected = array( - array( - 'OverallFavorite' => array( + $result = $OverallFavorite->find('all', [ + 'fields' => ['model_type', 'model_id', 'priority'] + ]); + $expected = [ + [ + 'OverallFavorite' => [ 'model_type' => 'Book', 'model_id' => 1, 'priority' => 2 - ))); + ]]]; $this->assertTrue(is_array($result)); $this->assertEquals($expected, $result); $Book->delete(1); - $result = $OverallFavorite->find('all', array( - 'fields' => array('model_type', 'model_id', 'priority') - )); - $expected = array(); + $result = $OverallFavorite->find('all', [ + 'fields' => ['model_type', 'model_id', 'priority'] + ]); + $expected = []; $this->assertTrue(is_array($result)); $this->assertEquals($expected, $result); @@ -195,38 +195,38 @@ public function testDelete() { $this->assertTrue($result); $result = $TestModel->read(null, 2); - $this->assertSame(array(), $result); + $this->assertSame([], $result); $TestModel->recursive = -1; - $result = $TestModel->find('all', array( - 'fields' => array('id', 'title') - )); - $expected = array( - array('Article' => array( + $result = $TestModel->find('all', [ + 'fields' => ['id', 'title'] + ]); + $expected = [ + ['Article' => [ 'id' => 1, 'title' => 'First Article' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 3, 'title' => 'Third Article' - ))); + ]]]; $this->assertEquals($expected, $result); $result = $TestModel->delete(3); $this->assertTrue($result); $result = $TestModel->read(null, 3); - $this->assertSame(array(), $result); + $this->assertSame([], $result); $TestModel->recursive = -1; - $result = $TestModel->find('all', array( - 'fields' => array('id', 'title') - )); - $expected = array( - array('Article' => array( + $result = $TestModel->find('all', [ + 'fields' => ['id', 'title'] + ]); + $expected = [ + ['Article' => [ 'id' => 1, 'title' => 'First Article' - ))); + ]]]; $this->assertEquals($expected, $result); @@ -234,29 +234,29 @@ public function testDelete() { // ticket #6293 $this->loadFixtures('Uuid'); $Uuid = new Uuid(); - $data = array( + $data = [ 'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3', '52C8865C-10EE-4302-AE6C-6E7D8E12E2C8', - '8208C7FE-E89C-47C5-B378-DED6C271F9B8'); + '8208C7FE-E89C-47C5-B378-DED6C271F9B8']; foreach ($data as $id) { - $Uuid->save(array('id' => $id)); + $Uuid->save(['id' => $id]); } $Uuid->delete('52C8865C-10EE-4302-AE6C-6E7D8E12E2C8'); $Uuid->delete('52C8865C-10EE-4302-AE6C-6E7D8E12E2C8'); foreach ($data as $id) { - $Uuid->save(array('id' => $id)); + $Uuid->save(['id' => $id]); } - $result = $Uuid->find('all', array( - 'conditions' => array('id' => $data), - 'fields' => array('id'), - 'order' => 'id')); - $expected = array( - array('Uuid' => array( - 'id' => '52C8865C-10EE-4302-AE6C-6E7D8E12E2C8')), - array('Uuid' => array( - 'id' => '8208C7FE-E89C-47C5-B378-DED6C271F9B8')), - array('Uuid' => array( - 'id' => 'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3'))); + $result = $Uuid->find('all', [ + 'conditions' => ['id' => $data], + 'fields' => ['id'], + 'order' => 'id']); + $expected = [ + ['Uuid' => [ + 'id' => '52C8865C-10EE-4302-AE6C-6E7D8E12E2C8']], + ['Uuid' => [ + 'id' => '8208C7FE-E89C-47C5-B378-DED6C271F9B8']], + ['Uuid' => [ + 'id' => 'B607DAB9-88A2-46CF-B57C-842CA9E3B3B3']]]; $this->assertEquals($expected, $result); } @@ -286,138 +286,138 @@ public function testDeleteAll() { $this->loadFixtures('Article'); $TestModel = new Article(); - $data = array('Article' => array( + $data = ['Article' => [ 'user_id' => 2, 'id' => 4, 'title' => 'Fourth Article', 'published' => 'N' - )); + ]]; $result = $TestModel->set($data) && $TestModel->save(); $this->assertTrue($result); - $data = array('Article' => array( + $data = ['Article' => [ 'user_id' => 2, 'id' => 5, 'title' => 'Fifth Article', 'published' => 'Y' - )); + ]]; $result = $TestModel->set($data) && $TestModel->save(); $this->assertTrue($result); - $data = array('Article' => array( + $data = ['Article' => [ 'user_id' => 1, 'id' => 6, 'title' => 'Sixth Article', 'published' => 'N' - )); + ]]; $result = $TestModel->set($data) && $TestModel->save(); $this->assertTrue($result); $TestModel->recursive = -1; - $result = $TestModel->find('all', array( - 'fields' => array('id', 'user_id', 'title', 'published'), - 'order' => array('Article.id' => 'ASC') - )); + $result = $TestModel->find('all', [ + 'fields' => ['id', 'user_id', 'title', 'published'], + 'order' => ['Article.id' => 'ASC'] + ]); - $expected = array( - array('Article' => array( + $expected = [ + ['Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'published' => 'Y' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', - 'published' => 'Y')), - array('Article' => array( + 'published' => 'Y']], + ['Article' => [ 'id' => 4, 'user_id' => 2, 'title' => 'Fourth Article', 'published' => 'N' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 5, 'user_id' => 2, 'title' => 'Fifth Article', 'published' => 'Y' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 6, 'user_id' => 1, 'title' => 'Sixth Article', 'published' => 'N' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->deleteAll(array('Article.published' => 'N')); + $result = $TestModel->deleteAll(['Article.published' => 'N']); $this->assertTrue($result); $TestModel->recursive = -1; - $result = $TestModel->find('all', array( - 'fields' => array('id', 'user_id', 'title', 'published'), - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array('Article' => array( + $result = $TestModel->find('all', [ + 'fields' => ['id', 'user_id', 'title', 'published'], + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + ['Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', 'published' => 'Y' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'published' => 'Y' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 5, 'user_id' => 2, 'title' => 'Fifth Article', 'published' => 'Y' - ))); + ]]]; $this->assertEquals($expected, $result); - $data = array('Article.user_id' => array(2, 3)); + $data = ['Article.user_id' => [2, 3]]; $result = $TestModel->deleteAll($data, true, true); $this->assertTrue($result); $TestModel->recursive = -1; - $result = $TestModel->find('all', array( - 'fields' => array('id', 'user_id', 'title', 'published'), - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array('Article' => array( + $result = $TestModel->find('all', [ + 'fields' => ['id', 'user_id', 'title', 'published'], + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + ['Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'published' => 'Y' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', 'published' => 'Y' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->deleteAll(array('Article.user_id' => 999)); + $result = $TestModel->deleteAll(['Article.user_id' => 999]); $this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s'); } @@ -430,7 +430,7 @@ public function testDeleteAllDiamondOperator() { $this->loadFixtures('Article'); $article = new Article(); - $result = $article->deleteAll(array('Article.id <>' => 1)); + $result = $article->deleteAll(['Article.id <>' => 1]); $this->assertTrue($result); $this->assertFalse($article->exists(2)); } @@ -444,7 +444,7 @@ public function testDeleteAllUnknownColumn() { $this->expectException(PDOException::class); $this->loadFixtures('Article'); $TestModel = new Article(); - $result = $TestModel->deleteAll(array('Article.non_existent_field' => 999)); + $result = $TestModel->deleteAll(['Article.non_existent_field' => 999]); $this->assertFalse($result, 'deleteAll returned true when find query generated sql error. %s'); } @@ -457,12 +457,12 @@ public function testDeleteAllUnknownColumn() { */ public function testDeleteAllFailedFind() { $this->loadFixtures('Article'); - $TestModel = $this->getMock('Article', array('find')); + $TestModel = $this->getMock('Article', ['find']); $TestModel->expects($this->once()) ->method('find') ->will($this->returnValue(null)); - $result = $TestModel->deleteAll(array('Article.user_id' => 999)); + $result = $TestModel->deleteAll(['Article.user_id' => 999]); $this->assertFalse($result); } @@ -478,24 +478,24 @@ public function testDeleteAllMultipleRowsPerId() { $this->loadFixtures('Article', 'User'); $TestModel = new Article(); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment'), - 'hasAndBelongsToMany' => array('Tag') - ), false); - $TestModel->bindModel(array( - 'belongsTo' => array( - 'User' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'], + 'hasAndBelongsToMany' => ['Tag'] + ], false); + $TestModel->bindModel([ + 'belongsTo' => [ + 'User' => [ 'foreignKey' => false, - 'conditions' => array( + 'conditions' => [ 'Article.user_id = 1' - ) - ) - ) - ), false); + ] + ] + ] + ], false); $result = $TestModel->deleteAll( - array('Article.user_id' => array(1, 3)), + ['Article.user_id' => [1, 3]], true, true ); @@ -515,14 +515,14 @@ public function testDeleteAllWithOrderProperty() { $TestModel = new Article(); $TestModel->order = 'Article.published desc'; - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment'), - 'hasAndBelongsToMany' => array('Tag') - ), false); + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'], + 'hasAndBelongsToMany' => ['Tag'] + ], false); $result = $TestModel->deleteAll( - array('Article.user_id' => array(1, 3)), + ['Article.user_id' => [1, 3]], true, true ); @@ -544,16 +544,16 @@ public function testRecursiveDel() { $TestModel->recursive = 2; $result = $TestModel->read(null, 2); - $this->assertSame(array(), $result); + $this->assertSame([], $result); $result = $TestModel->Comment->read(null, 5); - $this->assertSame(array(), $result); + $this->assertSame([], $result); $result = $TestModel->Comment->read(null, 6); - $this->assertSame(array(), $result); + $this->assertSame([], $result); $result = $TestModel->Comment->Attachment->read(null, 1); - $this->assertSame(array(), $result); + $this->assertSame([], $result); $result = $TestModel->find('count'); $this->assertEquals(2, $result); @@ -593,40 +593,40 @@ public function testDeleteLinks() { $TestModel = new Article(); $result = $TestModel->ArticlesTag->find('all'); - $expected = array( - array('ArticlesTag' => array( + $expected = [ + ['ArticlesTag' => [ 'article_id' => '1', 'tag_id' => '1' - )), - array('ArticlesTag' => array( + ]], + ['ArticlesTag' => [ 'article_id' => '1', 'tag_id' => '2' - )), - array('ArticlesTag' => array( + ]], + ['ArticlesTag' => [ 'article_id' => '2', 'tag_id' => '1' - )), - array('ArticlesTag' => array( + ]], + ['ArticlesTag' => [ 'article_id' => '2', 'tag_id' => '3' - ))); + ]]]; $this->assertEquals($expected, $result); $TestModel->delete(1); $result = $TestModel->ArticlesTag->find('all'); - $expected = array( - array('ArticlesTag' => array( + $expected = [ + ['ArticlesTag' => [ 'article_id' => '2', 'tag_id' => '1' - )), - array('ArticlesTag' => array( + ]], + ['ArticlesTag' => [ 'article_id' => '2', 'tag_id' => '3' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->deleteAll(array('Article.user_id' => 999)); + $result = $TestModel->deleteAll(['Article.user_id' => 999]); $this->assertTrue($result, 'deleteAll returned false when all no records matched conditions. %s'); } @@ -638,11 +638,11 @@ public function testDeleteLinks() { public function testDeleteLinksWithPLuginJoinModel() { $this->loadFixtures('Article', 'ArticlesTag', 'Tag'); $Article = new Article(); - $Article->unbindModel(array('hasAndBelongsToMany' => array('Tag')), false); + $Article->unbindModel(['hasAndBelongsToMany' => ['Tag']], false); unset($Article->Tag, $Article->ArticleTags); - $Article->bindModel(array('hasAndBelongsToMany' => array( - 'Tag' => array('with' => 'TestPlugin.ArticlesTag') - )), false); + $Article->bindModel(['hasAndBelongsToMany' => [ + 'Tag' => ['with' => 'TestPlugin.ArticlesTag'] + ]], false); $Article->ArticlesTag->order = null; $this->assertTrue($Article->delete(1)); @@ -658,88 +658,88 @@ public function testDeleteDependent() { 'ArticlesTag', 'Comment', 'User', 'Attachment' ); $Bidding = new Bidding(); - $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC'))); - $expected = array( - array( - 'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), - 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'), - ), - array( - 'Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), - 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2'), - ), - array( - 'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), - 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'), - ), - array( - 'Bidding' => array('id' => 4, 'bid' => 'Five', 'name' => 'Bid 5'), - 'BiddingMessage' => array('bidding' => '', 'name' => ''), - ), - ); + $result = $Bidding->find('all', ['order' => ['Bidding.id' => 'ASC']]); + $expected = [ + [ + 'Bidding' => ['id' => 1, 'bid' => 'One', 'name' => 'Bid 1'], + 'BiddingMessage' => ['bidding' => 'One', 'name' => 'Message 1'], + ], + [ + 'Bidding' => ['id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'], + 'BiddingMessage' => ['bidding' => 'Two', 'name' => 'Message 2'], + ], + [ + 'Bidding' => ['id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'], + 'BiddingMessage' => ['bidding' => 'Three', 'name' => 'Message 3'], + ], + [ + 'Bidding' => ['id' => 4, 'bid' => 'Five', 'name' => 'Bid 5'], + 'BiddingMessage' => ['bidding' => '', 'name' => ''], + ], + ]; $this->assertEquals($expected, $result); $Bidding->delete(4, true); - $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC'))); - $expected = array( - array( - 'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), - 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'), - ), - array( - 'Bidding' => array('id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'), - 'BiddingMessage' => array('bidding' => 'Two', 'name' => 'Message 2'), - ), - array( - 'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), - 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'), - ), - ); + $result = $Bidding->find('all', ['order' => ['Bidding.id' => 'ASC']]); + $expected = [ + [ + 'Bidding' => ['id' => 1, 'bid' => 'One', 'name' => 'Bid 1'], + 'BiddingMessage' => ['bidding' => 'One', 'name' => 'Message 1'], + ], + [ + 'Bidding' => ['id' => 2, 'bid' => 'Two', 'name' => 'Bid 2'], + 'BiddingMessage' => ['bidding' => 'Two', 'name' => 'Message 2'], + ], + [ + 'Bidding' => ['id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'], + 'BiddingMessage' => ['bidding' => 'Three', 'name' => 'Message 3'], + ], + ]; $this->assertEquals($expected, $result); $Bidding->delete(2, true); - $result = $Bidding->find('all', array('order' => array('Bidding.id' => 'ASC'))); - $expected = array( - array( - 'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), - 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'), - ), - array( - 'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), - 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'), - ), - ); + $result = $Bidding->find('all', ['order' => ['Bidding.id' => 'ASC']]); + $expected = [ + [ + 'Bidding' => ['id' => 1, 'bid' => 'One', 'name' => 'Bid 1'], + 'BiddingMessage' => ['bidding' => 'One', 'name' => 'Message 1'], + ], + [ + 'Bidding' => ['id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'], + 'BiddingMessage' => ['bidding' => 'Three', 'name' => 'Message 3'], + ], + ]; $this->assertEquals($expected, $result); - $result = $Bidding->BiddingMessage->find('all', array('order' => array('BiddingMessage.name' => 'ASC'))); - $expected = array( - array( - 'BiddingMessage' => array('bidding' => 'One', 'name' => 'Message 1'), - 'Bidding' => array('id' => 1, 'bid' => 'One', 'name' => 'Bid 1'), - ), - array( - 'BiddingMessage' => array('bidding' => 'Three', 'name' => 'Message 3'), - 'Bidding' => array('id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'), - ), - array( - 'BiddingMessage' => array('bidding' => 'Four', 'name' => 'Message 4'), - 'Bidding' => array('id' => '', 'bid' => '', 'name' => ''), - ), - ); + $result = $Bidding->BiddingMessage->find('all', ['order' => ['BiddingMessage.name' => 'ASC']]); + $expected = [ + [ + 'BiddingMessage' => ['bidding' => 'One', 'name' => 'Message 1'], + 'Bidding' => ['id' => 1, 'bid' => 'One', 'name' => 'Bid 1'], + ], + [ + 'BiddingMessage' => ['bidding' => 'Three', 'name' => 'Message 3'], + 'Bidding' => ['id' => 3, 'bid' => 'Three', 'name' => 'Bid 3'], + ], + [ + 'BiddingMessage' => ['bidding' => 'Four', 'name' => 'Message 4'], + 'Bidding' => ['id' => '', 'bid' => '', 'name' => ''], + ], + ]; $this->assertEquals($expected, $result); $Article = new Article(); - $result = $Article->Comment->find('count', array( - 'conditions' => array('Comment.article_id' => 1) - )); + $result = $Article->Comment->find('count', [ + 'conditions' => ['Comment.article_id' => 1] + ]); $this->assertEquals(4, $result); $result = $Article->delete(1, true); $this->assertTrue($result); - $result = $Article->Comment->find('count', array( - 'conditions' => array('Comment.article_id' => 1) - )); + $result = $Article->Comment->find('count', [ + 'conditions' => ['Comment.article_id' => 1] + ]); $this->assertEquals(0, $result); } @@ -753,28 +753,28 @@ public function testDeleteLinksWithMultipleHabtmAssociations() { $JoinA = new JoinA(); //create two new join records to expose the issue. - $JoinA->JoinAsJoinC->create(array( + $JoinA->JoinAsJoinC->create([ 'join_a_id' => 1, 'join_c_id' => 2, - )); + ]); $JoinA->JoinAsJoinC->save(); - $JoinA->JoinAsJoinB->create(array( + $JoinA->JoinAsJoinB->create([ 'join_a_id' => 1, 'join_b_id' => 2, - )); + ]); $JoinA->JoinAsJoinB->save(); $result = $JoinA->delete(1); $this->assertTrue($result, 'Delete failed %s'); - $joinedBs = $JoinA->JoinAsJoinB->find('count', array( - 'conditions' => array('JoinAsJoinB.join_a_id' => 1) - )); + $joinedBs = $JoinA->JoinAsJoinB->find('count', [ + 'conditions' => ['JoinAsJoinB.join_a_id' => 1] + ]); $this->assertEquals(0, $joinedBs, 'JoinA/JoinB link records left over. %s'); - $joinedBs = $JoinA->JoinAsJoinC->find('count', array( - 'conditions' => array('JoinAsJoinC.join_a_id' => 1) - )); + $joinedBs = $JoinA->JoinAsJoinC->find('count', [ + 'conditions' => ['JoinAsJoinC.join_a_id' => 1] + ]); $this->assertEquals(0, $joinedBs, 'JoinA/JoinC link records left over. %s'); } @@ -787,59 +787,59 @@ public function testHabtmDeleteLinksWhenNoPrimaryKeyInJoinTable() { $this->loadFixtures('Apple', 'Device', 'ThePaperMonkies'); $ThePaper = new ThePaper(); $ThePaper->id = 1; - $ThePaper->save(array('Monkey' => array(2, 3))); + $ThePaper->save(['Monkey' => [2, 3]]); $result = $ThePaper->findById(1); - $expected = array( - array( + $expected = [ + [ 'id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1' - ), - array( + ], + [ 'id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2' - )); + ]]; $this->assertEquals($expected, $result['Monkey']); $ThePaper = new ThePaper(); $ThePaper->id = 2; - $ThePaper->save(array('Monkey' => array(2, 3))); + $ThePaper->save(['Monkey' => [2, 3]]); $result = $ThePaper->findById(2); - $expected = array( - array( + $expected = [ + [ 'id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1' - ), - array( + ], + [ 'id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2' - )); + ]]; $this->assertEquals($expected, $result['Monkey']); $ThePaper->delete(1); $result = $ThePaper->findById(2); - $expected = array( - array( + $expected = [ + [ 'id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1' - ), - array( + ], + [ 'id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2' - )); + ]]; $this->assertEquals($expected, $result['Monkey']); } @@ -873,35 +873,35 @@ public function testDeleteHabtmPostgresFailure() { $Article->hasAndBelongsToMany['Tag']['unique'] = true; $Tag = ClassRegistry::init('Tag'); - $Tag->bindModel(array('hasAndBelongsToMany' => array( - 'Article' => array( + $Tag->bindModel(['hasAndBelongsToMany' => [ + 'Article' => [ 'className' => 'Article', 'unique' => true - ) - )), true); + ] + ]], true); // Article 1 should have Tag.1 and Tag.2 - $before = $Article->find("all", array( - "conditions" => array("Article.id" => 1), - )); + $before = $Article->find("all", [ + "conditions" => ["Article.id" => 1], + ]); $this->assertEquals(2, count($before[0]['Tag']), 'Tag count for Article.id = 1 is incorrect, should be 2 %s'); // From now on, Tag #1 is only associated with Post #1 - $submittedData = array( - "Tag" => array("id" => 1, 'tag' => 'tag1'), - "Article" => array( - "Article" => array(1) - ) - ); + $submittedData = [ + "Tag" => ["id" => 1, 'tag' => 'tag1'], + "Article" => [ + "Article" => [1] + ] + ]; $Tag->save($submittedData); // One more submission (The other way around) to make sure the reverse save looks good. - $submittedData = array( - "Article" => array("id" => 2, 'title' => 'second article'), - "Tag" => array( - "Tag" => array(2, 3) - ) - ); + $submittedData = [ + "Article" => ["id" => 2, 'title' => 'second article'], + "Tag" => [ + "Tag" => [2, 3] + ] + ]; // ERROR: // Postgresql: DELETE FROM "articles_tags" WHERE tag_id IN ('1', '3') @@ -909,9 +909,9 @@ public function testDeleteHabtmPostgresFailure() { $Article->save($submittedData); // Want to make sure Article #1 has Tag #1 and Tag #2 still. - $after = $Article->find("all", array( - "conditions" => array("Article.id" => 1), - )); + $after = $Article->find("all", [ + "conditions" => ["Article.id" => 1], + ]); // Removing Article #2 from Tag #1 is all that should have happened. $this->assertEquals(count($before[0]["Tag"]), count($after[0]["Tag"])); @@ -931,12 +931,12 @@ public function testBeforeDeleteWipingTable() { $result = $Comment->find('count'); $this->assertTrue($result > 1, 'Comments are all gone.'); - $Comment->create(array( + $Comment->create([ 'article_id' => 1, 'user_id' => 2, 'comment' => 'new record', 'published' => 'Y' - )); + ]); $Comment->save(); $Comment->delete(5); diff --git a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php index 7f4107d34e..5272ddce1e 100644 --- a/lib/Cake/Test/Case/Model/ModelIntegrationTest.php +++ b/lib/Cake/Test/Case/Model/ModelIntegrationTest.php @@ -16,7 +16,7 @@ * @license https://opensource.org/licenses/mit-license.php MIT License */ -require_once dirname(__FILE__) . DS . 'ModelTestBase.php'; +require_once __DIR__ . DS . 'ModelTestBase.php'; App::uses('DboSource', 'Model/Datasource'); App::uses('DboMock', 'Model/Datasource'); @@ -131,7 +131,7 @@ public function testAssociationLazyLoadWithBindModel() { $this->assertFalse(isset($Article->belongsTo['User'])); $this->assertFalse(property_exists($Article, 'User')); - $Article->bindModel(array('belongsTo' => array('User'))); + $Article->bindModel(['belongsTo' => ['User']]); $this->assertTrue(isset($Article->belongsTo['User'])); $this->assertFalse(property_exists($Article, 'User')); $this->assertInstanceOf('User', $Article->User); @@ -213,13 +213,13 @@ public function testPkInHabtmLinkModel() { public function testDynamicBehaviorAttachment() { $this->loadFixtures('Apple', 'Sample', 'Author'); $TestModel = new Apple(); - $this->assertEquals(array(), $TestModel->Behaviors->loaded()); + $this->assertEquals([], $TestModel->Behaviors->loaded()); - $TestModel->Behaviors->load('Tree', array('left' => 'left_field', 'right' => 'right_field')); + $TestModel->Behaviors->load('Tree', ['left' => 'left_field', 'right' => 'right_field']); $this->assertTrue(is_object($TestModel->Behaviors->Tree)); - $this->assertEquals(array('Tree'), $TestModel->Behaviors->loaded()); + $this->assertEquals(['Tree'], $TestModel->Behaviors->loaded()); - $expected = array( + $expected = [ 'parent' => 'parent_id', 'left' => 'left_field', 'right' => 'right_field', @@ -228,15 +228,15 @@ public function testDynamicBehaviorAttachment() { '__parentChange' => false, 'recursive' => -1, 'level' => null - ); + ]; $this->assertEquals($expected, $TestModel->Behaviors->Tree->settings['Apple']); - $TestModel->Behaviors->load('Tree', array('enabled' => false)); + $TestModel->Behaviors->load('Tree', ['enabled' => false]); $this->assertEquals($expected, $TestModel->Behaviors->Tree->settings['Apple']); - $this->assertEquals(array('Tree'), $TestModel->Behaviors->loaded()); + $this->assertEquals(['Tree'], $TestModel->Behaviors->loaded()); $TestModel->Behaviors->unload('Tree'); - $this->assertEquals(array(), $TestModel->Behaviors->loaded()); + $this->assertEquals([], $TestModel->Behaviors->loaded()); $this->assertFalse(isset($TestModel->Behaviors->Tree)); } @@ -255,13 +255,13 @@ public function testTreeWithContainable() { $node['Ad']['parent_id'] = 1; $TestModel->save($node); - $result = $TestModel->getParentNode(array('id' => 2, 'contain' => 'Campaign')); + $result = $TestModel->getParentNode(['id' => 2, 'contain' => 'Campaign']); $this->assertTrue(array_key_exists('Campaign', $result)); - $result = $TestModel->children(array('id' => 1, 'contain' => 'Campaign')); + $result = $TestModel->children(['id' => 1, 'contain' => 'Campaign']); $this->assertTrue(array_key_exists('Campaign', $result[0])); - $result = $TestModel->getPath(array('id' => 2, 'contain' => 'Campaign')); + $result = $TestModel->getPath(['id' => 2, 'contain' => 'Campaign']); $this->assertTrue(array_key_exists('Campaign', $result[0])); $this->assertTrue(array_key_exists('Campaign', $result[1])); } @@ -275,32 +275,32 @@ public function testFindWithJoinsOption() { $this->loadFixtures('Article', 'User'); $TestUser = new User(); - $options = array( - 'fields' => array( + $options = [ + 'fields' => [ 'user', 'Article.published', - ), - 'joins' => array( - array( + ], + 'joins' => [ + [ 'table' => 'articles', 'alias' => 'Article', 'type' => 'LEFT', - 'conditions' => array( + 'conditions' => [ 'User.id = Article.user_id', - ), - ), - ), - 'group' => array('User.user', 'Article.published'), + ], + ], + ], + 'group' => ['User.user', 'Article.published'], 'recursive' => -1, - 'order' => array('User.user') - ); + 'order' => ['User.user'] + ]; $result = $TestUser->find('all', $options); - $expected = array( - array('User' => array('user' => 'garrett'), 'Article' => array('published' => '')), - array('User' => array('user' => 'larry'), 'Article' => array('published' => 'Y')), - array('User' => array('user' => 'mariano'), 'Article' => array('published' => 'Y')), - array('User' => array('user' => 'nate'), 'Article' => array('published' => '')) - ); + $expected = [ + ['User' => ['user' => 'garrett'], 'Article' => ['published' => '']], + ['User' => ['user' => 'larry'], 'Article' => ['published' => 'Y']], + ['User' => ['user' => 'mariano'], 'Article' => ['published' => 'Y']], + ['User' => ['user' => 'nate'], 'Article' => ['published' => '']] + ]; $this->assertEquals($expected, $result); } @@ -324,9 +324,9 @@ public function testCrossDatabaseJoins() { $this->loadFixtures('Article', 'Tag', 'ArticlesTag', 'User', 'Comment'); $TestModel = new Article(); - $expected = array( - array( - 'Article' => array( + $expected = [ + [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -334,16 +334,16 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -351,8 +351,8 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -360,8 +360,8 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - ), - array( + ], + [ 'id' => '3', 'article_id' => '1', 'user_id' => '1', @@ -369,8 +369,8 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => '4', 'article_id' => '1', 'user_id' => '1', @@ -378,22 +378,22 @@ public function testCrossDatabaseJoins() { 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - )), - 'Tag' => array( - array( + ]], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ))), - array( - 'Article' => array( + ]]], + [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -401,16 +401,16 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -418,8 +418,8 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -427,22 +427,22 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - )), - 'Tag' => array( - array( + ]], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))), - array( - 'Article' => array( + ]]], + [ + 'Article' => [ 'id' => '3', 'user_id' => '1', 'title' => 'Third Article', @@ -450,17 +450,17 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array(), - 'Tag' => array() - )); + ], + 'Comment' => [], + 'Tag' => [] + ]]; $this->assertEquals($expected, $TestModel->find('all')); $db2 = ConnectionManager::getDataSource('test2'); @@ -490,13 +490,13 @@ public function testCrossDatabaseJoins() { $this->assertEquals($expected, $result); $result = Hash::extract($TestModel->User->find('all'), '{n}.User.id'); - $this->assertEquals(array('1', '2', '3', '4'), $result); + $this->assertEquals(['1', '2', '3', '4'], $result); $this->assertEquals($expected, $TestModel->find('all')); - $TestModel->Comment->unbindModel(array('hasOne' => array('Attachment'))); - $expected = array( - array( - 'Comment' => array( + $TestModel->Comment->unbindModel(['hasOne' => ['Attachment']]); + $expected = [ + [ + 'Comment' => [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -504,15 +504,15 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -520,9 +520,9 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array( - 'Comment' => array( + ]], + [ + 'Comment' => [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -530,15 +530,15 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -546,9 +546,9 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array( - 'Comment' => array( + ]], + [ + 'Comment' => [ 'id' => '3', 'article_id' => '1', 'user_id' => '1', @@ -556,15 +556,15 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -572,9 +572,9 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array( - 'Comment' => array( + ]], + [ + 'Comment' => [ 'id' => '4', 'article_id' => '1', 'user_id' => '1', @@ -582,15 +582,15 @@ public function testCrossDatabaseJoins() { 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -598,9 +598,9 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array( - 'Comment' => array( + ]], + [ + 'Comment' => [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -608,15 +608,15 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -624,9 +624,9 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - )), - array( - 'Comment' => array( + ]], + [ + 'Comment' => [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -634,15 +634,15 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -650,7 +650,7 @@ public function testCrossDatabaseJoins() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ))); + ]]]; $this->assertEquals($expected, $TestModel->Comment->find('all')); } @@ -670,7 +670,7 @@ public function testHABTMKeepExisting() { $data = $Site->findById(1); // include api.cakephp.org - $data['Domain'] = array('Domain' => array(1, 2, 3)); + $data['Domain'] = ['Domain' => [1, 2, 3]]; $Site->save($data); $Site->id = 1; @@ -687,14 +687,14 @@ public function testHABTMKeepExisting() { $results = $Site->read(); $expected = 2; $this->assertEquals($expected, count($results['Domain'])); - $results['Domain'] = array('Domain' => array(7)); + $results['Domain'] = ['Domain' => [7]]; $Site->save($results); // remove association from domain 6 $results = $Site->read(); $expected = 1; // only 1 domain left belonging to rchavik $this->assertEquals($expected, count($results['Domain'])); // add deleted domain back - $results['Domain'] = array('Domain' => array(6, 7)); + $results['Domain'] = ['Domain' => [6, 7]]; $Site->save($results); $results = $Site->read(); $expected = 2; // 2 domains belonging to rchavik @@ -703,11 +703,11 @@ public function testHABTMKeepExisting() { $Site->DomainsSite->id = $results['Domain'][0]['DomainsSite']['id']; $Site->DomainsSite->saveField('active', true); - $results = $Site->Domain->DomainsSite->find('count', array( - 'conditions' => array( + $results = $Site->Domain->DomainsSite->find('count', [ + 'conditions' => [ 'DomainsSite.active' => true, - ), - )); + ], + ]); $expected = 5; $this->assertEquals($expected, $results); @@ -716,21 +716,21 @@ public function testHABTMKeepExisting() { $activated['DomainsSite']['active'] = true; $Site->DomainsSite->save($activated); - $results = $Site->DomainsSite->find('count', array( - 'conditions' => array( + $results = $Site->DomainsSite->find('count', [ + 'conditions' => [ 'DomainsSite.active' => true, - ), - )); + ], + ]); $expected = 6; $this->assertEquals($expected, $results); // remove 2 previously active domains, and leave $activated alone - $data = array( - 'Site' => array('id' => 1, 'name' => 'cakephp (modified)'), - 'Domain' => array( - 'Domain' => array(3), - ) - ); + $data = [ + 'Site' => ['id' => 1, 'name' => 'cakephp (modified)'], + 'Domain' => [ + 'Domain' => [3], + ] + ]; $Site->create($data); $Site->save($data); @@ -752,89 +752,89 @@ public function testHABTMKeepExistingAlternateDataFormat() { $Site = new Site(); - $expected = array( - array( - 'DomainsSite' => array( + $expected = [ + [ + 'DomainsSite' => [ 'id' => 1, 'site_id' => 1, 'domain_id' => 1, 'active' => true, 'created' => '2007-03-17 01:16:23' - ) - ), - array( - 'DomainsSite' => array( + ] + ], + [ + 'DomainsSite' => [ 'id' => 2, 'site_id' => 1, 'domain_id' => 2, 'active' => true, 'created' => '2007-03-17 01:16:23' - ) - ) - ); - $result = $Site->DomainsSite->find('all', array( - 'conditions' => array('DomainsSite.site_id' => 1), - 'fields' => array( + ] + ] + ]; + $result = $Site->DomainsSite->find('all', [ + 'conditions' => ['DomainsSite.site_id' => 1], + 'fields' => [ 'DomainsSite.id', 'DomainsSite.site_id', 'DomainsSite.domain_id', 'DomainsSite.active', 'DomainsSite.created' - ), + ], 'order' => 'DomainsSite.id' - )); + ]); $this->assertEquals($expected, $result); $time = date('Y-m-d H:i:s'); - $data = array( - 'Site' => array( + $data = [ + 'Site' => [ 'id' => 1 - ), - 'Domain' => array( - array( + ], + 'Domain' => [ + [ 'site_id' => 1, 'domain_id' => 3, 'created' => $time, - ), - array( + ], + [ 'id' => 2, 'site_id' => 1, 'domain_id' => 2 - ), - ) - ); + ], + ] + ]; $Site->save($data); - $expected = array( - array( - 'DomainsSite' => array( + $expected = [ + [ + 'DomainsSite' => [ 'id' => 2, 'site_id' => 1, 'domain_id' => 2, 'active' => true, 'created' => '2007-03-17 01:16:23' - ) - ), - array( - 'DomainsSite' => array( + ] + ], + [ + 'DomainsSite' => [ 'id' => 7, 'site_id' => 1, 'domain_id' => 3, 'active' => false, 'created' => $time - ) - ) - ); - $result = $Site->DomainsSite->find('all', array( - 'conditions' => array('DomainsSite.site_id' => 1), - 'fields' => array( + ] + ] + ]; + $result = $Site->DomainsSite->find('all', [ + 'conditions' => ['DomainsSite.site_id' => 1], + 'fields' => [ 'DomainsSite.id', 'DomainsSite.site_id', 'DomainsSite.domain_id', 'DomainsSite.active', 'DomainsSite.created' - ), + ], 'order' => 'DomainsSite.id' - )); + ]); $this->assertEquals($expected, $result); } @@ -853,14 +853,14 @@ public function testHABTMKeepExistingWithThreeDbs() { $this->loadFixtures('Player', 'Guild', 'GuildsPlayer', 'Armor', 'ArmorsPlayer'); $Player = ClassRegistry::init('Player'); - $Player->bindModel(array( - 'hasAndBelongsToMany' => array( - 'Armor' => array( + $Player->bindModel([ + 'hasAndBelongsToMany' => [ + 'Armor' => [ 'with' => 'ArmorsPlayer', 'unique' => 'keepExisting', - ), - ), - ), false); + ], + ], + ], false); $this->assertEquals('test', $Player->useDbConfig); $this->assertEquals('test', $Player->Guild->useDbConfig); $this->assertEquals('test2', $Player->Guild->GuildsPlayer->useDbConfig); @@ -879,8 +879,8 @@ public function testHABTMKeepExistingWithThreeDbs() { $larrysArmor = Hash::extract($larry, 'Armor.{n}.ArmorsPlayer'); $this->assertEquals(1, count($larrysArmor)); - $larry['Guild']['Guild'] = array(1, 3); // larry joins another guild - $larry['Armor']['Armor'] = array(2, 3); // purchases chainmail + $larry['Guild']['Guild'] = [1, 3]; // larry joins another guild + $larry['Armor']['Armor'] = [2, 3]; // purchases chainmail $Player->save($larry); unset($larry); @@ -894,7 +894,7 @@ public function testHABTMKeepExistingWithThreeDbs() { $Player->ArmorsPlayer->saveField('broken', true); // larry's cloak broke $larry = $Player->findByName('larry'); - $larrysCloak = Hash::extract($larry, 'Armor.{n}.ArmorsPlayer[armor_id=3]', $larry); + $larrysCloak = Hash::extract($larry, 'Armor.{n}.ArmorsPlayer[armor_id=3]'); $this->assertNotEmpty($larrysCloak); $this->assertTrue($larrysCloak[0]['broken']); // still broken } @@ -924,10 +924,10 @@ public function testSchema() { $Post = new Post(); $result = $Post->schema(); - $columns = array('id', 'author_id', 'title', 'body', 'published', 'created', 'updated'); + $columns = ['id', 'author_id', 'title', 'body', 'published', 'created', 'updated']; $this->assertEquals($columns, array_keys($result)); - $types = array('integer', 'integer', 'string', 'text', 'string', 'datetime', 'datetime'); + $types = ['integer', 'integer', 'string', 'text', 'string', 'datetime', 'datetime']; $this->assertEquals(Hash::extract(array_values($result), '{n}.type'), $types); $result = $Post->schema('body'); @@ -959,54 +959,54 @@ public function testSchemaUseTableFalse() { public static function timeProvider() { $db = ConnectionManager::getDataSource('test'); $now = $db->expression('NOW()'); - return array( + return [ // blank - array( - array('hour' => '', 'min' => '', 'meridian' => ''), + [ + ['hour' => '', 'min' => '', 'meridian' => ''], '' - ), + ], // missing hour - array( - array('hour' => '', 'min' => '00', 'meridian' => 'pm'), + [ + ['hour' => '', 'min' => '00', 'meridian' => 'pm'], '' - ), + ], // all blank - array( - array('hour' => '', 'min' => '', 'sec' => ''), + [ + ['hour' => '', 'min' => '', 'sec' => ''], '' - ), + ], // set and empty merdian - array( - array('hour' => '1', 'min' => '00', 'meridian' => ''), + [ + ['hour' => '1', 'min' => '00', 'meridian' => ''], '' - ), + ], // midnight - array( - array('hour' => '12', 'min' => '0', 'meridian' => 'am'), + [ + ['hour' => '12', 'min' => '0', 'meridian' => 'am'], '00:00:00' - ), - array( - array('hour' => '00', 'min' => '00'), + ], + [ + ['hour' => '00', 'min' => '00'], '00:00:00' - ), + ], // 3am - array( - array('hour' => '03', 'min' => '04', 'sec' => '04'), + [ + ['hour' => '03', 'min' => '04', 'sec' => '04'], '03:04:04' - ), - array( - array('hour' => '3', 'min' => '4', 'sec' => '4'), + ], + [ + ['hour' => '3', 'min' => '4', 'sec' => '4'], '03:04:04' - ), - array( - array('hour' => '03', 'min' => '4', 'sec' => '4'), + ], + [ + ['hour' => '03', 'min' => '4', 'sec' => '4'], '03:04:04' - ), - array( + ], + [ $now, $now - ) - ); + ] + ]; } /** @@ -1021,15 +1021,15 @@ public function testDeconstructFieldsTime($input, $result) { $this->loadFixtures('Apple'); $TestModel = new Apple(); - $data = array( - 'Apple' => array( + $data = [ + 'Apple' => [ 'mytime' => $input - ) - ); + ] + ]; $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('mytime' => $result)); + $expected = ['Apple' => ['mytime' => $result]]; $this->assertEquals($expected, $TestModel->data); } @@ -1054,20 +1054,20 @@ public function testDeconstructFieldsDateTime() { $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('created' => '')); + $expected = ['Apple' => ['created' => '']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['date']['year'] = ''; $data['Apple']['date']['month'] = ''; $data['Apple']['date']['day'] = ''; $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('date' => '')); + $expected = ['Apple' => ['date' => '']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['year'] = '2007'; $data['Apple']['created']['month'] = '08'; $data['Apple']['created']['day'] = '20'; @@ -1077,10 +1077,10 @@ public function testDeconstructFieldsDateTime() { $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('created' => '2007-08-20 00:00:00')); + $expected = ['Apple' => ['created' => '2007-08-20 00:00:00']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['year'] = '2007'; $data['Apple']['created']['month'] = '08'; $data['Apple']['created']['day'] = '20'; @@ -1090,10 +1090,10 @@ public function testDeconstructFieldsDateTime() { $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('created' => '2007-08-20 10:12:00')); + $expected = ['Apple' => ['created' => '2007-08-20 10:12:00']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['year'] = '2007'; $data['Apple']['created']['month'] = ''; $data['Apple']['created']['day'] = '12'; @@ -1103,29 +1103,29 @@ public function testDeconstructFieldsDateTime() { $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('created' => '')); + $expected = ['Apple' => ['created' => '']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['hour'] = '20'; $data['Apple']['created']['min'] = '33'; $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('created' => '')); + $expected = ['Apple' => ['created' => '']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['hour'] = '20'; $data['Apple']['created']['min'] = '33'; $data['Apple']['created']['sec'] = '33'; $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('created' => '')); + $expected = ['Apple' => ['created' => '']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['hour'] = '13'; $data['Apple']['created']['min'] = '00'; $data['Apple']['date']['year'] = '2006'; @@ -1134,14 +1134,14 @@ public function testDeconstructFieldsDateTime() { $TestModel->data = null; $TestModel->set($data); - $expected = array( - 'Apple' => array( + $expected = [ + 'Apple' => [ 'created' => '', 'date' => '2006-12-25' - )); + ]]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['year'] = '2007'; $data['Apple']['created']['month'] = '08'; $data['Apple']['created']['day'] = '20'; @@ -1154,14 +1154,14 @@ public function testDeconstructFieldsDateTime() { $TestModel->data = null; $TestModel->set($data); - $expected = array( - 'Apple' => array( + $expected = [ + 'Apple' => [ 'created' => '2007-08-20 10:12:09', 'date' => '2006-12-25' - )); + ]]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['year'] = '--'; $data['Apple']['created']['month'] = '--'; $data['Apple']['created']['day'] = '--'; @@ -1174,10 +1174,10 @@ public function testDeconstructFieldsDateTime() { $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('created' => '', 'date' => '')); + $expected = ['Apple' => ['created' => '', 'date' => '']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['created']['year'] = '2007'; $data['Apple']['created']['month'] = '--'; $data['Apple']['created']['day'] = '20'; @@ -1190,21 +1190,21 @@ public function testDeconstructFieldsDateTime() { $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('created' => '', 'date' => '2006-12-25')); + $expected = ['Apple' => ['created' => '', 'date' => '2006-12-25']]; $this->assertEquals($expected, $TestModel->data); - $data = array(); + $data = []; $data['Apple']['date']['year'] = '2006'; $data['Apple']['date']['month'] = '12'; $data['Apple']['date']['day'] = '25'; $TestModel->data = null; $TestModel->set($data); - $expected = array('Apple' => array('date' => '2006-12-25')); + $expected = ['Apple' => ['date' => '2006-12-25']]; $this->assertEquals($expected, $TestModel->data); $db = ConnectionManager::getDataSource('test'); - $data = array(); + $data = []; $data['Apple']['modified'] = $db->expression('NOW()'); $TestModel->data = null; $TestModel->set($data); @@ -1218,10 +1218,10 @@ public function testDeconstructFieldsDateTime() { */ public function testTablePrefixSwitching() { ConnectionManager::create('database1', - array_merge($this->db->config, array('prefix' => 'aaa_') + array_merge($this->db->config, ['prefix' => 'aaa_'] )); ConnectionManager::create('database2', - array_merge($this->db->config, array('prefix' => 'bbb_') + array_merge($this->db->config, ['prefix' => 'bbb_'] )); $db1 = ConnectionManager::getDataSource('database1'); @@ -1347,9 +1347,9 @@ public function testPluginAssociations() { $TestModel = new TestPluginArticle(); $result = $TestModel->find('all'); - $expected = array( - array( - 'TestPluginArticle' => array( + $expected = [ + [ + 'TestPluginArticle' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Plugin Article', @@ -1357,16 +1357,16 @@ public function testPluginAssociations() { 'published' => 'Y', 'created' => '2008-09-24 10:39:23', 'updated' => '2008-09-24 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'TestPluginComment' => array( - array( + ], + 'TestPluginComment' => [ + [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, @@ -1374,8 +1374,8 @@ public function testPluginAssociations() { 'published' => 'Y', 'created' => '2008-09-24 10:45:23', 'updated' => '2008-09-24 10:47:31' - ), - array( + ], + [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, @@ -1383,8 +1383,8 @@ public function testPluginAssociations() { 'published' => 'Y', 'created' => '2008-09-24 10:47:23', 'updated' => '2008-09-24 10:49:31' - ), - array( + ], + [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, @@ -1392,8 +1392,8 @@ public function testPluginAssociations() { 'published' => 'Y', 'created' => '2008-09-24 10:49:23', 'updated' => '2008-09-24 10:51:31' - ), - array( + ], + [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, @@ -1401,9 +1401,9 @@ public function testPluginAssociations() { 'published' => 'N', 'created' => '2008-09-24 10:51:23', 'updated' => '2008-09-24 10:53:31' - ))), - array( - 'TestPluginArticle' => array( + ]]], + [ + 'TestPluginArticle' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Plugin Article', @@ -1411,16 +1411,16 @@ public function testPluginAssociations() { 'published' => 'Y', 'created' => '2008-09-24 10:41:23', 'updated' => '2008-09-24 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'TestPluginComment' => array( - array( + ], + 'TestPluginComment' => [ + [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, @@ -1428,8 +1428,8 @@ public function testPluginAssociations() { 'published' => 'Y', 'created' => '2008-09-24 10:53:23', 'updated' => '2008-09-24 10:55:31' - ), - array( + ], + [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, @@ -1437,9 +1437,9 @@ public function testPluginAssociations() { 'published' => 'Y', 'created' => '2008-09-24 10:55:23', 'updated' => '2008-09-24 10:57:31' - ))), - array( - 'TestPluginArticle' => array( + ]]], + [ + 'TestPluginArticle' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Plugin Article', @@ -1447,16 +1447,16 @@ public function testPluginAssociations() { 'published' => 'Y', 'created' => '2008-09-24 10:43:23', 'updated' => '2008-09-24 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'TestPluginComment' => array() - )); + ], + 'TestPluginComment' => [] + ]]; $this->assertEquals($expected, $result); } @@ -1470,24 +1470,24 @@ public function testGetAssociated() { $this->loadFixtures('Article', 'Tag'); $Article = ClassRegistry::init('Article'); - $assocTypes = array('hasMany', 'hasOne', 'belongsTo', 'hasAndBelongsToMany'); + $assocTypes = ['hasMany', 'hasOne', 'belongsTo', 'hasAndBelongsToMany']; foreach ($assocTypes as $type) { $this->assertEquals($Article->getAssociated($type), array_keys($Article->{$type})); } - $Article->bindModel(array('hasMany' => array('Category'))); - $this->assertEquals(array('Comment', 'Category'), $Article->getAssociated('hasMany')); + $Article->bindModel(['hasMany' => ['Category']]); + $this->assertEquals(['Comment', 'Category'], $Article->getAssociated('hasMany')); $results = $Article->getAssociated(); $results = array_keys($results); sort($results); - $this->assertEquals(array('Category', 'Comment', 'Tag', 'User'), $results); + $this->assertEquals(['Category', 'Comment', 'Tag', 'User'], $results); - $Article->unbindModel(array('hasAndBelongsToMany' => array('Tag'))); - $this->assertEquals(array(), $Article->getAssociated('hasAndBelongsToMany')); + $Article->unbindModel(['hasAndBelongsToMany' => ['Tag']]); + $this->assertEquals([], $Article->getAssociated('hasAndBelongsToMany')); $result = $Article->getAssociated('Category'); - $expected = array( + $expected = [ 'className' => 'Category', 'foreignKey' => 'article_id', 'conditions' => '', @@ -1500,7 +1500,7 @@ public function testGetAssociated() { 'finderQuery' => '', 'counterQuery' => '', 'association' => 'hasMany', - ); + ]; $this->assertEquals($expected, $result); } @@ -1514,7 +1514,7 @@ public function testAutoConstructAssociations() { $TestModel = new AssociationTest1(); $result = $TestModel->hasAndBelongsToMany; - $expected = array('AssociationTest2' => array( + $expected = ['AssociationTest2' => [ 'unique' => false, 'joinTable' => 'join_as_join_bs', 'foreignKey' => false, @@ -1524,22 +1524,22 @@ public function testAutoConstructAssociations() { 'associationForeignKey' => 'join_b_id', 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'finderQuery' => '' - )); + ]]; $this->assertEquals($expected, $result); $TestModel = new ArticleFeatured(); - $TestFakeModel = new ArticleFeatured(array('table' => false)); + $TestFakeModel = new ArticleFeatured(['table' => false]); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'className' => 'User', 'foreignKey' => 'user_id', 'conditions' => '', 'fields' => '', 'order' => '', 'counterCache' => '' - ), - 'Category' => array( + ], + 'Category' => [ 'className' => 'Category', 'foreignKey' => 'category_id', 'conditions' => '', 'fields' => '', 'order' => '', 'counterCache' => '' - ) - ); + ] + ]; $this->assertSame($expected, $TestModel->belongsTo); $this->assertSame($expected, $TestFakeModel->belongsTo); @@ -1548,15 +1548,15 @@ public function testAutoConstructAssociations() { $this->assertEquals('Category', $TestModel->Category->name); $this->assertEquals('Category', $TestFakeModel->Category->name); - $expected = array( - 'Featured' => array( + $expected = [ + 'Featured' => [ 'className' => 'Featured', 'foreignKey' => 'article_featured_id', 'conditions' => '', 'fields' => '', 'order' => '', 'dependent' => '' - )); + ]]; $this->assertSame($expected, $TestModel->hasOne); $this->assertSame($expected, $TestFakeModel->hasOne); @@ -1564,8 +1564,8 @@ public function testAutoConstructAssociations() { $this->assertEquals('Featured', $TestModel->Featured->name); $this->assertEquals('Featured', $TestFakeModel->Featured->name); - $expected = array( - 'Comment' => array( + $expected = [ + 'Comment' => [ 'className' => 'Comment', 'dependent' => true, 'foreignKey' => 'article_featured_id', @@ -1577,7 +1577,7 @@ public function testAutoConstructAssociations() { 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' - )); + ]]; $this->assertSame($expected, $TestModel->hasMany); $this->assertSame($expected, $TestFakeModel->hasMany); @@ -1585,8 +1585,8 @@ public function testAutoConstructAssociations() { $this->assertEquals('Comment', $TestModel->Comment->name); $this->assertEquals('Comment', $TestFakeModel->Comment->name); - $expected = array( - 'Tag' => array( + $expected = [ + 'Tag' => [ 'className' => 'Tag', 'joinTable' => 'article_featureds_tags', 'with' => 'ArticleFeaturedsTag', @@ -1600,7 +1600,7 @@ public function testAutoConstructAssociations() { 'offset' => '', 'unique' => true, 'finderQuery' => '', - )); + ]]; $this->assertSame($expected, $TestModel->hasAndBelongsToMany); $this->assertSame($expected, $TestFakeModel->hasAndBelongsToMany); @@ -1636,12 +1636,12 @@ public function testConstruct() { $this->loadFixtures('Post'); $TestModel = ClassRegistry::init('MergeVarPluginPost'); - $this->assertEquals(array('Containable' => null, 'Tree' => null), $TestModel->actsAs); + $this->assertEquals(['Containable' => null, 'Tree' => null], $TestModel->actsAs); $this->assertTrue(isset($TestModel->Behaviors->Containable)); $this->assertTrue(isset($TestModel->Behaviors->Tree)); $TestModel = ClassRegistry::init('MergeVarPluginComment'); - $expected = array('Containable' => array('some_settings')); + $expected = ['Containable' => ['some_settings']]; $this->assertEquals($expected, $TestModel->actsAs); $this->assertTrue(isset($TestModel->Behaviors->Containable)); } @@ -1654,9 +1654,9 @@ public function testConstruct() { * @return void */ public function testConstructWithAlternateDataSource() { - $TestModel = ClassRegistry::init(array( + $TestModel = ClassRegistry::init([ 'class' => 'DoesntMatter', 'ds' => 'test', 'table' => false - )); + ]); $this->assertEquals('test', $TestModel->useDbConfig); //deprecated but test it anyway @@ -1708,7 +1708,7 @@ public function testIdentity() { $expected = 'TestAlias'; $this->assertEquals($expected, $result); - $TestModel = new Test(array('alias' => 'AnotherTest')); + $TestModel = new Test(['alias' => 'AnotherTest']); $result = $TestModel->alias; $expected = 'AnotherTest'; $this->assertEquals($expected, $result); @@ -1732,9 +1732,9 @@ public function testWithAssociation() { $TestModel = new Something(); $result = $TestModel->SomethingElse->find('all'); - $expected = array( - array( - 'SomethingElse' => array( + $expected = [ + [ + 'SomethingElse' => [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', @@ -1742,16 +1742,16 @@ public function testWithAssociation() { 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'Something' => array( - array( + ], + 'Something' => [ + [ 'id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'JoinThing' => array( + 'JoinThing' => [ 'id' => '3', 'something_id' => '3', 'something_else_id' => '1', @@ -1759,9 +1759,9 @@ public function testWithAssociation() { 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', 'afterFind' => 'Successfully added by AfterFind' - )))), - array( - 'SomethingElse' => array( + ]]]], + [ + 'SomethingElse' => [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', @@ -1769,16 +1769,16 @@ public function testWithAssociation() { 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'Something' => array( - array( + ], + 'Something' => [ + [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'JoinThing' => array( + 'JoinThing' => [ 'id' => '1', 'something_id' => '1', 'something_else_id' => '2', @@ -1786,9 +1786,9 @@ public function testWithAssociation() { 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', 'afterFind' => 'Successfully added by AfterFind' - )))), - array( - 'SomethingElse' => array( + ]]]], + [ + 'SomethingElse' => [ 'id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', @@ -1796,16 +1796,16 @@ public function testWithAssociation() { 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'Something' => array( - array( + ], + 'Something' => [ + [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'JoinThing' => array( + 'JoinThing' => [ 'id' => '2', 'something_id' => '2', 'something_else_id' => '3', @@ -1813,114 +1813,114 @@ public function testWithAssociation() { 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'afterFind' => 'Successfully added by AfterFind' - ))))); + ]]]]]; $this->assertEquals($expected, $result); $result = $TestModel->find('all'); - $expected = array( - array( - 'Something' => array( + $expected = [ + [ + 'Something' => [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'SomethingElse' => array( - array( + ], + 'SomethingElse' => [ + [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => true, 'something_id' => '1', 'something_else_id' => '2', 'afterFind' => 'Successfully added by AfterFind' - ), + ], 'afterFind' => 'Successfully added by AfterFind' - ))), - array( - 'Something' => array( + ]]], + [ + 'Something' => [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'SomethingElse' => array( - array( + ], + 'SomethingElse' => [ + [ 'id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => false, 'something_id' => '2', 'something_else_id' => '3', 'afterFind' => 'Successfully added by AfterFind' - ), + ], 'afterFind' => 'Successfully added by AfterFind' - ))), - array( - 'Something' => array( + ]]], + [ + 'Something' => [ 'id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'SomethingElse' => array( - array( + ], + 'SomethingElse' => [ + [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => true, 'something_id' => '3', 'something_else_id' => '1', 'afterFind' => 'Successfully added by AfterFind' - ), + ], 'afterFind' => 'Successfully added by AfterFind' - )))); + ]]]]; $this->assertEquals($expected, $result); $result = $TestModel->findById(1); - $expected = array( - 'Something' => array( + $expected = [ + 'Something' => [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'SomethingElse' => array( - array( + ], + 'SomethingElse' => [ + [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => true, 'something_id' => '1', 'something_else_id' => '2', 'afterFind' => 'Successfully added by AfterFind' - ), + ], 'afterFind' => 'Successfully added by AfterFind' - ))); + ]]]; $this->assertEquals($expected, $result); $expected = $TestModel->findById(1); @@ -1930,72 +1930,72 @@ public function testWithAssociation() { $this->assertEquals($expected, $result); $TestModel->hasAndBelongsToMany['SomethingElse']['unique'] = false; - $TestModel->create(array( - 'Something' => array('id' => 1), - 'SomethingElse' => array(3, array( + $TestModel->create([ + 'Something' => ['id' => 1], + 'SomethingElse' => [3, [ 'something_else_id' => 1, 'doomed' => true - )))); + ]]]); $TestModel->save(); $TestModel->hasAndBelongsToMany['SomethingElse']['order'] = 'SomethingElse.id ASC'; $result = $TestModel->findById(1); - $expected = array( - 'Something' => array( + $expected = [ + 'Something' => [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23' - ), - 'SomethingElse' => array( - array( + ], + 'SomethingElse' => [ + [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => true, 'something_id' => '1', 'something_else_id' => '1', 'afterFind' => 'Successfully added by AfterFind' - ), + ], 'afterFind' => 'Successfully added by AfterFind' - ), - array( + ], + [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => true, 'something_id' => '1', 'something_else_id' => '2', 'afterFind' => 'Successfully added by AfterFind' - ), + ], 'afterFind' => 'Successfully added by AfterFind' - ), - array( + ], + [ 'id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => false, 'something_id' => '1', 'something_else_id' => '3', 'afterFind' => 'Successfully added by AfterFind' - ), + ], 'afterFind' => 'Successfully added by AfterFind' - ) - )); + ] + ]]; $this->assertEquals(static::date(), $result['Something']['updated']); unset($result['Something']['updated']); $this->assertEquals($expected, $result); @@ -2012,100 +2012,100 @@ public function testFindSelfAssociations() { $TestModel = new Person(); $TestModel->recursive = 2; $result = $TestModel->read(null, 1); - $expected = array( - 'Person' => array( + $expected = [ + 'Person' => [ 'id' => 1, 'name' => 'person', 'mother_id' => 2, 'father_id' => 3 - ), - 'Mother' => array( + ], + 'Mother' => [ 'id' => 2, 'name' => 'mother', 'mother_id' => 4, 'father_id' => 5, - 'Mother' => array( + 'Mother' => [ 'id' => 4, 'name' => 'mother - grand mother', 'mother_id' => 0, 'father_id' => 0 - ), - 'Father' => array( + ], + 'Father' => [ 'id' => 5, 'name' => 'mother - grand father', 'mother_id' => 0, 'father_id' => 0 - )), - 'Father' => array( + ]], + 'Father' => [ 'id' => 3, 'name' => 'father', 'mother_id' => 6, 'father_id' => 7, - 'Father' => array( + 'Father' => [ 'id' => 7, 'name' => 'father - grand father', 'mother_id' => 0, 'father_id' => 0 - ), - 'Mother' => array( + ], + 'Mother' => [ 'id' => 6, 'name' => 'father - grand mother', 'mother_id' => 0, 'father_id' => 0 - ))); + ]]]; $this->assertEquals($expected, $result); $TestModel->recursive = 3; $result = $TestModel->read(null, 1); - $expected = array( - 'Person' => array( + $expected = [ + 'Person' => [ 'id' => 1, 'name' => 'person', 'mother_id' => 2, 'father_id' => 3 - ), - 'Mother' => array( + ], + 'Mother' => [ 'id' => 2, 'name' => 'mother', 'mother_id' => 4, 'father_id' => 5, - 'Mother' => array( + 'Mother' => [ 'id' => 4, 'name' => 'mother - grand mother', 'mother_id' => 0, 'father_id' => 0, - 'Mother' => array(), - 'Father' => array()), - 'Father' => array( + 'Mother' => [], + 'Father' => []], + 'Father' => [ 'id' => 5, 'name' => 'mother - grand father', 'mother_id' => 0, 'father_id' => 0, - 'Father' => array(), - 'Mother' => array() - )), - 'Father' => array( + 'Father' => [], + 'Mother' => [] + ]], + 'Father' => [ 'id' => 3, 'name' => 'father', 'mother_id' => 6, 'father_id' => 7, - 'Father' => array( + 'Father' => [ 'id' => 7, 'name' => 'father - grand father', 'mother_id' => 0, 'father_id' => 0, - 'Father' => array(), - 'Mother' => array() - ), - 'Mother' => array( + 'Father' => [], + 'Mother' => [] + ], + 'Mother' => [ 'id' => 6, 'name' => 'father - grand mother', 'mother_id' => 0, 'father_id' => 0, - 'Mother' => array(), - 'Father' => array() - ))); + 'Mother' => [], + 'Father' => [] + ]]]; $this->assertEquals($expected, $result); } @@ -2119,15 +2119,15 @@ public function testDynamicAssociations() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->hasOne = array(); - $TestModel->hasMany['Comment'] = array_merge($TestModel->hasMany['Comment'], array( + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->hasOne = []; + $TestModel->hasMany['Comment'] = array_merge($TestModel->hasMany['Comment'], [ 'foreignKey' => false, - 'conditions' => array('Comment.user_id =' => '2') - )); + 'conditions' => ['Comment.user_id =' => '2'] + ]); $result = $TestModel->find('all'); - $expected = array( - array( - 'Article' => array( + $expected = [ + [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -2135,9 +2135,9 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -2145,8 +2145,8 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -2154,9 +2154,9 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ))), - array( - 'Article' => array( + ]]], + [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -2164,9 +2164,9 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -2174,8 +2174,8 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -2183,9 +2183,9 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ))), - array( - 'Article' => array( + ]]], + [ + 'Article' => [ 'id' => '3', 'user_id' => '1', 'title' => 'Third Article', @@ -2193,9 +2193,9 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -2203,8 +2203,8 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -2212,7 +2212,7 @@ public function testDynamicAssociations() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - )))); + ]]]]; $this->assertEquals($expected, $result); } @@ -2226,7 +2226,7 @@ public function testCreation() { $this->loadFixtures('Article', 'ArticleFeaturedsTags', 'User', 'Featured'); $TestModel = new Test(); $result = $TestModel->create(); - $expected = array('Test' => array('notes' => 'write some notes here')); + $expected = ['Test' => ['notes' => 'write some notes here']]; $this->assertEquals($expected, $result); $TestModel = new User(); $result = $TestModel->schema(); @@ -2238,99 +2238,99 @@ public function testCreation() { } else { $intLength = 11; } - foreach (array('collate', 'charset', 'comment', 'unsigned') as $type) { + foreach (['collate', 'charset', 'comment', 'unsigned'] as $type) { foreach ($result as $i => $r) { unset($result[$i][$type]); } } - $expected = array( - 'id' => array( + $expected = [ + 'id' => [ 'type' => 'integer', 'null' => false, 'default' => null, 'length' => $intLength, 'key' => 'primary' - ), - 'user' => array( + ], + 'user' => [ 'type' => 'string', 'null' => true, 'default' => '', 'length' => 255 - ), - 'password' => array( + ], + 'password' => [ 'type' => 'string', 'null' => true, 'default' => '', 'length' => 255 - ), - 'created' => array( + ], + 'created' => [ 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null - ), - 'updated' => array( + ], + 'updated' => [ 'type' => 'datetime', 'null' => true, 'default' => null, 'length' => null - )); + ]]; $this->assertEquals($expected, $result); $TestModel = new Article(); $result = $TestModel->create(); - $expected = array('Article' => array('published' => 'N')); + $expected = ['Article' => ['published' => 'N']]; $this->assertEquals($expected, $result); $FeaturedModel = new Featured(); - $data = array( + $data = [ 'article_featured_id' => 1, 'category_id' => 1, - 'published_date' => array( + 'published_date' => [ 'year' => 2008, 'month' => 06, 'day' => 11 - ), - 'end_date' => array( + ], + 'end_date' => [ 'year' => 2008, 'month' => 06, 'day' => 20 - )); + ]]; - $expected = array( - 'Featured' => array( + $expected = [ + 'Featured' => [ 'article_featured_id' => 1, 'category_id' => 1, 'published_date' => '2008-06-11 00:00:00', 'end_date' => '2008-06-20 00:00:00' - )); + ]]; $this->assertEquals($expected, $FeaturedModel->create($data)); - $data = array( - 'published_date' => array( + $data = [ + 'published_date' => [ 'year' => 2008, 'month' => 06, 'day' => 11 - ), - 'end_date' => array( + ], + 'end_date' => [ 'year' => 2008, 'month' => 06, 'day' => 20 - ), + ], 'article_featured_id' => 1, 'category_id' => 1 - ); + ]; - $expected = array( - 'Featured' => array( + $expected = [ + 'Featured' => [ 'published_date' => '2008-06-11 00:00:00', 'end_date' => '2008-06-20 00:00:00', 'article_featured_id' => 1, 'category_id' => 1 - )); + ]]; $this->assertEquals($expected, $FeaturedModel->create($data)); } @@ -2356,7 +2356,7 @@ public function testEscapeField() { $expected = $db->name('Domain.DomainHandle'); $this->assertEquals($expected, $result); - ConnectionManager::create('mock', array('datasource' => 'DboMock')); + ConnectionManager::create('mock', ['datasource' => 'DboMock']); $TestModel->setDataSource('mock'); $db = $TestModel->getDataSource(); @@ -2381,11 +2381,11 @@ public function testGetID() { $result = $TestModel->getID(); $this->assertEquals(9, $result); - $TestModel->id = array(10, 9, 8, 7); + $TestModel->id = [10, 9, 8, 7]; $result = $TestModel->getID(2); $this->assertEquals(8, $result); - $TestModel->id = array(array(), 1, 2, 3); + $TestModel->id = [[], 1, 2, 3]; $result = $TestModel->getID(); $this->assertFalse($result); } @@ -2433,9 +2433,9 @@ public function testMultischemaFixture() { $this->assertEquals('test2', $Player->Guild->GuildsPlayer->useDbConfig); $this->assertEquals('test2', $Player->GuildsPlayer->useDbConfig); - $players = $Player->find('all', array('recursive' => -1)); - $guilds = $Player->Guild->find('all', array('recursive' => -1)); - $guildsPlayers = $Player->GuildsPlayer->find('all', array('recursive' => -1)); + $players = $Player->find('all', ['recursive' => -1]); + $guilds = $Player->Guild->find('all', ['recursive' => -1]); + $guildsPlayers = $Player->GuildsPlayer->find('all', ['recursive' => -1]); $this->assertEquals(true, count($players) > 1); $this->assertEquals(true, count($guilds) > 1); @@ -2458,13 +2458,13 @@ public function testMultischemaFixtureWithThreeDatabases() { $this->loadFixtures('Player', 'Guild', 'GuildsPlayer', 'Armor', 'ArmorsPlayer'); $Player = ClassRegistry::init('Player'); - $Player->bindModel(array( - 'hasAndBelongsToMany' => array( - 'Armor' => array( + $Player->bindModel([ + 'hasAndBelongsToMany' => [ + 'Armor' => [ 'with' => 'ArmorsPlayer', - ), - ), - ), false); + ], + ], + ], false); $this->assertEquals('test', $Player->useDbConfig); $this->assertEquals('test', $Player->Guild->useDbConfig); $this->assertEquals('test2', $Player->Guild->GuildsPlayer->useDbConfig); @@ -2477,10 +2477,10 @@ public function testMultischemaFixtureWithThreeDatabases() { $this->assertEquals('test2', $Player->Armor->getDataSource()->configKeyName); $this->assertEquals('test_database_three', $Player->Armor->ArmorsPlayer->getDataSource()->configKeyName); - $players = $Player->find('all', array('recursive' => -1)); - $guilds = $Player->Guild->find('all', array('recursive' => -1)); - $guildsPlayers = $Player->GuildsPlayer->find('all', array('recursive' => -1)); - $armorsPlayers = $Player->ArmorsPlayer->find('all', array('recursive' => -1)); + $players = $Player->find('all', ['recursive' => -1]); + $guilds = $Player->Guild->find('all', ['recursive' => -1]); + $guildsPlayers = $Player->GuildsPlayer->find('all', ['recursive' => -1]); + $armorsPlayers = $Player->ArmorsPlayer->find('all', ['recursive' => -1]); $this->assertEquals(true, count($players) > 1); $this->assertEquals(true, count($guilds) > 1); @@ -2495,7 +2495,7 @@ public function testMultischemaFixtureWithThreeDatabases() { * @return void */ public function testSchemaNoDB() { - $model = $this->getMock('Article', array('getDataSource')); + $model = $this->getMock('Article', ['getDataSource']); $model->useTable = false; $model->expects($this->never())->method('getDataSource'); $this->assertEmpty($model->schema()); @@ -2508,7 +2508,7 @@ public function testSchemaNoDB() { * @return void */ public function testGetColumnTypeNoDB() { - $model = $this->getMock('Example', array('getDataSource')); + $model = $this->getMock('Example', ['getDataSource']); $model->expects($this->never())->method('getDataSource'); $result = $model->getColumnType('filefield'); $this->assertEquals('string', $result); diff --git a/lib/Cake/Test/Case/Model/ModelReadTest.php b/lib/Cake/Test/Case/Model/ModelReadTest.php index d2c707977d..8a31fd3091 100644 --- a/lib/Cake/Test/Case/Model/ModelReadTest.php +++ b/lib/Cake/Test/Case/Model/ModelReadTest.php @@ -16,7 +16,7 @@ * @license https://opensource.org/licenses/mit-license.php MIT License */ -require_once dirname(__FILE__) . DS . 'ModelTestBase.php'; +require_once __DIR__ . DS . 'ModelTestBase.php'; /** * ModelReadTest @@ -59,20 +59,20 @@ public function testFetchingNonUniqueFKJoinTableRecords() { $this->loadFixtures('Something', 'SomethingElse', 'JoinThing'); $Something = new Something(); - $joinThingData = array( - 'JoinThing' => array( + $joinThingData = [ + 'JoinThing' => [ 'something_id' => 1, 'something_else_id' => 2, 'doomed' => '0', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ); + ] + ]; $Something->JoinThing->create($joinThingData); $Something->JoinThing->save(); - $result = $Something->JoinThing->find('all', array('conditions' => array('something_else_id' => 2))); + $result = $Something->JoinThing->find('all', ['conditions' => ['something_else_id' => 2]]); $this->assertEquals(true, $result[0]['JoinThing']['doomed']); $this->assertEquals(false, $result[1]['JoinThing']['doomed']); @@ -94,101 +94,101 @@ public function testFetchingNonUniqueFKJoinTableRecords() { public function testInOperator() { $this->loadFixtures('Product'); $Product = new Product(); - $expected = array( - array( - 'Product' => array( + $expected = [ + [ + 'Product' => [ 'id' => 1, 'name' => "Park's Great Hits", 'type' => 'Music', 'price' => 19 - ) - ) - ); + ] + ] + ]; - $result = $Product->find('all', array('conditions' => array('Product.id IN' => array(1)))); + $result = $Product->find('all', ['conditions' => ['Product.id IN' => [1]]]); $this->assertEquals($expected, $result); - $expected = array( - array( - 'Product' => array( + $expected = [ + [ + 'Product' => [ 'id' => 2, 'name' => "Silly Puddy", 'type' => 'Toy', 'price' => 3 - ) - ), - array( - 'Product' => array( + ] + ], + [ + 'Product' => [ 'id' => 3, 'name' => "Playstation", 'type' => 'Toy', 'price' => 89 - ) - ), - array( - 'Product' => array( + ] + ], + [ + 'Product' => [ 'id' => 4, 'name' => "Men's T-Shirt", 'type' => 'Clothing', 'price' => 32 - ) - ), - array( - 'Product' => array( + ] + ], + [ + 'Product' => [ 'id' => 5, 'name' => "Blouse", 'type' => 'Clothing', 'price' => 34 - ) - ), - array( - 'Product' => array( + ] + ], + [ + 'Product' => [ 'id' => 6, 'name' => "Electronica 2002", 'type' => 'Music', 'price' => 4 - ) - ), - array( - 'Product' => array( + ] + ], + [ + 'Product' => [ 'id' => 7, 'name' => "Country Tunes", 'type' => 'Music', 'price' => 21 - ) - ), - array( - 'Product' => array( + ] + ], + [ + 'Product' => [ 'id' => 8, 'name' => "Watermelon", 'type' => 'Food', 'price' => 9 - ) - ) - ); - $result = $Product->find('all', array('conditions' => array('Product.id NOT IN' => array(1)))); + ] + ] + ]; + $result = $Product->find('all', ['conditions' => ['Product.id NOT IN' => [1]]]); $this->assertEquals($expected, $result); - $expected = array( - array( - 'Product' => array( + $expected = [ + [ + 'Product' => [ 'id' => 1, 'name' => "Park's Great Hits", 'type' => 'Music', 'price' => 19 - ) - ), - array( - 'Product' => array( + ] + ], + [ + 'Product' => [ 'id' => 2, 'name' => "Silly Puddy", 'type' => 'Toy', 'price' => 3 - ) - ), - ); + ] + ], + ]; - $result = $Product->find('all', array('conditions' => array('Product.id IN' => array(1, 2)))); + $result = $Product->find('all', ['conditions' => ['Product.id IN' => [1, 2]]]); $this->assertEquals($expected, $result); } @@ -222,48 +222,48 @@ public function testGroupByAndOrder() { $this->skipIfIsStrictGroupBy(); $this->loadFixtures('Project', 'Thread', 'Message'); $Thread = new Thread(); - $result = $Thread->find('all', array( + $result = $Thread->find('all', [ 'group' => 'Thread.project_id', 'order' => 'Thread.id ASC', - )); - $expected = array( - array( - 'Thread' => array( + ]); + $expected = [ + [ + 'Thread' => [ 'id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1', - ), - 'Project' => array( + ], + 'Project' => [ 'id' => 1, 'name' => 'Project 1', - ), - 'Message' => array( - array( + ], + 'Message' => [ + [ 'id' => 1, 'thread_id' => 1, 'name' => 'Thread 1, Message 1', - ), - ), - ), - array ( - 'Thread' => array( + ], + ], + ], + [ + 'Thread' => [ 'id' => 3, 'project_id' => 2, 'name' => 'Project 2, Thread 1', - ), - 'Project' => array( + ], + 'Project' => [ 'id' => 2, 'name' => 'Project 2', - ), - 'Message' => array( - array( + ], + 'Message' => [ + [ 'id' => 3, 'thread_id' => 3, 'name' => 'Thread 3, Message 1', - ), - ), - ), - ); + ], + ], + ], + ]; $this->assertEquals($expected, $result); } @@ -282,105 +282,105 @@ public function testGroupBy() { $Thread = new Thread(); $Product = new Product(); - $rows = $Thread->find('all', array( + $rows = $Thread->find('all', [ 'group' => 'Thread.project_id', - 'fields' => array('Thread.project_id', 'COUNT(*) AS total') - )); - $result = array(); + 'fields' => ['Thread.project_id', 'COUNT(*) AS total'] + ]); + $result = []; foreach ($rows as $row) { $result[$row['Thread']['project_id']] = $row[0]['total']; } - $expected = array( + $expected = [ 1 => 2, 2 => 1 - ); + ]; $this->assertEquals($expected, $result); - $rows = $Thread->find('all', array( + $rows = $Thread->find('all', [ 'group' => 'Thread.project_id', - 'fields' => array('Thread.project_id', 'COUNT(*) AS total'), + 'fields' => ['Thread.project_id', 'COUNT(*) AS total'], 'order' => 'Thread.project_id' - )); - $result = array(); + ]); + $result = []; foreach ($rows as $row) { $result[$row['Thread']['project_id']] = $row[0]['total']; } - $expected = array( + $expected = [ 1 => 2, 2 => 1 - ); + ]; $this->assertEquals($expected, $result); - $result = $Thread->find('all', array( - 'conditions' => array('Thread.project_id' => 1), + $result = $Thread->find('all', [ + 'conditions' => ['Thread.project_id' => 1], 'group' => 'Thread.project_id' - )); - $expected = array( - array( - 'Thread' => array( + ]); + $expected = [ + [ + 'Thread' => [ 'id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1' - ), - 'Project' => array( + ], + 'Project' => [ 'id' => 1, 'name' => 'Project 1' - ), - 'Message' => array( - array( + ], + 'Message' => [ + [ 'id' => 1, 'thread_id' => 1, 'name' => 'Thread 1, Message 1' - )))); + ]]]]; $this->assertEquals($expected, $result); - $result = $Thread->find('all', array( - 'conditions' => array('Thread.project_id' => 1), + $result = $Thread->find('all', [ + 'conditions' => ['Thread.project_id' => 1], 'group' => 'Thread.project_id, Project.id' - )); + ]); $this->assertEquals($expected, $result); - $result = $Thread->find('all', array( - 'conditions' => array('Thread.project_id' => 1), + $result = $Thread->find('all', [ + 'conditions' => ['Thread.project_id' => 1], 'group' => 'project_id' - )); + ]); $this->assertEquals($expected, $result); - $result = $Thread->find('all', array( - 'conditions' => array('Thread.project_id' => 1), - 'group' => array('project_id') - )); + $result = $Thread->find('all', [ + 'conditions' => ['Thread.project_id' => 1], + 'group' => ['project_id'] + ]); $this->assertEquals($expected, $result); - $result = $Thread->find('all', array( - 'conditions' => array('Thread.project_id' => 1), - 'group' => array('project_id', 'Project.id') - )); + $result = $Thread->find('all', [ + 'conditions' => ['Thread.project_id' => 1], + 'group' => ['project_id', 'Project.id'] + ]); $this->assertEquals($expected, $result); - $result = $Thread->find('all', array( - 'conditions' => array('Thread.project_id' => 1), - 'group' => array('Thread.project_id', 'Project.id') - )); + $result = $Thread->find('all', [ + 'conditions' => ['Thread.project_id' => 1], + 'group' => ['Thread.project_id', 'Project.id'] + ]); $this->assertEquals($expected, $result); - $expected = array( - array('Product' => array('type' => 'Clothing'), array('price' => 32)), - array('Product' => array('type' => 'Food'), array('price' => 9)), - array('Product' => array('type' => 'Music'), array('price' => 4)), - array('Product' => array('type' => 'Toy'), array('price' => 3)) - ); - $result = $Product->find('all', array( - 'fields' => array('Product.type', 'MIN(Product.price) as price'), + $expected = [ + ['Product' => ['type' => 'Clothing'], ['price' => 32]], + ['Product' => ['type' => 'Food'], ['price' => 9]], + ['Product' => ['type' => 'Music'], ['price' => 4]], + ['Product' => ['type' => 'Toy'], ['price' => 3]] + ]; + $result = $Product->find('all', [ + 'fields' => ['Product.type', 'MIN(Product.price) as price'], 'group' => 'Product.type', 'order' => 'Product.type ASC' - )); + ]); $this->assertEquals($expected, $result); - $result = $Product->find('all', array( - 'fields' => array('Product.type', 'MIN(Product.price) as price'), - 'group' => array('Product.type'), - 'order' => 'Product.type ASC')); + $result = $Product->find('all', [ + 'fields' => ['Product.type', 'MIN(Product.price) as price'], + 'group' => ['Product.type'], + 'order' => 'Product.type ASC']); $this->assertEquals($expected, $result); } @@ -393,20 +393,20 @@ public function testHaving() { $this->loadFixtures('Comment'); $Comment = ClassRegistry::init('Comment'); - $comments = $Comment->find('all', array( - 'fields' => array('user_id', 'COUNT(*) AS count'), - 'group' => array('user_id'), - 'having' => array('COUNT(*) >' => 1), - 'order' => array('COUNT(*)' => 'DESC'), + $comments = $Comment->find('all', [ + 'fields' => ['user_id', 'COUNT(*) AS count'], + 'group' => ['user_id'], + 'having' => ['COUNT(*) >' => 1], + 'order' => ['COUNT(*)' => 'DESC'], 'recursive' => -1, - )); + ]); $results = Hash::combine($comments, '{n}.Comment.user_id', '{n}.0.count'); - $expected = array( + $expected = [ 1 => 3, 2 => 2, - ); + ]; $this->assertEquals($expected, $results); } @@ -461,13 +461,13 @@ public function testPreparedQuery() { $query .= ' WHERE ' . $this->db->fullTableName('articles'); $query .= '.id = ? AND ' . $this->db->fullTableName('articles') . '.published = ?'; - $params = array(1, 'Y'); + $params = [1, 'Y']; $result = $Article->query($query, $params, true); - $expected = array( - '0' => array( - $this->db->fullTableName('articles', false, false) => array( - 'title' => 'First Article', 'published' => 'Y') - )); + $expected = [ + '0' => [ + $this->db->fullTableName('articles', false, false) => [ + 'title' => 'First Article', 'published' => 'Y'] + ]]; if (isset($result[0][0])) { $expected[0][0] = $expected[0][$this->db->fullTableName('articles', false, false)]; @@ -482,7 +482,7 @@ public function testPreparedQuery() { $query .= $this->db->fullTableName('articles'); $query .= ' WHERE ' . $this->db->fullTableName('articles') . '.title = ?'; - $params = array('First Article'); + $params = ['First Article']; $result = $Article->query($query, $params, false); $this->assertTrue(is_array($result)); $this->assertTrue( @@ -496,7 +496,7 @@ public function testPreparedQuery() { $query .= $this->db->fullTableName('articles'); $query .= ' WHERE ' . $this->db->fullTableName('articles') . '.title LIKE ?'; - $params = array('%First%'); + $params = ['%First%']; $result = $Article->query($query, $params, true); $this->assertTrue(is_array($result)); $this->assertTrue( @@ -507,7 +507,7 @@ public function testPreparedQuery() { //related to ticket #5035 $query = 'SELECT title FROM '; $query .= $this->db->fullTableName('articles') . ' WHERE title = ? AND published = ?'; - $params = array('First? Article', 'Y'); + $params = ['First? Article', 'Y']; $Article->query($query, $params, true); $result = $this->db->getQueryCache($query, $params); @@ -528,7 +528,7 @@ public function testParameterMismatch() { $query = 'SELECT * FROM ' . $this->db->fullTableName('articles'); $query .= ' WHERE ' . $this->db->fullTableName('articles'); $query .= '.published = ? AND ' . $this->db->fullTableName('articles') . '.user_id = ?'; - $params = array('Y'); + $params = ['Y']; $Article->query($query, $params); } @@ -544,11 +544,11 @@ public function testVeryStrangeUseCase() { $Article = new Article(); $query = 'SELECT * FROM ? WHERE ? = ? AND ? = ?'; - $param = array( + $param = [ $this->db->fullTableName('articles'), $this->db->fullTableName('articles') . '.user_id', '3', $this->db->fullTableName('articles') . '.published', 'Y' - ); + ]; $Article->query($query, $param); } @@ -566,9 +566,9 @@ public function testRecursiveUnbind() { $TestModel->recursive = 2; $result = $TestModel->find('all'); - $expected = array( - array( - 'Apple' => array( + $expected = [ + [ + 'Apple' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -577,8 +577,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -587,7 +587,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -596,14 +596,14 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -612,8 +612,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -622,8 +622,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -632,14 +632,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -648,7 +648,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -657,14 +657,14 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -673,8 +673,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -683,8 +683,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -693,9 +693,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))))), - array( - 'Apple' => array( + ]]]]], + [ + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -704,8 +704,8 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -714,7 +714,7 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -723,10 +723,10 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array(), - 'Child' => array( - array( + ], + 'Sample' => [], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -735,12 +735,12 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2', - 'Apple' => array( + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -749,9 +749,9 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - )), - 'Child' => array( - array( + ]], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -760,7 +760,7 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -769,10 +769,10 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array(), - 'Child' => array( - array( + ], + 'Sample' => [], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -781,8 +781,8 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - array( + ]]], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -791,7 +791,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -800,13 +800,13 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 1, 'apple_id' => 3, 'name' => 'sample1' - )), - array( + ]], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -815,7 +815,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -824,14 +824,14 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -840,9 +840,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ))))), - array( - 'Apple' => array( + ]]]]], + [ + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -851,8 +851,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -861,7 +861,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -870,14 +870,14 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -886,8 +886,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -896,8 +896,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -906,12 +906,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 1, 'apple_id' => 3, 'name' => 'sample1', - 'Apple' => array( + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -920,11 +920,11 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - )), - 'Child' => array() - ), - array( - 'Apple' => array( + ]], + 'Child' => [] + ], + [ + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -933,8 +933,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -943,17 +943,17 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', 'name' => 'Red Apple 1', 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', - 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'), - 'Sample' => array('id' => 2, 'apple_id' => 2, 'name' => 'sample2'), - 'Child' => array( - array( + 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17'], + 'Sample' => ['id' => 2, 'apple_id' => 2, 'name' => 'sample2'], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -962,8 +962,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -972,8 +972,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -982,12 +982,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3', - 'Apple' => array( + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -996,9 +996,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - )), - 'Child' => array( - array( + ]], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1007,7 +1007,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1016,10 +1016,10 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Sample' => array(), - 'Child' => array( - array( + ], + 'Sample' => [], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -1028,9 +1028,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ))))), - array( - 'Apple' => array( + ]]]]], + [ + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1039,8 +1039,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1049,7 +1049,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1058,14 +1058,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1074,12 +1074,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4', - 'Apple' => array( + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1088,9 +1088,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - )), - 'Child' => array( - array( + ]], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1099,7 +1099,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1108,14 +1108,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1124,9 +1124,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))))), - array( - 'Apple' => array( + ]]]]], + [ + 'Apple' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1135,8 +1135,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1145,7 +1145,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1154,14 +1154,14 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1170,14 +1170,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -1186,7 +1186,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1195,11 +1195,11 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ), - 'Sample' => array() - ))), - array( - 'Apple' => array( + ], + 'Sample' => [] + ]]], + [ + 'Apple' => [ 'id' => 7, 'apple_id' => 6, 'color' => @@ -1209,8 +1209,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1219,7 +1219,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1228,10 +1228,10 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Sample' => array(), - 'Child' => array( - array( + ], + 'Sample' => [], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -1240,22 +1240,22 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ), - 'Child' => array())); + ], + 'Child' => []]]; $this->assertEquals($expected, $result); - $result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample'))); + $result = $TestModel->Parent->unbindModel(['hasOne' => ['Sample']]); $this->assertTrue($result); $result = $TestModel->find('all'); - $expected = array( - array( - 'Apple' => array( + $expected = [ + [ + 'Apple' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1263,8 +1263,8 @@ public function testRecursiveUnbind() { 'created' => '2006-11-22 10:38:58', 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', - 'mytime' => '22:57:17'), - 'Parent' => array( + 'mytime' => '22:57:17'], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1273,7 +1273,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1282,9 +1282,9 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1293,8 +1293,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -1303,8 +1303,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1313,14 +1313,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1329,7 +1329,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1338,14 +1338,14 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1354,8 +1354,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -1364,8 +1364,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1374,9 +1374,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))))), - array( - 'Apple' => array( + ]]]]], + [ + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1385,8 +1385,8 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1395,7 +1395,7 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1404,9 +1404,9 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1415,12 +1415,12 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2', - 'Apple' => array( + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1429,9 +1429,9 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - )), - 'Child' => array( - array( + ]], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1440,7 +1440,7 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1449,10 +1449,10 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array(), - 'Child' => array( - array( + ], + 'Sample' => [], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1461,8 +1461,8 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - array( + ]]], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -1471,7 +1471,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1480,13 +1480,13 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 1, 'apple_id' => 3, 'name' => 'sample1' - )), - array( + ]], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1495,7 +1495,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1504,14 +1504,14 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1520,9 +1520,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ))))), - array( - 'Apple' => array( + ]]]]], + [ + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -1531,8 +1531,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1541,7 +1541,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1550,9 +1550,9 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1561,8 +1561,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -1571,8 +1571,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1581,12 +1581,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 1, 'apple_id' => 3, 'name' => 'sample1', - 'Apple' => array( + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -1595,11 +1595,11 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - )), - 'Child' => array() - ), - array( - 'Apple' => array( + ]], + 'Child' => [] + ], + [ + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1608,8 +1608,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1618,7 +1618,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1627,9 +1627,9 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1638,8 +1638,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -1648,8 +1648,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1658,12 +1658,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3', - 'Apple' => array( + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1672,9 +1672,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - )), - 'Child' => array( - array( + ]], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1683,7 +1683,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1692,10 +1692,10 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Sample' => array(), - 'Child' => array( - array( + ], + 'Sample' => [], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -1704,9 +1704,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ))))), - array( - 'Apple' => array( + ]]]]], + [ + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1715,8 +1715,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1725,7 +1725,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1734,9 +1734,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1745,12 +1745,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4', - 'Apple' => array( + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1759,9 +1759,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - )), - 'Child' => array( - array( + ]], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1770,7 +1770,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1779,14 +1779,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -1795,9 +1795,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))))), - array( - 'Apple' => array( + ]]]]], + [ + 'Apple' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1806,8 +1806,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1816,7 +1816,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1825,9 +1825,9 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1836,14 +1836,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -1852,7 +1852,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1861,11 +1861,11 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ), - 'Sample' => array() - ))), - array( - 'Apple' => array( + ], + 'Sample' => [] + ]]], + [ + 'Apple' => [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -1874,8 +1874,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -1884,7 +1884,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1893,9 +1893,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -1904,27 +1904,27 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ), - 'Child' => array() - )); + ], + 'Child' => [] + ]]; $this->assertEquals($expected, $result); - $result = $TestModel->Parent->unbindModel(array('hasOne' => array('Sample'))); + $result = $TestModel->Parent->unbindModel(['hasOne' => ['Sample']]); $this->assertTrue($result); - $result = $TestModel->unbindModel(array('hasMany' => array('Child'))); + $result = $TestModel->unbindModel(['hasMany' => ['Child']]); $this->assertTrue($result); $result = $TestModel->find('all'); - $expected = array( - array( - 'Apple' => array( + $expected = [ + [ + 'Apple' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1933,8 +1933,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1943,7 +1943,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1952,9 +1952,9 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -1963,8 +1963,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -1973,8 +1973,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -1983,14 +1983,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -1999,8 +1999,8 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2009,7 +2009,7 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2018,9 +2018,9 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2029,12 +2029,12 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2', - 'Apple' => array( + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2043,9 +2043,9 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2054,8 +2054,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2064,7 +2064,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2073,9 +2073,9 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2084,8 +2084,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2094,8 +2094,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2104,12 +2104,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 1, 'apple_id' => 3, 'name' => 'sample1', - 'Apple' => array( + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2118,9 +2118,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2129,8 +2129,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2139,7 +2139,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2148,9 +2148,9 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2159,8 +2159,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2169,8 +2169,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2179,12 +2179,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3', - 'Apple' => array( + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2193,9 +2193,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2204,8 +2204,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2214,7 +2214,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2223,9 +2223,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2234,12 +2234,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4', - 'Apple' => array( + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2248,9 +2248,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -2259,8 +2259,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2269,7 +2269,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2278,9 +2278,9 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -2289,14 +2289,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -2305,8 +2305,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -2315,7 +2315,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2324,9 +2324,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -2335,25 +2335,25 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->unbindModel(array('hasMany' => 'Child')); + $result = $TestModel->unbindModel(['hasMany' => 'Child']); $this->assertTrue($result); - $result = $TestModel->Sample->unbindModel(array('belongsTo' => 'Apple')); + $result = $TestModel->Sample->unbindModel(['belongsTo' => 'Apple']); $this->assertTrue($result); $result = $TestModel->find('all'); - $expected = array( - array( - 'Apple' => array( + $expected = [ + [ + 'Apple' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2362,8 +2362,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2372,7 +2372,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2381,14 +2381,14 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2397,8 +2397,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2407,8 +2407,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2417,14 +2417,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2433,8 +2433,8 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2443,7 +2443,7 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2452,10 +2452,10 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array(), - 'Child' => array( - array( + ], + 'Sample' => [], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2464,14 +2464,14 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2480,8 +2480,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2490,7 +2490,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2499,14 +2499,14 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2515,8 +2515,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2525,8 +2525,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2535,14 +2535,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 1, 'apple_id' => 3, 'name' => 'sample1' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2551,8 +2551,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2561,7 +2561,7 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2570,14 +2570,14 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2586,8 +2586,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2596,8 +2596,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2606,14 +2606,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2622,8 +2622,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2632,7 +2632,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2641,14 +2641,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -2657,14 +2657,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -2673,8 +2673,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2683,7 +2683,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2692,14 +2692,14 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -2708,14 +2708,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -2724,8 +2724,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -2734,7 +2734,7 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17', - 'Parent' => array( + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2743,10 +2743,10 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Sample' => array(), - 'Child' => array( - array( + ], + 'Sample' => [], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -2755,24 +2755,24 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->Parent->unbindModel(array('belongsTo' => array('Parent'))); + $result = $TestModel->Parent->unbindModel(['belongsTo' => ['Parent']]); $this->assertTrue($result); - $result = $TestModel->unbindModel(array('hasMany' => array('Child'))); + $result = $TestModel->unbindModel(['hasMany' => ['Child']]); $this->assertTrue($result); $result = $TestModel->find('all'); - $expected = array( - array( - 'Apple' => array( + $expected = [ + [ + 'Apple' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2781,8 +2781,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2791,13 +2791,13 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Sample' => array( + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2806,8 +2806,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2816,8 +2816,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2826,14 +2826,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2842,8 +2842,8 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2852,9 +2852,9 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17', - 'Sample' => array(), - 'Child' => array( - array( + 'Sample' => [], + 'Child' => [ + [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2863,12 +2863,12 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2', - 'Apple' => array( + 'Apple' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2877,9 +2877,9 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2888,8 +2888,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2898,13 +2898,13 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Sample' => array( + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2913,8 +2913,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2923,8 +2923,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2933,12 +2933,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 1, 'apple_id' => 3, 'name' => 'sample1', - 'Apple' => array( + 'Apple' => [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2947,9 +2947,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -2958,8 +2958,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 2, 'apple_id' => 1, 'color' => 'Bright Red 1', @@ -2968,13 +2968,13 @@ public function testRecursiveUnbind() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17', - 'Sample' => array( + 'Sample' => [ 'id' => 2, 'apple_id' => 2, 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 1, 'apple_id' => 2, 'color' => 'Red 1', @@ -2983,8 +2983,8 @@ public function testRecursiveUnbind() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 3, 'apple_id' => 2, 'color' => 'blue green', @@ -2993,8 +2993,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -3003,12 +3003,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3', - 'Apple' => array( + 'Apple' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -3017,9 +3017,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -3029,8 +3029,8 @@ public function testRecursiveUnbind() { 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -3039,13 +3039,13 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17', - 'Sample' => array( + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -3054,12 +3054,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => 4, 'apple_id' => 5, 'name' => 'sample4', - 'Apple' => array( + 'Apple' => [ 'id' => 5, 'apple_id' => 5, 'color' => 'Green', @@ -3068,9 +3068,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -3078,8 +3078,8 @@ public function testRecursiveUnbind() { 'created' => '2006-12-25 05:29:39', 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', - 'mytime' => '22:57:17'), - 'Parent' => array( + 'mytime' => '22:57:17'], + 'Parent' => [ 'id' => 4, 'apple_id' => 2, 'color' => 'Blue Green', @@ -3088,13 +3088,13 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17', - 'Sample' => array( + 'Sample' => [ 'id' => 3, 'apple_id' => 4, 'name' => 'sample3' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -3103,14 +3103,14 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - )), - array( - 'Apple' => array( + ]], + [ + 'Apple' => [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -3119,8 +3119,8 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => 6, 'apple_id' => 4, 'color' => 'My new appleOrange', @@ -3129,9 +3129,9 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17', - 'Sample' => array(), - 'Child' => array( - array( + 'Sample' => [], + 'Child' => [ + [ 'id' => 7, 'apple_id' => 6, 'color' => 'Some wierd color', @@ -3140,12 +3140,12 @@ public function testRecursiveUnbind() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ))), - 'Sample' => array( + ]]], + 'Sample' => [ 'id' => '', 'apple_id' => '', 'name' => '' - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -3179,14 +3179,14 @@ public function testSelfAssociationAfterFind() { public function testAfterFindUnset() { $this->loadFixtures('Article', 'Comment', 'User'); $model = new CustomArticle(); - $model->bindModel(array( - 'hasMany' => array( - 'ModifiedComment' => array( + $model->bindModel([ + 'hasMany' => [ + 'ModifiedComment' => [ 'className' => 'ModifiedComment', 'foreignKey' => 'article_id', - ) - ) - )); + ] + ] + ]); $model->ModifiedComment->remove = true; $result = $model->find('all'); $this->assertTrue( @@ -3205,7 +3205,7 @@ public function testFindThreadedNoParent() { $Apple = new Apple(); $result = $Apple->find('threaded'); $result = Hash::extract($result, '{n}.children'); - $expected = array(array(), array(), array(), array(), array(), array(), array()); + $expected = [[], [], [], [], [], [], []]; $this->assertEquals($expected, $result); } @@ -3220,78 +3220,78 @@ public function testFindThreaded() { $Model->recursive = -1; $result = $Model->find('threaded'); $result = Hash::extract($result, '{n}.children'); - $expected = array(array(), array(), array(), array(), array(), array(), array()); + $expected = [[], [], [], [], [], [], []]; $this->assertEquals($expected, $result); - $result = $Model->find('threaded', array('parent' => 'mother_id')); - $expected = array( - array( - 'Person' => array( + $result = $Model->find('threaded', ['parent' => 'mother_id']); + $expected = [ + [ + 'Person' => [ 'id' => '4', 'name' => 'mother - grand mother', 'mother_id' => '0', 'father_id' => '0' - ), - 'children' => array( - array( - 'Person' => array( + ], + 'children' => [ + [ + 'Person' => [ 'id' => '2', 'name' => 'mother', 'mother_id' => '4', 'father_id' => '5' - ), - 'children' => array( - array( - 'Person' => array( + ], + 'children' => [ + [ + 'Person' => [ 'id' => '1', 'name' => 'person', 'mother_id' => '2', 'father_id' => '3' - ), - 'children' => array() - ) - ) - ) - ) - ), - array( - 'Person' => array( + ], + 'children' => [] + ] + ] + ] + ] + ], + [ + 'Person' => [ 'id' => '5', 'name' => 'mother - grand father', 'mother_id' => '0', 'father_id' => '0' - ), - 'children' => array() - ), - array( - 'Person' => array( + ], + 'children' => [] + ], + [ + 'Person' => [ 'id' => '6', 'name' => 'father - grand mother', 'mother_id' => '0', 'father_id' => '0' - ), - 'children' => array( - array( - 'Person' => array( + ], + 'children' => [ + [ + 'Person' => [ 'id' => '3', 'name' => 'father', 'mother_id' => '6', 'father_id' => '7' - ), - 'children' => array() - ) - ) - ), - array( - 'Person' => array( + ], + 'children' => [] + ] + ] + ], + [ + 'Person' => [ 'id' => '7', 'name' => 'father - grand father', 'mother_id' => '0', 'father_id' => '0' - ), - 'children' => array() - ) - ); + ], + 'children' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -3305,469 +3305,469 @@ public function testFindAllThreaded() { $TestModel = new Category(); $result = $TestModel->find('threaded'); - $expected = array( - array( - 'Category' => array( + $expected = [ + [ + 'Category' => [ 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array('Category' => array( + ], + 'children' => [ + ['Category' => [ 'id' => '7', 'parent_id' => '2', 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array()), - array('Category' => array( + 'updated' => '2007-03-18 15:32:31'], + 'children' => []], + ['Category' => [ 'id' => '8', 'parent_id' => '2', 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array())) - ), - array( - 'Category' => array( + 'updated' => '2007-03-18 15:32:31'], + 'children' => []]] + ], + [ + 'Category' => [ 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array() - ) - ) - ), - array( - 'Category' => array( + ], + 'children' => [] + ] + ] + ], + [ + 'Category' => [ 'id' => '4', 'parent_id' => '0', 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array() - ), - array( - 'Category' => array( + ], + 'children' => [] + ], + [ + 'Category' => [ 'id' => '5', 'parent_id' => '0', 'name' => 'Category 3', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => '6', 'parent_id' => '5', 'name' => 'Category 3.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array() - ) - ) - ) - ); + ], + 'children' => [] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('threaded', array( - 'conditions' => array('Category.name LIKE' => 'Category 1%') - )); + $result = $TestModel->find('threaded', [ + 'conditions' => ['Category.name LIKE' => 'Category 1%'] + ]); - $expected = array( - array( - 'Category' => array( + $expected = [ + [ + 'Category' => [ 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array('Category' => array( + ], + 'children' => [ + ['Category' => [ 'id' => '7', 'parent_id' => '2', 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array()), - array('Category' => array( + 'updated' => '2007-03-18 15:32:31'], + 'children' => []], + ['Category' => [ 'id' => '8', 'parent_id' => '2', 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array())) - ), - array( - 'Category' => array( + 'updated' => '2007-03-18 15:32:31'], + 'children' => []]] + ], + [ + 'Category' => [ 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array() - ) - ) - ) - ); + ], + 'children' => [] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('threaded', array( + $result = $TestModel->find('threaded', [ 'fields' => 'id, parent_id, name' - )); + ]); - $expected = array( - array( - 'Category' => array( + $expected = [ + [ + 'Category' => [ 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1' - ), - 'children' => array( - array('Category' => array( + ], + 'children' => [ + ['Category' => [ 'id' => '7', 'parent_id' => '2', - 'name' => 'Category 1.1.1'), - 'children' => array()), - array('Category' => array( + 'name' => 'Category 1.1.1'], + 'children' => []], + ['Category' => [ 'id' => '8', 'parent_id' => '2', - 'name' => 'Category 1.1.2'), - 'children' => array())) - ), - array( - 'Category' => array( + 'name' => 'Category 1.1.2'], + 'children' => []]] + ], + [ + 'Category' => [ 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2' - ), - 'children' => array() - ) - ) - ), - array( - 'Category' => array( + ], + 'children' => [] + ] + ] + ], + [ + 'Category' => [ 'id' => '4', 'parent_id' => '0', 'name' => 'Category 2' - ), - 'children' => array() - ), - array( - 'Category' => array( + ], + 'children' => [] + ], + [ + 'Category' => [ 'id' => '5', 'parent_id' => '0', 'name' => 'Category 3' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => '6', 'parent_id' => '5', 'name' => 'Category 3.1' - ), - 'children' => array() - ) - ) - ) - ); + ], + 'children' => [] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('threaded', array('order' => 'id DESC')); + $result = $TestModel->find('threaded', ['order' => 'id DESC']); - $expected = array( - array( - 'Category' => array( + $expected = [ + [ + 'Category' => [ 'id' => 5, 'parent_id' => 0, 'name' => 'Category 3', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => 6, 'parent_id' => 5, 'name' => 'Category 3.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array() - ) - ) - ), - array( - 'Category' => array( + ], + 'children' => [] + ] + ] + ], + [ + 'Category' => [ 'id' => 4, 'parent_id' => 0, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array() - ), - array( - 'Category' => array( + ], + 'children' => [] + ], + [ + 'Category' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => 3, 'parent_id' => 1, 'name' => 'Category 1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array() - ), - array( - 'Category' => array( + ], + 'children' => [] + ], + [ + 'Category' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array('Category' => array( + ], + 'children' => [ + ['Category' => [ 'id' => '8', 'parent_id' => '2', 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array()), - array('Category' => array( + 'updated' => '2007-03-18 15:32:31'], + 'children' => []], + ['Category' => [ 'id' => '7', 'parent_id' => '2', 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array())) - ) - ) - ) - ); - $this->assertEquals($expected, $result); - - $result = $TestModel->find('threaded', array( - 'conditions' => array('Category.name LIKE' => 'Category 3%') - )); - $expected = array( - array( - 'Category' => array( + 'updated' => '2007-03-18 15:32:31'], + 'children' => []]] + ] + ] + ] + ]; + $this->assertEquals($expected, $result); + + $result = $TestModel->find('threaded', [ + 'conditions' => ['Category.name LIKE' => 'Category 3%'] + ]); + $expected = [ + [ + 'Category' => [ 'id' => '5', 'parent_id' => '0', 'name' => 'Category 3', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => '6', 'parent_id' => '5', 'name' => 'Category 3.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'children' => array() - ) - ) - ) - ); - $this->assertEquals($expected, $result); - - $result = $TestModel->find('threaded', array( - 'conditions' => array('Category.name LIKE' => 'Category 1.1%') - )); - $expected = array( - array('Category' => - array( + ], + 'children' => [] + ] + ] + ] + ]; + $this->assertEquals($expected, $result); + + $result = $TestModel->find('threaded', [ + 'conditions' => ['Category.name LIKE' => 'Category 1.1%'] + ]); + $expected = [ + ['Category' => + [ 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array( - array('Category' => array( + 'updated' => '2007-03-18 15:32:31'], + 'children' => [ + ['Category' => [ 'id' => '7', 'parent_id' => '2', 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array()), - array('Category' => array( + 'updated' => '2007-03-18 15:32:31'], + 'children' => []], + ['Category' => [ 'id' => '8', 'parent_id' => '2', 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', - 'updated' => '2007-03-18 15:32:31'), - 'children' => array())))); + 'updated' => '2007-03-18 15:32:31'], + 'children' => []]]]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('threaded', array( + $result = $TestModel->find('threaded', [ 'fields' => 'id, parent_id, name', - 'conditions' => array('Category.id !=' => 2) - )); - $expected = array( - array( - 'Category' => array( + 'conditions' => ['Category.id !=' => 2] + ]); + $expected = [ + [ + 'Category' => [ 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2' - ), - 'children' => array() - ) - ) - ), - array( - 'Category' => array( + ], + 'children' => [] + ] + ] + ], + [ + 'Category' => [ 'id' => '4', 'parent_id' => '0', 'name' => 'Category 2' - ), - 'children' => array() - ), - array( - 'Category' => array( + ], + 'children' => [] + ], + [ + 'Category' => [ 'id' => '5', 'parent_id' => '0', 'name' => 'Category 3' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'id' => '6', 'parent_id' => '5', 'name' => 'Category 3.1' - ), - 'children' => array() - ) - ) - ) - ); + ], + 'children' => [] + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'id, name, parent_id', - 'conditions' => array('Category.id !=' => 1) - )); - $expected = array( - array('Category' => array( + 'conditions' => ['Category.id !=' => 1] + ]); + $expected = [ + ['Category' => [ 'id' => '2', 'name' => 'Category 1.1', 'parent_id' => '1' - )), - array('Category' => array( + ]], + ['Category' => [ 'id' => '3', 'name' => 'Category 1.2', 'parent_id' => '1' - )), - array('Category' => array( + ]], + ['Category' => [ 'id' => '4', 'name' => 'Category 2', 'parent_id' => '0' - )), - array('Category' => array( + ]], + ['Category' => [ 'id' => '5', 'name' => 'Category 3', 'parent_id' => '0' - )), - array('Category' => array( + ]], + ['Category' => [ 'id' => '6', 'name' => 'Category 3.1', 'parent_id' => '5' - )), - array('Category' => array( + ]], + ['Category' => [ 'id' => '7', 'name' => 'Category 1.1.1', 'parent_id' => '2' - )), - array('Category' => array( + ]], + ['Category' => [ 'id' => '8', 'name' => 'Category 1.1.2', 'parent_id' => '2' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('threaded', array( + $result = $TestModel->find('threaded', [ 'fields' => 'id, parent_id, name', - 'conditions' => array('Category.id !=' => 1) - )); - $expected = array( - array( - 'Category' => array( + 'conditions' => ['Category.id !=' => 1] + ]); + $expected = [ + [ + 'Category' => [ 'id' => '2', 'parent_id' => '1', 'name' => 'Category 1.1' - ), - 'children' => array( - array('Category' => array( + ], + 'children' => [ + ['Category' => [ 'id' => '7', 'parent_id' => '2', - 'name' => 'Category 1.1.1'), - 'children' => array()), - array('Category' => array( + 'name' => 'Category 1.1.1'], + 'children' => []], + ['Category' => [ 'id' => '8', 'parent_id' => '2', - 'name' => 'Category 1.1.2'), - 'children' => array())) - ), - array( - 'Category' => array( + 'name' => 'Category 1.1.2'], + 'children' => []]] + ], + [ + 'Category' => [ 'id' => '3', 'parent_id' => '1', 'name' => 'Category 1.2' - ), - 'children' => array() - ) - ); + ], + 'children' => [] + ] + ]; $this->assertEquals($expected, $result); } @@ -3781,45 +3781,45 @@ public function testFindNeighbors() { $TestModel = new Article(); $TestModel->id = 1; - $result = $TestModel->find('neighbors', array('fields' => array('id'))); + $result = $TestModel->find('neighbors', ['fields' => ['id']]); $this->assertNull($result['prev']); - $this->assertEquals(array('id' => 2), $result['next']['Article']); + $this->assertEquals(['id' => 2], $result['next']['Article']); $this->assertEquals(2, count($result['next']['Comment'])); $this->assertEquals(2, count($result['next']['Tag'])); $TestModel->id = 2; $TestModel->recursive = 0; - $result = $TestModel->find('neighbors', array( - 'fields' => array('id') - )); + $result = $TestModel->find('neighbors', [ + 'fields' => ['id'] + ]); - $expected = array( - 'prev' => array( - 'Article' => array( + $expected = [ + 'prev' => [ + 'Article' => [ 'id' => 1 - )), - 'next' => array( - 'Article' => array( + ]], + 'next' => [ + 'Article' => [ 'id' => 3 - ))); + ]]]; $this->assertEquals($expected, $result); $TestModel->id = 3; $TestModel->recursive = 1; - $result = $TestModel->find('neighbors', array('fields' => array('id'))); + $result = $TestModel->find('neighbors', ['fields' => ['id']]); $this->assertNull($result['next']); - $this->assertEquals(array('id' => 2), $result['prev']['Article']); + $this->assertEquals(['id' => 2], $result['prev']['Article']); $this->assertEquals(2, count($result['prev']['Comment'])); $this->assertEquals(2, count($result['prev']['Tag'])); $TestModel->id = 1; - $result = $TestModel->find('neighbors', array('recursive' => -1)); - $expected = array( + $result = $TestModel->find('neighbors', ['recursive' => -1]); + $expected = [ 'prev' => null, - 'next' => array( - 'Article' => array( + 'next' => [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', @@ -3827,16 +3827,16 @@ public function testFindNeighbors() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $TestModel->id = 2; - $result = $TestModel->find('neighbors', array('recursive' => -1)); - $expected = array( - 'prev' => array( - 'Article' => array( + $result = $TestModel->find('neighbors', ['recursive' => -1]); + $expected = [ + 'prev' => [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', @@ -3844,10 +3844,10 @@ public function testFindNeighbors() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ), - 'next' => array( - 'Article' => array( + ] + ], + 'next' => [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', @@ -3855,16 +3855,16 @@ public function testFindNeighbors() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $TestModel->id = 3; - $result = $TestModel->find('neighbors', array('recursive' => -1)); - $expected = array( - 'prev' => array( - 'Article' => array( + $result = $TestModel->find('neighbors', ['recursive' => -1]); + $expected = [ + 'prev' => [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', @@ -3872,10 +3872,10 @@ public function testFindNeighbors() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), + ] + ], 'next' => null - ); + ]; $this->assertEquals($expected, $result); $TestModel->recursive = 0; @@ -3888,17 +3888,17 @@ public function testFindNeighbors() { $TestModel->id = 1; $result = $TestModel->find('neighbors'); - $expected = array('prev' => null, 'next' => $two); + $expected = ['prev' => null, 'next' => $two]; $this->assertEquals($expected, $result); $TestModel->id = 2; $result = $TestModel->find('neighbors'); - $expected = array('prev' => $one, 'next' => $three); + $expected = ['prev' => $one, 'next' => $three]; $this->assertEquals($expected, $result); $TestModel->id = 3; $result = $TestModel->find('neighbors'); - $expected = array('prev' => $two, 'next' => null); + $expected = ['prev' => $two, 'next' => null]; $this->assertEquals($expected, $result); $TestModel->recursive = 2; @@ -3910,18 +3910,18 @@ public function testFindNeighbors() { $three = $TestModel->read(); $TestModel->id = 1; - $result = $TestModel->find('neighbors', array('recursive' => 2)); - $expected = array('prev' => null, 'next' => $two); + $result = $TestModel->find('neighbors', ['recursive' => 2]); + $expected = ['prev' => null, 'next' => $two]; $this->assertEquals($expected, $result); $TestModel->id = 2; - $result = $TestModel->find('neighbors', array('recursive' => 2)); - $expected = array('prev' => $one, 'next' => $three); + $result = $TestModel->find('neighbors', ['recursive' => 2]); + $expected = ['prev' => $one, 'next' => $three]; $this->assertEquals($expected, $result); $TestModel->id = 3; - $result = $TestModel->find('neighbors', array('recursive' => 2)); - $expected = array('prev' => $two, 'next' => null); + $result = $TestModel->find('neighbors', ['recursive' => 2]); + $expected = ['prev' => $two, 'next' => null]; $this->assertEquals($expected, $result); } @@ -3934,19 +3934,19 @@ public function testFindNeighborsNoPrev() { $this->loadFixtures('User', 'Article', 'Comment', 'Tag', 'ArticlesTag', 'Attachment'); $Article = new Article(); - $result = $Article->find('neighbors', array( + $result = $Article->find('neighbors', [ 'field' => 'Article.title', 'value' => 'Second Article', - 'fields' => array('id'), - 'conditions' => array( + 'fields' => ['id'], + 'conditions' => [ 'Article.title LIKE' => '%Article%' - ), + ], 'recursive' => 0, - )); - $expected = array( + ]); + $expected = [ 'prev' => null, 'next' => null - ); + ]; $this->assertEquals($expected, $result); } @@ -3963,9 +3963,9 @@ public function testFindCombinedRelations() { $result = $TestModel->find('all'); - $expected = array( - array( - 'Apple' => array( + $expected = [ + [ + 'Apple' => [ 'id' => '1', 'apple_id' => '2', 'color' => 'Red 1', @@ -3974,8 +3974,8 @@ public function testFindCombinedRelations() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', @@ -3984,14 +3984,14 @@ public function testFindCombinedRelations() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => null, 'apple_id' => null, 'name' => null - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', @@ -4000,9 +4000,9 @@ public function testFindCombinedRelations() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', @@ -4011,8 +4011,8 @@ public function testFindCombinedRelations() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => '1', 'apple_id' => '2', 'color' => 'Red 1', @@ -4021,14 +4021,14 @@ public function testFindCombinedRelations() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => '2', 'apple_id' => '2', 'name' => 'sample2' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => '1', 'apple_id' => '2', 'color' => 'Red 1', @@ -4037,8 +4037,8 @@ public function testFindCombinedRelations() { 'date' => '1951-01-04', 'modified' => '2006-12-01 13:31:26', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => '3', 'apple_id' => '2', 'color' => 'blue green', @@ -4047,8 +4047,8 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - array( + ], + [ 'id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', @@ -4057,9 +4057,9 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => '3', 'apple_id' => '2', 'color' => 'blue green', @@ -4068,8 +4068,8 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:24', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', @@ -4078,16 +4078,16 @@ public function testFindCombinedRelations() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => '1', 'apple_id' => '3', 'name' => 'sample1' - ), - 'Child' => array() - ), - array( - 'Apple' => array( + ], + 'Child' => [] + ], + [ + 'Apple' => [ 'id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', @@ -4096,8 +4096,8 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => '2', 'apple_id' => '1', 'color' => 'Bright Red 1', @@ -4106,14 +4106,14 @@ public function testFindCombinedRelations() { 'date' => '2014-01-01', 'modified' => '2006-11-30 18:38:10', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => '3', 'apple_id' => '4', 'name' => 'sample3' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', @@ -4122,9 +4122,9 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => '5', 'apple_id' => '5', 'color' => 'Green', @@ -4133,8 +4133,8 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => '5', 'apple_id' => '5', 'color' => 'Green', @@ -4143,14 +4143,14 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => '4', 'apple_id' => '5', 'name' => 'sample4' - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => '5', 'apple_id' => '5', 'color' => 'Green', @@ -4159,9 +4159,9 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:16', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', @@ -4170,8 +4170,8 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => '4', 'apple_id' => '2', 'color' => 'Blue Green', @@ -4180,14 +4180,14 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:23:36', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => null, 'apple_id' => null, 'name' => null - ), - 'Child' => array( - array( + ], + 'Child' => [ + [ 'id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', @@ -4196,9 +4196,9 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ))), - array( - 'Apple' => array( + ]]], + [ + 'Apple' => [ 'id' => '7', 'apple_id' => '6', 'color' => 'Some wierd color', @@ -4207,8 +4207,8 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:34:21', 'mytime' => '22:57:17' - ), - 'Parent' => array( + ], + 'Parent' => [ 'id' => '6', 'apple_id' => '4', 'color' => 'My new appleOrange', @@ -4217,14 +4217,14 @@ public function testFindCombinedRelations() { 'date' => '2006-12-25', 'modified' => '2006-12-25 05:29:39', 'mytime' => '22:57:17' - ), - 'Sample' => array( + ], + 'Sample' => [ 'id' => null, 'apple_id' => null, 'name' => null - ), - 'Child' => array() - )); + ], + 'Child' => [] + ]]; $this->assertEquals($expected, $result); } @@ -4236,7 +4236,7 @@ public function testFindCombinedRelations() { public function testSaveEmpty() { $this->loadFixtures('Thread'); $TestModel = new Thread(); - $data = array(); + $data = []; $expected = $TestModel->save($data); $this->assertFalse($expected); } @@ -4253,34 +4253,34 @@ public function testFindAllWithConditionInChildQuery() { $recursive = 3; $result = $TestModel->find('all', compact('recursive')); - $expected = array( - array( - 'Basket' => array( + $expected = [ + [ + 'Basket' => [ 'id' => 1, 'type' => 'nonfile', 'name' => 'basket1', 'object_id' => 1, 'user_id' => 1, - ), - 'FilmFile' => array( + ], + 'FilmFile' => [ 'id' => '', 'name' => '', - ) - ), - array( - 'Basket' => array( + ] + ], + [ + 'Basket' => [ 'id' => 2, 'type' => 'file', 'name' => 'basket2', 'object_id' => 2, 'user_id' => 1, - ), - 'FilmFile' => array( + ], + 'FilmFile' => [ 'id' => 2, 'name' => 'two', - ) - ), - ); + ] + ], + ]; $this->assertEquals($expected, $result); } @@ -4292,9 +4292,9 @@ public function testFindAllWithConditionInChildQuery() { public function testFindAllWithConditionsHavingMixedDataTypes() { $this->loadFixtures('Article', 'User', 'Tag', 'ArticlesTag'); $TestModel = new Article(); - $expected = array( - array( - 'Article' => array( + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', @@ -4302,10 +4302,10 @@ public function testFindAllWithConditionsHavingMixedDataTypes() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', @@ -4313,10 +4313,10 @@ public function testFindAllWithConditionsHavingMixedDataTypes() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ) - ); - $conditions = array('id' => array('1', 2)); + ] + ] + ]; + $conditions = ['id' => ['1', 2]]; $recursive = -1; $order = 'Article.id ASC'; $result = $TestModel->find('all', compact('conditions', 'recursive', 'order')); @@ -4324,12 +4324,12 @@ public function testFindAllWithConditionsHavingMixedDataTypes() { $this->skipIf($this->db instanceof Postgres, 'The rest of testFindAllWithConditionsHavingMixedDataTypes test is not compatible with Postgres.'); - $conditions = array('id' => array('1', 2, '3.0')); + $conditions = ['id' => ['1', 2, '3.0']]; $order = 'Article.id ASC'; $result = $TestModel->find('all', compact('recursive', 'conditions', 'order')); - $expected = array( - array( - 'Article' => array( + $expected = [ + [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', @@ -4337,10 +4337,10 @@ public function testFindAllWithConditionsHavingMixedDataTypes() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', @@ -4348,10 +4348,10 @@ public function testFindAllWithConditionsHavingMixedDataTypes() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', @@ -4359,9 +4359,9 @@ public function testFindAllWithConditionsHavingMixedDataTypes() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); } @@ -4385,24 +4385,24 @@ public function testBindUnbind() { $TestModel = new User(); $result = $TestModel->hasMany; - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); - $result = $TestModel->bindModel(array('hasMany' => array('Comment'))); + $result = $TestModel->bindModel(['hasMany' => ['Comment']]); $this->assertTrue($result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'User.id, User.user', - 'order' => array('User.id' => 'ASC'), - )); - $expected = array( - array( - 'User' => array( + 'order' => ['User.id' => 'ASC'], + ]); + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '3', 'article_id' => '1', 'user_id' => '1', @@ -4410,8 +4410,8 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => '4', 'article_id' => '1', 'user_id' => '1', @@ -4419,8 +4419,8 @@ public function testBindUnbind() { 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - array( + ], + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -4428,14 +4428,14 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -4443,8 +4443,8 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -4452,21 +4452,21 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry' - ), - 'Comment' => array() - ), - array( - 'User' => array( + ], + 'Comment' => [] + ], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -4474,30 +4474,30 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - )))); + ]]]]; $this->assertEquals($expected, $result); $TestModel->resetAssociations(); $result = $TestModel->hasMany; - $this->assertSame(array(), $result); + $this->assertSame([], $result); - $result = $TestModel->bindModel(array('hasMany' => array('Comment')), false); + $result = $TestModel->bindModel(['hasMany' => ['Comment']], false); $this->assertTrue($result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'User.id, User.user', - 'order' => array('User.id' => 'ASC'), - )); + 'order' => ['User.id' => 'ASC'], + ]); - $expected = array( - array( - 'User' => array( + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '3', 'article_id' => '1', 'user_id' => '1', @@ -4505,8 +4505,8 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => '4', 'article_id' => '1', 'user_id' => '1', @@ -4514,8 +4514,8 @@ public function testBindUnbind() { 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - array( + ], + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -4523,14 +4523,14 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -4538,8 +4538,8 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -4547,21 +4547,21 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry' - ), - 'Comment' => array() - ), - array( - 'User' => array( + ], + 'Comment' => [] + ], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -4569,13 +4569,13 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - )))); + ]]]]; $this->assertEquals($expected, $result); $result = $TestModel->hasMany; - $expected = array( - 'Comment' => array( + $expected = [ + 'Comment' => [ 'className' => 'Comment', 'foreignKey' => 'user_id', 'conditions' => null, @@ -4587,39 +4587,39 @@ public function testBindUnbind() { 'exclusive' => null, 'finderQuery' => null, 'counterQuery' => null - )); + ]]; $this->assertEquals($expected, $result); - $result = $TestModel->unbindModel(array('hasMany' => array('Comment'))); + $result = $TestModel->unbindModel(['hasMany' => ['Comment']]); $this->assertTrue($result); $result = $TestModel->hasMany; - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'User.id, User.user', - 'order' => array('User.id' => 'ASC'), - )); - $expected = array( - array('User' => array('id' => '1', 'user' => 'mariano')), - array('User' => array('id' => '2', 'user' => 'nate')), - array('User' => array('id' => '3', 'user' => 'larry')), - array('User' => array('id' => '4', 'user' => 'garrett'))); + 'order' => ['User.id' => 'ASC'], + ]); + $expected = [ + ['User' => ['id' => '1', 'user' => 'mariano']], + ['User' => ['id' => '2', 'user' => 'nate']], + ['User' => ['id' => '3', 'user' => 'larry']], + ['User' => ['id' => '4', 'user' => 'garrett']]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'User.id, User.user', - 'order' => array('User.id' => 'ASC'), - )); - $expected = array( - array( - 'User' => array( + 'order' => ['User.id' => 'ASC'], + ]); + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '3', 'article_id' => '1', 'user_id' => '1', @@ -4627,8 +4627,8 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => '4', 'article_id' => '1', 'user_id' => '1', @@ -4636,8 +4636,8 @@ public function testBindUnbind() { 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - array( + ], + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -4645,14 +4645,14 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -4660,8 +4660,8 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -4669,21 +4669,21 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry' - ), - 'Comment' => array() - ), - array( - 'User' => array( + ], + 'Comment' => [] + ], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -4692,44 +4692,44 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - )))); + ]]]]; $this->assertEquals($expected, $result); - $result = $TestModel->unbindModel(array('hasMany' => array('Comment')), false); + $result = $TestModel->unbindModel(['hasMany' => ['Comment']], false); $this->assertTrue($result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'User.id, User.user', - 'order' => array('User.id' => 'ASC'), - )); - $expected = array( - array('User' => array('id' => '1', 'user' => 'mariano')), - array('User' => array('id' => '2', 'user' => 'nate')), - array('User' => array('id' => '3', 'user' => 'larry')), - array('User' => array('id' => '4', 'user' => 'garrett'))); + 'order' => ['User.id' => 'ASC'], + ]); + $expected = [ + ['User' => ['id' => '1', 'user' => 'mariano']], + ['User' => ['id' => '2', 'user' => 'nate']], + ['User' => ['id' => '3', 'user' => 'larry']], + ['User' => ['id' => '4', 'user' => 'garrett']]]; $this->assertEquals($expected, $result); $result = $TestModel->hasMany; - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); - $result = $TestModel->bindModel(array('hasMany' => array( - 'Comment' => array('className' => 'Comment', 'conditions' => 'Comment.published = \'Y\'') - ))); + $result = $TestModel->bindModel(['hasMany' => [ + 'Comment' => ['className' => 'Comment', 'conditions' => 'Comment.published = \'Y\''] + ]]); $this->assertTrue($result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'User.id, User.user', - 'order' => array('User.id' => 'ASC'), - )); - $expected = array( - array( - 'User' => array( + 'order' => ['User.id' => 'ASC'], + ]); + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '3', 'article_id' => '1', 'user_id' => '1', @@ -4737,8 +4737,8 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -4746,14 +4746,14 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -4761,8 +4761,8 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -4770,21 +4770,21 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry' - ), - 'Comment' => array() - ), - array( - 'User' => array( + ], + 'Comment' => [] + ], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -4792,58 +4792,58 @@ public function testBindUnbind() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - )))); + ]]]]; $this->assertEquals($expected, $result); $TestModel2 = new DeviceType(); - $expected = array( + $expected = [ 'className' => 'FeatureSet', 'foreignKey' => 'feature_set_id', 'conditions' => '', 'fields' => '', 'order' => '', 'counterCache' => '' - ); + ]; $this->assertEquals($expected, $TestModel2->belongsTo['FeatureSet']); - $TestModel2->bindModel(array( - 'belongsTo' => array( - 'FeatureSet' => array( + $TestModel2->bindModel([ + 'belongsTo' => [ + 'FeatureSet' => [ 'className' => 'FeatureSet', - 'conditions' => array('active' => true) - ) - ) - )); - $expected['conditions'] = array('active' => true); + 'conditions' => ['active' => true] + ] + ] + ]); + $expected['conditions'] = ['active' => true]; $this->assertEquals($expected, $TestModel2->belongsTo['FeatureSet']); - $TestModel2->bindModel(array( - 'belongsTo' => array( - 'FeatureSet' => array( + $TestModel2->bindModel([ + 'belongsTo' => [ + 'FeatureSet' => [ 'className' => 'FeatureSet', 'foreignKey' => false, - 'conditions' => array('Feature.name' => 'DeviceType.name') - ) - ) - )); - $expected['conditions'] = array('Feature.name' => 'DeviceType.name'); + 'conditions' => ['Feature.name' => 'DeviceType.name'] + ] + ] + ]); + $expected['conditions'] = ['Feature.name' => 'DeviceType.name']; $expected['foreignKey'] = false; $this->assertEquals($expected, $TestModel2->belongsTo['FeatureSet']); - $TestModel2->bindModel(array( - 'hasMany' => array( - 'NewFeatureSet' => array( + $TestModel2->bindModel([ + 'hasMany' => [ + 'NewFeatureSet' => [ 'className' => 'FeatureSet', - 'conditions' => array('active' => true) - ) - ) - )); + 'conditions' => ['active' => true] + ] + ] + ]); - $expected = array( + $expected = [ 'className' => 'FeatureSet', - 'conditions' => array('active' => true), + 'conditions' => ['active' => true], 'foreignKey' => 'device_type_id', 'fields' => '', 'order' => '', @@ -4853,7 +4853,7 @@ public function testBindUnbind() { 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' - ); + ]; $this->assertEquals($expected, $TestModel2->hasMany['NewFeatureSet']); $this->assertTrue(is_object($TestModel2->NewFeatureSet)); } @@ -4868,27 +4868,27 @@ public function testBindMultipleTimes() { $TestModel = new User(); $result = $TestModel->hasMany; - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); - $result = $TestModel->bindModel(array( - 'hasMany' => array( - 'Items' => array('className' => 'Comment') - ))); + $result = $TestModel->bindModel([ + 'hasMany' => [ + 'Items' => ['className' => 'Comment'] + ]]); $this->assertTrue($result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'User.id, User.user' - )); + ]); - $expected = array( - array( - 'User' => array( + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano' - ), - 'Items' => array( - array( + ], + 'Items' => [ + [ 'id' => '3', 'article_id' => '1', 'user_id' => '1', @@ -4896,8 +4896,8 @@ public function testBindMultipleTimes() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => '4', 'article_id' => '1', 'user_id' => '1', @@ -4905,8 +4905,8 @@ public function testBindMultipleTimes() { 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ), - array( + ], + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -4914,14 +4914,14 @@ public function testBindMultipleTimes() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate' - ), - 'Items' => array( - array( + ], + 'Items' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -4929,8 +4929,8 @@ public function testBindMultipleTimes() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -4938,21 +4938,21 @@ public function testBindMultipleTimes() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry' - ), - 'Items' => array() - ), - array( - 'User' => array( + ], + 'Items' => [] + ], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett' - ), - 'Items' => array( - array( + ], + 'Items' => [ + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -4960,26 +4960,26 @@ public function testBindMultipleTimes() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - )))); + ]]]]; $this->assertEquals($expected, $result); - $result = $TestModel->bindModel(array( - 'hasMany' => array( - 'Items' => array('className' => 'Article') - ))); + $result = $TestModel->bindModel([ + 'hasMany' => [ + 'Items' => ['className' => 'Article'] + ]]); $this->assertTrue($result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'fields' => 'User.id, User.user' - )); - $expected = array( - array( - 'User' => array( + ]); + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano' - ), - 'Items' => array( - array( + ], + 'Items' => [ + [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', @@ -4987,8 +4987,8 @@ public function testBindMultipleTimes() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', @@ -4996,21 +4996,21 @@ public function testBindMultipleTimes() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate' - ), - 'Items' => array() - ), - array( - 'User' => array( + ], + 'Items' => [] + ], + [ + 'User' => [ 'id' => '3', 'user' => 'larry' - ), - 'Items' => array( - array( + ], + 'Items' => [ + [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', @@ -5018,14 +5018,14 @@ public function testBindMultipleTimes() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ))), - array( - 'User' => array( + ]]], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett' - ), - 'Items' => array() - )); + ], + 'Items' => [] + ]]; $this->assertEquals($expected, $result); } @@ -5039,8 +5039,8 @@ public function testBindModelMultipleTimesResetCorrectly() { $this->loadFixtures('User', 'Comment', 'Article'); $TestModel = new User(); - $TestModel->bindModel(array('hasMany' => array('Comment'))); - $TestModel->bindModel(array('hasMany' => array('Comment'))); + $TestModel->bindModel(['hasMany' => ['Comment']]); + $TestModel->bindModel(['hasMany' => ['Comment']]); $TestModel->resetAssociations(); $this->assertFalse(isset($TestModel->hasMany['Comment']), 'Association left behind'); @@ -5056,27 +5056,27 @@ public function testBindMultipleTimesWithDifferentResetSettings() { $TestModel = new User(); $result = $TestModel->hasMany; - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); - $result = $TestModel->bindModel(array( - 'hasMany' => array('Comment') - )); + $result = $TestModel->bindModel([ + 'hasMany' => ['Comment'] + ]); $this->assertTrue($result); $result = $TestModel->bindModel( - array('hasMany' => array('Article')), + ['hasMany' => ['Article']], false ); $this->assertTrue($result); $result = array_keys($TestModel->hasMany); - $expected = array('Comment', 'Article'); + $expected = ['Comment', 'Article']; $this->assertEquals($expected, $result); $TestModel->resetAssociations(); $result = array_keys($TestModel->hasMany); - $expected = array('Article'); + $expected = ['Article']; $this->assertEquals($expected, $result); } @@ -5088,12 +5088,12 @@ public function testBindMultipleTimesWithDifferentResetSettings() { public function testBindWithCustomPrimaryKey() { $this->loadFixtures('Story', 'StoriesTag', 'Tag'); $Model = ClassRegistry::init('StoriesTag'); - $Model->bindModel(array( - 'belongsTo' => array( - 'Tag' => array( + $Model->bindModel([ + 'belongsTo' => [ + 'Tag' => [ 'className' => 'Tag', 'foreignKey' => 'story' - )))); + ]]]); $result = $Model->find('all'); $this->assertFalse(empty($result)); @@ -5109,8 +5109,8 @@ public function testUnbindMultipleTimesResetCorrectly() { $this->loadFixtures('User', 'Comment', 'Article'); $TestModel = new Article10(); - $TestModel->unbindModel(array('hasMany' => array('Comment'))); - $TestModel->unbindModel(array('hasMany' => array('Comment'))); + $TestModel->unbindModel(['hasMany' => ['Comment']]); + $TestModel->unbindModel(['hasMany' => ['Comment']]); $TestModel->resetAssociations(); $this->assertTrue(isset($TestModel->hasMany['Comment']), 'Association permanently removed'); @@ -5126,27 +5126,27 @@ public function testUnBindMultipleTimesWithDifferentResetSettings() { $TestModel = new Comment(); $result = array_keys($TestModel->belongsTo); - $expected = array('Article', 'User'); + $expected = ['Article', 'User']; $this->assertEquals($expected, $result); - $result = $TestModel->unbindModel(array( - 'belongsTo' => array('User') - )); + $result = $TestModel->unbindModel([ + 'belongsTo' => ['User'] + ]); $this->assertTrue($result); $result = $TestModel->unbindModel( - array('belongsTo' => array('Article')), + ['belongsTo' => ['Article']], false ); $this->assertTrue($result); $result = array_keys($TestModel->belongsTo); - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); $TestModel->resetAssociations(); $result = array_keys($TestModel->belongsTo); - $expected = array('User'); + $expected = ['User']; $this->assertEquals($expected, $result); } @@ -5158,12 +5158,12 @@ public function testUnBindMultipleTimesWithDifferentResetSettings() { public function testAssociationAfterFind() { $this->loadFixtures('Post', 'Author', 'Comment'); $TestModel = new Post(); - $result = $TestModel->find('all', array( - 'order' => array('Post.id' => 'ASC') - )); - $expected = array( - array( - 'Post' => array( + $result = $TestModel->find('all', [ + 'order' => ['Post.id' => 'ASC'] + ]); + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '1', 'title' => 'First Post', @@ -5171,17 +5171,17 @@ public function testAssociationAfterFind() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '2', 'author_id' => '3', 'title' => 'Second Post', @@ -5189,17 +5189,17 @@ public function testAssociationAfterFind() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', 'test' => 'working' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '3', 'author_id' => '1', 'title' => 'Third Post', @@ -5207,32 +5207,32 @@ public function testAssociationAfterFind() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working' - ))); + ]]]; $this->assertEquals($expected, $result); unset($TestModel); $Author = new Author(); - $Author->Post->bindModel(array( - 'hasMany' => array( - 'Comment' => array( + $Author->Post->bindModel([ + 'hasMany' => [ + 'Comment' => [ 'className' => 'ModifiedComment', 'foreignKey' => 'article_id', - ) - ))); - $result = $Author->find('all', array( - 'conditions' => array('Author.id' => 1), - 'order' => array('Author.id' => 'ASC'), + ] + ]]); + $result = $Author->find('all', [ + 'conditions' => ['Author.id' => 1], + 'order' => ['Author.id' => 'ASC'], 'recursive' => 2 - )); - $expected = array( + ]); + $expected = [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, @@ -5241,7 +5241,7 @@ public function testAssociationAfterFind() { 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31', 'callback' => 'Fire' - ); + ]; $this->assertEquals($expected, $result[0]['Post'][0]['Comment'][0]); } @@ -5254,24 +5254,24 @@ public function testDeeperAssociationAfterFind() { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment', 'Article'); $Post = new Post(); - $Post->bindModel(array( - 'hasMany' => array( - 'Comment' => array( + $Post->bindModel([ + 'hasMany' => [ + 'Comment' => [ 'className' => 'ModifiedComment', 'foreignKey' => 'article_id', - ) - ))); - $Post->Comment->bindModel(array( - 'hasOne' => array( - 'Attachment' => array( + ] + ]]); + $Post->Comment->bindModel([ + 'hasOne' => [ + 'Attachment' => [ 'className' => 'ModifiedAttachment', - ) - ))); + ] + ]]); - $result = $Post->find('first', array( - 'conditions' => array('Post.id' => 2), + $result = $Post->find('first', [ + 'conditions' => ['Post.id' => 2], 'recursive' => 2 - )); + ]); $this->assertTrue(isset($result['Comment'][0]['callback'])); $this->assertEquals('Fire', $result['Comment'][0]['callback']); $this->assertTrue(isset($result['Comment'][0]['Attachment']['callback'])); @@ -5288,19 +5288,19 @@ public function testCallbackDisabling() { $TestModel = new ModifiedAuthor(); $result = Hash::extract($TestModel->find('all'), '{n}.Author.user'); - $expected = array('mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)'); + $expected = ['mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)']; $this->assertEquals($expected, $result); - $result = Hash::extract($TestModel->find('all', array('callbacks' => 'after')), '{n}.Author.user'); - $expected = array('mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)'); + $result = Hash::extract($TestModel->find('all', ['callbacks' => 'after']), '{n}.Author.user'); + $expected = ['mariano (CakePHP)', 'nate (CakePHP)', 'larry (CakePHP)', 'garrett (CakePHP)']; $this->assertEquals($expected, $result); - $result = Hash::extract($TestModel->find('all', array('callbacks' => 'before')), '{n}.Author.user'); - $expected = array('mariano', 'nate', 'larry', 'garrett'); + $result = Hash::extract($TestModel->find('all', ['callbacks' => 'before']), '{n}.Author.user'); + $expected = ['mariano', 'nate', 'larry', 'garrett']; $this->assertEquals($expected, $result); - $result = Hash::extract($TestModel->find('all', array('callbacks' => false)), '{n}.Author.user'); - $expected = array('mariano', 'nate', 'larry', 'garrett'); + $result = Hash::extract($TestModel->find('all', ['callbacks' => false]), '{n}.Author.user'); + $expected = ['mariano', 'nate', 'larry', 'garrett']; $this->assertEquals($expected, $result); } @@ -5312,13 +5312,13 @@ public function testCallbackDisabling() { public function testAssociationAfterFindCalbacksDisabled() { $this->loadFixtures('Post', 'Author', 'Comment'); $TestModel = new Post(); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'callbacks' => false, - 'order' => array('Post.id' => 'ASC'), - )); - $expected = array( - array( - 'Post' => array( + 'order' => ['Post.id' => 'ASC'], + ]); + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '1', 'title' => 'First Post', @@ -5326,16 +5326,16 @@ public function testAssociationAfterFindCalbacksDisabled() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '2', 'author_id' => '3', 'title' => 'Second Post', @@ -5343,16 +5343,16 @@ public function testAssociationAfterFindCalbacksDisabled() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '3', 'author_id' => '1', 'title' => 'Third Post', @@ -5360,32 +5360,32 @@ public function testAssociationAfterFindCalbacksDisabled() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ))); + ]]]; $this->assertEquals($expected, $result); unset($TestModel); $Author = new Author(); - $Author->Post->bindModel(array( - 'hasMany' => array( - 'Comment' => array( + $Author->Post->bindModel([ + 'hasMany' => [ + 'Comment' => [ 'className' => 'ModifiedComment', 'foreignKey' => 'article_id', - ) - ))); - $result = $Author->find('all', array( - 'conditions' => array('Author.id' => 1), + ] + ]]); + $result = $Author->find('all', [ + 'conditions' => ['Author.id' => 1], 'recursive' => 2, - 'order' => array('Author.id' => 'ASC'), + 'order' => ['Author.id' => 'ASC'], 'callbacks' => false - )); - $expected = array( + ]); + $expected = [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, @@ -5393,7 +5393,7 @@ public function testAssociationAfterFindCalbacksDisabled() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ); + ]; $this->assertEquals($expected, $result[0]['Post'][0]['Comment'][0]); } @@ -5418,7 +5418,7 @@ public function testCallbackSourceChangeUnknownDatasource() { $this->expectException(MissingDatasourceConfigException::class); $this->loadFixtures('Post', 'Author'); $TestModel = new Post(); - $this->assertFalse($TestModel->find('all', array('connection' => 'foo'))); + $this->assertFalse($TestModel->find('all', ['connection' => 'foo'])); } /** @@ -5442,8 +5442,8 @@ public function testMultipleBelongsToWithSameClass() { $DeviceType->recursive = 2; $result = $DeviceType->read(null, 1); - $expected = array( - 'DeviceType' => array( + $expected = [ + 'DeviceType' => [ 'id' => 1, 'device_type_category_id' => 1, 'feature_set_id' => 1, @@ -5453,68 +5453,68 @@ public function testMultipleBelongsToWithSameClass() { 'extra2_id' => 1, 'name' => 'DeviceType 1', 'order' => 0 - ), - 'Image' => array( + ], + 'Image' => [ 'id' => 1, 'document_directory_id' => 1, 'name' => 'Document 1', - 'DocumentDirectory' => array( + 'DocumentDirectory' => [ 'id' => 1, 'name' => 'DocumentDirectory 1' - )), - 'Extra1' => array( + ]], + 'Extra1' => [ 'id' => 1, 'document_directory_id' => 1, 'name' => 'Document 1', - 'DocumentDirectory' => array( + 'DocumentDirectory' => [ 'id' => 1, 'name' => 'DocumentDirectory 1' - )), - 'Extra2' => array( + ]], + 'Extra2' => [ 'id' => 1, 'document_directory_id' => 1, 'name' => 'Document 1', - 'DocumentDirectory' => array( + 'DocumentDirectory' => [ 'id' => 1, 'name' => 'DocumentDirectory 1' - )), - 'DeviceTypeCategory' => array( + ]], + 'DeviceTypeCategory' => [ 'id' => 1, 'name' => 'DeviceTypeCategory 1' - ), - 'FeatureSet' => array( + ], + 'FeatureSet' => [ 'id' => 1, 'name' => 'FeatureSet 1' - ), - 'ExteriorTypeCategory' => array( + ], + 'ExteriorTypeCategory' => [ 'id' => 1, 'image_id' => 1, 'name' => 'ExteriorTypeCategory 1', - 'Image' => array( + 'Image' => [ 'id' => 1, 'device_type_id' => 1, 'name' => 'Device 1', 'typ' => 1 - )), - 'Device' => array( - array( + ]], + 'Device' => [ + [ 'id' => 1, 'device_type_id' => 1, 'name' => 'Device 1', 'typ' => 1 - ), - array( + ], + [ 'id' => 2, 'device_type_id' => 1, 'name' => 'Device 2', 'typ' => 1 - ), - array( + ], + [ 'id' => 3, 'device_type_id' => 1, 'name' => 'Device 3', 'typ' => 2 - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -5528,51 +5528,51 @@ public function testHabtmRecursiveBelongsTo() { $this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio', 'Syfile', 'Image'); $Portfolio = new Portfolio(); - $result = $Portfolio->find('first', array('conditions' => array('id' => 2), 'recursive' => 3)); - $expected = array( - 'Portfolio' => array( + $result = $Portfolio->find('first', ['conditions' => ['id' => 2], 'recursive' => 3]); + $expected = [ + 'Portfolio' => [ 'id' => 2, 'seller_id' => 1, 'name' => 'Portfolio 2' - ), - 'Item' => array( - array( + ], + 'Item' => [ + [ 'id' => 2, 'syfile_id' => 2, 'published' => false, 'name' => 'Item 2', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 2, 'item_id' => 2, 'portfolio_id' => 2 - ), - 'Syfile' => array( + ], + 'Syfile' => [ 'id' => 2, 'image_id' => 2, 'name' => 'Syfile 2', 'item_count' => null, - 'Image' => array( + 'Image' => [ 'id' => 2, 'name' => 'Image 2' - ) - )), - array( + ] + ]], + [ 'id' => 6, 'syfile_id' => 6, 'published' => false, 'name' => 'Item 6', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 6, 'item_id' => 6, 'portfolio_id' => 2 - ), - 'Syfile' => array( + ], + 'Syfile' => [ 'id' => 6, 'image_id' => null, 'name' => 'Syfile 6', 'item_count' => null, - 'Image' => array() - )))); + 'Image' => [] + ]]]]; $this->assertEquals($expected, $result); } @@ -5585,17 +5585,17 @@ public function testHabtmRecursiveBelongsTo() { public function testNonNumericHabtmJoinKey() { $this->loadFixtures('Post', 'Tag', 'PostsTag', 'Author'); $Post = new Post(); - $Post->bindModel(array( - 'hasAndBelongsToMany' => array('Tag') - )); + $Post->bindModel([ + 'hasAndBelongsToMany' => ['Tag'] + ]); $Post->Tag->primaryKey = 'tag'; - $result = $Post->find('all', array( + $result = $Post->find('all', [ 'order' => 'Post.id ASC', - )); - $expected = array( - array( - 'Post' => array( + ]); + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '1', 'title' => 'First Post', @@ -5603,30 +5603,30 @@ public function testNonNumericHabtmJoinKey() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ))), - array( - 'Post' => array( + ]]], + [ + 'Post' => [ 'id' => '2', 'author_id' => '3', 'title' => 'Second Post', @@ -5634,30 +5634,30 @@ public function testNonNumericHabtmJoinKey() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => 3, 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', 'test' => 'working' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))), - array( - 'Post' => array( + ]]], + [ + 'Post' => [ 'id' => '3', 'author_id' => '1', 'title' => 'Third Post', @@ -5665,17 +5665,17 @@ public function testNonNumericHabtmJoinKey() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => 1, 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working' - ), - 'Tag' => array() - )); + ], + 'Tag' => [] + ]]; $this->assertEquals($expected, $result); } @@ -5689,40 +5689,40 @@ public function testHabtmFinderQuery() { $Article = new Article(); $sql = $this->db->buildStatement( - array( - 'fields' => $this->db->fields($Article->Tag, null, array( + [ + 'fields' => $this->db->fields($Article->Tag, null, [ 'Tag.id', 'Tag.tag', 'ArticlesTag.article_id', 'ArticlesTag.tag_id' - )), + ]), 'table' => $this->db->fullTableName('tags'), 'alias' => 'Tag', 'limit' => null, 'offset' => null, 'group' => null, - 'joins' => array(array( + 'joins' => [[ 'alias' => 'ArticlesTag', 'table' => 'articles_tags', - 'conditions' => array( - array("ArticlesTag.article_id" => '{$__cakeID__$}'), - array("ArticlesTag.tag_id" => $this->db->identifier('Tag.id')) - ) - )), - 'conditions' => array(), + 'conditions' => [ + ["ArticlesTag.article_id" => '{$__cakeID__$}'], + ["ArticlesTag.tag_id" => $this->db->identifier('Tag.id')] + ] + ]], + 'conditions' => [], 'order' => null - ), + ], $Article ); $Article->hasAndBelongsToMany['Tag']['finderQuery'] = $sql; $result = $Article->find('first'); - $expected = array( - array( + $expected = [ + [ 'id' => '1', 'tag' => 'tag1' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2' - )); + ]]; $this->assertEquals($expected, $result['Tag']); } @@ -5738,8 +5738,8 @@ public function testHabtmLimitOptimization() { $TestModel->hasAndBelongsToMany['Tag']['limit'] = 2; $result = $TestModel->read(null, 2); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -5747,16 +5747,16 @@ public function testHabtmLimitOptimization() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -5764,8 +5764,8 @@ public function testHabtmLimitOptimization() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -5773,20 +5773,20 @@ public function testHabtmLimitOptimization() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - )), - 'Tag' => array( - array( + ]], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))); + ]]]; $this->assertEquals($expected, $result); @@ -5807,108 +5807,108 @@ public function testHasManyLimitOptimization() { $Project = new Project(); $Project->recursive = 3; - $result = $Project->find('all', array( + $result = $Project->find('all', [ 'order' => 'Project.id ASC', - )); - $expected = array( - array( - 'Project' => array( + ]); + $expected = [ + [ + 'Project' => [ 'id' => 1, 'name' => 'Project 1' - ), - 'Thread' => array( - array( + ], + 'Thread' => [ + [ 'id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1', - 'Project' => array( + 'Project' => [ 'id' => 1, 'name' => 'Project 1', - 'Thread' => array( - array( + 'Thread' => [ + [ 'id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1' - ), - array( + ], + [ 'id' => 2, 'project_id' => 1, 'name' => 'Project 1, Thread 2' - ))), - 'Message' => array( - array( + ]]], + 'Message' => [ + [ 'id' => 1, 'thread_id' => 1, 'name' => 'Thread 1, Message 1', - 'Bid' => array( + 'Bid' => [ 'id' => 1, 'message_id' => 1, 'name' => 'Bid 1.1' - )))), - array( + ]]]], + [ 'id' => 2, 'project_id' => 1, 'name' => 'Project 1, Thread 2', - 'Project' => array( + 'Project' => [ 'id' => 1, 'name' => 'Project 1', - 'Thread' => array( - array( + 'Thread' => [ + [ 'id' => 1, 'project_id' => 1, 'name' => 'Project 1, Thread 1' - ), - array( + ], + [ 'id' => 2, 'project_id' => 1, 'name' => 'Project 1, Thread 2' - ))), - 'Message' => array( - array( + ]]], + 'Message' => [ + [ 'id' => 2, 'thread_id' => 2, 'name' => 'Thread 2, Message 1', - 'Bid' => array( + 'Bid' => [ 'id' => 4, 'message_id' => 2, 'name' => 'Bid 2.1' - )))))), - array( - 'Project' => array( + ]]]]]], + [ + 'Project' => [ 'id' => 2, 'name' => 'Project 2' - ), - 'Thread' => array( - array( + ], + 'Thread' => [ + [ 'id' => 3, 'project_id' => 2, 'name' => 'Project 2, Thread 1', - 'Project' => array( + 'Project' => [ 'id' => 2, 'name' => 'Project 2', - 'Thread' => array( - array( + 'Thread' => [ + [ 'id' => 3, 'project_id' => 2, 'name' => 'Project 2, Thread 1' - ))), - 'Message' => array( - array( + ]]], + 'Message' => [ + [ 'id' => 3, 'thread_id' => 3, 'name' => 'Thread 3, Message 1', - 'Bid' => array( + 'Bid' => [ 'id' => 3, 'message_id' => 3, 'name' => 'Bid 3.1' - )))))), - array( - 'Project' => array( + ]]]]]], + [ + 'Project' => [ 'id' => 3, 'name' => 'Project 3' - ), - 'Thread' => array() - )); + ], + 'Thread' => [] + ]]; $this->assertEquals($expected, $result); } @@ -5923,100 +5923,100 @@ public function testFindAllRecursiveSelfJoin() { $TestModel = new Home(); $TestModel->recursive = 2; - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'order' => 'Home.id ASC', - )); - $expected = array( - array( - 'Home' => array( + ]); + $expected = [ + [ + 'Home' => [ 'id' => '1', 'another_article_id' => '1', 'advertisement_id' => '1', 'title' => 'First Home', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'AnotherArticle' => array( + ], + 'AnotherArticle' => [ 'id' => '1', 'title' => 'First Article', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Home' => array( - array( + 'Home' => [ + [ 'id' => '1', 'another_article_id' => '1', 'advertisement_id' => '1', 'title' => 'First Home', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ))), - 'Advertisement' => array( + ]]], + 'Advertisement' => [ 'id' => '1', 'title' => 'First Ad', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Home' => array( - array( + 'Home' => [ + [ 'id' => '1', 'another_article_id' => '1', 'advertisement_id' => '1', 'title' => 'First Home', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => '2', 'another_article_id' => '3', 'advertisement_id' => '1', 'title' => 'Second Home', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - )))), - array( - 'Home' => array( + ]]]], + [ + 'Home' => [ 'id' => '2', 'another_article_id' => '3', 'advertisement_id' => '1', 'title' => 'Second Home', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'AnotherArticle' => array( + ], + 'AnotherArticle' => [ 'id' => '3', 'title' => 'Third Article', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', - 'Home' => array( - array( + 'Home' => [ + [ 'id' => '2', 'another_article_id' => '3', 'advertisement_id' => '1', 'title' => 'Second Home', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ))), - 'Advertisement' => array( + ]]], + 'Advertisement' => [ 'id' => '1', 'title' => 'First Ad', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', - 'Home' => array( - array( + 'Home' => [ + [ 'id' => '1', 'another_article_id' => '1', 'advertisement_id' => '1', 'title' => 'First Home', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => '2', 'another_article_id' => '3', 'advertisement_id' => '1', 'title' => 'Second Home', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ))))); + ]]]]]; $this->assertEquals($expected, $result); } @@ -6038,55 +6038,55 @@ public function testFindAllRecursiveWithHabtm() { $MyUser = new MyUser(); $MyUser->recursive = 2; - $result = $MyUser->find('all', array( + $result = $MyUser->find('all', [ 'order' => 'MyUser.id ASC' - )); - $expected = array( - array( - 'MyUser' => array('id' => '1', 'firstname' => 'userA'), - 'MyCategory' => array( - array( + ]); + $expected = [ + [ + 'MyUser' => ['id' => '1', 'firstname' => 'userA'], + 'MyCategory' => [ + [ 'id' => '1', 'name' => 'A', - 'MyProduct' => array( - array( + 'MyProduct' => [ + [ 'id' => '1', 'name' => 'book' - ))), - array( + ]]], + [ 'id' => '3', 'name' => 'C', - 'MyProduct' => array( - array( + 'MyProduct' => [ + [ 'id' => '2', 'name' => 'computer' - ))))), - array( - 'MyUser' => array( + ]]]]], + [ + 'MyUser' => [ 'id' => '2', 'firstname' => 'userB' - ), - 'MyCategory' => array( - array( + ], + 'MyCategory' => [ + [ 'id' => '1', 'name' => 'A', - 'MyProduct' => array( - array( + 'MyProduct' => [ + [ 'id' => '1', 'name' => 'book' - ))), - array( + ]]], + [ 'id' => '2', 'name' => 'B', - 'MyProduct' => array( - array( + 'MyProduct' => [ + [ 'id' => '1', 'name' => 'book' - ), - array( + ], + [ 'id' => '2', 'name' => 'computer' - )))))); + ]]]]]]; $this->assertEquals($expected, $result); } @@ -6105,51 +6105,51 @@ public function testReadFakeThread() { $TestModel->recursive = 6; $TestModel->id = 7; $result = $TestModel->read(); - $expected = array( - 'CategoryThread' => array( + $expected = [ + 'CategoryThread' => [ 'id' => 7, 'parent_id' => 6, 'name' => 'Category 2.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => 6, 'parent_id' => 5, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 5, 'parent_id' => 4, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 4, 'parent_id' => 3, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ))))))); + ]]]]]]]; $this->db->fullDebug = $fullDebug; $this->assertEquals($expected, $result); @@ -6167,53 +6167,53 @@ public function testFindFakeThread() { $fullDebug = $this->db->fullDebug; $this->db->fullDebug = true; $TestModel->recursive = 6; - $result = $TestModel->find('first', array('conditions' => array('CategoryThread.id' => 7))); + $result = $TestModel->find('first', ['conditions' => ['CategoryThread.id' => 7]]); - $expected = array( - 'CategoryThread' => array( + $expected = [ + 'CategoryThread' => [ 'id' => 7, 'parent_id' => 6, 'name' => 'Category 2.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => 6, 'parent_id' => 5, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 5, 'parent_id' => 4, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 4, 'parent_id' => 3, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ))))))); + ]]]]]]]; $this->db->fullDebug = $fullDebug; $this->assertEquals($expected, $result); @@ -6232,208 +6232,208 @@ public function testFindAllFakeThread() { $this->db->fullDebug = true; $TestModel->recursive = 6; $result = $TestModel->find('all'); - $expected = array( - array( - 'CategoryThread' => array( + $expected = [ + [ + 'CategoryThread' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => null, 'parent_id' => null, 'name' => null, 'created' => null, 'updated' => null, - 'ParentCategory' => array() - )), - array( - 'CategoryThread' => array( + 'ParentCategory' => [] + ]], + [ + 'CategoryThread' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array() - )), - array( - 'CategoryThread' => array( + 'ParentCategory' => [] + ]], + [ + 'CategoryThread' => [ 'id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array() - ))), - array( - 'CategoryThread' => array( + 'ParentCategory' => [] + ]]], + [ + 'CategoryThread' => [ 'id' => 4, 'parent_id' => 3, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array() - )))), - array( - 'CategoryThread' => array( + 'ParentCategory' => [] + ]]]], + [ + 'CategoryThread' => [ 'id' => 5, 'parent_id' => 4, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => 4, 'parent_id' => 3, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array() - ))))), - array( - 'CategoryThread' => array( + 'ParentCategory' => [] + ]]]]], + [ + 'CategoryThread' => [ 'id' => 6, 'parent_id' => 5, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => 5, 'parent_id' => 4, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 4, 'parent_id' => 3, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array() - )))))), - array( - 'CategoryThread' => array( + 'ParentCategory' => [] + ]]]]]], + [ + 'CategoryThread' => [ 'id' => 7, 'parent_id' => 6, 'name' => 'Category 2.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ), - 'ParentCategory' => array( + ], + 'ParentCategory' => [ 'id' => 6, 'parent_id' => 5, 'name' => 'Category 2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 5, 'parent_id' => 4, 'name' => 'Category 1.1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 4, 'parent_id' => 3, 'name' => 'Category 1.1.2', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 3, 'parent_id' => 2, 'name' => 'Category 1.1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 2, 'parent_id' => 1, 'name' => 'Category 1.1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31', - 'ParentCategory' => array( + 'ParentCategory' => [ 'id' => 1, 'parent_id' => 0, 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - )))))))); + ]]]]]]]]; $this->db->fullDebug = $fullDebug; $this->assertEquals($expected, $result); @@ -6447,11 +6447,11 @@ public function testFindAllFakeThread() { public function testConditionalNumerics() { $this->loadFixtures('NumericArticle'); $NumericArticle = new NumericArticle(); - $data = array('conditions' => array('title' => '12345abcde')); + $data = ['conditions' => ['title' => '12345abcde']]; $result = $NumericArticle->find('first', $data); $this->assertTrue(!empty($result)); - $data = array('conditions' => array('title' => '12345')); + $data = ['conditions' => ['title' => '12345']]; $result = $NumericArticle->find('first', $data); $this->assertTrue(empty($result)); } @@ -6466,21 +6466,21 @@ public function testBuildQuery() { $TestModel = new User(); $TestModel->cacheQueries = false; $TestModel->order = null; - $expected = array( - 'conditions' => array( + $expected = [ + 'conditions' => [ 'user' => 'larry' - ), + ], 'fields' => null, - 'joins' => array(), + 'joins' => [], 'limit' => null, 'offset' => null, - 'order' => array(), + 'order' => [], 'page' => 1, 'group' => null, 'callbacks' => true, 'returnQuery' => true - ); - $result = $TestModel->buildQuery('all', array('returnQuery' => true, 'conditions' => array('user' => 'larry'))); + ]; + $result = $TestModel->buildQuery('all', ['returnQuery' => true, 'conditions' => ['user' => 'larry']]); $this->assertEquals($expected, $result); } @@ -6492,66 +6492,66 @@ public function testBuildQueryAllI18nConditions() { $TestModel = new TranslatedArticle(); $TestModel->cacheQueries = false; $TestModel->locale = 'eng'; - $expected = array( - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + $expected = [ + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'fields' => null, - 'joins' => array( - array( + 'joins' => [ + [ 'type' => 'INNER', 'alias' => 'I18n__title', - 'table' => (object)array( + 'table' => (object)[ 'tablePrefix' => '', 'table' => 'article_i18n', 'schemaName' => $dbName - ), - 'conditions' => array( - 'TranslatedArticle.id' => (object)array( + ], + 'conditions' => [ + 'TranslatedArticle.id' => (object)[ 'type' => 'identifier', 'value' => 'I18n__title.foreign_key', - ), + ], 'I18n__title.model' => 'TranslatedArticle', 'I18n__title.field' => 'title', 'I18n__title.locale' => 'eng', - ), - ), - array( + ], + ], + [ 'type' => 'INNER', 'alias' => 'I18n__body', - 'table' => (object)array( + 'table' => (object)[ 'tablePrefix' => '', 'table' => 'article_i18n', 'schemaName' => $dbName - ), - 'conditions' => array( - 'TranslatedArticle.id' => (object)array( + ], + 'conditions' => [ + 'TranslatedArticle.id' => (object)[ 'type' => 'identifier', 'value' => 'I18n__body.foreign_key', - ), + ], 'I18n__body.model' => 'TranslatedArticle', 'I18n__body.field' => 'body', 'I18n__body.locale' => 'eng', - ), - ), - ), + ], + ], + ], 'limit' => 2, 'offset' => null, - 'order' => array( + 'order' => [ 'TranslatedArticle.id' => 'ASC', - ), + ], 'page' => 1, 'group' => null, 'callbacks' => true, 'recursive' => 0, - ); - $query = array( + ]; + $query = [ 'recursive' => 0, - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'limit' => 2, - ); + ]; $result = $TestModel->buildQuery('all', $query); $this->assertEquals($expected, $result); } @@ -6563,65 +6563,65 @@ public function testBuildQueryCountI18nConditions() { $TestModel = new TranslatedArticle(); $TestModel->cacheQueries = false; $TestModel->locale = 'eng'; - $expected = array( - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + $expected = [ + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'fields' => 'COUNT(DISTINCT(`TranslatedArticle`.`id`)) AS count', - 'joins' => array( - array( + 'joins' => [ + [ 'type' => 'INNER', 'alias' => 'TranslateArticleModel', - 'table' => (object)array( + 'table' => (object)[ 'tablePrefix' => '', 'table' => 'article_i18n', 'schemaName' => $dbName - ), - 'conditions' => array( - '`TranslatedArticle`.`id`' => (object)array( + ], + 'conditions' => [ + '`TranslatedArticle`.`id`' => (object)[ 'type' => 'identifier', 'value' => '`TranslateArticleModel`.`foreign_key`', - ), + ], '`TranslateArticleModel`.`model`' => 'TranslatedArticle', '`TranslateArticleModel`.`locale`' => 'eng', - ), - ), - array( + ], + ], + [ 'type' => 'INNER', 'alias' => 'I18n__title', - 'table' => (object)array( + 'table' => (object)[ 'tablePrefix' => '', 'table' => 'article_i18n', 'schemaName' => $dbName - ), - 'conditions' => array( - 'TranslatedArticle.id' => (object)array( + ], + 'conditions' => [ + 'TranslatedArticle.id' => (object)[ 'type' => 'identifier', 'value' => 'I18n__title.foreign_key', - ), + ], 'I18n__title.model' => 'TranslatedArticle', 'I18n__title.field' => 'title', 'I18n__title.locale' => 'eng', - ), - ), - ), + ], + ], + ], 'limit' => 2, 'offset' => null, - 'order' => array( + 'order' => [ 0 => false, - ), + ], 'page' => 1, 'group' => null, 'callbacks' => true, 'recursive' => 0, - ); - $query = array( + ]; + $query = [ 'recursive' => 0, - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'limit' => 2, - ); + ]; $result = $TestModel->buildQuery('count', $query); $this->assertEquals($expected, $result); } @@ -6637,220 +6637,220 @@ public function testFindAll() { $TestModel->cacheQueries = false; $result = $TestModel->find('all'); - $expected = array( - array( - 'User' => array( + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('conditions' => 'User.id > 2')); - $expected = array( - array( - 'User' => array( + $result = $TestModel->find('all', ['conditions' => 'User.id > 2']); + $expected = [ + [ + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array( - 'conditions' => array('User.id !=' => '0', 'User.user LIKE' => '%arr%') - )); - $expected = array( - array( - 'User' => array( + $result = $TestModel->find('all', [ + 'conditions' => ['User.id !=' => '0', 'User.user LIKE' => '%arr%'] + ]); + $expected = [ + [ + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('conditions' => array('User.id' => '0'))); - $expected = array(); + $result = $TestModel->find('all', ['conditions' => ['User.id' => '0']]); + $expected = []; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array( - 'conditions' => array('or' => array('User.id' => '0', 'User.user LIKE' => '%a%') - ))); + $result = $TestModel->find('all', [ + 'conditions' => ['or' => ['User.id' => '0', 'User.user LIKE' => '%a%'] + ]]); - $expected = array( - array( - 'User' => array( + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('fields' => 'User.id, User.user')); - $expected = array( - array('User' => array('id' => '1', 'user' => 'mariano')), - array('User' => array('id' => '2', 'user' => 'nate')), - array('User' => array('id' => '3', 'user' => 'larry')), - array('User' => array('id' => '4', 'user' => 'garrett'))); + $result = $TestModel->find('all', ['fields' => 'User.id, User.user']); + $expected = [ + ['User' => ['id' => '1', 'user' => 'mariano']], + ['User' => ['id' => '2', 'user' => 'nate']], + ['User' => ['id' => '3', 'user' => 'larry']], + ['User' => ['id' => '4', 'user' => 'garrett']]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('fields' => 'User.user', 'order' => 'User.user ASC')); - $expected = array( - array('User' => array('user' => 'garrett')), - array('User' => array('user' => 'larry')), - array('User' => array('user' => 'mariano')), - array('User' => array('user' => 'nate'))); + $result = $TestModel->find('all', ['fields' => 'User.user', 'order' => 'User.user ASC']); + $expected = [ + ['User' => ['user' => 'garrett']], + ['User' => ['user' => 'larry']], + ['User' => ['user' => 'mariano']], + ['User' => ['user' => 'nate']]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('fields' => 'User.user', 'order' => 'User.user DESC')); - $expected = array( - array('User' => array('user' => 'nate')), - array('User' => array('user' => 'mariano')), - array('User' => array('user' => 'larry')), - array('User' => array('user' => 'garrett'))); + $result = $TestModel->find('all', ['fields' => 'User.user', 'order' => 'User.user DESC']); + $expected = [ + ['User' => ['user' => 'nate']], + ['User' => ['user' => 'mariano']], + ['User' => ['user' => 'larry']], + ['User' => ['user' => 'garrett']]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('limit' => 3, 'page' => 1)); + $result = $TestModel->find('all', ['limit' => 3, 'page' => 1]); - $expected = array( - array( - 'User' => array( + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $ids = array(4 => 1, 5 => 3); - $result = $TestModel->find('all', array( - 'conditions' => array('User.id' => $ids), + $ids = [4 => 1, 5 => 3]; + $result = $TestModel->find('all', [ + 'conditions' => ['User.id' => $ids], 'order' => 'User.id' - )); - $expected = array( - array( - 'User' => array( + ]); + $expected = [ + [ + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - )), - array( - 'User' => array( + ]], + [ + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ))); + ]]]; $this->assertEquals($expected, $result); // These tests are expected to fail on SQL Server since the LIMIT/OFFSET // hack can't handle small record counts. if (!($this->db instanceof Sqlserver)) { - $result = $TestModel->find('all', array('limit' => 3, 'page' => 2)); - $expected = array( - array( - 'User' => array( + $result = $TestModel->find('all', ['limit' => 3, 'page' => 2]); + $expected = [ + [ + 'User' => [ 'id' => '4', 'user' => 'garrett', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array('limit' => 3, 'page' => 3)); - $expected = array(); + $result = $TestModel->find('all', ['limit' => 3, 'page' => 3]); + $expected = []; $this->assertEquals($expected, $result); } } @@ -6865,24 +6865,24 @@ public function testFindAllArrayConditions() { $TestModel = new User(); $TestModel->cacheQueries = false; - $result = $TestModel->find('all', array( - 'conditions' => array('User.id' => array(3)), - )); - $expected = array( - array( - 'User' => array( + $result = $TestModel->find('all', [ + 'conditions' => ['User.id' => [3]], + ]); + $expected = [ + [ + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - )) - ); + ]] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array( - 'conditions' => array('User.user' => array('larry')), - )); + $result = $TestModel->find('all', [ + 'conditions' => ['User.user' => ['larry']], + ]); $this->assertEquals($expected, $result); } @@ -6891,17 +6891,17 @@ public function testFindAllI18nConditions() { $TestModel = new TranslatedArticle(); $TestModel->cacheQueries = false; $TestModel->locale = 'eng'; - $options = array( + $options = [ 'recursive' => 0, - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'limit' => 2, - ); + ]; $result = $TestModel->find('all', $options); - $expected = array( - array( - 'TranslatedArticle' => array( + $expected = [ + [ + 'TranslatedArticle' => [ 'id' => '1', 'user_id' => '1', 'published' => 'Y', @@ -6910,17 +6910,17 @@ public function testFindAllI18nConditions() { 'locale' => 'eng', 'title' => 'Title (eng) #1', 'body' => 'Body (eng) #1', - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', - ), - ), - array( - 'TranslatedArticle' => array( + ], + ], + [ + 'TranslatedArticle' => [ 'id' => '2', 'user_id' => '3', 'published' => 'Y', @@ -6929,16 +6929,16 @@ public function testFindAllI18nConditions() { 'locale' => 'eng', 'title' => 'Title (eng) #2', 'body' => 'Body (eng) #2', - ), - 'User' => array( + ], + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $result); } @@ -6953,52 +6953,52 @@ public function testFindList() { $TestModel = new Article(); $TestModel->displayField = 'title'; - $result = $TestModel->find('list', array( + $result = $TestModel->find('list', [ 'order' => 'Article.title ASC' - )); + ]); - $expected = array( + $expected = [ 1 => 'First Article', 2 => 'Second Article', 3 => 'Third Article' - ); + ]; $this->assertEquals($expected, $result); $db = ConnectionManager::getDataSource('test'); if ($db instanceof Mysql) { - $result = $TestModel->find('list', array( - 'order' => array('FIELD(Article.id, 3, 2) ASC', 'Article.title ASC') - )); - $expected = array( + $result = $TestModel->find('list', [ + 'order' => ['FIELD(Article.id, 3, 2) ASC', 'Article.title ASC'] + ]); + $expected = [ 1 => 'First Article', 3 => 'Third Article', 2 => 'Second Article' - ); + ]; $this->assertEquals($expected, $result); } $result = Hash::combine( - $TestModel->find('all', array( + $TestModel->find('all', [ 'order' => 'Article.title ASC', - 'fields' => array('id', 'title') - )), + 'fields' => ['id', 'title'] + ]), '{n}.Article.id', '{n}.Article.title' ); - $expected = array( + $expected = [ 1 => 'First Article', 2 => 'Second Article', 3 => 'Third Article' - ); + ]; $this->assertEquals($expected, $result); $result = Hash::combine( - $TestModel->find('all', array( + $TestModel->find('all', [ 'order' => 'Article.title ASC' - )), + ]), '{n}.Article.id', '{n}.Article' ); - $expected = array( - 1 => array( + $expected = [ + 1 => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', @@ -7006,8 +7006,8 @@ public function testFindList() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 2 => array( + ], + 2 => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', @@ -7015,8 +7015,8 @@ public function testFindList() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 3 => array( + ], + 3 => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', @@ -7024,19 +7024,19 @@ public function testFindList() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - )); + ]]; $this->assertEquals($expected, $result); $result = Hash::combine( - $TestModel->find('all', array( + $TestModel->find('all', [ 'order' => 'Article.title ASC' - )), + ]), '{n}.Article.id', '{n}.Article', '{n}.Article.user_id' ); - $expected = array( - 1 => array( - 1 => array( + $expected = [ + 1 => [ + 1 => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', @@ -7044,8 +7044,8 @@ public function testFindList() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 3 => array( + ], + 3 => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', @@ -7053,9 +7053,9 @@ public function testFindList() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - )), - 3 => array( - 2 => array( + ]], + 3 => [ + 2 => [ 'id' => 2, 'user_id' => 3, 'title' => 'Second Article', @@ -7063,30 +7063,30 @@ public function testFindList() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ))); + ]]]; $this->assertEquals($expected, $result); $result = Hash::combine( - $TestModel->find('all', array( + $TestModel->find('all', [ 'order' => 'Article.title ASC', - 'fields' => array('id', 'title', 'user_id') - )), + 'fields' => ['id', 'title', 'user_id'] + ]), '{n}.Article.id', '{n}.Article.title', '{n}.Article.user_id' ); - $expected = array( - 1 => array( + $expected = [ + 1 => [ 1 => 'First Article', 3 => 'Third Article' - ), - 3 => array( + ], + 3 => [ 2 => 'Second Article' - )); + ]]; $this->assertEquals($expected, $result); $TestModel = new Apple(); - $expected = array( + $expected = [ 1 => 'Red Apple 1', 2 => 'Bright Red Apple', 3 => 'green blue', @@ -7094,126 +7094,126 @@ public function testFindList() { 5 => 'Blue Green', 6 => 'My new apple', 7 => 'Some odd color' - ); + ]; $this->assertEquals($expected, $TestModel->find('list')); $this->assertEquals($expected, $TestModel->Parent->find('list')); $TestModel = new Post(); - $result = $TestModel->find('list', array( + $result = $TestModel->find('list', [ 'fields' => 'Post.title' - )); - $expected = array( + ]); + $expected = [ 1 => 'First Post', 2 => 'Second Post', 3 => 'Third Post' - ); + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('list', array( + $result = $TestModel->find('list', [ 'fields' => 'title' - )); - $expected = array( + ]); + $expected = [ 1 => 'First Post', 2 => 'Second Post', 3 => 'Third Post' - ); + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('list', array( - 'fields' => array('title', 'id') - )); - $expected = array( + $result = $TestModel->find('list', [ + 'fields' => ['title', 'id'] + ]); + $expected = [ 'First Post' => '1', 'Second Post' => '2', 'Third Post' => '3' - ); + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('list', array( - 'fields' => array('title', 'id', 'created') - )); - $expected = array( - '2007-03-18 10:39:23' => array( + $result = $TestModel->find('list', [ + 'fields' => ['title', 'id', 'created'] + ]); + $expected = [ + '2007-03-18 10:39:23' => [ 'First Post' => '1' - ), - '2007-03-18 10:41:23' => array( + ], + '2007-03-18 10:41:23' => [ 'Second Post' => '2' - ), - '2007-03-18 10:43:23' => array( + ], + '2007-03-18 10:43:23' => [ 'Third Post' => '3' - ), - ); + ], + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('list', array( - 'fields' => array('Post.body') - )); - $expected = array( + $result = $TestModel->find('list', [ + 'fields' => ['Post.body'] + ]); + $expected = [ 1 => 'First Post Body', 2 => 'Second Post Body', 3 => 'Third Post Body' - ); + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('list', array( - 'fields' => array('Post.title', 'Post.body') - )); - $expected = array( + $result = $TestModel->find('list', [ + 'fields' => ['Post.title', 'Post.body'] + ]); + $expected = [ 'First Post' => 'First Post Body', 'Second Post' => 'Second Post Body', 'Third Post' => 'Third Post Body' - ); + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('list', array( - 'fields' => array('Post.id', 'Post.title', 'Author.user'), + $result = $TestModel->find('list', [ + 'fields' => ['Post.id', 'Post.title', 'Author.user'], 'recursive' => 1 - )); - $expected = array( - 'mariano' => array( + ]); + $expected = [ + 'mariano' => [ 1 => 'First Post', 3 => 'Third Post' - ), - 'larry' => array( + ], + 'larry' => [ 2 => 'Second Post' - )); + ]]; $this->assertEquals($expected, $result); $TestModel = new User(); - $result = $TestModel->find('list', array( - 'fields' => array('User.user', 'User.password') - )); - $expected = array( + $result = $TestModel->find('list', [ + 'fields' => ['User.user', 'User.password'] + ]); + $expected = [ 'mariano' => '5f4dcc3b5aa765d61d8327deb882cf99', 'nate' => '5f4dcc3b5aa765d61d8327deb882cf99', 'larry' => '5f4dcc3b5aa765d61d8327deb882cf99', 'garrett' => '5f4dcc3b5aa765d61d8327deb882cf99' - ); + ]; $this->assertEquals($expected, $result); $TestModel = new ModifiedAuthor(); - $result = $TestModel->find('list', array( - 'fields' => array('Author.id', 'Author.user') - )); - $expected = array( + $result = $TestModel->find('list', [ + 'fields' => ['Author.id', 'Author.user'] + ]); + $expected = [ 1 => 'mariano (CakePHP)', 2 => 'nate (CakePHP)', 3 => 'larry (CakePHP)', 4 => 'garrett (CakePHP)' - ); + ]; $this->assertEquals($expected, $result); $TestModel = new Article(); $TestModel->displayField = 'title'; - $result = $TestModel->find('list', array( - 'conditions' => array('User.user' => 'mariano'), + $result = $TestModel->find('list', [ + 'conditions' => ['User.user' => 'mariano'], 'recursive' => 0 - )); - $expected = array( + ]); + $expected = [ 1 => 'First Article', 3 => 'Third Article' - ); + ]; $this->assertEquals($expected, $result); } @@ -7227,21 +7227,21 @@ public function testFindListZeroValue() { $model = new Article(); $model->displayField = 'title'; - $model->save(array( + $model->save([ 'title' => 'Zeroth Article', 'user_id' => 0, 'published' => 'Y' - )); + ]); - $result = $model->find('list', array( - 'fields' => array('title', 'user_id') - )); - $expected = array( + $result = $model->find('list', [ + 'fields' => ['title', 'user_id'] + ]); + $expected = [ 'Zeroth Article' => 0, 'First Article' => 1, 'Second Article' => 3, 'Third Article' => 1, - ); + ]; $this->assertEquals($expected, $result); } @@ -7255,19 +7255,19 @@ public function testFindListArrayCondition() { $TestModel = new User(); $TestModel->cacheQueries = false; - $result = $TestModel->find('list', array( - 'fields' => array('id', 'user'), - 'conditions' => array('User.id' => array(3)), - )); - $expected = array( + $result = $TestModel->find('list', [ + 'fields' => ['id', 'user'], + 'conditions' => ['User.id' => [3]], + ]); + $expected = [ 3 => 'larry' - ); + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('list', array( - 'fields' => array('id', 'user'), - 'conditions' => array('User.user' => array('larry')), - )); + $result = $TestModel->find('list', [ + 'fields' => ['id', 'user'], + 'conditions' => ['User.user' => ['larry']], + ]); $this->assertEquals($expected, $result); } @@ -7288,9 +7288,9 @@ public function testFindField() { $this->assertEquals('mariano', $result); $TestModel->id = false; - $result = $TestModel->field('user', array( + $result = $TestModel->field('user', [ 'user' => 'mariano' - )); + ]); $this->assertEquals('mariano', $result); $TestModel->order = null; $result = $TestModel->field('COUNT(*) AS count', true); @@ -7300,9 +7300,9 @@ public function testFindField() { $this->assertEquals(4, $result); $TestModel->id = null; - $result = $TestModel->field('user', array( + $result = $TestModel->field('user', [ 'user' => 'mariano' - )); + ]); $this->assertEquals('mariano', $result); } @@ -7315,17 +7315,17 @@ public function testFindUnique() { $this->loadFixtures('User'); $TestModel = new User(); - $this->assertFalse($TestModel->isUnique(array( + $this->assertFalse($TestModel->isUnique([ 'user' => 'nate' - ))); + ])); $TestModel->id = 2; - $this->assertTrue($TestModel->isUnique(array( + $this->assertTrue($TestModel->isUnique([ 'user' => 'nate' - ))); - $this->assertFalse($TestModel->isUnique(array( + ])); + $this->assertFalse($TestModel->isUnique([ 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99' - ))); + ])); } /** @@ -7356,22 +7356,22 @@ public function testFindCount() { $Article = new Article(); $Article->order = null; $Article->recursive = -1; - $expected = count($Article->find('all', array( - 'fields' => array('Article.user_id'), - 'group' => 'Article.user_id') + $expected = count($Article->find('all', [ + 'fields' => ['Article.user_id'], + 'group' => 'Article.user_id'] )); - $result = $Article->find('count', array('group' => array('Article.user_id'))); + $result = $Article->find('count', ['group' => ['Article.user_id']]); $this->assertEquals($expected, $result); - $expected = count($Article->find('all', array( - 'fields' => array('Article.user_id'), - 'conditions' => array('Article.user_id' => 1), - 'group' => 'Article.user_id') - )); - $result = $Article->find('count', array( - 'conditions' => array('Article.user_id' => 1), - 'group' => array('Article.user_id'), + $expected = count($Article->find('all', [ + 'fields' => ['Article.user_id'], + 'conditions' => ['Article.user_id' => 1], + 'group' => 'Article.user_id'] )); + $result = $Article->find('count', [ + 'conditions' => ['Article.user_id' => 1], + 'group' => ['Article.user_id'], + ]); $this->assertEquals($expected, $result); } @@ -7380,13 +7380,13 @@ public function testFindCountI18nConditions() { $TestModel = new TranslatedArticle(); $TestModel->cacheQueries = false; $TestModel->locale = 'eng'; - $options = array( + $options = [ 'recursive' => 0, - 'conditions' => array( - 'NOT' => array('I18n__title.content' => ''), - ), + 'conditions' => [ + 'NOT' => ['I18n__title.content' => ''], + ], 'limit' => 2, - ); + ]; $result = $TestModel->find('count', $options); $this->assertEquals(3, $result); } @@ -7417,11 +7417,11 @@ public function testFindCountDistinct() { $this->loadFixtures('Project', 'Thread'); $TestModel = new Project(); - $TestModel->create(array('name' => 'project')) && $TestModel->save(); - $TestModel->create(array('name' => 'project')) && $TestModel->save(); - $TestModel->create(array('name' => 'project')) && $TestModel->save(); + $TestModel->create(['name' => 'project']) && $TestModel->save(); + $TestModel->create(['name' => 'project']) && $TestModel->save(); + $TestModel->create(['name' => 'project']) && $TestModel->save(); - $result = $TestModel->find('count', array('fields' => 'DISTINCT name')); + $result = $TestModel->find('count', ['fields' => 'DISTINCT name']); $this->assertEquals(4, $result); } @@ -7437,14 +7437,14 @@ public function testFindCountWithDbExpressions() { $db = ConnectionManager::getDataSource('test'); $TestModel = new Project(); - $result = $TestModel->find('count', array('conditions' => array( + $result = $TestModel->find('count', ['conditions' => [ $db->expression('Project.name = \'Project 3\'') - ))); + ]]); $this->assertEquals(1, $result); - $result = $TestModel->find('count', array('conditions' => array( + $result = $TestModel->find('count', ['conditions' => [ 'Project.name' => $db->expression('\'Project 3\'') - ))); + ]]); $this->assertEquals(1, $result); } @@ -7456,26 +7456,26 @@ public function testOrderWithDbExpressions() { $User = new User(); - $results = $User->find('all', array( - 'fields' => array('id'), + $results = $User->find('all', [ + 'fields' => ['id'], 'recursive' => -1, 'order' => $this->db->expression('CASE id WHEN 4 THEN 0 ELSE id END'), - )); - - $expected = array( - array( - 'User' => array('id' => 4), - ), - array( - 'User' => array('id' => 1), - ), - array( - 'User' => array('id' => 2), - ), - array( - 'User' => array('id' => 3), - ), - ); + ]); + + $expected = [ + [ + 'User' => ['id' => 4], + ], + [ + 'User' => ['id' => 1], + ], + [ + 'User' => ['id' => 2], + ], + [ + 'User' => ['id' => 3], + ], + ]; $this->assertEquals($expected, $results); } @@ -7490,32 +7490,32 @@ public function testFindMagic() { $TestModel = new User(); $result = $TestModel->findByUser('mariano'); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - )); + ]]; $this->assertEquals($expected, $result); $result = $TestModel->findByPassword('5f4dcc3b5aa765d61d8327deb882cf99'); - $expected = array('User' => array( + $expected = ['User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - )); + ]]; $this->assertEquals($expected, $result); $Comment = new Comment(); $Comment->recursive = -1; $results = $Comment->findAllByUserId(1); - $expected = array( - array( - 'Comment' => array( + $expected = [ + [ + 'Comment' => [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, @@ -7523,10 +7523,10 @@ public function testFindMagic() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ) - ), - array( - 'Comment' => array( + ] + ], + [ + 'Comment' => [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, @@ -7534,10 +7534,10 @@ public function testFindMagic() { 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( - 'Comment' => array( + ] + ], + [ + 'Comment' => [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, @@ -7545,15 +7545,15 @@ public function testFindMagic() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $results); $results = $Comment->findAllByUserIdAndPublished(1, 'Y'); - $expected = array( - array( - 'Comment' => array( + $expected = [ + [ + 'Comment' => [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, @@ -7561,10 +7561,10 @@ public function testFindMagic() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ) - ), - array( - 'Comment' => array( + ] + ], + [ + 'Comment' => [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, @@ -7572,24 +7572,24 @@ public function testFindMagic() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $results); $Article = new CustomArticle(); $Article->recursive = -1; $results = $Article->findListByUserId(1); - $expected = array( + $expected = [ 1 => 'First Article', 3 => 'Third Article' - ); + ]; $this->assertEquals($expected, $results); $results = $Article->findPublishedByUserId(1); - $expected = array( - array( - 'CustomArticle' => array( + $expected = [ + [ + 'CustomArticle' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', @@ -7597,10 +7597,10 @@ public function testFindMagic() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ), - array( - 'CustomArticle' => array( + ] + ], + [ + 'CustomArticle' => [ 'id' => 3, 'user_id' => 1, 'title' => 'Third Article', @@ -7608,13 +7608,13 @@ public function testFindMagic() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $results); $results = $Article->findUnPublishedByUserId(1); - $expected = array(); + $expected = []; $this->assertEquals($expected, $results); } @@ -7632,52 +7632,52 @@ public function testRead() { $TestModel->id = 2; $result = $TestModel->read(); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - )); + ]]; $this->assertEquals($expected, $result); $result = $TestModel->read(null, 2); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - )); + ]]; $this->assertEquals($expected, $result); $TestModel->id = 2; - $result = $TestModel->read(array('id', 'user')); - $expected = array('User' => array('id' => '2', 'user' => 'nate')); + $result = $TestModel->read(['id', 'user']); + $expected = ['User' => ['id' => '2', 'user' => 'nate']]; $this->assertEquals($expected, $result); $result = $TestModel->read('id, user', 2); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => '2', 'user' => 'nate' - )); + ]]; $this->assertEquals($expected, $result); - $result = $TestModel->bindModel(array('hasMany' => array('Article'))); + $result = $TestModel->bindModel(['hasMany' => ['Article']]); $this->assertTrue($result); $TestModel->id = 1; $result = $TestModel->read('id, user'); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => '1', 'user' => 'mariano' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -7685,8 +7685,8 @@ public function testRead() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => '3', 'user_id' => '1', 'title' => 'Third Article', @@ -7694,7 +7694,7 @@ public function testRead() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -7715,25 +7715,25 @@ public function testRecursiveRead() { ); $TestModel = new User(); - $result = $TestModel->bindModel(array('hasMany' => array('Article')), false); + $result = $TestModel->bindModel(['hasMany' => ['Article']], false); $this->assertTrue($result); $TestModel->recursive = 0; $result = $TestModel->read('id, user', 1); - $expected = array( - 'User' => array('id' => '1', 'user' => 'mariano'), - ); + $expected = [ + 'User' => ['id' => '1', 'user' => 'mariano'], + ]; $this->assertEquals($expected, $result); $TestModel->recursive = 1; $result = $TestModel->read('id, user', 1); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => '1', 'user' => 'mariano' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -7741,8 +7741,8 @@ public function testRecursiveRead() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - array( + ], + [ 'id' => '3', 'user_id' => '1', 'title' => 'Third Article', @@ -7750,18 +7750,18 @@ public function testRecursiveRead() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ))); + ]]]; $this->assertEquals($expected, $result); $TestModel->recursive = 2; $result = $TestModel->read('id, user', 3); - $expected = array( - 'User' => array( + $expected = [ + 'User' => [ 'id' => '3', 'user' => 'larry' - ), - 'Article' => array( - array( + ], + 'Article' => [ + [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -7769,15 +7769,15 @@ public function testRecursiveRead() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', - 'User' => array( + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -7785,8 +7785,8 @@ public function testRecursiveRead() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -7794,20 +7794,20 @@ public function testRecursiveRead() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - )), - 'Tag' => array( - array( + ]], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))))); + ]]]]]; $this->assertEquals($expected, $result); } @@ -7826,10 +7826,10 @@ public function testRecursiveFindAll() { ); $TestModel = new Article(); - $result = $TestModel->find('all', array('conditions' => array('Article.user_id' => 1))); - $expected = array( - array( - 'Article' => array( + $result = $TestModel->find('all', ['conditions' => ['Article.user_id' => 1]]); + $expected = [ + [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -7837,16 +7837,16 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -7854,8 +7854,8 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -7863,8 +7863,8 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - ), - array( + ], + [ 'id' => '3', 'article_id' => '1', 'user_id' => '1', @@ -7872,8 +7872,8 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:49:23', 'updated' => '2007-03-18 10:51:31' - ), - array( + ], + [ 'id' => '4', 'article_id' => '1', 'user_id' => '1', @@ -7881,23 +7881,23 @@ public function testRecursiveFindAll() { 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - 'Tag' => array( - array( + ] + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ))), - array( - 'Article' => array( + ]]], + [ + 'Article' => [ 'id' => '3', 'user_id' => '1', 'title' => 'Third Article', @@ -7905,29 +7905,29 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array(), - 'Tag' => array() - ) - ); + ], + 'Comment' => [], + 'Tag' => [] + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->find('all', array( - 'conditions' => array('Article.user_id' => 3), + $result = $TestModel->find('all', [ + 'conditions' => ['Article.user_id' => 3], 'limit' => 1, 'recursive' => 2 - )); + ]); - $expected = array( - array( - 'Article' => array( + $expected = [ + [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -7935,16 +7935,16 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -7952,7 +7952,7 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Article' => array( + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -7960,23 +7960,23 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => '1', 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ), - array( + ] + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -7984,7 +7984,7 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31', - 'Article' => array( + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -7992,58 +7992,58 @@ public function testRecursiveFindAll() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Attachment' => array() - ) - ), - 'Tag' => array( - array( + ], + 'Attachment' => [] + ] + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - )))); + ]]]]; $this->assertEquals($expected, $result); $Featured = new Featured(); $Featured->recursive = 2; - $Featured->bindModel(array( - 'belongsTo' => array( - 'ArticleFeatured' => array( + $Featured->bindModel([ + 'belongsTo' => [ + 'ArticleFeatured' => [ 'conditions' => "ArticleFeatured.published = 'Y'", 'fields' => 'id, title, user_id, published' - ) - ) - )); + ] + ] + ]); - $Featured->ArticleFeatured->unbindModel(array( - 'hasMany' => array('Attachment', 'Comment'), - 'hasAndBelongsToMany' => array('Tag')) + $Featured->ArticleFeatured->unbindModel([ + 'hasMany' => ['Attachment', 'Comment'], + 'hasAndBelongsToMany' => ['Tag']] ); $orderBy = 'ArticleFeatured.id ASC'; - $result = $Featured->find('all', array( + $result = $Featured->find('all', [ 'order' => $orderBy, 'limit' => 3 - )); + ]); - $expected = array( - array( - 'Featured' => array( + $expected = [ + [ + 'Featured' => [ 'id' => '1', 'article_featured_id' => '1', 'category_id' => '1', @@ -8051,21 +8051,21 @@ public function testRecursiveFindAll() { 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'ArticleFeatured' => array( + ], + 'ArticleFeatured' => [ 'id' => '1', 'title' => 'First Article', 'user_id' => '1', 'published' => 'Y', - 'User' => array( + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Category' => array(), - 'Featured' => array( + ], + 'Category' => [], + 'Featured' => [ 'id' => '1', 'article_featured_id' => '1', 'category_id' => '1', @@ -8073,16 +8073,16 @@ public function testRecursiveFindAll() { 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - 'Category' => array( + ]], + 'Category' => [ 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - )), - array( - 'Featured' => array( + ]], + [ + 'Featured' => [ 'id' => '2', 'article_featured_id' => '2', 'category_id' => '1', @@ -8090,21 +8090,21 @@ public function testRecursiveFindAll() { 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'ArticleFeatured' => array( + ], + 'ArticleFeatured' => [ 'id' => '2', 'title' => 'Second Article', 'user_id' => '3', 'published' => 'Y', - 'User' => array( + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Category' => array(), - 'Featured' => array( + ], + 'Category' => [], + 'Featured' => [ 'id' => '2', 'article_featured_id' => '2', 'category_id' => '1', @@ -8112,14 +8112,14 @@ public function testRecursiveFindAll() { 'end_date' => '2007-05-15 10:39:23', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - 'Category' => array( + ]], + 'Category' => [ 'id' => '1', 'parent_id' => '0', 'name' => 'Category 1', 'created' => '2007-03-18 15:30:23', 'updated' => '2007-03-18 15:32:31' - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -8134,12 +8134,12 @@ public function testRecursiveFindAllWithLimit() { $TestModel->hasMany['Comment']['limit'] = 2; - $result = $TestModel->find('all', array( - 'conditions' => array('Article.user_id' => 1) - )); - $expected = array( - array( - 'Article' => array( + $result = $TestModel->find('all', [ + 'conditions' => ['Article.user_id' => 1] + ]); + $expected = [ + [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', @@ -8147,16 +8147,16 @@ public function testRecursiveFindAllWithLimit() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', @@ -8164,8 +8164,8 @@ public function testRecursiveFindAllWithLimit() { 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31' - ), - array( + ], + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', @@ -8173,23 +8173,23 @@ public function testRecursiveFindAllWithLimit() { 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31' - ), - ), - 'Tag' => array( - array( + ], + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ))), - array( - 'Article' => array( + ]]], + [ + 'Article' => [ 'id' => '3', 'user_id' => '1', 'title' => 'Third Article', @@ -8197,30 +8197,30 @@ public function testRecursiveFindAllWithLimit() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Comment' => array(), - 'Tag' => array() - ) - ); + ], + 'Comment' => [], + 'Tag' => [] + ] + ]; $this->assertEquals($expected, $result); $TestModel->hasMany['Comment']['limit'] = 1; - $result = $TestModel->find('all', array( - 'conditions' => array('Article.user_id' => 3), + $result = $TestModel->find('all', [ + 'conditions' => ['Article.user_id' => 3], 'limit' => 1, 'recursive' => 2 - )); - $expected = array( - array( - 'Article' => array( + ]); + $expected = [ + [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -8228,16 +8228,16 @@ public function testRecursiveFindAllWithLimit() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -8245,7 +8245,7 @@ public function testRecursiveFindAllWithLimit() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31', - 'Article' => array( + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -8253,39 +8253,39 @@ public function testRecursiveFindAllWithLimit() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => '1', 'comment_id' => 5, 'attachment' => 'attachment.zip', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31' - ) - ) - ), - 'Tag' => array( - array( + ] + ] + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, $result); } @@ -8314,74 +8314,74 @@ public function testFindQueryTypeInCallbacks() { public function testVirtualFields() { $this->loadFixtures('Post', 'Author'); $Post = ClassRegistry::init('Post'); - $Post->virtualFields = array('two' => "1 + 1"); + $Post->virtualFields = ['two' => "1 + 1"]; $result = $Post->find('first'); $this->assertEquals(2, $result['Post']['two']); // SQL Server does not support operators in expressions if (!($this->db instanceof Sqlserver)) { - $Post->Author->virtualFields = array('false' => '1 = 2'); + $Post->Author->virtualFields = ['false' => '1 = 2']; $result = $Post->find('first'); $this->assertEquals(2, $result['Post']['two']); $this->assertFalse((bool)$result['Author']['false']); } - $result = $Post->find('first', array('fields' => array('author_id'))); + $result = $Post->find('first', ['fields' => ['author_id']]); $this->assertFalse(isset($result['Post']['two'])); $this->assertFalse(isset($result['Author']['false'])); - $result = $Post->find('first', array('fields' => array('author_id', 'two'))); + $result = $Post->find('first', ['fields' => ['author_id', 'two']]); $this->assertEquals(2, $result['Post']['two']); $this->assertFalse(isset($result['Author']['false'])); - $result = $Post->find('first', array('fields' => array('two'))); + $result = $Post->find('first', ['fields' => ['two']]); $this->assertEquals(2, $result['Post']['two']); $Post->id = 1; $result = $Post->field('two'); $this->assertEquals(2, $result); - $result = $Post->find('first', array( - 'conditions' => array('two' => 2), + $result = $Post->find('first', [ + 'conditions' => ['two' => 2], 'limit' => 1 - )); + ]); $this->assertEquals(2, $result['Post']['two']); - $result = $Post->find('first', array( - 'conditions' => array('two <' => 3), + $result = $Post->find('first', [ + 'conditions' => ['two <' => 3], 'limit' => 1 - )); + ]); $this->assertEquals(2, $result['Post']['two']); - $result = $Post->find('first', array( - 'conditions' => array('NOT' => array('two >' => 3)), + $result = $Post->find('first', [ + 'conditions' => ['NOT' => ['two >' => 3]], 'limit' => 1 - )); + ]); $this->assertEquals(2, $result['Post']['two']); $dbo = $Post->getDataSource(); - $Post->virtualFields = array('other_field' => 'Post.id + 1'); - $result = $Post->find('first', array( - 'conditions' => array('other_field' => 3), + $Post->virtualFields = ['other_field' => 'Post.id + 1']; + $result = $Post->find('first', [ + 'conditions' => ['other_field' => 3], 'limit' => 1 - )); + ]); $this->assertEquals(2, $result['Post']['id']); $Post->order = null; - $Post->virtualFields = array('other_field' => 'Post.id + 1'); - $result = $Post->find('all', array( - 'fields' => array($dbo->calculate($Post, 'max', array('other_field'))) - )); + $Post->virtualFields = ['other_field' => 'Post.id + 1']; + $result = $Post->find('all', [ + 'fields' => [$dbo->calculate($Post, 'max', ['other_field'])] + ]); $this->assertEquals(4, $result[0][0]['other_field']); ClassRegistry::flush(); - $Writing = ClassRegistry::init(array('class' => 'Post', 'alias' => 'Writing')); - $Writing->virtualFields = array('two' => "1 + 1"); + $Writing = ClassRegistry::init(['class' => 'Post', 'alias' => 'Writing']); + $Writing->virtualFields = ['two' => "1 + 1"]; $result = $Writing->find('first'); $this->assertEquals(2, $result['Writing']['two']); $Post->create(); - $Post->virtualFields = array('other_field' => 'COUNT(Post.id) + 1'); + $Post->virtualFields = ['other_field' => 'COUNT(Post.id) + 1']; $result = $Post->field('other_field'); $this->assertEquals(4, $result); } @@ -8399,20 +8399,20 @@ public function testVirtualFieldSubqueryReservedWords() { $ds = $user->getDataSource(); $sub = $ds->buildStatement( - array( - 'fields' => array('Table.user'), + [ + 'fields' => ['Table.user'], 'table' => $ds->fullTableName($user), 'alias' => 'Table', 'limit' => 1, - 'conditions' => array( + 'conditions' => [ "Table.id > 1" - ) - ), + ] + ], $user ); - $user->virtualFields = array( + $user->virtualFields = [ 'sub_test' => $sub - ); + ]; $result = $user->find('first'); $this->assertNotEmpty($result); @@ -8428,39 +8428,39 @@ public function testVirtualFieldSubqueryReservedWords() { public function testVirtualFieldsOrder() { $this->loadFixtures('Post', 'Author'); $Post = ClassRegistry::init('Post'); - $Post->virtualFields = array('other_field' => '10 - Post.id'); - $result = $Post->find('list', array('order' => array('Post.other_field' => 'ASC'))); - $expected = array( + $Post->virtualFields = ['other_field' => '10 - Post.id']; + $result = $Post->find('list', ['order' => ['Post.other_field' => 'ASC']]); + $expected = [ '3' => 'Third Post', '2' => 'Second Post', '1' => 'First Post' - ); + ]; $this->assertEquals($expected, $result); - $result = $Post->find('list', array('order' => array('Post.other_field' => 'DESC'))); - $expected = array( + $result = $Post->find('list', ['order' => ['Post.other_field' => 'DESC']]); + $expected = [ '1' => 'First Post', '2' => 'Second Post', '3' => 'Third Post' - ); + ]; $this->assertEquals($expected, $result); - $Post->Author->virtualFields = array('joined' => 'Post.id * Author.id'); - $result = $Post->find('all', array( - 'order' => array('Post.id' => 'ASC') - )); + $Post->Author->virtualFields = ['joined' => 'Post.id * Author.id']; + $result = $Post->find('all', [ + 'order' => ['Post.id' => 'ASC'] + ]); $result = Hash::extract($result, '{n}.Author.joined'); - $expected = array(1, 6, 3); + $expected = [1, 6, 3]; $this->assertEquals($expected, $result); - $result = $Post->find('all', array('order' => array('Author.joined' => 'ASC'))); + $result = $Post->find('all', ['order' => ['Author.joined' => 'ASC']]); $result = Hash::extract($result, '{n}.Author.joined'); - $expected = array(1, 3, 6); + $expected = [1, 3, 6]; $this->assertEquals($expected, $result); - $result = $Post->find('all', array('order' => array('Author.joined' => 'DESC'))); + $result = $Post->find('all', ['order' => ['Author.joined' => 'DESC']]); $result = Hash::extract($result, '{n}.Author.joined'); - $expected = array(6, 3, 1); + $expected = [6, 3, 1]; $this->assertEquals($expected, $result); } @@ -8470,20 +8470,20 @@ public function testVirtualFieldsMysqlGroup() { $this->loadFixtures('Post'); $Post = ClassRegistry::init('Post'); $Post->create(); - $Post->virtualFields = array( + $Post->virtualFields = [ 'low_title' => 'lower(Post.title)', 'unique_test_field' => 'COUNT(Post.id)', - ); - $expectation = array( - 'Post' => array( + ]; + $expectation = [ + 'Post' => [ 'low_title' => 'first post', 'unique_test_field' => 1, - ), - ); - $result = $Post->find('first', array( + ], + ]; + $result = $Post->find('first', [ 'fields' => array_keys($Post->virtualFields), - 'group' => array('low_title'), - )); + 'group' => ['low_title'], + ]); $this->assertEquals($expectation, $result); } @@ -8499,20 +8499,20 @@ public function testVirtualFieldsMysql() { $this->skipIf(!($this->db instanceof Mysql), 'The rest of virtualFields test only compatible with Mysql.'); $this->loadFixtures('Author'); $Author = ClassRegistry::init('Author'); - $Author->virtualFields = array( + $Author->virtualFields = [ 'full_name' => 'CONCAT(Author.user, " ", Author.id)' - ); - $result = $Author->find('first', array( - 'conditions' => array('Author.user' => 'mariano'), - 'fields' => array('Author.password', 'Author.full_name'), + ]; + $result = $Author->find('first', [ + 'conditions' => ['Author.user' => 'mariano'], + 'fields' => ['Author.password', 'Author.full_name'], 'recursive' => -1 - )); + ]); $this->assertTrue(isset($result['Author']['full_name'])); - $result = $Author->find('first', array( - 'conditions' => array('Author.user' => 'mariano'), - 'fields' => array('Author.full_name', 'Author.password'), + $result = $Author->find('first', [ + 'conditions' => ['Author.user' => 'mariano'], + 'fields' => ['Author.full_name', 'Author.password'], 'recursive' => -1 - )); + ]); $this->assertTrue(isset($result['Author']['full_name'])); } @@ -8524,9 +8524,9 @@ public function testVirtualFieldsMysql() { public function testVirtualFieldAsAString() { $this->loadFixtures('Post', 'Author'); $Post = new Post(); - $Post->virtualFields = array( + $Post->virtualFields = [ 'writer' => 'Author.user' - ); + ]; $result = $Post->find('first'); $this->assertTrue(isset($result['Post']['writer']), 'virtual field not fetched %s'); } @@ -8539,14 +8539,14 @@ public function testVirtualFieldAsAString() { public function testIsVirtualField() { $this->loadFixtures('Post'); $Post = ClassRegistry::init('Post'); - $Post->virtualFields = array('other_field' => 'COUNT(Post.id) + 1'); + $Post->virtualFields = ['other_field' => 'COUNT(Post.id) + 1']; $this->assertTrue($Post->isVirtualField('other_field')); $this->assertTrue($Post->isVirtualField('Post.other_field')); $this->assertFalse($Post->isVirtualField('Comment.other_field'), 'Other models should not match.'); $this->assertFalse($Post->isVirtualField('id')); $this->assertFalse($Post->isVirtualField('Post.id')); - $this->assertFalse($Post->isVirtualField(array())); + $this->assertFalse($Post->isVirtualField([])); } /** @@ -8557,7 +8557,7 @@ public function testIsVirtualField() { public function testGetVirtualField() { $this->loadFixtures('Post'); $Post = ClassRegistry::init('Post'); - $Post->virtualFields = array('other_field' => 'COUNT(Post.id) + 1'); + $Post->virtualFields = ['other_field' => 'COUNT(Post.id) + 1']; $this->assertEquals($Post->getVirtualField('other_field'), $Post->virtualFields['other_field']); $this->assertEquals($Post->getVirtualField('Post.other_field'), $Post->virtualFields['other_field']); @@ -8575,11 +8575,11 @@ public function testNotInArrayWithOneValue() { $result = $Article->find( 'all', - array( - 'conditions' => array( - 'Article.id NOT' => array(1) - ) - ) + [ + 'conditions' => [ + 'Article.id NOT' => [1] + ] + ] ); $this->assertTrue(is_array($result) && !empty($result)); } @@ -8596,11 +8596,11 @@ public function testNotEqualsInArrayWithOneValue() { $result = $Article->find( 'all', - array( - 'conditions' => array( - 'Article.id !=' => array(1) - ) - ) + [ + 'conditions' => [ + 'Article.id !=' => [1] + ] + ] ); $this->assertTrue(is_array($result) && !empty($result)); } @@ -8613,7 +8613,7 @@ public function testNotEqualsInArrayWithOneValue() { public function testfindCustom() { $this->loadFixtures('Article'); $Article = new CustomArticle(); - $data = array('user_id' => 3, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N'); + $data = ['user_id' => 3, 'title' => 'Fourth Article', 'body' => 'Article Body, unpublished', 'published' => 'N']; $Article->create($data); $Article->save(null, false); $this->assertEquals(4, $Article->id); @@ -8634,34 +8634,34 @@ public function testRelatedAfterFindCallback() { $this->loadFixtures('Something', 'SomethingElse', 'JoinThing'); $Something = new Something(); - $Something->bindModel(array( - 'hasMany' => array( - 'HasMany' => array( + $Something->bindModel([ + 'hasMany' => [ + 'HasMany' => [ 'className' => 'JoinThing', 'foreignKey' => 'something_id' - ) - ), - 'hasOne' => array( - 'HasOne' => array( + ] + ], + 'hasOne' => [ + 'HasOne' => [ 'className' => 'JoinThing', 'foreignKey' => 'something_id' - ) - ) - )); + ] + ] + ]); $results = $Something->find('all'); - $expected = array( - array( - 'Something' => array( + $expected = [ + [ + 'Something' => [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ), - 'HasOne' => array( + ], + 'HasOne' => [ 'id' => '1', 'something_id' => '1', 'something_else_id' => '2', @@ -8669,9 +8669,9 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'HasMany' => array( - array( + ], + 'HasMany' => [ + [ 'id' => '1', 'something_id' => '1', 'something_else_id' => '2', @@ -8679,10 +8679,10 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', 'afterFind' => 'Successfully added by AfterFind' - ) - ), - 'SomethingElse' => array( - array( + ] + ], + 'SomethingElse' => [ + [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', @@ -8690,25 +8690,25 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'afterFind' => 'Successfully added by AfterFind', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => true, 'something_id' => '1', 'something_else_id' => '2', 'afterFind' => 'Successfully added by AfterFind' - ) - ) - ) - ), - array( - 'Something' => array( + ] + ] + ] + ], + [ + 'Something' => [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'HasOne' => array( + ], + 'HasOne' => [ 'id' => '2', 'something_id' => '2', 'something_else_id' => '3', @@ -8716,9 +8716,9 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'HasMany' => array( - array( + ], + 'HasMany' => [ + [ 'id' => '2', 'something_id' => '2', 'something_else_id' => '3', @@ -8726,10 +8726,10 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'afterFind' => 'Successfully added by AfterFind' - ) - ), - 'SomethingElse' => array( - array( + ] + ], + 'SomethingElse' => [ + [ 'id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', @@ -8737,25 +8737,25 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', 'afterFind' => 'Successfully added by AfterFind', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => false, 'something_id' => '2', 'something_else_id' => '3', 'afterFind' => 'Successfully added by AfterFind' - ) - ) - ) - ), - array( - 'Something' => array( + ] + ] + ] + ], + [ + 'Something' => [ 'id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ), - 'HasOne' => array( + ], + 'HasOne' => [ 'id' => '3', 'something_id' => '3', 'something_else_id' => '1', @@ -8763,9 +8763,9 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'HasMany' => array( - array( + ], + 'HasMany' => [ + [ 'id' => '3', 'something_id' => '3', 'something_else_id' => '1', @@ -8773,10 +8773,10 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', 'afterFind' => 'Successfully added by AfterFind' - ) - ), - 'SomethingElse' => array( - array( + ] + ], + 'SomethingElse' => [ + [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', @@ -8784,29 +8784,29 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', 'afterFind' => 'Successfully added by AfterFind', - 'JoinThing' => array( + 'JoinThing' => [ 'doomed' => true, 'something_id' => '3', 'something_else_id' => '1', 'afterFind' => 'Successfully added by AfterFind' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $this->assertEquals($expected, $results, 'Model related with has* afterFind callback fails'); $JoinThing = new JoinThing(); - $JoinThing->unbindModel(array( - 'belongsTo' => array( + $JoinThing->unbindModel([ + 'belongsTo' => [ 'Something' - ) - )); + ] + ]); $results = $JoinThing->find('all'); - $expected = array( - array( - 'JoinThing' => array( + $expected = [ + [ + 'JoinThing' => [ 'id' => '1', 'something_id' => '1', 'something_else_id' => '2', @@ -8814,8 +8814,8 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'SomethingElse' => array( + ], + 'SomethingElse' => [ 'id' => '2', 'title' => 'Second Post', 'body' => 'Second Post Body', @@ -8823,10 +8823,10 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'afterFind' => 'Successfully added by AfterFind' - ) - ), - array( - 'JoinThing' => array( + ] + ], + [ + 'JoinThing' => [ 'id' => '2', 'something_id' => '2', 'something_else_id' => '3', @@ -8834,8 +8834,8 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'SomethingElse' => array( + ], + 'SomethingElse' => [ 'id' => '3', 'title' => 'Third Post', 'body' => 'Third Post Body', @@ -8843,10 +8843,10 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', 'afterFind' => 'Successfully added by AfterFind' - ) - ), - array( - 'JoinThing' => array( + ] + ], + [ + 'JoinThing' => [ 'id' => '3', 'something_id' => '3', 'something_else_id' => '1', @@ -8854,8 +8854,8 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', 'afterFind' => 'Successfully added by AfterFind' - ), - 'SomethingElse' => array( + ], + 'SomethingElse' => [ 'id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', @@ -8863,9 +8863,9 @@ public function testRelatedAfterFindCallback() { 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', 'afterFind' => 'Successfully added by AfterFind' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $results, 'Model related with belongsTo afterFind callback fails'); } @@ -8886,7 +8886,7 @@ public static function extractUserNameFromQueryResult(array $result) { */ public function testQueryRespectsCacheQueriesAsSecondArgument() { $model = new User(); - $model->save(array('user' => 'Chuck')); + $model->save(['user' => 'Chuck']); $userTableName = $this->db->fullTableName('users'); $getUserNameFromDb = function ($cacheArgument) use ($model, $userTableName) { @@ -8899,7 +8899,7 @@ public function testQueryRespectsCacheQueriesAsSecondArgument() { $this->assertSame('Chuck', $getUserNameFromDb(true)); $this->assertSame('Chuck', $getUserNameFromDb(false)); - $model->updateAll(array('User.user' => "'Sylvester'"), array('User.id' => $model->id)); + $model->updateAll(['User.user' => "'Sylvester'"], ['User.id' => $model->id]); $model->cacheQueries = false; $this->assertSame('Chuck', $getUserNameFromDb(true)); $this->assertSame('Sylvester', $getUserNameFromDb(false)); @@ -8913,12 +8913,12 @@ public function testQueryRespectsCacheQueriesAsSecondArgument() { */ public function testQueryRespectsCacheQueriesAsThirdArgument() { $model = new User(); - $model->save(array('user' => 'Chuck')); + $model->save(['user' => 'Chuck']); $userTableName = $this->db->fullTableName('users'); $getUserNameFromDb = function ($cacheArgument) use ($model, $userTableName) { $query = sprintf('SELECT u.user FROM %s u WHERE id=?', $userTableName); - $users = $model->query($query, array($model->id), $cacheArgument); + $users = $model->query($query, [$model->id], $cacheArgument); return ModelReadTest::extractUserNameFromQueryResult($users); }; @@ -8926,7 +8926,7 @@ public function testQueryRespectsCacheQueriesAsThirdArgument() { $this->assertSame('Chuck', $getUserNameFromDb(true)); $this->assertSame('Chuck', $getUserNameFromDb(false)); - $model->updateAll(array('User.user' => "'Sylvester'"), array('User.id' => $model->id)); + $model->updateAll(['User.user' => "'Sylvester'"], ['User.id' => $model->id]); $model->cacheQueries = false; $this->assertSame('Chuck', $getUserNameFromDb(true)); $this->assertSame('Sylvester', $getUserNameFromDb(false)); @@ -8939,7 +8939,7 @@ public function testQueryRespectsCacheQueriesAsThirdArgument() { */ public function testQueryTakesModelCacheQueriesValueAsDefaultForOneArgument() { $model = new User(); - $model->save(array('user' => 'Chuck')); + $model->save(['user' => 'Chuck']); $userTableName = $this->db->fullTableName('users'); $getUserNameFromDb = function () use ($model, $userTableName) { @@ -8950,7 +8950,7 @@ public function testQueryTakesModelCacheQueriesValueAsDefaultForOneArgument() { $model->cacheQueries = true; $this->assertSame('Chuck', $getUserNameFromDb()); - $model->updateAll(array('User.user' => "'Sylvester'"), array('User.id' => $model->id)); + $model->updateAll(['User.user' => "'Sylvester'"], ['User.id' => $model->id]); $this->assertSame('Chuck', $getUserNameFromDb()); $model->cacheQueries = false; @@ -8964,19 +8964,19 @@ public function testQueryTakesModelCacheQueriesValueAsDefaultForOneArgument() { */ public function testQueryTakesModelCacheQueriesValueAsDefaultForTwoArguments() { $model = new User(); - $model->save(array('user' => 'Chuck')); + $model->save(['user' => 'Chuck']); $userTableName = $this->db->fullTableName('users'); $getUserNameFromDb = function () use ($model, $userTableName) { $query = sprintf('SELECT u.user FROM %s u WHERE id=?', $userTableName); - $users = $model->query($query, array($model->id)); + $users = $model->query($query, [$model->id]); return ModelReadTest::extractUserNameFromQueryResult($users); }; $model->cacheQueries = true; $this->assertSame('Chuck', $getUserNameFromDb()); - $model->updateAll(array('User.user' => "'Sylvester'"), array('User.id' => $model->id)); + $model->updateAll(['User.user' => "'Sylvester'"], ['User.id' => $model->id]); $this->assertSame('Chuck', $getUserNameFromDb()); $model->cacheQueries = false; diff --git a/lib/Cake/Test/Case/Model/ModelTestBase.php b/lib/Cake/Test/Case/Model/ModelTestBase.php index 30f7efe3c2..a71f2eb7fa 100644 --- a/lib/Cake/Test/Case/Model/ModelTestBase.php +++ b/lib/Cake/Test/Case/Model/ModelTestBase.php @@ -19,7 +19,7 @@ App::uses('Model', 'Model'); App::uses('AppModel', 'Model'); -require_once dirname(__FILE__) . DS . 'models.php'; +require_once __DIR__ . DS . 'models.php'; /** * ModelBaseTest @@ -47,7 +47,7 @@ abstract class BaseModelTest extends CakeTestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.category', 'core.category_thread', 'core.user', 'core.my_category', 'core.my_product', 'core.my_user', 'core.my_categories_my_users', 'core.my_categories_my_products', 'core.article', 'core.featured', 'core.article_featureds_tags', 'core.article_featured', @@ -74,7 +74,7 @@ abstract class BaseModelTest extends CakeTestCase { 'core.uuidnativeitem', 'core.uuidnativeportfolio', 'core.uuidnativeitems_uuidnativeportfolio', 'core.uuidnativeitems_uuidnativeportfolio_numericid', 'core.translated_article', 'core.translate_article', - ); + ]; /** * setUp method diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 673d2dddf7..4f3e582c35 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -16,7 +16,7 @@ * @license https://opensource.org/licenses/mit-license.php MIT License */ -require_once dirname(__FILE__) . DS . 'ModelTestBase.php'; +require_once __DIR__ . DS . 'ModelTestBase.php'; /** * ModelValidationTest @@ -42,90 +42,90 @@ public function setUp() : void { */ public function testValidationParams() { $TestModel = new ValidationTest1(); - $TestModel->validate['title'] = array( + $TestModel->validate['title'] = [ 'rule' => 'customValidatorWithParams', 'required' => true - ); - $TestModel->create(array('title' => 'foo')); + ]; + $TestModel->create(['title' => 'foo']); $TestModel->invalidFields(); - $expected = array( - 'data' => array( + $expected = [ + 'data' => [ 'title' => 'foo' - ), - 'validator' => array( + ], + 'validator' => [ 'rule' => 'customValidatorWithParams', 'on' => null, 'last' => true, 'allowEmpty' => false, 'required' => true, 'message' => null - ), + ], 'or' => true, 'ignoreOnSame' => 'id' - ); + ]; $this->assertEquals($expected, $TestModel->validatorParams); - $TestModel->validate['title'] = array( + $TestModel->validate['title'] = [ 'rule' => 'customValidatorWithMessage', 'required' => true - ); - $expected = array( - 'title' => array('This field will *never* validate! Muhahaha!') - ); + ]; + $expected = [ + 'title' => ['This field will *never* validate! Muhahaha!'] + ]; $this->assertEquals($expected, $TestModel->invalidFields()); - $TestModel->validate['title'] = array( - 'rule' => array('customValidatorWithSixParams', 'one', 'two', null, 'four'), + $TestModel->validate['title'] = [ + 'rule' => ['customValidatorWithSixParams', 'one', 'two', null, 'four'], 'required' => true - ); - $TestModel->create(array('title' => 'foo')); + ]; + $TestModel->create(['title' => 'foo']); $TestModel->invalidFields(); - $expected = array( - 'data' => array( + $expected = [ + 'data' => [ 'title' => 'foo' - ), + ], 'one' => 'one', 'two' => 'two', 'three' => null, 'four' => 'four', - 'five' => array( - 'rule' => array(1 => 'one', 2 => 'two', 3 => null, 4 => 'four'), + 'five' => [ + 'rule' => [1 => 'one', 2 => 'two', 3 => null, 4 => 'four'], 'on' => null, 'last' => true, 'allowEmpty' => false, 'required' => true, 'message' => null - ), + ], 'six' => 6 - ); + ]; $this->assertEquals($expected, $TestModel->validatorParams); - $TestModel->validate['title'] = array( - 'rule' => array('customValidatorWithSixParams', 'one', array('two'), null, 'four', array('five' => 5)), + $TestModel->validate['title'] = [ + 'rule' => ['customValidatorWithSixParams', 'one', ['two'], null, 'four', ['five' => 5]], 'required' => true - ); - $TestModel->create(array('title' => 'foo')); + ]; + $TestModel->create(['title' => 'foo']); $TestModel->invalidFields(); - $expected = array( - 'data' => array( + $expected = [ + 'data' => [ 'title' => 'foo' - ), + ], 'one' => 'one', - 'two' => array('two'), + 'two' => ['two'], 'three' => null, 'four' => 'four', - 'five' => array('five' => 5), - 'six' => array( - 'rule' => array(1 => 'one', 2 => array('two'), 3 => null, 4 => 'four', 5 => array('five' => 5)), + 'five' => ['five' => 5], + 'six' => [ + 'rule' => [1 => 'one', 2 => ['two'], 3 => null, 4 => 'four', 5 => ['five' => 5]], 'on' => null, 'last' => true, 'allowEmpty' => false, 'required' => true, 'message' => null - ) - ); + ] + ]; $this->assertEquals($expected, $TestModel->validatorParams); } @@ -136,41 +136,41 @@ public function testValidationParams() { */ public function testInvalidFieldsWithFieldListParams() { $TestModel = new ValidationTest1(); - $TestModel->validate = $validate = array( - 'title' => array( + $TestModel->validate = $validate = [ + 'title' => [ 'rule' => 'alphaNumeric', 'required' => true - ), - 'name' => array( + ], + 'name' => [ 'rule' => 'alphaNumeric', 'required' => true - )); - $TestModel->set(array('title' => '$$', 'name' => '##')); - $TestModel->invalidFields(array('fieldList' => array('title'))); - $expected = array( - 'title' => array('This field cannot be left blank') - ); + ]]; + $TestModel->set(['title' => '$$', 'name' => '##']); + $TestModel->invalidFields(['fieldList' => ['title']]); + $expected = [ + 'title' => ['This field cannot be left blank'] + ]; $this->assertEquals($expected, $TestModel->validationErrors); - $TestModel->validationErrors = array(); + $TestModel->validationErrors = []; - $TestModel->invalidFields(array('fieldList' => array('name'))); - $expected = array( - 'name' => array('This field cannot be left blank') - ); + $TestModel->invalidFields(['fieldList' => ['name']]); + $expected = [ + 'name' => ['This field cannot be left blank'] + ]; $this->assertEquals($expected, $TestModel->validationErrors); - $TestModel->validationErrors = array(); + $TestModel->validationErrors = []; - $TestModel->invalidFields(array('fieldList' => array('name', 'title'))); - $expected = array( - 'name' => array('This field cannot be left blank'), - 'title' => array('This field cannot be left blank') - ); + $TestModel->invalidFields(['fieldList' => ['name', 'title']]); + $expected = [ + 'name' => ['This field cannot be left blank'], + 'title' => ['This field cannot be left blank'] + ]; $this->assertEquals($expected, $TestModel->validationErrors); - $TestModel->validationErrors = array(); + $TestModel->validationErrors = []; - $TestModel->whitelist = array('name'); + $TestModel->whitelist = ['name']; $TestModel->invalidFields(); - $expected = array('name' => array('This field cannot be left blank')); + $expected = ['name' => ['This field cannot be left blank']]; $this->assertEquals($expected, $TestModel->validationErrors); $this->assertEquals($TestModel->validate, $validate); @@ -183,20 +183,20 @@ public function testInvalidFieldsWithFieldListParams() { */ public function testInvalidFieldsWhitelist() { $TestModel = new ValidationTest1(); - $TestModel->validate = array( - 'title' => array( + $TestModel->validate = [ + 'title' => [ 'rule' => 'alphaNumeric', 'required' => true - ), - 'name' => array( + ], + 'name' => [ 'rule' => 'alphaNumeric', 'required' => true - )); + ]]; - $TestModel->whitelist = array('name'); - $TestModel->save(array('name' => '#$$#', 'title' => '$$$$')); + $TestModel->whitelist = ['name']; + $TestModel->save(['name' => '#$$#', 'title' => '$$$$']); - $expected = array('name' => array('This field cannot be left blank')); + $expected = ['name' => ['This field cannot be left blank']]; $this->assertEquals($expected, $TestModel->validationErrors); } @@ -208,347 +208,347 @@ public function testInvalidFieldsWhitelist() { public function testValidates() { $TestModel = new TestValidate(); - $TestModel->validate = array( + $TestModel->validate = [ 'user_id' => 'numeric', - 'title' => array('allowEmpty' => false, 'rule' => 'notBlank'), + 'title' => ['allowEmpty' => false, 'rule' => 'notBlank'], 'body' => 'notBlank' - ); + ]; - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => '', 'body' => 'body' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 'title', 'body' => 'body' - )); + ]]; $result = $TestModel->create($data) && $TestModel->validates(); $this->assertTrue($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => '0', 'body' => 'body' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $TestModel->validate['modified'] = array('allowEmpty' => true, 'rule' => 'date'); + $TestModel->validate['modified'] = ['allowEmpty' => true, 'rule' => 'date']; - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body', 'modified' => '' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body', 'modified' => '2007-05-01' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body', 'modified' => 'invalid-date-here' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body', 'modified' => 0 - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body', 'modified' => '0' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $TestModel->validate['modified'] = array('allowEmpty' => false, 'rule' => 'date'); + $TestModel->validate['modified'] = ['allowEmpty' => false, 'rule' => 'date']; - $data = array('TestValidate' => array('modified' => null)); + $data = ['TestValidate' => ['modified' => null]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array('modified' => false)); + $data = ['TestValidate' => ['modified' => false]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array('modified' => '')); + $data = ['TestValidate' => ['modified' => '']]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'modified' => '2007-05-01' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $TestModel->validate['slug'] = array('allowEmpty' => false, 'rule' => array('maxLength', 45)); + $TestModel->validate['slug'] = ['allowEmpty' => false, 'rule' => ['maxLength', 45]]; - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body', 'slug' => '' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body', 'slug' => 'slug-right-here' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'user_id' => '1', 'title' => 0, 'body' => 'body', 'slug' => 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $TestModel->validate = array( - 'number' => array( + $TestModel->validate = [ + 'number' => [ 'rule' => 'validateNumber', 'min' => 3, 'max' => 5 - ), - 'title' => array( + ], + 'title' => [ 'allowEmpty' => false, 'rule' => 'notBlank' - )); + ]]; - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'title' => 'title', 'number' => '0' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'title' => 'title', 'number' => 0 - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'title' => 'title', 'number' => '3' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'title' => 'title', 'number' => 3 - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $TestModel->validate = array( - 'number' => array( + $TestModel->validate = [ + 'number' => [ 'rule' => 'validateNumber', 'min' => 5, 'max' => 10 - ), - 'title' => array( + ], + 'title' => [ 'allowEmpty' => false, 'rule' => 'notBlank' - )); + ]]; - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'title' => 'title', 'number' => '3' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'title' => 'title', 'number' => 3 - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $TestModel->validate = array( - 'title' => array( + $TestModel->validate = [ + 'title' => [ 'allowEmpty' => false, 'rule' => 'validateTitle' - )); + ]]; - $data = array('TestValidate' => array('title' => '')); + $data = ['TestValidate' => ['title' => '']]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array('title' => 'new title')); + $data = ['TestValidate' => ['title' => 'new title']]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array('title' => 'title-new')); + $data = ['TestValidate' => ['title' => 'title-new']]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $TestModel->validate = array('title' => array( + $TestModel->validate = ['title' => [ 'allowEmpty' => true, 'rule' => 'validateTitle' - )); - $data = array('TestValidate' => array('title' => '')); + ]]; + $data = ['TestValidate' => ['title' => '']]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $TestModel->validate = array( - 'title' => array( - 'length' => array( + $TestModel->validate = [ + 'title' => [ + 'length' => [ 'allowEmpty' => true, - 'rule' => array('maxLength', 10) - ))); - $data = array('TestValidate' => array('title' => '')); + 'rule' => ['maxLength', 10] + ]]]; + $data = ['TestValidate' => ['title' => '']]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $TestModel->validate = array( - 'title' => array( - 'rule' => array('userDefined', 'Article', 'titleDuplicate') - )); - $data = array('TestValidate' => array('title' => 'My Article Title')); + $TestModel->validate = [ + 'title' => [ + 'rule' => ['userDefined', 'Article', 'titleDuplicate'] + ]]; + $data = ['TestValidate' => ['title' => 'My Article Title']]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array('TestValidate' => array( + $data = ['TestValidate' => [ 'title' => 'My Article With a Different Title' - )); + ]]; $result = $TestModel->create($data); $this->assertEquals($data, $result); $result = $TestModel->validates(); $this->assertTrue($result); - $TestModel->validate = array( - 'title' => array( - 'tooShort' => array('rule' => array('minLength', 50)), - 'onlyLetters' => array('rule' => '/^[a-z]+$/i') - ), - ); - $data = array('TestValidate' => array( + $TestModel->validate = [ + 'title' => [ + 'tooShort' => ['rule' => ['minLength', 50]], + 'onlyLetters' => ['rule' => '/^[a-z]+$/i'] + ], + ]; + $data = ['TestValidate' => [ 'title' => 'I am a short string' - )); + ]]; $TestModel->create($data); $result = $TestModel->validates(); $this->assertFalse($result); $result = $TestModel->validationErrors; - $expected = array( - 'title' => array('tooShort') - ); + $expected = [ + 'title' => ['tooShort'] + ]; $this->assertEquals($expected, $result); - $TestModel->validate = array( - 'title' => array( - 'tooShort' => array( - 'rule' => array('minLength', 50), + $TestModel->validate = [ + 'title' => [ + 'tooShort' => [ + 'rule' => ['minLength', 50], 'last' => false - ), - 'onlyLetters' => array('rule' => '/^[a-z]+$/i') - ), - ); - $data = array('TestValidate' => array( + ], + 'onlyLetters' => ['rule' => '/^[a-z]+$/i'] + ], + ]; + $data = ['TestValidate' => [ 'title' => 'I am a short string' - )); + ]]; $TestModel->create($data); $result = $TestModel->validates(); $this->assertFalse($result); $result = $TestModel->validationErrors; - $expected = array( - 'title' => array('tooShort', 'onlyLetters') - ); + $expected = [ + 'title' => ['tooShort', 'onlyLetters'] + ]; $this->assertEquals($expected, $result); $result = $TestModel->validationErrors; $this->assertEquals($expected, $result); @@ -561,32 +561,32 @@ public function testValidates() { */ public function testValidatesWithNoTable() { $TestModel = new TheVoid(); - $TestModel->validate = array( - 'title' => array( - 'notEmpty' => array( - 'rule' => array('notBlank'), + $TestModel->validate = [ + 'title' => [ + 'notEmpty' => [ + 'rule' => ['notBlank'], 'required' => true, - ), - 'tooShort' => array( - 'rule' => array('minLength', 10), - ), - ), - ); - $data = array( - 'TheVoid' => array( + ], + 'tooShort' => [ + 'rule' => ['minLength', 10], + ], + ], + ]; + $data = [ + 'TheVoid' => [ 'title' => 'too short', - ), - ); + ], + ]; $TestModel->create($data); $result = $TestModel->validates(); $this->assertFalse($result); - $data = array( - 'TheVoid' => array( + $data = [ + 'TheVoid' => [ 'id' => '1', 'title' => 'A good title', - ), - ); + ], + ]; $TestModel->create($data); $result = $TestModel->validates(); $this->assertTrue($result); @@ -600,51 +600,51 @@ public function testValidatesWithNoTable() { */ public function testValidatesWithAssociations() { $this->loadFixtures('Something', 'SomethingElse', 'JoinThing'); - $data = array( - 'Something' => array( + $data = [ + 'Something' => [ 'id' => 5, 'title' => 'Extra Fields', 'body' => 'Extra Fields Body', 'published' => '1' - ), - 'SomethingElse' => array( - array('something_else_id' => 1, 'doomed' => '') - ) - ); + ], + 'SomethingElse' => [ + ['something_else_id' => 1, 'doomed' => ''] + ] + ]; $Something = new Something(); $JoinThing = $Something->JoinThing; - $JoinThing->validate = array('doomed' => array('rule' => 'notBlank')); + $JoinThing->validate = ['doomed' => ['rule' => 'notBlank']]; - $expectedError = array('doomed' => array('This field cannot be left blank')); + $expectedError = ['doomed' => ['This field cannot be left blank']]; $Something->create(); $result = $Something->save($data); $this->assertFalse($result, 'Save occurred even when with models failed. %s'); $this->assertEquals($expectedError, $JoinThing->validationErrors); - $count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id']))); + $count = $Something->find('count', ['conditions' => ['Something.id' => $data['Something']['id']]]); $this->assertSame(0, $count); - $data = array( - 'Something' => array( + $data = [ + 'Something' => [ 'id' => 5, 'title' => 'Extra Fields', 'body' => 'Extra Fields Body', 'published' => '1' - ), - 'SomethingElse' => array( - array('something_else_id' => 1, 'doomed' => 1), - array('something_else_id' => 1, 'doomed' => '') - ) - ); + ], + 'SomethingElse' => [ + ['something_else_id' => 1, 'doomed' => 1], + ['something_else_id' => 1, 'doomed' => ''] + ] + ]; $Something->create(); $result = $Something->save($data); $this->assertFalse($result, 'Save occurred even when with models failed. %s'); - $joinRecords = $JoinThing->find('count', array( - 'conditions' => array('JoinThing.something_id' => $data['Something']['id']) - )); + $joinRecords = $JoinThing->find('count', [ + 'conditions' => ['JoinThing.something_id' => $data['Something']['id']] + ]); $this->assertEquals(0, $joinRecords, 'Records were saved on the join table. %s'); } @@ -656,23 +656,23 @@ public function testValidatesWithAssociations() { */ public function testValidateWithFieldListAndBehavior() { $TestModel = new ValidationTest1(); - $TestModel->validate = array( - 'title' => array( + $TestModel->validate = [ + 'title' => [ 'rule' => 'notBlank', - ), - 'name' => array( + ], + 'name' => [ 'rule' => 'notBlank', - )); - $TestModel->Behaviors->attach('ValidationRule', array('fields' => array('name'))); + ]]; + $TestModel->Behaviors->attach('ValidationRule', ['fields' => ['name']]); - $data = array( + $data = [ 'title' => '', 'name' => '', - ); - $result = $TestModel->save($data, array('fieldList' => array('title'))); + ]; + $result = $TestModel->save($data, ['fieldList' => ['title']]); $this->assertFalse($result); - $expected = array('title' => array('This field cannot be left blank'), 'name' => array('This field cannot be left blank')); + $expected = ['title' => ['This field cannot be left blank'], 'name' => ['This field cannot be left blank']]; $this->assertEquals($expected, $TestModel->validationErrors); } @@ -683,25 +683,25 @@ public function testValidateWithFieldListAndBehavior() { */ public function testValidatesWithModelsAndSaveAll() { $this->loadFixtures('Something', 'SomethingElse', 'JoinThing'); - $data = array( - 'Something' => array( + $data = [ + 'Something' => [ 'id' => 5, 'title' => 'Extra Fields', 'body' => 'Extra Fields Body', 'published' => '1' - ), - 'SomethingElse' => array( - array('something_else_id' => 1, 'doomed' => '') - ) - ); + ], + 'SomethingElse' => [ + ['something_else_id' => 1, 'doomed' => ''] + ] + ]; $Something = new Something(); $JoinThing = $Something->JoinThing; - $JoinThing->validate = array('doomed' => array('rule' => 'notBlank')); - $expectedError = array('doomed' => array('This field cannot be left blank')); + $JoinThing->validate = ['doomed' => ['rule' => 'notBlank']]; + $expectedError = ['doomed' => ['This field cannot be left blank']]; $Something->create(); - $result = $Something->saveAll($data, array('validate' => 'only')); + $result = $Something->saveAll($data, ['validate' => 'only']); $this->assertFalse($result); $result = $Something->validateAssociated($data); $this->assertFalse($result); @@ -710,16 +710,16 @@ public function testValidatesWithModelsAndSaveAll() { $this->assertFalse($result); $Something->create(); - $result = $Something->saveAll($data, array('validate' => 'first')); + $result = $Something->saveAll($data, ['validate' => 'first']); $this->assertFalse($result); $this->assertEquals($expectedError, $JoinThing->validationErrors); - $count = $Something->find('count', array('conditions' => array('Something.id' => $data['Something']['id']))); + $count = $Something->find('count', ['conditions' => ['Something.id' => $data['Something']['id']]]); $this->assertSame(0, $count); - $joinRecords = $JoinThing->find('count', array( - 'conditions' => array('JoinThing.something_id' => $data['Something']['id']) - )); + $joinRecords = $JoinThing->find('count', [ + 'conditions' => ['JoinThing.something_id' => $data['Something']['id']] + ]); $this->assertEquals(0, $joinRecords, 'Records were saved on the join table. %s'); } @@ -732,39 +732,39 @@ public function testValidatesWithModelsAndSaveAll() { public function testValidatesWithModelsAndSaveAllWithoutId() { $this->loadFixtures('Post', 'Author'); - $data = array( - 'Author' => array( + $data = [ + 'Author' => [ 'name' => 'Foo Bar', - ), - 'Post' => array( - array('title' => 'Hello'), - array('title' => 'World'), - ) - ); + ], + 'Post' => [ + ['title' => 'Hello'], + ['title' => 'World'], + ] + ]; $Author = new Author(); $Post = $Author->Post; - $Post->validate = array('author_id' => array('rule' => 'numeric')); + $Post->validate = ['author_id' => ['rule' => 'numeric']]; $Author->create(); - $result = $Author->saveAll($data, array('validate' => 'only')); + $result = $Author->saveAll($data, ['validate' => 'only']); $this->assertTrue($result); $result = $Author->validateAssociated($data); $this->assertTrue($result); $this->assertTrue($result); $Author->create(); - $result = $Author->saveAll($data, array('validate' => 'first')); + $result = $Author->saveAll($data, ['validate' => 'first']); $this->assertTrue($result); $this->assertNotNull($Author->id); $id = $Author->id; - $count = $Author->find('count', array('conditions' => array('Author.id' => $id))); + $count = $Author->find('count', ['conditions' => ['Author.id' => $id]]); $this->assertSame(1, $count); - $count = $Post->find('count', array( - 'conditions' => array('Post.author_id' => $id) - )); + $count = $Post->find('count', [ + 'conditions' => ['Post.author_id' => $id] + ]); $this->assertEquals($count, count($data['Post'])); } @@ -779,14 +779,14 @@ public function testMissingValidationErrorTriggering() { Configure::write('debug', 2); $TestModel = new ValidationTest1(); - $TestModel->create(array('title' => 'foo')); - $TestModel->validate = array( - 'title' => array( - 'rule' => array('thisOneBringsThePain'), + $TestModel->create(['title' => 'foo']); + $TestModel->validate = [ + 'title' => [ + 'rule' => ['thisOneBringsThePain'], 'required' => true - ) - ); - $TestModel->invalidFields(array('fieldList' => array('title'))); + ] + ]; + $TestModel->invalidFields(['fieldList' => ['title']]); } /** @@ -796,37 +796,37 @@ public function testMissingValidationErrorTriggering() { */ public function testValidationMessageAsArray() { $TestModel = new ValidationTest1(); - $TestModel->validate = array( - 'title' => array( - 'minLength' => array( - 'rule' => array('minLength', 6), + $TestModel->validate = [ + 'title' => [ + 'minLength' => [ + 'rule' => ['minLength', 6], 'required' => true, 'message' => 'Minimum length allowed is %d chars', 'last' => false - ), - 'between' => array( - 'rule' => array('lengthBetween', 5, 15), - 'message' => array('You may enter up to %s chars (minimum is %s chars)', 14, 6) - ) - ) - ); + ], + 'between' => [ + 'rule' => ['lengthBetween', 5, 15], + 'message' => ['You may enter up to %s chars (minimum is %s chars)', 14, 6] + ] + ] + ]; $TestModel->create(); - $expected = array( - 'title' => array( + $expected = [ + 'title' => [ 'Minimum length allowed is 6 chars', - ) - ); + ] + ]; $TestModel->invalidFields(); $this->assertEquals($expected, $TestModel->validationErrors); - $TestModel->create(array('title' => 'foo')); - $expected = array( - 'title' => array( + $TestModel->create(['title' => 'foo']); + $expected = [ + 'title' => [ 'Minimum length allowed is 6 chars', 'You may enter up to 14 chars (minimum is 6 chars)' - ) - ); + ] + ]; $TestModel->invalidFields(); $this->assertEquals($expected, $TestModel->validationErrors); } @@ -839,28 +839,28 @@ public function testValidationMessageAsArray() { public function testValidationMessageTranslation() { $lang = Configure::read('Config.language'); Configure::write('Config.language', 'en'); - App::build(array( - 'Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS), - ), App::RESET); + App::build([ + 'Locale' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS], + ], App::RESET); $TestModel = new ValidationTest1(); $TestModel->validationDomain = 'validation_messages'; - $TestModel->validate = array( - 'title' => array( - array( - 'rule' => array('customValidationMethod', 'arg1'), + $TestModel->validate = [ + 'title' => [ + [ + 'rule' => ['customValidationMethod', 'arg1'], 'required' => true, 'message' => 'Validation failed: %s' - ) - ) - ); + ] + ] + ]; $TestModel->create(); - $expected = array( - 'title' => array( + $expected = [ + 'title' => [ 'Translated validation failed: Translated arg1', - ) - ); + ] + ]; $TestModel->invalidFields(); $this->assertEquals($expected, $TestModel->validationErrors); @@ -878,45 +878,45 @@ public function testStateValidation() { $this->loadFixtures('Article'); $Article = new Article(); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'title' => '', 'body' => 'Extra Fields Body', 'published' => '1' - ) - ); + ] + ]; - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'on' => 'create' - ) - ) - ); + ] + ] + ]; $Article->create($data); $this->assertFalse($Article->validates()); - $Article->save(null, array('validate' => false)); + $Article->save(null, ['validate' => false]); $data['Article']['id'] = $Article->id; $Article->set($data); $this->assertTrue($Article->validates()); unset($data['Article']['id']); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'on' => 'update' - ) - ) - ); + ] + ] + ]; $Article->create($data); $this->assertTrue($Article->validates()); - $Article->save(null, array('validate' => false)); + $Article->save(null, ['validate' => false]); $data['Article']['id'] = $Article->id; $Article->set($data); $this->assertFalse($Article->validates()); @@ -932,44 +932,44 @@ public function testStateRequiredValidation() { $Article = new Article(); // no title field present - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'body' => 'Extra Fields Body', 'published' => '1' - ) - ); + ] + ]; - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'create' - ) - ) - ); + ] + ] + ]; $Article->create($data); $this->assertFalse($Article->validates()); - $Article->save(null, array('validate' => false)); + $Article->save(null, ['validate' => false]); $data['Article']['id'] = $Article->id; $Article->set($data); $this->assertTrue($Article->validates()); unset($data['Article']['id']); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'update' - ) - ) - ); + ] + ] + ]; $Article->create($data); $this->assertTrue($Article->validates()); - $Article->save(null, array('validate' => false)); + $Article->save(null, ['validate' => false]); $data['Article']['id'] = $Article->id; $Article->set($data); $this->assertFalse($Article->validates()); @@ -985,115 +985,115 @@ public function testOnRequiredConflictValidation() { $Article = new Article(); // no title field present - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'body' => 'Extra Fields Body', 'published' => '1' - ) - ); + ] + ]; - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'create', 'on' => 'create' - ) - ) - ); + ] + ] + ]; $Article->create($data); $this->assertFalse($Article->validates()); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'update', 'on' => 'create' - ) - ) - ); + ] + ] + ]; $Article->create($data); $this->assertTrue($Article->validates()); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'create', 'on' => 'update' - ) - ) - ); + ] + ] + ]; $Article->create($data); $this->assertTrue($Article->validates()); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'update', 'on' => 'update' - ) - ) - ); + ] + ] + ]; $Article->create($data); $this->assertTrue($Article->validates()); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'create', 'on' => 'create' - ) - ) - ); + ] + ] + ]; - $Article->save(null, array('validate' => false)); + $Article->save(null, ['validate' => false]); $data['Article']['id'] = $Article->id; $Article->set($data); $this->assertTrue($Article->validates()); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'update', 'on' => 'create' - ) - ) - ); + ] + ] + ]; $Article->set($data); $this->assertTrue($Article->validates()); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'create', 'on' => 'update' - ) - ) - ); + ] + ] + ]; $Article->set($data); $this->assertTrue($Article->validates()); - $Article->validate = array( - 'title' => array( - 'notBlank' => array( + $Article->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => 'update', 'on' => 'update' - ) - ) - ); + ] + ] + ]; $Article->set($data); $this->assertFalse($Article->validates()); @@ -1108,322 +1108,322 @@ public function testOnRequiredConflictValidation() { public function testSaveAllDeepValidateOnly() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->hasAndBelongsToMany = array(); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->hasAndBelongsToMany = []; $TestModel->Comment->Attachment->validate['attachment'] = 'notBlank'; $TestModel->Comment->validate['comment'] = 'notBlank'; - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => 'newuser', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'deep' => true)); + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => 'newuser', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertTrue($result); - $result = $TestModel->validateAssociated($data, array('deep' => true)); + $result = $TestModel->validateAssociated($data, ['deep' => true]); $this->assertTrue($result); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'deep' => true)); + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); - $result = $TestModel->validateAssociated($data, array('deep' => true)); + $result = $TestModel->validateAssociated($data, ['deep' => true]); $this->assertFalse($result); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => 'newuser', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ); - $expected = array( + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => 'newuser', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]; + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, true - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $result = $TestModel->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ); - $expected = array( + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]; + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ false, true - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $result = $TestModel->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => 'deepsaved')) - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'deep' => true)); + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => 'deepsaved']] + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertTrue($result); - $result = $TestModel->validateAssociated($data, array('deep' => true)); + $result = $TestModel->validateAssociated($data, ['deep' => true]); $this->assertTrue($result); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => '')) - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'deep' => true)); + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => '']] + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); - $result = $TestModel->validateAssociated($data, array('deep' => true)); + $result = $TestModel->validateAssociated($data, ['deep' => true]); $this->assertFalse($result); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => 'deepsave')) - ) - ); - $expected = array( + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => 'deepsave']] + ] + ]; + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, true - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $result = $TestModel->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => '')) - ) - ); - $expected = array( + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => '']] + ] + ]; + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, false - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $result = $TestModel->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $expected = array( - 'Comment' => array( - 1 => array( - 'Attachment' => array( - 'attachment' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'Comment' => [ + 1 => [ + 'Attachment' => [ + 'attachment' => ['This field cannot be left blank'] + ] + ] + ] + ]; $result = $TestModel->validationErrors; $this->assertSame($expected, $result); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'First comment deepsave insert', 'published' => 'Y', 'user_id' => 5, - 'Article' => array( + 'Article' => [ 'title' => 'First Article deepsave insert', 'body' => 'First Article Body deepsave insert', - 'User' => array( + 'User' => [ 'user' => 'deepsave', 'password' => 'magic' - ), - ), - ) - ); + ], + ], + ] + ]; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertTrue($result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['deep' => true]); $this->assertTrue($result); - $expected = array( + $expected = [ 'Attachment' => true, 'Comment' => true - ); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ]; + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertSame($expected, $result); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'First comment deepsave insert', 'published' => 'Y', 'user_id' => 5, - 'Article' => array( + 'Article' => [ 'title' => 'First Article deepsave insert', 'body' => 'First Article Body deepsave insert', - 'User' => array( + 'User' => [ 'user' => '', 'password' => 'magic' - ), - ), - ) - ); + ], + ], + ] + ]; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['deep' => true]); $this->assertFalse($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array( - 'Comment' => array( - 'Article' => array( - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'Comment' => [ + 'Article' => [ + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ]; $this->assertSame($expected, $result); - $expected = array( + $expected = [ 'Attachment' => true, 'Comment' => false - ); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ]; + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertEquals($expected, $result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertEquals($expected, $result); $data['Comment']['Article']['body'] = ''; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['deep' => true]); $this->assertFalse($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array( - 'Comment' => array( - 'Article' => array( - 'body' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'Comment' => [ + 'Article' => [ + 'body' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ]; $this->assertSame($expected, $result); - $expected = array( + $expected = [ 'Attachment' => true, 'Comment' => false - ); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ]; + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertEquals($expected, $result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertEquals($expected, $result); $data['Comment']['comment'] = ''; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['deep' => true]); $this->assertFalse($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array( - 'Comment' => array( - 'comment' => array('This field cannot be left blank'), - 'Article' => array( - 'body' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'Comment' => [ + 'comment' => ['This field cannot be left blank'], + 'Article' => [ + 'body' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ]; $this->assertSame($expected, $result); - $expected = array( + $expected = [ 'Attachment' => true, 'Comment' => false - ); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ]; + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertEquals($expected, $result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertEquals($expected, $result); $data['Attachment']['attachment'] = ''; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['deep' => true]); $this->assertFalse($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array( - 'attachment' => array('This field cannot be left blank'), - 'Comment' => array( - 'comment' => array('This field cannot be left blank'), - 'Article' => array( - 'body' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'attachment' => ['This field cannot be left blank'], + 'Comment' => [ + 'comment' => ['This field cannot be left blank'], + 'Article' => [ + 'body' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ]; $this->assertSame($expected, $result); $result = $TestModel->Comment->validationErrors; - $expected = array( - 'comment' => array('This field cannot be left blank'), - 'Article' => array( - 'body' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ); + $expected = [ + 'comment' => ['This field cannot be left blank'], + 'Article' => [ + 'body' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ]; $this->assertSame($expected, $result); - $expected = array( + $expected = [ 'Attachment' => false, 'Comment' => false - ); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); + ]; + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); $this->assertEquals($expected, $result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('atomic' => false, 'deep' => true)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['atomic' => false, 'deep' => true]); $this->assertEquals($expected, $result); } @@ -1436,147 +1436,147 @@ public function testSaveAllDeepValidateOnly() { public function testSaveAllNotDeepValidateOnly() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->hasAndBelongsToMany = array(); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->hasAndBelongsToMany = []; $TestModel->Comment->Attachment->validate['attachment'] = 'notBlank'; $TestModel->Comment->validate['comment'] = 'notBlank'; - $data = array( - 'Article' => array('id' => 2, 'body' => ''), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'deep' => false)); + $data = [ + 'Article' => ['id' => 2, 'body' => ''], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'deep' => false]); $this->assertFalse($result); - $result = $TestModel->validateAssociated($data, array('deep' => false)); + $result = $TestModel->validateAssociated($data, ['deep' => false]); $this->assertFalse($result); - $expected = array('body' => array('This field cannot be left blank')); + $expected = ['body' => ['This field cannot be left blank']]; $result = $TestModel->validationErrors; $this->assertSame($expected, $result); - $data = array( - 'Article' => array('id' => 2, 'body' => 'Ignore invalid user data'), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'deep' => false)); + $data = [ + 'Article' => ['id' => 2, 'body' => 'Ignore invalid user data'], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'deep' => false]); $this->assertTrue($result); - $result = $TestModel->validateAssociated($data, array('deep' => false)); + $result = $TestModel->validateAssociated($data, ['deep' => false]); $this->assertTrue($result); - $data = array( - 'Article' => array('id' => 2, 'body' => 'Ignore invalid user data'), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ); - $expected = array( + $data = [ + 'Article' => ['id' => 2, 'body' => 'Ignore invalid user data'], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]; + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, true - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => false)); + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => false]); $this->assertSame($expected, $result); - $result = $TestModel->validateAssociated($data, array('atomic' => false, 'deep' => false)); + $result = $TestModel->validateAssociated($data, ['atomic' => false, 'deep' => false]); $this->assertSame($expected, $result); - $data = array( - 'Article' => array('id' => 2, 'body' => 'Ignore invalid attachment data'), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => '')) - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'deep' => false)); + $data = [ + 'Article' => ['id' => 2, 'body' => 'Ignore invalid attachment data'], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => '']] + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'deep' => false]); $this->assertTrue($result); - $result = $TestModel->validateAssociated($data, array('deep' => false)); + $result = $TestModel->validateAssociated($data, ['deep' => false]); $this->assertTrue($result); - $data = array( - 'Article' => array('id' => 2, 'body' => 'Ignore invalid attachment data'), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => '')) - ) - ); - $expected = array( + $data = [ + 'Article' => ['id' => 2, 'body' => 'Ignore invalid attachment data'], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => '']] + ] + ]; + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, true - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => false)); + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => false]); $this->assertSame($expected, $result); - $result = $TestModel->validateAssociated($data, array('atomic' => false, 'deep' => false)); + $result = $TestModel->validateAssociated($data, ['atomic' => false, 'deep' => false]); $this->assertSame($expected, $result); - $expected = array(); + $expected = []; $result = $TestModel->validationErrors; $this->assertSame($expected, $result); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'First comment deepsave insert', 'published' => 'Y', 'user_id' => 5, - 'Article' => array( + 'Article' => [ 'title' => 'First Article deepsave insert ignored', 'body' => 'First Article Body deepsave insert', - 'User' => array( + 'User' => [ 'user' => '', 'password' => 'magic' - ), - ), - ) - ); + ], + ], + ] + ]; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => false)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => false]); $this->assertTrue($result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('deep' => false)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['deep' => false]); $this->assertTrue($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array(); + $expected = []; $this->assertSame($expected, $result); - $expected = array( + $expected = [ 'Attachment' => true, 'Comment' => true - ); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => false)); + ]; + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => false]); $this->assertEquals($expected, $result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('atomic' => false, 'deep' => false)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['atomic' => false, 'deep' => false]); $this->assertEquals($expected, $result); $data['Comment']['Article']['body'] = ''; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => false)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => false]); $this->assertTrue($result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('deep' => false)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['deep' => false]); $this->assertTrue($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array(); + $expected = []; $this->assertSame($expected, $result); - $expected = array( + $expected = [ 'Attachment' => true, 'Comment' => true - ); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => false)); + ]; + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => false]); $this->assertEquals($expected, $result); - $result = $TestModel->Comment->Attachment->validateAssociated($data, array('atomic' => false, 'deep' => false)); + $result = $TestModel->Comment->Attachment->validateAssociated($data, ['atomic' => false, 'deep' => false]); $this->assertEquals($expected, $result); } @@ -1588,124 +1588,124 @@ public function testSaveAllNotDeepValidateOnly() { public function testValidateAssociated() { $this->loadFixtures('Comment', 'Attachment', 'Article', 'User'); $TestModel = new Comment(); - $TestModel->Attachment->validate = array('attachment' => 'notBlank'); + $TestModel->Attachment->validate = ['attachment' => 'notBlank']; - $data = array( - 'Comment' => array( + $data = [ + 'Comment' => [ 'comment' => 'This is the comment' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => '' - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'only')); + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only']); $this->assertFalse($result); $result = $TestModel->validateAssociated($data); $this->assertFalse($result); - $fieldList = array( - 'Attachment' => array('comment_id') - ); - $result = $TestModel->saveAll($data, array( + $fieldList = [ + 'Attachment' => ['comment_id'] + ]; + $result = $TestModel->saveAll($data, [ 'fieldList' => $fieldList, 'validate' => 'only' - )); + ]); $this->assertTrue($result); $this->assertEmpty($TestModel->validationErrors); - $result = $TestModel->validateAssociated($data, array('fieldList' => $fieldList)); + $result = $TestModel->validateAssociated($data, ['fieldList' => $fieldList]); $this->assertTrue($result); $this->assertEmpty($TestModel->validationErrors); - $TestModel->validate = array('comment' => 'notBlank'); - $record = array( - 'Comment' => array( + $TestModel->validate = ['comment' => 'notBlank']; + $record = [ + 'Comment' => [ 'user_id' => 1, 'article_id' => 1, 'comment' => '', - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => '' - ) - ); - $result = $TestModel->saveAll($record, array('validate' => 'only')); + ] + ]; + $result = $TestModel->saveAll($record, ['validate' => 'only']); $this->assertFalse($result); $result = $TestModel->validateAssociated($record); $this->assertFalse($result); - $fieldList = array( - 'Comment' => array('id', 'article_id', 'user_id'), - 'Attachment' => array('comment_id') - ); - $result = $TestModel->saveAll($record, array( + $fieldList = [ + 'Comment' => ['id', 'article_id', 'user_id'], + 'Attachment' => ['comment_id'] + ]; + $result = $TestModel->saveAll($record, [ 'fieldList' => $fieldList, 'validate' => 'only' - )); + ]); $this->assertTrue($result); $this->assertEmpty($TestModel->validationErrors); - $result = $TestModel->validateAssociated($record, array('fieldList' => $fieldList)); + $result = $TestModel->validateAssociated($record, ['fieldList' => $fieldList]); $this->assertTrue($result); $this->assertEmpty($TestModel->validationErrors); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notBlank'); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; + $TestModel->Comment->validate = ['comment' => 'notBlank']; + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'id' => 1, 'comment' => '', 'published' => 'Y', 'user_id' => 1, - ), - array( + ], + [ 'id' => 2, 'comment' => 'comment', 'published' => 'Y', 'user_id' => 1 - ), - array( + ], + [ 'id' => 3, 'comment' => '', 'published' => 'Y', 'user_id' => 1 - ))); - $result = $TestModel->saveAll($data, array('validate' => 'only')); + ]]]; + $result = $TestModel->saveAll($data, ['validate' => 'only']); $this->assertFalse($result); $result = $TestModel->validateAssociated($data); $this->assertFalse($result); - $expected = array( + $expected = [ 'Article' => true, - 'Comment' => array(false, true, false) - ); - $result = $TestModel->saveAll($data, array('atomic' => false, 'validate' => 'only')); + 'Comment' => [false, true, false] + ]; + $result = $TestModel->saveAll($data, ['atomic' => false, 'validate' => 'only']); $this->assertSame($expected, $result); - $result = $TestModel->validateAssociated($data, array('atomic' => false)); + $result = $TestModel->validateAssociated($data, ['atomic' => false]); $this->assertSame($expected, $result); - $expected = array('Comment' => array( - 0 => array('comment' => array('This field cannot be left blank')), - 2 => array('comment' => array('This field cannot be left blank')) - )); + $expected = ['Comment' => [ + 0 => ['comment' => ['This field cannot be left blank']], + 2 => ['comment' => ['This field cannot be left blank']] + ]]; $this->assertEquals($expected['Comment'], $TestModel->Comment->validationErrors); $model = new Comment(); $model->deleteAll(true); - $model->validate = array('comment' => 'notBlank'); - $model->Attachment->validate = array('attachment' => 'notBlank'); - $model->Attachment->bindModel(array('belongsTo' => array('Comment'))); - $expected = array( - 'comment' => array('This field cannot be left blank'), - 'Attachment' => array( - 'attachment' => array('This field cannot be left blank') - ) - ); - - $data = array( - 'Comment' => array('comment' => '', 'article_id' => 1, 'user_id' => 1), - 'Attachment' => array('attachment' => '') - ); - $result = $model->saveAll($data, array('validate' => 'only')); + $model->validate = ['comment' => 'notBlank']; + $model->Attachment->validate = ['attachment' => 'notBlank']; + $model->Attachment->bindModel(['belongsTo' => ['Comment']]); + $expected = [ + 'comment' => ['This field cannot be left blank'], + 'Attachment' => [ + 'attachment' => ['This field cannot be left blank'] + ] + ]; + + $data = [ + 'Comment' => ['comment' => '', 'article_id' => 1, 'user_id' => 1], + 'Attachment' => ['attachment' => ''] + ]; + $result = $model->saveAll($data, ['validate' => 'only']); $this->assertFalse($result); $result = $model->validateAssociated($data); $this->assertFalse($result); @@ -1720,32 +1720,32 @@ public function testValidateAssociated() { */ public function testValidateMany() { $TestModel = new Article(); - $TestModel->validate = array('title' => 'notBlank'); - $data = array( - 0 => array('title' => ''), - 1 => array('title' => 'title 1'), - 2 => array('title' => 'title 2'), - ); - $expected = array( - 0 => array('title' => array('This field cannot be left blank')), - ); - - $result = $TestModel->saveAll($data, array('validate' => 'only')); + $TestModel->validate = ['title' => 'notBlank']; + $data = [ + 0 => ['title' => ''], + 1 => ['title' => 'title 1'], + 2 => ['title' => 'title 2'], + ]; + $expected = [ + 0 => ['title' => ['This field cannot be left blank']], + ]; + + $result = $TestModel->saveAll($data, ['validate' => 'only']); $this->assertFalse($result); $this->assertEquals($expected, $TestModel->validationErrors); $result = $TestModel->validateMany($data); $this->assertFalse($result); $this->assertEquals($expected, $TestModel->validationErrors); - $data = array( - 0 => array('title' => 'title 0'), - 1 => array('title' => ''), - 2 => array('title' => 'title 2'), - ); - $expected = array( - 1 => array('title' => array('This field cannot be left blank')), - ); - $result = $TestModel->saveAll($data, array('validate' => 'only')); + $data = [ + 0 => ['title' => 'title 0'], + 1 => ['title' => ''], + 2 => ['title' => 'title 2'], + ]; + $expected = [ + 1 => ['title' => ['This field cannot be left blank']], + ]; + $result = $TestModel->saveAll($data, ['validate' => 'only']); $this->assertFalse($result); $this->assertEquals($expected, $TestModel->validationErrors); $result = $TestModel->validateMany($data); @@ -1785,13 +1785,13 @@ public function testGetMethodsRefresh() { $this->assertEquals($expected, array_keys($result)); $TestModel->Behaviors->load('Containable'); - $newList = array( + $newList = [ 'contain', 'resetbindings', 'containments', 'fielddependencies', 'containmentsmap' - ); + ]; $this->assertEquals(array_merge($expected, $newList), array_keys($Validator->getMethods())); $TestModel->Behaviors->unload('Containable'); @@ -1880,10 +1880,10 @@ public function testArrayAccessSet() { $TestModel = new Article(); $Validator = $TestModel->validator(); - $set = array( - 'numeric' => array('rule' => 'numeric', 'allowEmpty' => false), - 'between' => array('rule' => array('lengthBetween', 1, 5), 'allowEmpty' => false), - ); + $set = [ + 'numeric' => ['rule' => 'numeric', 'allowEmpty' => false], + 'between' => ['rule' => ['lengthBetween', 1, 5], 'allowEmpty' => false], + ]; $Validator['other'] = $set; $rules = $Validator['other']; $this->assertEquals('other', $rules->field); @@ -1891,16 +1891,16 @@ public function testArrayAccessSet() { $validators = $rules->getRules(); $this->assertCount(2, $validators); $this->assertEquals('numeric', $validators['numeric']->rule); - $this->assertEquals(array('lengthBetween', 1, 5), $validators['between']->rule); + $this->assertEquals(['lengthBetween', 1, 5], $validators['between']->rule); - $Validator['new'] = new CakeValidationSet('new', $set, array()); + $Validator['new'] = new CakeValidationSet('new', $set, []); $rules = $Validator['new']; $this->assertEquals('new', $rules->field); $validators = $rules->getRules(); $this->assertCount(2, $validators); $this->assertEquals('numeric', $validators['numeric']->rule); - $this->assertEquals(array('lengthBetween', 1, 5), $validators['between']->rule); + $this->assertEquals(['lengthBetween', 1, 5], $validators['between']->rule); } /** @@ -1953,10 +1953,10 @@ public function testCount() { $Validator = $TestModel->validator(); $this->assertCount(3, $Validator); - $set = array( - 'numeric' => array('rule' => 'numeric', 'allowEmpty' => false), - 'range' => array('rule' => array('lengthBetween', 1, 5), 'allowEmpty' => false), - ); + $set = [ + 'numeric' => ['rule' => 'numeric', 'allowEmpty' => false], + 'range' => ['rule' => ['lengthBetween', 1, 5], 'allowEmpty' => false], + ]; $Validator['other'] = $set; $this->assertCount(4, $Validator); @@ -1975,15 +1975,15 @@ public function testAddRule() { $TestModel = new Article(); $Validator = $TestModel->validator(); - $Validator->add('other', 'numeric', array('rule' => 'numeric', 'allowEmpty' => false)); - $Validator->add('other', 'between', array('rule' => array('lengthBetween', 1, 5), 'allowEmpty' => false)); + $Validator->add('other', 'numeric', ['rule' => 'numeric', 'allowEmpty' => false]); + $Validator->add('other', 'between', ['rule' => ['lengthBetween', 1, 5], 'allowEmpty' => false]); $rules = $Validator['other']; $this->assertEquals('other', $rules->field); $validators = $rules->getRules(); $this->assertCount(2, $validators); $this->assertEquals('numeric', $validators['numeric']->rule); - $this->assertEquals(array('lengthBetween', 1, 5), $validators['between']->rule); + $this->assertEquals(['lengthBetween', 1, 5], $validators['between']->rule); } /** @@ -1999,8 +1999,8 @@ public function testRemoveRule() { $Validator->remove('title'); $this->assertFalse(isset($Validator['title'])); - $Validator->add('other', 'numeric', array('rule' => 'numeric', 'allowEmpty' => false)); - $Validator->add('other', 'between', array('rule' => array('lengthBetween', 1, 5), 'allowEmpty' => false)); + $Validator->add('other', 'numeric', ['rule' => 'numeric', 'allowEmpty' => false]); + $Validator->add('other', 'between', ['rule' => ['lengthBetween', 1, 5], 'allowEmpty' => false]); $this->assertTrue(isset($Validator['other'])); $Validator->remove('other', 'numeric'); @@ -2018,11 +2018,11 @@ public function testRemoveRule() { * @return void */ public function testValidateCallbacks() { - $TestModel = $this->getMock('Article', array('beforeValidate', 'afterValidate')); + $TestModel = $this->getMock('Article', ['beforeValidate', 'afterValidate']); $TestModel->expects($this->once())->method('beforeValidate'); $TestModel->expects($this->once())->method('afterValidate'); - $TestModel->set(array('title' => '', 'body' => 'body')); + $TestModel->set(['title' => '', 'body' => 'body']); $TestModel->validates(); } @@ -2035,49 +2035,49 @@ public function testValidateCallbacks() { public function testValidateFirstWithBeforeValidate() { $this->loadFixtures('Article', 'User'); $model = new CustomArticle(); - $model->validate = array( - 'title' => array( - 'notBlank' => array( + $model->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => true, 'allowEmpty' => false - ) - ) - ); - $data = array( - 'CustomArticle' => array( + ] + ] + ]; + $data = [ + 'CustomArticle' => [ 'body' => 'foo0' - ) - ); - $result = $model->saveAll($data, array('validate' => 'first')); + ] + ]; + $result = $model->saveAll($data, ['validate' => 'first']); $this->assertTrue($result); $this->assertFalse($model->findMethods['unPublished'], 'beforeValidate was run twice'); $model->findMethods['unPublished'] = true; - $data = array( - 'CustomArticle' => array( + $data = [ + 'CustomArticle' => [ 'body' => 'foo1' - ) - ); - $result = $model->saveAll($data, array('validate' => 'first', 'deep' => true)); + ] + ]; + $result = $model->saveAll($data, ['validate' => 'first', 'deep' => true]); $this->assertTrue($result); - $title = $model->field('title', array('body' => 'foo1')); + $title = $model->field('title', ['body' => 'foo1']); $this->assertEquals('foo', $title); $this->assertFalse($model->findMethods['unPublished'], 'beforeValidate was run twice'); - $data = array( - array('body' => 'foo2'), - array('body' => 'foo3'), - array('body' => 'foo4') - ); + $data = [ + ['body' => 'foo2'], + ['body' => 'foo3'], + ['body' => 'foo4'] + ]; - $result = $model->saveAll($data, array('validate' => 'first', 'deep' => true)); + $result = $model->saveAll($data, ['validate' => 'first', 'deep' => true]); $this->assertTrue($result); - $this->assertEquals('foo', $model->field('title', array('body' => 'foo2'))); - $this->assertEquals('foo', $model->field('title', array('body' => 'foo3'))); - $this->assertEquals('foo', $model->field('title', array('body' => 'foo4'))); + $this->assertEquals('foo', $model->field('title', ['body' => 'foo2'])); + $this->assertEquals('foo', $model->field('title', ['body' => 'foo3'])); + $this->assertEquals('foo', $model->field('title', ['body' => 'foo4'])); } /** @@ -2089,31 +2089,31 @@ public function testValidateFirstWithBeforeValidate() { public function testValidateFirstAssociatedWithBeforeValidate() { $this->loadFixtures('Article', 'User'); $model = new CustomArticle(); - $model->validate = array( - 'title' => array( - 'notBlank' => array( + $model->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => true - ) - ) - ); - $articles = array( - array('body' => 'foo1'), - array('body' => 'foo2'), - array('body' => 'foo3') - ); + ] + ] + ]; + $articles = [ + ['body' => 'foo1'], + ['body' => 'foo2'], + ['body' => 'foo3'] + ]; $user = new User(); - $user->bindModel(array('hasMany' => array('CustomArticle'))); - $data = array( - 'User' => array('user' => 'foo', 'password' => 'bar'), + $user->bindModel(['hasMany' => ['CustomArticle']]); + $data = [ + 'User' => ['user' => 'foo', 'password' => 'bar'], 'CustomArticle' => $articles - ); - $result = $user->saveAll($data, array('validate' => 'first')); + ]; + $result = $user->saveAll($data, ['validate' => 'first']); $this->assertTrue($result); - $this->assertEquals('foo', $model->field('title', array('body' => 'foo1'))); - $this->assertEquals('foo', $model->field('title', array('body' => 'foo2'))); - $this->assertEquals('foo', $model->field('title', array('body' => 'foo3'))); + $this->assertEquals('foo', $model->field('title', ['body' => 'foo1'])); + $this->assertEquals('foo', $model->field('title', ['body' => 'foo2'])); + $this->assertEquals('foo', $model->field('title', ['body' => 'foo3'])); } /** @@ -2125,37 +2125,37 @@ public function testFirstWithDefaults() { $this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag'); $TestModel = new Article(); - $result = $TestModel->find('first', array( - 'conditions' => array('Article.id' => 1) - )); - $expected = array( - 'Article' => array( + $result = $TestModel->find('first', [ + 'conditions' => ['Article.id' => 1] + ]); + $expected = [ + 'Article' => [ 'id' => 1, 'user_id' => 1, 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23' - ), - ); + ], + ]; unset($result['Article']['updated']); $this->assertEquals($expected['Article'], $result['Article']); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'id' => 1, 'title' => 'First Article (modified)' - ), - 'Comment' => array( - array('comment' => 'Article comment', 'user_id' => 1) - ) - ); - $result = $TestModel->saveAll($data, array('validate' => 'first')); + ], + 'Comment' => [ + ['comment' => 'Article comment', 'user_id' => 1] + ] + ]; + $result = $TestModel->saveAll($data, ['validate' => 'first']); $this->assertTrue($result); - $result = $TestModel->find('first', array( - 'conditions' => array('Article.id' => 1) - )); + $result = $TestModel->find('first', [ + 'conditions' => ['Article.id' => 1] + ]); $expected['Article']['title'] = 'First Article (modified)'; unset($result['Article']['updated']); $this->assertEquals($expected['Article'], $result['Article']); @@ -2165,10 +2165,10 @@ public function testAddMultipleRules() { $TestModel = new Article(); $Validator = $TestModel->validator(); - $set = array( - 'numeric' => array('rule' => 'numeric', 'allowEmpty' => false), - 'between' => array('rule' => array('lengthBetween', 1, 5), 'allowEmpty' => false), - ); + $set = [ + 'numeric' => ['rule' => 'numeric', 'allowEmpty' => false], + 'between' => ['rule' => ['lengthBetween', 1, 5], 'allowEmpty' => false], + ]; $Validator->add('other', $set); $rules = $Validator['other']; @@ -2177,12 +2177,12 @@ public function testAddMultipleRules() { $validators = $rules->getRules(); $this->assertCount(2, $validators); $this->assertEquals('numeric', $validators['numeric']->rule); - $this->assertEquals(array('lengthBetween', 1, 5), $validators['between']->rule); + $this->assertEquals(['lengthBetween', 1, 5], $validators['between']->rule); - $set = new CakeValidationSet('other', array( - 'a' => array('rule' => 'numeric', 'allowEmpty' => false), - 'b' => array('rule' => array('lengthBetween', 1, 5), 'allowEmpty' => false), - )); + $set = new CakeValidationSet('other', [ + 'a' => ['rule' => 'numeric', 'allowEmpty' => false], + 'b' => ['rule' => ['lengthBetween', 1, 5], 'allowEmpty' => false], + ]); $Validator->add('other', $set); $this->assertSame($set, $Validator->getField('other')); @@ -2198,7 +2198,7 @@ public function testValidator() { $Validator = $TestModel->validator(); $result = $Validator->getField(); - $expected = array('user_id', 'title', 'body'); + $expected = ['user_id', 'title', 'body']; $this->assertEquals($expected, array_keys($result)); $this->assertTrue($result['user_id'] instanceof CakeValidationSet); @@ -2234,7 +2234,7 @@ public function testValidatorTypehintException() { try { new ModelValidator('asdasds'); $this->fail('No exeption raised'); - } catch (TypeError $e) { + } catch (TypeError) { throw new \PHPUnit\Framework\Error('Raised an error', 100); } } @@ -2248,25 +2248,25 @@ public function testValidatorTypehintException() { public function testValidateFirstAssociatedWithBeforeValidate2() { $this->loadFixtures('Article', 'User'); $model = new CustomArticle(); - $model->validate = array( - 'title' => array( - 'notBlank' => array( + $model->validate = [ + 'title' => [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => true - ) - ) - ); + ] + ] + ]; - $data = array( - 'User' => array('user' => 'foo', 'password' => 'bar'), - 'CustomArticle' => array( + $data = [ + 'User' => ['user' => 'foo', 'password' => 'bar'], + 'CustomArticle' => [ 'body' => 'a test' - ) - ); - $result = $model->saveAll($data, array('validate' => 'first')); + ] + ]; + $result = $model->saveAll($data, ['validate' => 'first']); $this->assertTrue($result); - $this->assertEquals('foo', $model->field('title', array('body' => 'a test'))); + $this->assertEquals('foo', $model->field('title', ['body' => 'a test'])); } /** @@ -2278,11 +2278,11 @@ public function testValidateFirstAssociatedWithBeforeValidate2() { public function testDynamicValidationRuleBuilding() { $model = new Article; $validator = $model->validator(); - $validator->add('body', 'isSpecial', array('rule' => 'special')); + $validator->add('body', 'isSpecial', ['rule' => 'special']); $rules = $validator['body']->getRules(); $this->assertCount(2, $rules); $this->assertEquals('special', $rules['isSpecial']->rule); - $validator['body']->setRule('isAwesome', array('rule' => 'awesome')); + $validator['body']->setRule('isAwesome', ['rule' => 'awesome']); $rules = $validator['body']->getRules(); $this->assertCount(3, $rules); $this->assertEquals('awesome', $rules['isAwesome']->rule); @@ -2297,38 +2297,38 @@ public function testCustomMethodsWithCakeValidationSet() { $TestModel = new TestValidate(); $Validator = $TestModel->validator(); - $Validator->add('title', 'validateTitle', array( + $Validator->add('title', 'validateTitle', [ 'rule' => 'validateTitle', 'message' => 'That aint right', - )); - $data = array('title' => 'notatitle'); + ]); + $data = ['title' => 'notatitle']; $result = $Validator->getField('title')->validate($data); - $expected = array(0 => 'That aint right'); + $expected = [0 => 'That aint right']; $this->assertEquals($expected, $result); - $data = array('title' => 'title-is-good'); + $data = ['title' => 'title-is-good']; $result = $Validator->getField('title')->validate($data); - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); } public function testCustomMethodWithEmptyValue() { $this->loadFixtures('Article'); - $model = $this->getMock('Article', array('isLegit')); - $model->validate = array( - 'title' => array( - 'custom' => array( - 'rule' => array('isLegit'), + $model = $this->getMock('Article', ['isLegit']); + $model->validate = [ + 'title' => [ + 'custom' => [ + 'rule' => ['isLegit'], 'message' => 'is no good' - ) - ) - ); + ] + ] + ]; $model->expects($this->once()) ->method('isLegit') ->will($this->returnValue(false)); - $model->set(array('title' => '')); + $model->set(['title' => '']); $this->assertFalse($model->validates()); } @@ -2340,54 +2340,54 @@ public function testCustomMethodWithEmptyValue() { public function testValidateAssociatedAtomicFalseDeepTrueWithErrors() { $this->loadFixtures('Comment', 'Article', 'User', 'Attachment'); $Attachment = ClassRegistry::init('Attachment'); - $Attachment->Comment->validator()->add('comment', array( - array('rule' => 'notBlank') - )); - $Attachment->Comment->User->bindModel(array( - 'hasMany' => array( + $Attachment->Comment->validator()->add('comment', [ + ['rule' => 'notBlank'] + ]); + $Attachment->Comment->User->bindModel([ + 'hasMany' => [ 'Article', 'Comment' - )), + ]], false ); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'text', - 'Comment' => array( + 'Comment' => [ 'comment' => '', 'published' => 'N', - 'User' => array( + 'User' => [ 'user' => 'Foo', 'password' => 'mypassword', - 'Comment' => array( - array( + 'Comment' => [ + [ 'comment' => '' - ) - ) - ) - ) - ) - ); - $result = $Attachment->validateAssociated($data, array('atomic' => false, 'deep' => true)); + ] + ] + ] + ] + ] + ]; + $result = $Attachment->validateAssociated($data, ['atomic' => false, 'deep' => true]); $result = $Attachment->validationErrors; - $expected = array( - 'Comment' => array( - 'comment' => array( + $expected = [ + 'Comment' => [ + 'comment' => [ 0 => 'This field cannot be left blank', - ), - 'User' => array( - 'Comment' => array( - 0 => array( - 'comment' => array( + ], + 'User' => [ + 'Comment' => [ + 0 => [ + 'comment' => [ 0 => 'This field cannot be left blank', - ), - ), - ), - ), - ), - ); + ], + ], + ], + ], + ], + ]; $this->assertEquals($expected, $result); } @@ -2399,56 +2399,56 @@ public function testValidateAssociatedAtomicFalseDeepTrueWithErrors() { public function testValidateManyAtomicFalseDeepTrueWithErrors() { $this->loadFixtures('Comment', 'Article', 'User'); $Article = ClassRegistry::init('Article'); - $Article->Comment->validator()->add('comment', array( - array('rule' => 'notBlank') - )); + $Article->Comment->validator()->add('comment', [ + ['rule' => 'notBlank'] + ]); - $data = array( - array( - 'Article' => array( + $data = [ + [ + 'Article' => [ 'user_id' => 1, 'title' => 'Foo', 'body' => 'text', 'published' => 'N' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'user_id' => 1, 'comment' => 'Baz', 'published' => 'N', - ) - ), - ), - array( - 'Article' => array( + ] + ], + ], + [ + 'Article' => [ 'user_id' => 1, 'title' => 'Bar', 'body' => 'text', 'published' => 'N' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'user_id' => 1, 'comment' => '', 'published' => 'N', - ) - ), - ), - ); - $Article->validateMany($data, array('atomic' => false, 'deep' => true)); + ] + ], + ], + ]; + $Article->validateMany($data, ['atomic' => false, 'deep' => true]); $result = $Article->validationErrors; - $expected = array( - 1 => array( - 'Comment' => array( - 0 => array( - 'comment' => array( + $expected = [ + 1 => [ + 'Comment' => [ + 0 => [ + 'comment' => [ 0 => 'This field cannot be left blank', - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; $this->assertEquals($expected, $result); } @@ -2460,38 +2460,38 @@ public function testValidateManyAtomicFalseDeepTrueWithErrors() { public function testIsUniqueValidator() { $this->loadFixtures('Article'); $Article = ClassRegistry::init('Article'); - $Article->validate = array( - 'user_id' => array( - 'duplicate' => array( - 'rule' => array('isUnique', array('user_id', 'title'), false) - ) - ) - ); - $data = array( + $Article->validate = [ + 'user_id' => [ + 'duplicate' => [ + 'rule' => ['isUnique', ['user_id', 'title'], false] + ] + ] + ]; + $data = [ 'user_id' => 1, 'title' => 'First Article', - ); + ]; $Article->create($data); $this->assertFalse($Article->validates(), 'Contains a dupe'); - $data = array( + $data = [ 'user_id' => 1, 'title' => 'Unique Article', - ); + ]; $Article->create($data); $this->assertTrue($Article->validates(), 'Should pass'); - $Article->validate = array( - 'user_id' => array( - 'duplicate' => array( - 'rule' => array('isUnique', array('user_id', 'title')) - ) - ) - ); - $data = array( + $Article->validate = [ + 'user_id' => [ + 'duplicate' => [ + 'rule' => ['isUnique', ['user_id', 'title']] + ] + ] + ]; + $data = [ 'user_id' => 1, 'title' => 'Unique Article', - ); + ]; $Article->create($data); $this->assertFalse($Article->validates(), 'Should fail, conditions are combined with or'); } @@ -2504,21 +2504,21 @@ public function testIsUniqueValidator() { public function testBackwardCompatIsUniqueValidator() { $this->loadFixtures('Article'); $Article = ClassRegistry::init('Article'); - $Article->validate = array( - 'title' => array( - 'duplicate' => array( + $Article->validate = [ + 'title' => [ + 'duplicate' => [ 'rule' => 'isUnique', 'message' => 'Title must be unique', - ), - 'minLength' => array( - 'rule' => array('minLength', 1), + ], + 'minLength' => [ + 'rule' => ['minLength', 1], 'message' => 'Title cannot be empty', - ), - ) - ); - $data = array( + ], + ] + ]; + $data = [ 'title' => 'First Article', - ); + ]; $data = $Article->create($data); $this->assertFalse($Article->validates(), 'Contains a dupe'); } @@ -2530,11 +2530,11 @@ public function testBackwardCompatIsUniqueValidator() { */ class ValidationRuleBehavior extends ModelBehavior { - public function setup(Model $Model, $config = array()) { + public function setup(Model $Model, $config = []) { $this->settings[$Model->alias] = $config; } - public function beforeValidate(Model $Model, $options = array()) { + public function beforeValidate(Model $Model, $options = []) { $fields = $this->settings[$Model->alias]['fields']; foreach ($fields as $field) { $Model->whitelist[] = $field; diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 85c4d737ee..16351cabb3 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -21,18 +21,18 @@ App::uses('MockManyTransactionDboSource', 'Model/Datasource'); App::uses('MockAssociatedTransactionDboSource', 'Model/Datasource'); -require_once dirname(__FILE__) . DS . 'ModelTestBase.php'; +require_once __DIR__ . DS . 'ModelTestBase.php'; /** * Helper class for testing with mocked datasources */ class TestAuthor extends Author { - public $hasMany = array( - 'Post' => array( + public $hasMany = [ + 'Post' => [ 'className' => 'TestPost' - ) - ); + ] + ]; protected $_dataSourceObject; @@ -68,11 +68,11 @@ public function getDataSource() { */ class TestPost extends Post { - public $belongsTo = array( - 'Author' => array( + public $belongsTo = [ + 'Author' => [ 'className' => 'TestAuthor' - ) - ); + ] + ]; protected $_dataSourceObject; @@ -131,10 +131,10 @@ public function testInsertNoData() { $this->assertFalse($Bid->save()); - $result = $Bid->save(array('Bid' => array())); + $result = $Bid->save(['Bid' => []]); $this->assertFalse($result); - $result = $Bid->save(array('Bid' => array('not in schema' => 1))); + $result = $Bid->save(['Bid' => ['not in schema' => 1]]); $this->assertFalse($result); } @@ -148,41 +148,41 @@ public function testInsertAnotherHabtmRecordWithSameForeignKey() { $TestModel = new JoinA(); $result = $TestModel->JoinAsJoinB->findById(1); - $expected = array( - 'JoinAsJoinB' => array( + $expected = [ + 'JoinAsJoinB' => [ 'id' => 1, 'join_a_id' => 1, 'join_b_id' => 2, 'other' => 'Data for Join A 1 Join B 2', 'created' => '2008-01-03 10:56:33', 'updated' => '2008-01-03 10:56:33' - )); + ]]; $this->assertEquals($expected, $result); $TestModel->JoinAsJoinB->create(); - $data = array( + $data = [ 'join_a_id' => 1, 'join_b_id' => 1, 'other' => 'Data for Join A 1 Join B 1', 'created' => '2008-01-03 10:56:44', 'updated' => '2008-01-03 10:56:44' - ); + ]; $result = $TestModel->JoinAsJoinB->save($data); $lastInsertId = $TestModel->JoinAsJoinB->getLastInsertID(); $data['id'] = $lastInsertId; - $this->assertEquals(array('JoinAsJoinB' => $data), $result); + $this->assertEquals(['JoinAsJoinB' => $data], $result); $this->assertTrue($lastInsertId > 0); $result = $TestModel->JoinAsJoinB->findById(1); - $expected = array( - 'JoinAsJoinB' => array( + $expected = [ + 'JoinAsJoinB' => [ 'id' => 1, 'join_a_id' => 1, 'join_b_id' => 2, 'other' => 'Data for Join A 1 Join B 2', 'created' => '2008-01-03 10:56:33', 'updated' => '2008-01-03 10:56:33' - )); + ]]; $this->assertEquals($expected, $result); $updatedValue = 'UPDATED Data for Join A 1 Join B 2'; @@ -204,21 +204,21 @@ public function testSaveDateAsFirstEntry() { $Article = new Article(); - $data = array( - 'Article' => array( - 'created' => array( + $data = [ + 'Article' => [ + 'created' => [ 'day' => '1', 'month' => '1', 'year' => '2008' - ), + ], 'title' => 'Test Title', 'user_id' => 1 - )); + ]]; $Article->create(); $result = $Article->save($data); $this->assertFalse(empty($result)); - $testResult = $Article->find('first', array('conditions' => array('Article.title' => 'Test Title'))); + $testResult = $Article->find('first', ['conditions' => ['Article.title' => 'Test Title']]); $this->assertEquals($data['Article']['title'], $testResult['Article']['title']); $this->assertEquals('2008-01-01 00:00:00', $testResult['Article']['created']); @@ -235,13 +235,13 @@ public function testUnderscoreFieldSave() { $currentCount = $UnderscoreField->find('count'); $this->assertEquals(3, $currentCount); - $data = array('UnderscoreField' => array( + $data = ['UnderscoreField' => [ 'user_id' => '1', 'my_model_has_a_field' => 'Content here', 'body' => 'Body', 'published' => 'Y', 'another_field' => 4 - )); + ]]; $ret = $UnderscoreField->save($data); $this->assertFalse(empty($ret)); @@ -261,10 +261,10 @@ public function testAutoSaveUuid() { $this->loadFixtures('Uuid'); $TestModel = new Uuid(); - $TestModel->save(array('title' => 'Test record')); + $TestModel->save(['title' => 'Test record']); $result = $TestModel->findByTitle('Test record'); $this->assertEquals( - array('id', 'title', 'count', 'created', 'updated'), + ['id', 'title', 'count', 'created', 'updated'], array_keys($result['Uuid']) ); $this->assertEquals(36, strlen($result['Uuid']['id'])); @@ -281,10 +281,10 @@ public function testAutoSaveUuidNative() { $this->loadFixtures('UuidNative'); $TestModel = new UuidNative(); - $TestModel->save(array('title' => 'Test record')); + $TestModel->save(['title' => 'Test record']); $result = $TestModel->findByTitle('Test record'); $this->assertEquals( - array('id', 'title', 'count', 'created', 'updated'), + ['id', 'title', 'count', 'created', 'updated'], array_keys($result['UuidNative']) ); $this->assertEquals(36, strlen($result['UuidNative']['id'])); @@ -303,10 +303,10 @@ public function testSaveUuidNull() { $this->loadFixtures('Uuid'); $TestModel = new Uuid(); - $TestModel->save(array('title' => 'Test record', 'id' => null)); + $TestModel->save(['title' => 'Test record', 'id' => null]); $result = $TestModel->findByTitle('Test record'); $this->assertEquals( - array('id', 'title', 'count', 'created', 'updated'), + ['id', 'title', 'count', 'created', 'updated'], array_keys($result['Uuid']) ); $this->assertEquals(36, strlen($result['Uuid']['id'])); @@ -324,10 +324,10 @@ public function testSaveUuidNullNative() { $this->loadFixtures('UuidNative'); $TestModel = new UuidNative(); - $TestModel->save(array('title' => 'Test record', 'id' => null)); + $TestModel->save(['title' => 'Test record', 'id' => null]); $result = $TestModel->findByTitle('Test record'); $this->assertEquals( - array('id', 'title', 'count', 'created', 'updated'), + ['id', 'title', 'count', 'created', 'updated'], array_keys($result['UuidNative']) ); $this->assertEquals(36, strlen($result['UuidNative']['id'])); @@ -344,7 +344,7 @@ public function testZeroDefaultFieldValue() { $this->loadFixtures('DataTest'); $TestModel = new DataTest(); - $TestModel->create(array()); + $TestModel->create([]); $TestModel->save(); $result = $TestModel->findById($TestModel->id); $this->assertEquals(0, $result['DataTest']['count']); @@ -359,15 +359,15 @@ public function testZeroDefaultFieldValue() { public function testAllowSimulatedFields() { $TestModel = new ValidationTest1(); - $TestModel->create(array( + $TestModel->create([ 'title' => 'foo', 'bar' => 'baz' - )); - $expected = array( - 'ValidationTest1' => array( + ]); + $expected = [ + 'ValidationTest1' => [ 'title' => 'foo', 'bar' => 'baz' - )); + ]]; $this->assertEquals($expected, $TestModel->data); } @@ -379,10 +379,10 @@ public function testAllowSimulatedFields() { * @return void */ public function testCacheClearOnSave() { - $_back = array( + $_back = [ 'check' => Configure::read('Cache.check'), 'disable' => Configure::read('Cache.disable'), - ); + ]; Configure::write('Cache.check', true); Configure::write('Cache.disable', false); @@ -392,14 +392,14 @@ public function testCacheClearOnSave() { touch(CACHE . 'views' . DS . 'some_dir_overallfavorites_index.php'); touch(CACHE . 'views' . DS . 'some_dir_overall_favorites_index.php'); - $data = array( - 'OverallFavorite' => array( + $data = [ + 'OverallFavorite' => [ 'id' => 22, 'model_type' => '8-track', 'model_id' => '3', 'priority' => '1' - ) - ); + ] + ]; $OverallFavorite->create($data); $OverallFavorite->save(); @@ -418,11 +418,11 @@ public function testCacheClearOnSave() { public function testSaveFieldListResetsWhitelistOnFailedSave() { $this->loadFixtures('Bidding'); $model = new Bidding(); - $whitelist = array('title'); + $whitelist = ['title']; $model->whitelist = $whitelist; $result = $model->save( - array(), - array('fieldList' => array('body')) + [], + ['fieldList' => ['body']] ); $this->assertFalse($result); $this->assertEquals($whitelist, $model->whitelist); @@ -437,22 +437,22 @@ public function testSaveFieldListResetsWhitelistOnFailedSave() { public function testSaveUpdatedWithFieldList() { $this->loadFixtures('Post', 'Author'); $model = ClassRegistry::init('Post'); - $original = $model->find('first', array( - 'conditions' => array('Post.id' => 1) - )); - $data = array( - 'Post' => array( + $original = $model->find('first', [ + 'conditions' => ['Post.id' => 1] + ]); + $data = [ + 'Post' => [ 'id' => 1, 'title' => 'New title', 'updated' => '1999-01-01 00:00:00', - ) - ); - $model->save($data, array( - 'fieldList' => array('title') - )); - $new = $model->find('first', array( - 'conditions' => array('Post.id' => 1) - )); + ] + ]; + $model->save($data, [ + 'fieldList' => ['title'] + ]); + $new = $model->find('first', [ + 'conditions' => ['Post.id' => 1] + ]); $this->assertGreaterThan($original['Post']['updated'], $new['Post']['updated']); } @@ -464,15 +464,15 @@ public function testSaveUpdatedWithFieldList() { public function testSaveResetWhitelistOnSuccess() { $this->loadFixtures('Post'); - $callback = array($this, 'callbackForWhitelistReset'); + $callback = [$this, 'callbackForWhitelistReset']; $model = ClassRegistry::init('Post'); - $model->whitelist = array('author_id', 'title', 'body'); + $model->whitelist = ['author_id', 'title', 'body']; $model->getEventManager()->attach($callback, 'Model.afterSave'); - $data = array( + $data = [ 'title' => 'New post', 'body' => 'Post body', 'author_id' => 1 - ); + ]; $result = $model->save($data); $this->assertNotEmpty($result); } @@ -484,7 +484,7 @@ public function testSaveResetWhitelistOnSuccess() { * @return void */ public function callbackForWhitelistReset($event) { - $expected = array('author_id', 'title', 'body', 'updated', 'created'); + $expected = ['author_id', 'title', 'body', 'updated', 'created']; $this->assertEquals($expected, $event->subject()->whitelist); } @@ -501,11 +501,11 @@ public function testSaveWithCounterCache() { $result = $TestModel->findById(1); $this->assertNull($result['Syfile']['item_count']); - $TestModel2->save(array( + $TestModel2->save([ 'name' => 'Item 7', 'syfile_id' => 1, 'published' => false - )); + ]); $result = $TestModel->findById(1); $this->assertEquals(2, $result['Syfile']['item_count']); @@ -533,17 +533,17 @@ public function testCounterCacheIncrease() { $this->loadFixtures('CounterCacheUser', 'CounterCachePost'); $User = new CounterCacheUser(); $Post = new CounterCachePost(); - $data = array('Post' => array( + $data = ['Post' => [ 'id' => 22, 'title' => 'New Post', 'user_id' => 66 - )); + ]]; $Post->save($data); - $user = $User->find('first', array( - 'conditions' => array('id' => 66), + $user = $User->find('first', [ + 'conditions' => ['id' => 66], 'recursive' => -1 - )); + ]); $result = $user[$User->alias]['post_count']; $expected = 3; @@ -561,10 +561,10 @@ public function testCounterCacheDecrease() { $Post = new CounterCachePost(); $Post->delete(2); - $user = $User->find('first', array( - 'conditions' => array('id' => 66), + $user = $User->find('first', [ + 'conditions' => ['id' => 66], 'recursive' => -1 - )); + ]); $result = $user[$User->alias]['post_count']; $expected = 1; @@ -581,14 +581,14 @@ public function testCounterCacheUpdated() { $User = new CounterCacheUser(); $Post = new CounterCachePost(); - $data = $Post->find('first', array( - 'conditions' => array('id' => 1), + $data = $Post->find('first', [ + 'conditions' => ['id' => 1], 'recursive' => -1 - )); + ]); $data[$Post->alias]['user_id'] = 301; $Post->save($data); - $users = $User->find('all', array('order' => 'User.id')); + $users = $User->find('all', ['order' => 'User.id']); $this->assertEquals(1, $users[0]['User']['post_count']); $this->assertEquals(2, $users[1]['User']['post_count']); } @@ -608,14 +608,14 @@ public function testCounterCacheWithNonstandardPrimaryKey() { $User = new CounterCacheUserNonstandardPrimaryKey(); $Post = new CounterCachePostNonstandardPrimaryKey(); - $data = $Post->find('first', array( - 'conditions' => array('pid' => 1), + $data = $Post->find('first', [ + 'conditions' => ['pid' => 1], 'recursive' => -1 - )); + ]); $data[$Post->alias]['uid'] = 301; $Post->save($data); - $users = $User->find('all', array('order' => 'User.uid')); + $users = $User->find('all', ['order' => 'User.uid']); $this->assertEquals(1, $users[0]['User']['post_count']); $this->assertEquals(2, $users[1]['User']['post_count']); } @@ -633,18 +633,18 @@ public function testCounterCacheWithSelfJoin() { if ($this->db instanceof Sqlserver) { $column = ''; } - $column .= $this->db->buildColumn(array('name' => 'child_count', 'type' => 'integer')); + $column .= $this->db->buildColumn(['name' => 'child_count', 'type' => 'integer']); $this->db->query('ALTER TABLE ' . $this->db->fullTableName('category_threads') . ' ADD ' . $column); $this->db->flushMethodCache(); $Category = new CategoryThread(); - $result = $Category->updateAll(array('CategoryThread.name' => "'updated'"), array('CategoryThread.parent_id' => 5)); + $result = $Category->updateAll(['CategoryThread.name' => "'updated'"], ['CategoryThread.parent_id' => 5]); $this->assertFalse(empty($result)); $Category = new CategoryThread(); $Category->belongsTo['ParentCategory']['counterCache'] = 'child_count'; - $Category->updateCounterCache(array('parent_id' => 5)); - $result = Hash::extract($Category->find('all', array('conditions' => array('CategoryThread.id' => 5))), '{n}.CategoryThread.child_count'); - $expected = array(1); + $Category->updateCounterCache(['parent_id' => 5]); + $result = Hash::extract($Category->find('all', ['conditions' => ['CategoryThread.id' => 5]]), '{n}.CategoryThread.child_count'); + $expected = [1]; $this->assertEquals($expected, $result); } @@ -658,16 +658,16 @@ public function testSaveWithCounterCacheScope() { $TestModel = new Syfile(); $TestModel2 = new Item(); $TestModel2->belongsTo['Syfile']['counterCache'] = true; - $TestModel2->belongsTo['Syfile']['counterScope'] = array('published' => true); + $TestModel2->belongsTo['Syfile']['counterScope'] = ['published' => true]; $result = $TestModel->findById(1); $this->assertNull($result['Syfile']['item_count']); - $TestModel2->save(array( + $TestModel2->save([ 'name' => 'Item 7', 'syfile_id' => 1, 'published' => true - )); + ]); $result = $TestModel->findById(1); @@ -678,11 +678,11 @@ public function testSaveWithCounterCacheScope() { $result = $TestModel->findById(1); $this->assertEquals(2, $result['Syfile']['item_count']); - $TestModel2->save(array( + $TestModel2->save([ 'id' => 1, 'syfile_id' => 1, 'published' => false - )); + ]); $result = $TestModel->findById(1); $this->assertEquals(1, $result['Syfile']['item_count']); @@ -697,52 +697,52 @@ public function testCounterCacheMultipleCaches() { $this->loadFixtures('CounterCacheUser', 'CounterCachePost'); $User = new CounterCacheUser(); $Post = new CounterCachePost(); - $Post->unbindModel(array('belongsTo' => array('User')), false); - $Post->bindModel(array( - 'belongsTo' => array( - 'User' => array( + $Post->unbindModel(['belongsTo' => ['User']], false); + $Post->bindModel([ + 'belongsTo' => [ + 'User' => [ 'className' => 'CounterCacheUser', 'foreignKey' => 'user_id', - 'counterCache' => array( + 'counterCache' => [ true, - 'posts_published' => array('Post.published' => true) - ) - ) - ) - ), false); + 'posts_published' => ['Post.published' => true] + ] + ] + ] + ], false); // Count Increase - $data = array('Post' => array( + $data = ['Post' => [ 'id' => 22, 'title' => 'New Post', 'user_id' => 66, 'published' => true - )); + ]]; $Post->save($data); - $result = $User->find('first', array( - 'conditions' => array('id' => 66), + $result = $User->find('first', [ + 'conditions' => ['id' => 66], 'recursive' => -1 - )); + ]); $this->assertEquals(3, $result[$User->alias]['post_count']); $this->assertEquals(2, $result[$User->alias]['posts_published']); // Count decrease $Post->delete(1); - $result = $User->find('first', array( - 'conditions' => array('id' => 66), + $result = $User->find('first', [ + 'conditions' => ['id' => 66], 'recursive' => -1 - )); + ]); $this->assertEquals(2, $result[$User->alias]['post_count']); $this->assertEquals(2, $result[$User->alias]['posts_published']); // Count update - $data = $Post->find('first', array( - 'conditions' => array('id' => 1), + $data = $Post->find('first', [ + 'conditions' => ['id' => 1], 'recursive' => -1 - )); + ]); $data[$Post->alias]['user_id'] = 301; $Post->save($data); - $result = $User->find('all', array('order' => 'User.id')); + $result = $User->find('all', ['order' => 'User.id']); $this->assertEquals(2, $result[0]['User']['post_count']); $this->assertEquals(1, $result[1]['User']['posts_published']); } @@ -757,14 +757,14 @@ public function testCounterCacheSkip() { $User = new CounterCacheUser(); $Post = new CounterCachePost(); - $data = $Post->find('first', array( - 'conditions' => array('id' => 1), + $data = $Post->find('first', [ + 'conditions' => ['id' => 1], 'recursive' => -1 - )); + ]); $data[$Post->alias]['user_id'] = 301; - $Post->save($data, array('counterCache' => false)); + $Post->save($data, ['counterCache' => false]); - $users = $User->find('all', array('order' => 'User.id')); + $users = $User->find('all', ['order' => 'User.id']); $this->assertEquals(2, $users[0]['User']['post_count']); $this->assertEquals(1, $users[1]['User']['post_count']); } @@ -779,10 +779,10 @@ public function testBeforeValidateSaveAbortion() { $Model = new CallbackPostTestModel(); $Model->beforeValidateReturn = false; - $data = array( + $data = [ 'title' => 'new article', 'body' => 'this is some text.' - ); + ]; $Model->create(); $result = $Model->save($data); $this->assertFalse($result); @@ -798,10 +798,10 @@ public function testBeforeSaveSaveAbortion() { $Model = new CallbackPostTestModel(); $Model->beforeSaveReturn = false; - $data = array( + $data = [ 'title' => 'new article', 'body' => 'this is some text.' - ); + ]; $Model->create(); $result = $Model->save($data); $this->assertFalse($result); @@ -818,60 +818,60 @@ public function testSaveAtomic() { // Create record with 'atomic' = false - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => '1', 'title' => 'Fourth Article', 'body' => 'Fourth Article Body', 'published' => 'Y' - ) - ); + ] + ]; $TestModel->create(); - $result = $TestModel->save($data, array('atomic' => false)); + $result = $TestModel->save($data, ['atomic' => false]); $this->assertTrue((bool)$result); // Check record we created $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 4); - $expected = array( - 'Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 4); + $expected = [ + 'Article' => [ 'id' => '4', 'user_id' => '1', 'title' => 'Fourth Article', 'body' => 'Fourth Article Body', 'published' => 'Y' - ) - ); + ] + ]; $this->assertEquals($expected, $result); // Create record with 'atomic' = true - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => '4', 'title' => 'Fifth Article', 'body' => 'Fifth Article Body', 'published' => 'Y' - ) - ); + ] + ]; $TestModel->create(); - $result = $TestModel->save($data, array('atomic' => true)); + $result = $TestModel->save($data, ['atomic' => true]); $this->assertTrue((bool)$result); // Check record we created $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5); - $expected = array( - 'Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 5); + $expected = [ + 'Article' => [ 'id' => '5', 'user_id' => '4', 'title' => 'Fifth Article', 'body' => 'Fifth Article Body', 'published' => 'Y' - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -883,11 +883,11 @@ public function testSaveAtomic() { public function testSaveTransactionNoRollback() { $this->loadFixtures('Post', 'Article'); - $db = $this->getMock('DboSource', array('begin', 'connect', 'rollback', 'describe')); + $db = $this->getMock('DboSource', ['begin', 'connect', 'rollback', 'describe']); $db->expects($this->once()) ->method('describe') - ->will($this->returnValue(array())); + ->will($this->returnValue([])); $db->expects($this->once()) ->method('begin') ->will($this->returnValue(true)); @@ -897,16 +897,16 @@ public function testSaveTransactionNoRollback() { $Post = new TestPost(); $Post->setDataSourceObject($db); - $callback = array($this, 'callbackForTestSaveTransaction'); + $callback = [$this, 'callbackForTestSaveTransaction']; $Post->getEventManager()->attach($callback, 'Model.beforeSave'); - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'author_id' => 1, 'title' => 'New Fourth Post' - ) - ); - $Post->save($data, array('atomic' => true)); + ] + ]; + $Post->save($data, ['atomic' => true]); } /** @@ -920,14 +920,14 @@ public function callbackForTestSaveTransaction($event) { // Create record. Do not use same model as in testSaveTransaction // to avoid infinite loop. - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => '1', 'title' => 'Fourth Article', 'body' => 'Fourth Article Body', 'published' => 'Y' - ) - ); + ] + ]; $TestModel->create(); $result = $TestModel->save($data); $this->assertTrue((bool)$result); @@ -948,18 +948,18 @@ public function testSaveTransaction() { // Check if Database supports transactions - $PostModel->validate = array('title' => 'notBlank'); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post'), - array('author_id' => 1, 'title' => '') - ); + $PostModel->validate = ['title' => 'notBlank']; + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post'], + ['author_id' => 1, 'title' => ''] + ]; $this->assertFalse($PostModel->saveAll($data)); - $result = $PostModel->find('all', array('recursive' => -1)); - $expectedPosts = array( - array( - 'Post' => array( + $result = $PostModel->find('all', ['recursive' => -1]); + $expectedPosts = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => 1, 'title' => 'First Post', @@ -967,10 +967,10 @@ public function testSaveTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '2', 'author_id' => 3, 'title' => 'Second Post', @@ -978,10 +978,10 @@ public function testSaveTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '3', 'author_id' => 1, 'title' => 'Third Post', @@ -989,9 +989,9 @@ public function testSaveTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ) - ); + ] + ] + ]; $this->skipIf(count($result) !== 3, 'Database does not support transactions.'); @@ -999,31 +999,31 @@ public function testSaveTransaction() { // Database supports transactions --> continue tests - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'author_id' => 1, 'title' => 'New Fourth Post' - ) - ); + ] + ]; - $callback = array($this, 'callbackForTestSaveTransaction'); + $callback = [$this, 'callbackForTestSaveTransaction']; $PostModel->getEventManager()->attach($callback, 'Model.beforeSave'); $PostModel->create(); - $result = $PostModel->save($data, array('atomic' => true)); + $result = $PostModel->save($data, ['atomic' => true]); $this->assertFalse($result); - $result = $PostModel->find('all', array('recursive' => -1)); + $result = $PostModel->find('all', ['recursive' => -1]); $this->assertEquals($expectedPosts, $result); // Check record we created in callbackForTestSaveTransaction method. // record should not exist due to rollback $ArticleModel = new Article(); - $result = $ArticleModel->find('all', array('recursive' => -1)); - $expectedArticles = array( - array( - 'Article' => array( + $result = $ArticleModel->find('all', ['recursive' => -1]); + $expectedArticles = [ + [ + 'Article' => [ 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', @@ -1031,10 +1031,10 @@ public function testSaveTransaction() { 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31', 'id' => '1' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'user_id' => '3', 'title' => 'Second Article', 'body' => 'Second Article Body', @@ -1042,10 +1042,10 @@ public function testSaveTransaction() { 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31', 'id' => '2' - ) - ), - array( - 'Article' => array( + ] + ], + [ + 'Article' => [ 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', @@ -1053,9 +1053,9 @@ public function testSaveTransaction() { 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31', 'id' => '3' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expectedArticles, $result); } @@ -1073,13 +1073,13 @@ public function testSaveField() { $this->assertFalse(empty($result)); $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body'), 1); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body'], 1); + $expected = ['Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'New First Article', 'body' => 'First Article Body' - )); + ]]; $this->assertEquals($expected, $result); $TestModel->id = 1; @@ -1087,13 +1087,13 @@ public function testSaveField() { $this->assertFalse(empty($result)); $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body'), 1); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body'], 1); + $expected = ['Article' => [ 'id' => '1', 'user_id' => '1', 'title' => '', 'body' => 'First Article Body' - )); + ]]; $result['Article']['title'] = trim($result['Article']['title']); $this->assertEquals($expected, $result); @@ -1101,17 +1101,17 @@ public function testSaveField() { $TestModel->set('body', 'Messed up data'); $result = $TestModel->saveField('title', 'First Article'); $this->assertFalse(empty($result)); - $result = $TestModel->read(array('id', 'user_id', 'title', 'body'), 1); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body'], 1); + $expected = ['Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body' - )); + ]]; $this->assertEquals($expected, $result); $TestModel->recursive = -1; - $TestModel->read(array('id', 'user_id', 'title', 'body'), 1); + $TestModel->read(['id', 'user_id', 'title', 'body'], 1); $TestModel->id = 1; $result = $TestModel->saveField('title', '', true); @@ -1122,22 +1122,22 @@ public function testSaveField() { $result = $TestModel->saveField('user_id', 9999); $this->assertTrue((bool)$result); - $result = $TestModel->read(array('id', 'user_id'), 1); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id'], 1); + $expected = ['Article' => [ 'id' => '1', 'user_id' => '9999', - )); + ]]; $this->assertEquals($expected, $result); $this->loadFixtures('Node', 'Dependency'); $Node = new Node(); $Node->set('id', 1); $result = $Node->read(); - $this->assertEquals(array('Second'), Hash::extract($result, 'ParentNode.{n}.name')); + $this->assertEquals(['Second'], Hash::extract($result, 'ParentNode.{n}.name')); $Node->saveField('state', 10); $result = $Node->read(); - $this->assertEquals(array('Second'), Hash::extract($result, 'ParentNode.{n}.name')); + $this->assertEquals(['Second'], Hash::extract($result, 'ParentNode.{n}.name')); } /** @@ -1157,91 +1157,91 @@ public function testSaveWithCreate() { ); $TestModel = new User(); - $data = array('User' => array( + $data = ['User' => [ 'user' => 'user', 'password' => '' - )); + ]]; $result = $TestModel->save($data); $this->assertFalse($result); $this->assertTrue(!empty($TestModel->validationErrors)); $TestModel = new Article(); - $data = array('Article' => array( + $data = ['Article' => [ 'user_id' => '', 'title' => '', 'body' => '' - )); + ]]; $result = $TestModel->create($data) && $TestModel->save(); $this->assertFalse($result); $this->assertTrue(!empty($TestModel->validationErrors)); - $data = array('Article' => array( + $data = ['Article' => [ 'id' => 1, 'user_id' => '1', 'title' => 'New First Article', 'body' => '' - )); + ]]; $result = $TestModel->create($data) && $TestModel->save(); $this->assertFalse($result); - $data = array('Article' => array( + $data = ['Article' => [ 'id' => 1, 'title' => 'New First Article' - )); + ]]; $result = $TestModel->create() && $TestModel->save($data, false); $this->assertFalse(empty($result)); $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 1); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 1); + $expected = ['Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'New First Article', 'body' => 'First Article Body', 'published' => 'N' - )); + ]]; $this->assertEquals($expected, $result); - $data = array('Article' => array( + $data = ['Article' => [ 'id' => 1, 'user_id' => '2', 'title' => 'First Article', 'body' => 'New First Article Body', 'published' => 'Y' - )); - $result = $TestModel->create() && $TestModel->save($data, true, array('id', 'title', 'published')); + ]]; + $result = $TestModel->create() && $TestModel->save($data, true, ['id', 'title', 'published']); $this->assertFalse(empty($result)); $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 1); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 1); + $expected = ['Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y' - )); + ]]; $this->assertEquals($expected, $result); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => '2', 'title' => 'New Article', 'body' => 'New Article Body', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' - ), - 'Tag' => array('Tag' => array(1, 3)) - ); + ], + 'Tag' => ['Tag' => [1, 3]] + ]; $TestModel->create(); $result = $TestModel->create() && $TestModel->save($data); $this->assertFalse(empty($result)); $TestModel->recursive = 2; $result = $TestModel->read(null, 4); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'id' => '4', 'user_id' => '2', 'title' => 'New Article', @@ -1249,54 +1249,54 @@ public function testSaveWithCreate() { 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Comment' => array(), - 'Tag' => array( - array( + ], + 'Comment' => [], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $data = array('Comment' => array( + $data = ['Comment' => [ 'article_id' => '4', 'user_id' => '1', 'comment' => 'Comment New Article', 'published' => 'Y', 'created' => '2007-03-18 14:57:23', 'updated' => '2007-03-18 14:59:31' - )); + ]]; $result = $TestModel->Comment->create() && $TestModel->Comment->save($data); $this->assertFalse(empty($result)); - $data = array('Attachment' => array( + $data = ['Attachment' => [ 'comment_id' => '7', 'attachment' => 'newattachment.zip', 'created' => '2007-03-18 15:02:23', 'updated' => '2007-03-18 15:04:31' - )); + ]]; $result = $TestModel->Comment->Attachment->save($data); $this->assertFalse(empty($result)); $TestModel->recursive = 2; $result = $TestModel->read(null, 4); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'id' => '4', 'user_id' => '2', 'title' => 'New Article', @@ -1304,16 +1304,16 @@ public function testSaveWithCreate() { 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '2', 'user' => 'nate', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '7', 'article_id' => '4', 'user_id' => '1', @@ -1321,7 +1321,7 @@ public function testSaveWithCreate() { 'published' => 'Y', 'created' => '2007-03-18 14:57:23', 'updated' => '2007-03-18 14:59:31', - 'Article' => array( + 'Article' => [ 'id' => '4', 'user_id' => '2', 'title' => 'New Article', @@ -1329,34 +1329,34 @@ public function testSaveWithCreate() { 'published' => 'N', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => '2', 'comment_id' => '7', 'attachment' => 'newattachment.zip', 'created' => '2007-03-18 15:02:23', 'updated' => '2007-03-18 15:04:31' - ))), - 'Tag' => array( - array( + ]]], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -1371,17 +1371,17 @@ public function testSaveWithNullId() { $User = new User(); $User->read(null, 1); $User->data['User']['id'] = null; - $result = $User->save(array('password' => 'test')); + $result = $User->save(['password' => 'test']); $this->assertFalse(empty($result)); $this->assertTrue($User->id > 0); $User->read(null, 2); $User->data['User']['id'] = null; - $result = $User->save(array('password' => 'test')); + $result = $User->save(['password' => 'test']); $this->assertFalse(empty($result)); $this->assertTrue($User->id > 0); - $User->data['User'] = array('password' => 'something'); + $User->data['User'] = ['password' => 'something']; $result = $User->save(); $this->assertFalse(empty($result)); $result = $User->read(); @@ -1399,122 +1399,122 @@ public function testSaveWithSet() { // Create record we will be updating later - $data = array('Article' => array( + $data = ['Article' => [ 'user_id' => '1', 'title' => 'Fourth Article', 'body' => 'Fourth Article Body', 'published' => 'Y' - )); + ]]; $result = $TestModel->create() && $TestModel->save($data); $this->assertFalse(empty($result)); // Check record we created $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 4); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 4); + $expected = ['Article' => [ 'id' => '4', 'user_id' => '1', 'title' => 'Fourth Article', 'body' => 'Fourth Article Body', 'published' => 'Y' - )); + ]]; $this->assertEquals($expected, $result); // Create new record just to overlap Model->id on previously created record - $data = array('Article' => array( + $data = ['Article' => [ 'user_id' => '4', 'title' => 'Fifth Article', 'body' => 'Fifth Article Body', 'published' => 'Y' - )); + ]]; $result = $TestModel->create() && $TestModel->save($data); $this->assertFalse(empty($result)); $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 5); + $expected = ['Article' => [ 'id' => '5', 'user_id' => '4', 'title' => 'Fifth Article', 'body' => 'Fifth Article Body', 'published' => 'Y' - )); + ]]; $this->assertEquals($expected, $result); // Go back and edit the first article we created, starting by checking it's still there $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 4); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 4); + $expected = ['Article' => [ 'id' => '4', 'user_id' => '1', 'title' => 'Fourth Article', 'body' => 'Fourth Article Body', 'published' => 'Y' - )); + ]]; $this->assertEquals($expected, $result); // And now do the update with set() - $data = array('Article' => array( + $data = ['Article' => [ 'id' => '4', 'title' => 'Fourth Article - New Title', 'published' => 'N' - )); + ]]; $result = $TestModel->set($data) && $TestModel->save(); $this->assertFalse(empty($result)); $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 4); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 4); + $expected = ['Article' => [ 'id' => '4', 'user_id' => '1', 'title' => 'Fourth Article - New Title', 'body' => 'Fourth Article Body', 'published' => 'N' - )); + ]]; $this->assertEquals($expected, $result); $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 5); + $expected = ['Article' => [ 'id' => '5', 'user_id' => '4', 'title' => 'Fifth Article', 'body' => 'Fifth Article Body', 'published' => 'Y' - )); + ]]; $this->assertEquals($expected, $result); - $data = array('Article' => array('id' => '5', 'title' => 'Fifth Article - New Title 5')); + $data = ['Article' => ['id' => '5', 'title' => 'Fifth Article - New Title 5']]; $result = ($TestModel->set($data) && $TestModel->save()); $this->assertFalse(empty($result)); $TestModel->recursive = -1; - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5); - $expected = array('Article' => array( + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 5); + $expected = ['Article' => [ 'id' => '5', 'user_id' => '4', 'title' => 'Fifth Article - New Title 5', 'body' => 'Fifth Article Body', 'published' => 'Y' - )); + ]]; $this->assertEquals($expected, $result); $TestModel->recursive = -1; - $result = $TestModel->find('all', array( - 'fields' => array('id', 'title'), - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array('Article' => array('id' => 1, 'title' => 'First Article')), - array('Article' => array('id' => 2, 'title' => 'Second Article')), - array('Article' => array('id' => 3, 'title' => 'Third Article')), - array('Article' => array('id' => 4, 'title' => 'Fourth Article - New Title')), - array('Article' => array('id' => 5, 'title' => 'Fifth Article - New Title 5')) - ); + $result = $TestModel->find('all', [ + 'fields' => ['id', 'title'], + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + ['Article' => ['id' => 1, 'title' => 'First Article']], + ['Article' => ['id' => 2, 'title' => 'Second Article']], + ['Article' => ['id' => 3, 'title' => 'Third Article']], + ['Article' => ['id' => 4, 'title' => 'Fourth Article - New Title']], + ['Article' => ['id' => 5, 'title' => 'Fifth Article - New Title 5']] + ]; $this->assertEquals($expected, $result); } @@ -1528,44 +1528,44 @@ public function testSaveWithNonExistentFields() { $TestModel = new Article(); $TestModel->recursive = -1; - $data = array( + $data = [ 'non_existent' => 'This field does not exist', 'user_id' => '1', 'title' => 'Fourth Article - New Title', 'body' => 'Fourth Article Body', 'published' => 'N' - ); + ]; $result = $TestModel->create() && $TestModel->save($data); $this->assertFalse(empty($result)); - $expected = array('Article' => array( + $expected = ['Article' => [ 'id' => '4', 'user_id' => '1', 'title' => 'Fourth Article - New Title', 'body' => 'Fourth Article Body', 'published' => 'N' - )); - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 4); + ]]; + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 4); $this->assertEquals($expected, $result); - $data = array( + $data = [ 'user_id' => '1', 'non_existent' => 'This field does not exist', 'title' => 'Fifth Article - New Title', 'body' => 'Fifth Article Body', 'published' => 'N' - ); + ]; $result = $TestModel->create() && $TestModel->save($data); $this->assertFalse(empty($result)); - $expected = array('Article' => array( + $expected = ['Article' => [ 'id' => '5', 'user_id' => '1', 'title' => 'Fifth Article - New Title', 'body' => 'Fifth Article Body', 'published' => 'N' - )); - $result = $TestModel->read(array('id', 'user_id', 'title', 'body', 'published'), 5); + ]]; + $result = $TestModel->read(['id', 'user_id', 'title', 'body', 'published'], 5); $this->assertEquals($expected, $result); } @@ -1582,17 +1582,17 @@ public function testSaveFromXml() { $Article = new Article(); $result = $Article->save(Xml::build('
')); $this->assertFalse(empty($result)); - $results = $Article->find('first', array('conditions' => array('Article.title' => 'test xml'))); + $results = $Article->find('first', ['conditions' => ['Article.title' => 'test xml']]); $this->assertFalse(empty($results)); $result = $Article->save(Xml::build('
testing6
')); $this->assertFalse(empty($result)); - $results = $Article->find('first', array('conditions' => array('Article.title' => 'testing'))); + $results = $Article->find('first', ['conditions' => ['Article.title' => 'testing']]); $this->assertFalse(empty($results)); - $result = $Article->save(Xml::build('
testing with DOMDocument7
', array('return' => 'domdocument'))); + $result = $Article->save(Xml::build('
testing with DOMDocument7
', ['return' => 'domdocument'])); $this->assertFalse(empty($result)); - $results = $Article->find('first', array('conditions' => array('Article.title' => 'testing with DOMDocument'))); + $results = $Article->find('first', ['conditions' => ['Article.title' => 'testing with DOMDocument']]); $this->assertFalse(empty($results)); } @@ -1606,8 +1606,8 @@ public function testSaveHabtm() { $TestModel = new Article(); $result = $TestModel->findById(2); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -1615,16 +1615,16 @@ public function testSaveHabtm() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'User' => array( + ], + 'User' => [ 'id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '5', 'article_id' => '2', 'user_id' => '1', @@ -1632,8 +1632,8 @@ public function testSaveHabtm() { 'published' => 'Y', 'created' => '2007-03-18 10:53:23', 'updated' => '2007-03-18 10:55:31' - ), - array( + ], + [ 'id' => '6', 'article_id' => '2', 'user_id' => '2', @@ -1641,31 +1641,31 @@ public function testSaveHabtm() { 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31' - )), - 'Tag' => array( - array( + ]], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'id' => '2', 'title' => 'New Second Article' - ), - 'Tag' => array('Tag' => array(1, 2)) - ); + ], + 'Tag' => ['Tag' => [1, 2]] + ]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); @@ -1673,78 +1673,78 @@ public function testSaveHabtm() { $this->assertFalse(empty($result)); $this->assertEquals($data['Tag'], $result['Tag']); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment'), - )); - $TestModel->bindModel(array( - 'hasAndBelongsToMany' => array( - 'Tag' => array('order' => 'Tag.id'), - ), - ), false); - $result = $TestModel->find('first', array( - 'fields' => array('id', 'user_id', 'title', 'body'), - 'conditions' => array('Article.id' => 2), - )); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'], + ]); + $TestModel->bindModel([ + 'hasAndBelongsToMany' => [ + 'Tag' => ['order' => 'Tag.id'], + ], + ], false); + $result = $TestModel->find('first', [ + 'fields' => ['id', 'user_id', 'title', 'body'], + 'conditions' => ['Article.id' => 2], + ]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $result); - $data = array('Article' => array('id' => '2'), 'Tag' => array('Tag' => array(2, 3))); + $data = ['Article' => ['id' => '2'], 'Tag' => ['Tag' => [2, 3]]]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); $result = $TestModel->save(); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); - $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); + $result = $TestModel->find('first', ['fields' => ['id', 'user_id', 'title', 'body'], 'conditions' => ['Article.id' => 2]]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $data = array('Tag' => array('Tag' => array(1, 2, 3))); + $data = ['Tag' => ['Tag' => [1, 2, 3]]]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); @@ -1752,233 +1752,233 @@ public function testSaveHabtm() { $result = $TestModel->save(); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); - $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); + $result = $TestModel->find('first', ['fields' => ['id', 'user_id', 'title', 'body'], 'conditions' => ['Article.id' => 2]]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $data = array('Tag' => array('Tag' => array())); + $data = ['Tag' => ['Tag' => []]]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); $result = $TestModel->save(); $this->assertFalse(empty($result)); - $data = array('Tag' => array('Tag' => '')); + $data = ['Tag' => ['Tag' => '']]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); $result = $TestModel->save(); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); - $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); + $result = $TestModel->find('first', ['fields' => ['id', 'user_id', 'title', 'body'], 'conditions' => ['Article.id' => 2]]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body' - ), - 'Tag' => array() - ); + ], + 'Tag' => [] + ]; $this->assertEquals($expected, $result); - $data = array('Tag' => array('Tag' => array(2, 3))); + $data = ['Tag' => ['Tag' => [2, 3]]]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); $result = $TestModel->save(); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); - $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); + $result = $TestModel->find('first', ['fields' => ['id', 'user_id', 'title', 'body'], 'conditions' => ['Article.id' => 2]]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $data = array( - 'Tag' => array( - 'Tag' => array(1, 2) - ), - 'Article' => array( + $data = [ + 'Tag' => [ + 'Tag' => [1, 2] + ], + 'Article' => [ 'id' => '2', 'title' => 'New Second Article' - )); + ]]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); $result = $TestModel->save(); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); - $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); + $result = $TestModel->find('first', ['fields' => ['id', 'user_id', 'title', 'body'], 'conditions' => ['Article.id' => 2]]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $data = array( - 'Tag' => array( - 'Tag' => array(1, 2) - ), - 'Article' => array( + $data = [ + 'Tag' => [ + 'Tag' => [1, 2] + ], + 'Article' => [ 'id' => '2', 'title' => 'New Second Article Title' - )); + ]]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); $result = $TestModel->save(); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); - $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); + $result = $TestModel->find('first', ['fields' => ['id', 'user_id', 'title', 'body'], 'conditions' => ['Article.id' => 2]]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'New Second Article Title', 'body' => 'Second Article Body' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); - $data = array( - 'Tag' => array( - 'Tag' => array(2, 3) - ), - 'Article' => array( + $data = [ + 'Tag' => [ + 'Tag' => [2, 3] + ], + 'Article' => [ 'id' => '2', 'title' => 'Changed Second Article' - )); + ]]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); $result = $TestModel->save(); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); - $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); + $result = $TestModel->find('first', ['fields' => ['id', 'user_id', 'title', 'body'], 'conditions' => ['Article.id' => 2]]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Changed Second Article', 'body' => 'Second Article Body' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); - $data = array( - 'Tag' => array( - 'Tag' => array(1, 3) - ), - 'Article' => array('id' => '2'), - ); + $data = [ + 'Tag' => [ + 'Tag' => [1, 3] + ], + 'Article' => ['id' => '2'], + ]; $result = $TestModel->set($data); $this->assertFalse(empty($result)); @@ -1986,57 +1986,57 @@ public function testSaveHabtm() { $result = $TestModel->save(); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); - $result = $TestModel->find('first', array('fields' => array('id', 'user_id', 'title', 'body'), 'conditions' => array('Article.id' => 2))); - $expected = array( - 'Article' => array( + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); + $result = $TestModel->find('first', ['fields' => ['id', 'user_id', 'title', 'body'], 'conditions' => ['Article.id' => 2]]); + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Changed Second Article', 'body' => 'Second Article Body' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))); + ]]]; $this->assertEquals($expected, $result); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'id' => 10, 'user_id' => '2', 'title' => 'New Article With Tags and fieldList', 'body' => 'New Article Body with Tags and fieldList', 'created' => '2007-03-18 14:55:23', 'updated' => '2007-03-18 14:57:31' - ), - 'Tag' => array( - 'Tag' => array(1, 2, 3) - ) - ); + ], + 'Tag' => [ + 'Tag' => [1, 2, 3] + ] + ]; $result = $TestModel->create() - && $TestModel->save($data, true, array('user_id', 'title', 'published')); + && $TestModel->save($data, true, ['user_id', 'title', 'published']); $this->assertFalse(empty($result)); - $TestModel->unbindModel(array( - 'belongsTo' => array('User'), - 'hasMany' => array('Comment') - )); + $TestModel->unbindModel([ + 'belongsTo' => ['User'], + 'hasMany' => ['Comment'] + ]); $result = $TestModel->read(); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'id' => 4, 'user_id' => 2, 'title' => 'New Article With Tags and fieldList', @@ -2044,49 +2044,49 @@ public function testSaveHabtm() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date(), - ), - 'Tag' => array( - 0 => array( + ], + 'Tag' => [ + 0 => [ 'id' => 1, 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - 1 => array( + ], + 1 => [ 'id' => 2, 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ), - 2 => array( + ], + 2 => [ 'id' => 3, 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))); + ]]]; $this->assertEquals($expected, $result); $this->loadFixtures('JoinA', 'JoinC', 'JoinAC', 'JoinB', 'JoinAB'); $TestModel = new JoinA(); - $TestModel->hasBelongsToMany = array('JoinC' => array('unique' => true)); - $data = array( - 'JoinA' => array( + $TestModel->hasBelongsToMany = ['JoinC' => ['unique' => true]]; + $data = [ + 'JoinA' => [ 'id' => 1, 'name' => 'Join A 1', 'body' => 'Join A 1 Body', - ), - 'JoinC' => array( - 'JoinC' => array( - array('join_c_id' => 2, 'other' => 'new record'), - array('join_c_id' => 3, 'other' => 'new record') - ) - ) - ); + ], + 'JoinC' => [ + 'JoinC' => [ + ['join_c_id' => 2, 'other' => 'new record'], + ['join_c_id' => 3, 'other' => 'new record'] + ] + ] + ]; $TestModel->save($data); $result = $TestModel->read(null, 1); - $expected = array(4, 5); + $expected = [4, 5]; $this->assertEquals($expected, Hash::extract($result, 'JoinC.{n}.JoinAsJoinC.id')); - $expected = array('new record', 'new record'); + $expected = ['new record', 'new record']; $this->assertEquals($expected, Hash::extract($result, 'JoinC.{n}.JoinAsJoinC.other')); } @@ -2100,34 +2100,34 @@ public function testSaveHabtmEmptyData() { $this->loadFixtures('Node', 'Dependency'); $Node = new Node(); - $data = array( - 'Node' => array('name' => 'New First') - ); + $data = [ + 'Node' => ['name' => 'New First'] + ]; $Node->id = 1; $Node->save($data); - $node = $Node->find('first', array( - 'conditions' => array('Node.id' => 1), - 'contain' => array('ParentNode') - )); + $node = $Node->find('first', [ + 'conditions' => ['Node.id' => 1], + 'contain' => ['ParentNode'] + ]); $result = Hash::extract($node, 'ParentNode.{n}.id'); - $expected = array(2); + $expected = [2]; $this->assertEquals($expected, $result); - $data = array( - 'ParentNode' => array() - ); + $data = [ + 'ParentNode' => [] + ]; $Node->id = 1; $Node->save($data); - $node = $Node->find('first', array( - 'conditions' => array('Node.id' => 1), - 'contain' => array('ParentNode') - )); + $node = $Node->find('first', [ + 'conditions' => ['Node.id' => 1], + 'contain' => ['ParentNode'] + ]); $result = Hash::extract($node, 'ParentNode.{n}.id'); - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); } @@ -2140,10 +2140,10 @@ public function testSaveHabtmNoPrimaryData() { $this->loadFixtures('Article', 'User', 'Comment', 'Tag', 'ArticlesTag'); $TestModel = new Article(); - $TestModel->unbindModel(array('belongsTo' => array('User'), 'hasMany' => array('Comment')), false); + $TestModel->unbindModel(['belongsTo' => ['User'], 'hasMany' => ['Comment']], false); $result = $TestModel->findById(2); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -2151,33 +2151,33 @@ public function testSaveHabtmNoPrimaryData() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31' - ), - array( + ], + [ 'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $TestModel->id = 2; - $data = array('Tag' => array('Tag' => array(2))); + $data = ['Tag' => ['Tag' => [2]]]; $result = $TestModel->save($data); $this->assertEquals($data['Tag'], $result['Tag']); $result = $TestModel->findById(2); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'id' => '2', 'user_id' => '3', 'title' => 'Second Article', @@ -2185,92 +2185,92 @@ public function testSaveHabtmNoPrimaryData() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => static::date() - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $this->loadFixtures('Portfolio', 'Item', 'ItemsPortfolio'); $TestModel = new Portfolio(); $result = $TestModel->findById(2); - $expected = array( - 'Portfolio' => array( + $expected = [ + 'Portfolio' => [ 'id' => 2, 'seller_id' => 1, 'name' => 'Portfolio 2' - ), - 'Item' => array( - array( + ], + 'Item' => [ + [ 'id' => 2, 'syfile_id' => 2, 'published' => '', 'name' => 'Item 2', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 2, 'item_id' => 2, 'portfolio_id' => 2 - ) - ), - array( + ] + ], + [ 'id' => 6, 'syfile_id' => 6, 'published' => '', 'name' => 'Item 6', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 6, 'item_id' => 6, 'portfolio_id' => 2 - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, $result); - $data = array('Item' => array('Item' => array(1, 2))); + $data = ['Item' => ['Item' => [1, 2]]]; $TestModel->id = 2; $result = $TestModel->save($data); $this->assertTrue((bool)$result); $result = $TestModel->findById(2); $result['Item'] = Hash::sort($result['Item'], '{n}.id', 'asc'); - $expected = array( - 'Portfolio' => array( + $expected = [ + 'Portfolio' => [ 'id' => 2, 'seller_id' => 1, 'name' => 'Portfolio 2' - ), - 'Item' => array( - array( + ], + 'Item' => [ + [ 'id' => 1, 'syfile_id' => 1, 'published' => '', 'name' => 'Item 1', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 7, 'item_id' => 1, 'portfolio_id' => 2 - ) - ), - array( + ] + ], + [ 'id' => 2, 'syfile_id' => 2, 'published' => '', 'name' => 'Item 2', - 'ItemsPortfolio' => array( + 'ItemsPortfolio' => [ 'id' => 8, 'item_id' => 2, 'portfolio_id' => 2 - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, $result); } @@ -2283,44 +2283,44 @@ public function testSaveHabtmCustomKeys() { $this->loadFixtures('Story', 'StoriesTag', 'Tag'); $Story = new Story(); - $data = array( - 'Story' => array('story' => '1'), - 'Tag' => array( - 'Tag' => array(2, 3) - )); + $data = [ + 'Story' => ['story' => '1'], + 'Tag' => [ + 'Tag' => [2, 3] + ]]; $result = $Story->set($data); $this->assertFalse(empty($result)); $result = $Story->save(); $this->assertFalse(empty($result)); - $result = $Story->find('all', array('order' => array('Story.story'))); - $expected = array( - array( - 'Story' => array( + $result = $Story->find('all', ['order' => ['Story.story']]); + $expected = [ + [ + 'Story' => [ 'story' => 1, 'title' => 'First Story' - ), - 'Tag' => array( - array( + ], + 'Tag' => [ + [ 'id' => 2, 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31' - ), - array( + ], + [ 'id' => 3, 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31' - ))), - array( - 'Story' => array( + ]]], + [ + 'Story' => [ 'story' => 2, 'title' => 'Second Story' - ), - 'Tag' => array() - )); + ], + 'Tag' => [] + ]]; $this->assertEquals($expected, $result); } @@ -2333,37 +2333,37 @@ public function testSaveHabtmCustomKeys() { public function testHabtmSaveWithConditionsInAssociation() { $this->loadFixtures('JoinThing', 'Something', 'SomethingElse'); $Something = new Something(); - $Something->unbindModel(array('hasAndBelongsToMany' => array('SomethingElse')), false); + $Something->unbindModel(['hasAndBelongsToMany' => ['SomethingElse']], false); - $Something->bindModel(array( - 'hasAndBelongsToMany' => array( - 'DoomedSomethingElse' => array( + $Something->bindModel([ + 'hasAndBelongsToMany' => [ + 'DoomedSomethingElse' => [ 'className' => 'SomethingElse', 'joinTable' => 'join_things', - 'conditions' => array('JoinThing.doomed' => true), + 'conditions' => ['JoinThing.doomed' => true], 'unique' => true - ), - 'NotDoomedSomethingElse' => array( + ], + 'NotDoomedSomethingElse' => [ 'className' => 'SomethingElse', 'joinTable' => 'join_things', - 'conditions' => array('JoinThing.doomed' => 0), + 'conditions' => ['JoinThing.doomed' => 0], 'unique' => true - ) - ) - ), false); + ] + ] + ], false); $result = $Something->read(null, 1); $this->assertTrue(empty($result['NotDoomedSomethingElse'])); $this->assertEquals(1, count($result['DoomedSomethingElse'])); - $data = array( - 'Something' => array('id' => 1), - 'NotDoomedSomethingElse' => array( - 'NotDoomedSomethingElse' => array( - array('something_else_id' => 2, 'doomed' => 0), - array('something_else_id' => 3, 'doomed' => 0) - ) - ) - ); + $data = [ + 'Something' => ['id' => 1], + 'NotDoomedSomethingElse' => [ + 'NotDoomedSomethingElse' => [ + ['something_else_id' => 2, 'doomed' => 0], + ['something_else_id' => 3, 'doomed' => 0] + ] + ] + ]; $Something->create($data); $result = $Something->save(); $this->assertFalse(empty($result)); @@ -2383,82 +2383,82 @@ public function testHabtmSaveKeyResolution() { $ThePaper = new ThePaper(); $ThePaper->id = 1; - $ThePaper->save(array('Monkey' => array(2, 3))); + $ThePaper->save(['Monkey' => [2, 3]]); $result = $ThePaper->findById(1); - $expected = array( - array( + $expected = [ + [ 'id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1' - ), - array( + ], + [ 'id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2' - )); + ]]; $this->assertEquals($expected, $result['Monkey']); $ThePaper->id = 2; - $ThePaper->save(array('Monkey' => array(1, 2, 3))); + $ThePaper->save(['Monkey' => [1, 2, 3]]); $result = $ThePaper->findById(2); - $expected = array( - array( + $expected = [ + [ 'id' => '1', 'device_type_id' => '1', 'name' => 'Device 1', 'typ' => '1' - ), - array( + ], + [ 'id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1' - ), - array( + ], + [ 'id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2' - )); + ]]; $this->assertEquals($expected, $result['Monkey']); $ThePaper->id = 2; - $ThePaper->save(array('Monkey' => array(1, 3))); + $ThePaper->save(['Monkey' => [1, 3]]); $result = $ThePaper->findById(2); - $expected = array( - array( + $expected = [ + [ 'id' => '1', 'device_type_id' => '1', 'name' => 'Device 1', 'typ' => '1' - ), - array( + ], + [ 'id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2' - )); + ]]; $this->assertEquals($expected, $result['Monkey']); $result = $ThePaper->findById(1); - $expected = array( - array( + $expected = [ + [ 'id' => '2', 'device_type_id' => '1', 'name' => 'Device 2', 'typ' => '1' - ), - array( + ], + [ 'id' => '3', 'device_type_id' => '1', 'name' => 'Device 3', 'typ' => '2' - )); + ]]; $this->assertEquals($expected, $result['Monkey']); } @@ -2488,53 +2488,53 @@ public function testCreationOfEmptyRecord() { */ public function testCreateWithPKFiltering() { $TestModel = new Article(); - $data = array( + $data = [ 'id' => 5, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text' - ); + ]; $result = $TestModel->create($data); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'published' => 'N', 'id' => 5, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text' - )); + ]]; $this->assertEquals($expected, $result); $this->assertEquals(5, $TestModel->id); $result = $TestModel->create($data, true); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'published' => 'N', 'id' => false, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text' - )); + ]]; $this->assertEquals($expected, $result); $this->assertFalse($TestModel->id); - $result = $TestModel->create(array('Article' => $data), true); - $expected = array( - 'Article' => array( + $result = $TestModel->create(['Article' => $data], true); + $expected = [ + 'Article' => [ 'published' => 'N', 'id' => false, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text' - )); + ]]; $this->assertEquals($expected, $result); $this->assertFalse($TestModel->id); - $data = array( + $data = [ 'id' => 6, 'user_id' => 2, 'title' => 'My article', @@ -2542,11 +2542,11 @@ public function testCreateWithPKFiltering() { 'created' => '1970-01-01 00:00:00', 'updated' => '1970-01-01 12:00:00', 'modified' => '1970-01-01 12:00:00' - ); + ]; $result = $TestModel->create($data); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'published' => 'N', 'id' => 6, 'user_id' => 2, @@ -2555,24 +2555,24 @@ public function testCreateWithPKFiltering() { 'created' => '1970-01-01 00:00:00', 'updated' => '1970-01-01 12:00:00', 'modified' => '1970-01-01 12:00:00' - )); + ]]; $this->assertEquals($expected, $result); $this->assertEquals(6, $TestModel->id); - $result = $TestModel->create(array( - 'Article' => array_diff_key($data, array( + $result = $TestModel->create([ + 'Article' => array_diff_key($data, [ 'created' => true, 'updated' => true, 'modified' => true - ))), true); - $expected = array( - 'Article' => array( + ])], true); + $expected = [ + 'Article' => [ 'published' => 'N', 'id' => false, 'user_id' => 2, 'title' => 'My article', 'body' => 'Some text' - )); + ]]; $this->assertEquals($expected, $result); $this->assertFalse($TestModel->id); } @@ -2587,168 +2587,168 @@ public function testCreationWithMultipleData() { $Article = new Article(); $Comment = new Comment(); - $articles = $Article->find('all', array( - 'fields' => array('id', 'title'), + $articles = $Article->find('all', [ + 'fields' => ['id', 'title'], 'recursive' => -1, - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array('Article' => array( + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + ['Article' => [ 'id' => 1, 'title' => 'First Article' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 2, 'title' => 'Second Article' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 3, 'title' => 'Third Article' - ))); + ]]]; $this->assertEquals($expected, $articles); - $comments = $Comment->find('all', array( - 'fields' => array('id', 'article_id', 'user_id', 'comment', 'published'), + $comments = $Comment->find('all', [ + 'fields' => ['id', 'article_id', 'user_id', 'comment', 'published'], 'recursive' => -1, - 'order' => array('Comment.id' => 'ASC') - )); - $expected = array( - array('Comment' => array( + 'order' => ['Comment.id' => 'ASC'] + ]); + $expected = [ + ['Comment' => [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y' - ))); + ]]]; $this->assertEquals($expected, $comments); - $data = array( - 'Comment' => array( + $data = [ + 'Comment' => [ 'article_id' => 2, 'user_id' => 4, 'comment' => 'Brand New Comment', 'published' => 'N' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => 2, 'title' => 'Second Article Modified' - )); + ]]; $result = $Comment->create($data); $this->assertFalse(empty($result)); $result = $Comment->save(); $this->assertFalse(empty($result)); - $articles = $Article->find('all', array( - 'fields' => array('id', 'title'), + $articles = $Article->find('all', [ + 'fields' => ['id', 'title'], 'recursive' => -1, - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array('Article' => array( + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + ['Article' => [ 'id' => 1, 'title' => 'First Article' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 2, 'title' => 'Second Article' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 3, 'title' => 'Third Article' - ))); + ]]]; $this->assertEquals($expected, $articles); - $comments = $Comment->find('all', array( - 'fields' => array('id', 'article_id', 'user_id', 'comment', 'published'), + $comments = $Comment->find('all', [ + 'fields' => ['id', 'article_id', 'user_id', 'comment', 'published'], 'recursive' => -1, - 'order' => array('Comment.id' => 'ASC') - )); - $expected = array( - array('Comment' => array( + 'order' => ['Comment.id' => 'ASC'] + ]); + $expected = [ + ['Comment' => [ 'id' => 1, 'article_id' => 1, 'user_id' => 2, 'comment' => 'First Comment for First Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 2, 'article_id' => 1, 'user_id' => 4, 'comment' => 'Second Comment for First Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 3, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Third Comment for First Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 4, 'article_id' => 1, 'user_id' => 1, 'comment' => 'Fourth Comment for First Article', 'published' => 'N' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 5, 'article_id' => 2, 'user_id' => 1, 'comment' => 'First Comment for Second Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 6, 'article_id' => 2, 'user_id' => 2, 'comment' => 'Second Comment for Second Article', 'published' => 'Y' - )), - array('Comment' => array( + ]], + ['Comment' => [ 'id' => 7, 'article_id' => 2, 'user_id' => 4, 'comment' => 'Brand New Comment', 'published' => 'N' - ))); + ]]]; $this->assertEquals($expected, $comments); } @@ -2761,19 +2761,19 @@ public function testCreationWithMultipleDataSameModel() { $this->loadFixtures('Article'); $Article = new Article(); - $result = $Article->field('title', array('id' => 1)); + $result = $Article->field('title', ['id' => 1]); $this->assertEquals('First Article', $result); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => 2, 'title' => 'Brand New Article', 'body' => 'Brand New Article Body', 'published' => 'Y' - ), - 'SecondaryArticle' => array( + ], + 'SecondaryArticle' => [ 'id' => 1 - )); + ]]; $Article->create(); $result = $Article->save($data); @@ -2782,31 +2782,31 @@ public function testCreationWithMultipleDataSameModel() { $result = $Article->getInsertID(); $this->assertTrue(!empty($result)); - $result = $Article->field('title', array('id' => 1)); + $result = $Article->field('title', ['id' => 1]); $this->assertEquals('First Article', $result); - $articles = $Article->find('all', array( - 'fields' => array('id', 'title'), + $articles = $Article->find('all', [ + 'fields' => ['id', 'title'], 'recursive' => -1, - 'order' => array('Article.id' => 'ASC') - )); - $expected = array( - array('Article' => array( + 'order' => ['Article.id' => 'ASC'] + ]); + $expected = [ + ['Article' => [ 'id' => 1, 'title' => 'First Article' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 2, 'title' => 'Second Article' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 3, 'title' => 'Third Article' - )), - array('Article' => array( + ]], + ['Article' => [ 'id' => 4, 'title' => 'Brand New Article' - ))); + ]]]; $this->assertEquals($expected, $articles); } @@ -2820,28 +2820,28 @@ public function testCreationWithMultipleDataSameModelManualInstances() { $this->loadFixtures('PrimaryModel'); $Primary = new PrimaryModel(); - $result = $Primary->field('primary_name', array('id' => 1)); + $result = $Primary->field('primary_name', ['id' => 1]); $this->assertEquals('Primary Name Existing', $result); - $data = array( - 'PrimaryModel' => array( + $data = [ + 'PrimaryModel' => [ 'primary_name' => 'Primary Name New' - ), - 'SecondaryModel' => array( - 'id' => array(1) - )); + ], + 'SecondaryModel' => [ + 'id' => [1] + ]]; $Primary->create(); $result = $Primary->save($data); $this->assertFalse(empty($result)); - $result = $Primary->field('primary_name', array('id' => 1)); + $result = $Primary->field('primary_name', ['id' => 1]); $this->assertEquals('Primary Name Existing', $result); $result = $Primary->getInsertID(); $this->assertTrue(!empty($result)); - $result = $Primary->field('primary_name', array('id' => $result)); + $result = $Primary->field('primary_name', ['id' => $result]); $this->assertEquals('Primary Name New', $result); $result = $Primary->find('count'); @@ -2882,18 +2882,18 @@ public function testUpdateExisting() { $TestModel = new User(); $TestModel->create(); - $TestModel->save(array( - 'User' => array( + $TestModel->save([ + 'User' => [ 'user' => 'some user', 'password' => 'some password' - ))); + ]]); $this->assertTrue(is_int($TestModel->id) || ((int)$TestModel->id === 5)); $id = $TestModel->id; - $TestModel->save(array( - 'User' => array( + $TestModel->save([ + 'User' => [ 'user' => 'updated user' - ))); + ]]); $this->assertEquals($id, $TestModel->id); $result = $TestModel->findById($id); @@ -2902,15 +2902,15 @@ public function testUpdateExisting() { $Article = new Article(); $Comment = new Comment(); - $data = array( - 'Comment' => array( + $data = [ + 'Comment' => [ 'id' => 1, 'comment' => 'First Comment for First Article' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => 2, 'title' => 'Second Article' - )); + ]]; $result = $Article->save($data); $this->assertFalse(empty($result)); @@ -2927,15 +2927,15 @@ public function testUpdateExisting() { public function testUpdateSavingBlankValues() { $this->loadFixtures('Article'); $Article = new Article(); - $Article->validate = array(); + $Article->validate = []; $Article->create(); - $result = $Article->save(array( + $result = $Article->save([ 'id' => 1, 'title' => '', 'body' => '' - )); + ]); $this->assertTrue((bool)$result); - $result = $Article->find('first', array('conditions' => array('Article.id' => 1))); + $result = $Article->find('first', ['conditions' => ['Article.id' => 1]]); $this->assertEquals('', $result['Article']['title'], 'Title is not blank'); $this->assertEquals('', $result['Article']['body'], 'Body is not blank'); } @@ -2949,24 +2949,24 @@ public function testUpdateMultiple() { $this->loadFixtures('Comment', 'Article', 'User', 'CategoryThread'); $TestModel = new Comment(); $result = Hash::extract($TestModel->find('all'), '{n}.Comment.user_id'); - $expected = array('2', '4', '1', '1', '1', '2'); + $expected = ['2', '4', '1', '1', '1', '2']; $this->assertEquals($expected, $result); - $TestModel->updateAll(array('Comment.user_id' => 5), array('Comment.user_id' => 2)); + $TestModel->updateAll(['Comment.user_id' => 5], ['Comment.user_id' => 2]); $result = Hash::combine($TestModel->find('all'), '{n}.Comment.id', '{n}.Comment.user_id'); - $expected = array(1 => 5, 2 => 4, 3 => 1, 4 => 1, 5 => 1, 6 => 5); + $expected = [1 => 5, 2 => 4, 3 => 1, 4 => 1, 5 => 1, 6 => 5]; $this->assertEquals($expected, $result); $result = $TestModel->updateAll( - array('Comment.comment' => "'Updated today'"), - array('Comment.user_id' => 5) + ['Comment.comment' => "'Updated today'"], + ['Comment.user_id' => 5] ); $this->assertFalse(empty($result)); $result = Hash::extract( - $TestModel->find('all', array( - 'conditions' => array( + $TestModel->find('all', [ + 'conditions' => [ 'Comment.user_id' => 5 - ))), + ]]), '{n}.Comment.comment' ); $expected = array_fill(0, 2, 'Updated today'); @@ -2982,8 +2982,8 @@ public function testHabtmUuidWithUuidId() { $this->loadFixtures('Uuidportfolio', 'Uuiditem', 'UuiditemsUuidportfolio', 'UuiditemsUuidportfolioNumericid'); $TestModel = new Uuidportfolio(); - $data = array('Uuidportfolio' => array('name' => 'Portfolio 3')); - $data['Uuiditem']['Uuiditem'] = array('483798c8-c7cc-430e-8cf9-4fcc40cf8569'); + $data = ['Uuidportfolio' => ['name' => 'Portfolio 3']]; + $data['Uuiditem']['Uuiditem'] = ['483798c8-c7cc-430e-8cf9-4fcc40cf8569']; $TestModel->create($data); $TestModel->save(); $id = $TestModel->id; @@ -3002,8 +3002,8 @@ public function testHabtmUuidWithUuidIdNative() { $this->loadFixtures('Uuidnativeportfolio', 'Uuidnativeitem', 'UuidnativeitemsUuidnativeportfolio', 'UuidnativeitemsUuidnativeportfolioNumericid'); $TestModel = new Uuidnativeportfolio(); - $data = array('Uuidnativeportfolio' => array('name' => 'Portfolio 3')); - $data['Uuidnativeitem']['Uuidnativeitem'] = array('483798c8-c7cc-430e-8cf9-4fcc40cf8569'); + $data = ['Uuidnativeportfolio' => ['name' => 'Portfolio 3']]; + $data['Uuidnativeitem']['Uuidnativeitem'] = ['483798c8-c7cc-430e-8cf9-4fcc40cf8569']; $TestModel->create($data); $TestModel->save(); $id = $TestModel->id; @@ -3021,19 +3021,19 @@ public function testHabtmSavingWithNoPrimaryKeyUuidJoinTable() { $this->loadFixtures('UuidTag', 'Fruit', 'FruitsUuidTag'); $Fruit = new Fruit(); $Fruit->FruitsUuidTag->order = null; - $data = array( - 'Fruit' => array( + $data = [ + 'Fruit' => [ 'color' => 'Red', 'shape' => 'Heart-shaped', 'taste' => 'sweet', 'name' => 'Strawberry', - ), - 'UuidTag' => array( - 'UuidTag' => array( + ], + 'UuidTag' => [ + 'UuidTag' => [ '481fc6d0-b920-43e0-e50f-6d1740cf8569' - ) - ) - ); + ] + ] + ]; $result = $Fruit->save($data); $this->assertFalse(empty($result)); } @@ -3046,19 +3046,19 @@ public function testHabtmSavingWithNoPrimaryKeyUuidJoinTable() { public function testHabtmSavingWithNoPrimaryKeyUuidJoinTableNoWith() { $this->loadFixtures('UuidTag', 'Fruit', 'FruitsUuidTag'); $Fruit = new FruitNoWith(); - $data = array( - 'Fruit' => array( + $data = [ + 'Fruit' => [ 'color' => 'Red', 'shape' => 'Heart-shaped', 'taste' => 'sweet', 'name' => 'Strawberry', - ), - 'UuidTag' => array( - 'UuidTag' => array( + ], + 'UuidTag' => [ + 'UuidTag' => [ '481fc6d0-b920-43e0-e50f-6d1740cf8569' - ) - ) - ); + ] + ] + ]; $result = $Fruit->save($data); $this->assertFalse(empty($result)); } @@ -3072,8 +3072,8 @@ public function testHabtmUuidWithNumericId() { $this->loadFixtures('Uuidportfolio', 'Uuiditem', 'UuiditemsUuidportfolioNumericid'); $TestModel = new Uuiditem(); - $data = array('Uuiditem' => array('name' => 'Item 7', 'published' => 0)); - $data['Uuidportfolio']['Uuidportfolio'] = array('480af662-eb8c-47d3-886b-230540cf8569'); + $data = ['Uuiditem' => ['name' => 'Item 7', 'published' => 0]]; + $data['Uuidportfolio']['Uuidportfolio'] = ['480af662-eb8c-47d3-886b-230540cf8569']; $TestModel->create($data); $TestModel->save(); $id = $TestModel->id; @@ -3091,8 +3091,8 @@ public function testHabtmUuidWithNumericIdNative() { $this->loadFixtures('Uuidnativeportfolio', 'Uuidnativeitem', 'UuidnativeitemsUuidnativeportfolioNumericid'); $TestModel = new Uuidnativeitem(); - $data = array('Uuidnativeitem' => array('name' => 'Item 7', 'published' => 0)); - $data['Uuidnativeportfolio']['Uuidnativeportfolio'] = array('480af662-eb8c-47d3-886b-230540cf8569'); + $data = ['Uuidnativeitem' => ['name' => 'Item 7', 'published' => 0]]; + $data['Uuidnativeportfolio']['Uuidnativeportfolio'] = ['480af662-eb8c-47d3-886b-230540cf8569']; $TestModel->create($data); $TestModel->save(); $id = $TestModel->id; @@ -3110,109 +3110,109 @@ public function testSaveMultipleHabtm() { $TestModel = new JoinA(); $result = $TestModel->findById(1); - $expected = array( - 'JoinA' => array( + $expected = [ + 'JoinA' => [ 'id' => 1, 'name' => 'Join A 1', 'body' => 'Join A 1 Body', 'created' => '2008-01-03 10:54:23', 'updated' => '2008-01-03 10:54:23' - ), - 'JoinB' => array( - 0 => array( + ], + 'JoinB' => [ + 0 => [ 'id' => 2, 'name' => 'Join B 2', 'created' => '2008-01-03 10:55:02', 'updated' => '2008-01-03 10:55:02', - 'JoinAsJoinB' => array( + 'JoinAsJoinB' => [ 'id' => 1, 'join_a_id' => 1, 'join_b_id' => 2, 'other' => 'Data for Join A 1 Join B 2', 'created' => '2008-01-03 10:56:33', 'updated' => '2008-01-03 10:56:33' - ))), - 'JoinC' => array( - 0 => array( + ]]], + 'JoinC' => [ + 0 => [ 'id' => 2, 'name' => 'Join C 2', 'created' => '2008-01-03 10:56:12', 'updated' => '2008-01-03 10:56:12', - 'JoinAsJoinC' => array( + 'JoinAsJoinC' => [ 'id' => 1, 'join_a_id' => 1, 'join_c_id' => 2, 'other' => 'Data for Join A 1 Join C 2', 'created' => '2008-01-03 10:57:22', 'updated' => '2008-01-03 10:57:22' - )))); + ]]]]; $this->assertEquals($expected, $result); $TestModel->id = 1; - $data = array( - 'JoinA' => array( + $data = [ + 'JoinA' => [ 'id' => '1', 'name' => 'New name for Join A 1', 'updated' => static::date() - ), - 'JoinB' => array( - array( + ], + 'JoinB' => [ + [ 'id' => 1, 'join_b_id' => 2, 'other' => 'New data for Join A 1 Join B 2', 'created' => static::date(), 'updated' => static::date() - )), - 'JoinC' => array( - array( + ]], + 'JoinC' => [ + [ 'id' => 1, 'join_c_id' => 2, 'other' => 'New data for Join A 1 Join C 2', 'created' => static::date(), 'updated' => static::date() - ))); + ]]]; $TestModel->set($data); $TestModel->save(); $result = $TestModel->findById(1); - $expected = array( - 'JoinA' => array( + $expected = [ + 'JoinA' => [ 'id' => 1, 'name' => 'New name for Join A 1', 'body' => 'Join A 1 Body', 'created' => '2008-01-03 10:54:23', 'updated' => static::date() - ), - 'JoinB' => array( - 0 => array( + ], + 'JoinB' => [ + 0 => [ 'id' => 2, 'name' => 'Join B 2', 'created' => '2008-01-03 10:55:02', 'updated' => '2008-01-03 10:55:02', - 'JoinAsJoinB' => array( + 'JoinAsJoinB' => [ 'id' => 1, 'join_a_id' => 1, 'join_b_id' => 2, 'other' => 'New data for Join A 1 Join B 2', 'created' => static::date(), 'updated' => static::date() - ))), - 'JoinC' => array( - 0 => array( + ]]], + 'JoinC' => [ + 0 => [ 'id' => 2, 'name' => 'Join C 2', 'created' => '2008-01-03 10:56:12', 'updated' => '2008-01-03 10:56:12', - 'JoinAsJoinC' => array( + 'JoinAsJoinC' => [ 'id' => 1, 'join_a_id' => 1, 'join_c_id' => 2, 'other' => 'New data for Join A 1 Join C 2', 'created' => static::date(), 'updated' => static::date() - )))); + ]]]]; $this->assertEquals($expected, $result); } @@ -3230,31 +3230,31 @@ public function testSaveAll() { $this->assertEquals(3, count($result)); $this->assertFalse(isset($result[3])); - $TestModel->saveAll(array( - 'Post' => array( + $TestModel->saveAll([ + 'Post' => [ 'title' => 'Post with Author', 'body' => 'This post will be saved with an author' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'bob', 'password' => '5f4dcc3b5aa765d61d8327deb882cf90' - ))); + ]]); $result = $TestModel->find('all'); - $expected = array( - 'Post' => array( + $expected = [ + 'Post' => [ 'id' => '4', 'author_id' => '5', 'title' => 'Post with Author', 'body' => 'This post will be saved with an author', 'published' => 'N' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '5', 'user' => 'bob', 'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'test' => 'working' - )); + ]]; $this->assertEquals(static::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Author']['created']); @@ -3265,44 +3265,44 @@ public function testSaveAll() { $this->assertEquals(4, count($result)); $TestModel->deleteAll(true); - $this->assertEquals(array(), $TestModel->find('all')); + $this->assertEquals([], $TestModel->find('all')); // SQLite seems to reset the PK counter when that happens, so we need this to make the tests pass $this->db->truncate($TestModel); - $TestModel->saveAll(array( - array( + $TestModel->saveAll([ + [ 'title' => 'Multi-record post 1', 'body' => 'First multi-record post', 'author_id' => 2 - ), - array( + ], + [ 'title' => 'Multi-record post 2', 'body' => 'Second multi-record post', 'author_id' => 2 - ))); + ]]); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'recursive' => -1, 'order' => 'Post.id ASC' - )); - $expected = array( - array( - 'Post' => array( + ]); + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '2', 'title' => 'Multi-record post 1', 'body' => 'First multi-record post', 'published' => 'N' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '2', 'author_id' => '2', 'title' => 'Multi-record post 2', 'body' => 'Second multi-record post', 'published' => 'N' - ))); + ]]]; $this->assertEquals(static::date(), $result[0]['Post']['created']); $this->assertEquals(static::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['created']); @@ -3312,36 +3312,36 @@ public function testSaveAll() { $this->assertEquals($expected, $result); $TestModel = new Comment(); - $result = $TestModel->saveAll(array( - 'Comment' => array( + $result = $TestModel->saveAll([ + 'Comment' => [ 'article_id' => 2, 'user_id' => 2, 'comment' => 'New comment with attachment', 'published' => 'Y' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => 'some_file.tgz' - ))); + ]]); $this->assertFalse(empty($result)); $result = $TestModel->find('all'); - $expected = array( + $expected = [ 'id' => '7', 'article_id' => '2', 'user_id' => '2', 'comment' => 'New comment with attachment', 'published' => 'Y' - ); + ]; $this->assertEquals(static::date(), $result[6]['Comment']['created']); $this->assertEquals(static::date(), $result[6]['Comment']['updated']); unset($result[6]['Comment']['created'], $result[6]['Comment']['updated']); $this->assertEquals($expected, $result[6]['Comment']); - $expected = array( + $expected = [ 'id' => '2', 'comment_id' => '7', 'attachment' => 'some_file.tgz' - ); + ]; $this->assertEquals(static::date(), $result[6]['Attachment']['created']); $this->assertEquals(static::date(), $result[6]['Attachment']['updated']); unset($result[6]['Attachment']['created'], $result[6]['Attachment']['updated']); @@ -3355,21 +3355,21 @@ public function testSaveAll() { */ public function testSaveAllHabtm() { $this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag'); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => 1, 'title' => 'Article Has and belongs to Many Tags' - ), - 'Tag' => array( - 'Tag' => array(1, 2) - ), - 'Comment' => array( - array( + ], + 'Tag' => [ + 'Tag' => [1, 2] + ], + 'Comment' => [ + [ 'comment' => 'Article comment', 'user_id' => 1 - ) - ) - ); + ] + ] + ]; $Article = new Article(); $result = $Article->saveAll($data); $this->assertFalse(empty($result)); @@ -3389,19 +3389,19 @@ public function testSaveAllHabtm() { public function testSaveAllHabtmWithExtraJoinTableFields() { $this->loadFixtures('Something', 'SomethingElse', 'JoinThing'); - $data = array( - 'Something' => array( + $data = [ + 'Something' => [ 'id' => 4, 'title' => 'Extra Fields', 'body' => 'Extra Fields Body', 'published' => '1' - ), - 'SomethingElse' => array( - array('something_else_id' => 1, 'doomed' => '1'), - array('something_else_id' => 2, 'doomed' => '0'), - array('something_else_id' => 3, 'doomed' => '1') - ) - ); + ], + 'SomethingElse' => [ + ['something_else_id' => 1, 'doomed' => '1'], + ['something_else_id' => 2, 'doomed' => '0'], + ['something_else_id' => 3, 'doomed' => '1'] + ] + ]; $Something = new Something(); $result = $Something->saveAll($data); @@ -3432,47 +3432,47 @@ public function testSaveAllHabtmWithExtraJoinTableFields() { public function testSaveAllHasOne() { $model = new Comment(); $model->deleteAll(true); - $this->assertEquals(array(), $model->find('all')); + $this->assertEquals([], $model->find('all')); $model->Attachment->deleteAll(true); - $this->assertEquals(array(), $model->Attachment->find('all')); + $this->assertEquals([], $model->Attachment->find('all')); - $this->assertTrue($model->saveAll(array( - 'Comment' => array( + $this->assertTrue($model->saveAll([ + 'Comment' => [ 'comment' => 'Comment with attachment', 'article_id' => 1, 'user_id' => 1 - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => 'some_file.zip' - )))); - $result = $model->find('all', array('fields' => array( + ]])); + $result = $model->find('all', ['fields' => [ 'Comment.id', 'Comment.comment', 'Attachment.id', 'Attachment.comment_id', 'Attachment.attachment' - ))); - $expected = array(array( - 'Comment' => array( + ]]); + $expected = [[ + 'Comment' => [ 'id' => '1', 'comment' => 'Comment with attachment' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => '1', 'comment_id' => '1', 'attachment' => 'some_file.zip' - ))); + ]]]; $this->assertEquals($expected, $result); - $model->Attachment->bindModel(array('belongsTo' => array('Comment')), false); - $data = array( - 'Comment' => array( + $model->Attachment->bindModel(['belongsTo' => ['Comment']], false); + $data = [ + 'Comment' => [ 'comment' => 'Comment with attachment', 'article_id' => 1, 'user_id' => 1 - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => 'some_file.zip' - )); - $this->assertTrue($model->saveAll($data, array('validate' => 'first'))); + ]]; + $this->assertTrue($model->saveAll($data, ['validate' => 'first'])); } /** @@ -3483,34 +3483,34 @@ public function testSaveAllHasOne() { public function testSaveAllBelongsTo() { $model = new Comment(); $model->deleteAll(true); - $this->assertEquals(array(), $model->find('all')); + $this->assertEquals([], $model->find('all')); $model->Article->deleteAll(true); - $this->assertEquals(array(), $model->Article->find('all')); + $this->assertEquals([], $model->Article->find('all')); - $this->assertTrue($model->saveAll(array( - 'Comment' => array( + $this->assertTrue($model->saveAll([ + 'Comment' => [ 'comment' => 'Article comment', 'article_id' => 1, 'user_id' => 1 - ), - 'Article' => array( + ], + 'Article' => [ 'title' => 'Model Associations 101', 'user_id' => 1 - )))); - $result = $model->find('all', array('fields' => array( + ]])); + $result = $model->find('all', ['fields' => [ 'Comment.id', 'Comment.comment', 'Comment.article_id', 'Article.id', 'Article.title' - ))); - $expected = array(array( - 'Comment' => array( + ]]); + $expected = [[ + 'Comment' => [ 'id' => '1', 'article_id' => '1', 'comment' => 'Article comment' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => '1', 'title' => 'Model Associations 101' - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -3522,33 +3522,33 @@ public function testSaveAllBelongsTo() { public function testSaveAllHasOneValidation() { $model = new Comment(); $model->deleteAll(true); - $this->assertEquals(array(), $model->find('all')); + $this->assertEquals([], $model->find('all')); $model->Attachment->deleteAll(true); - $this->assertEquals(array(), $model->Attachment->find('all')); + $this->assertEquals([], $model->Attachment->find('all')); - $model->validate = array('comment' => 'notBlank'); - $model->Attachment->validate = array('attachment' => 'notBlank'); - $model->Attachment->bindModel(array('belongsTo' => array('Comment'))); + $model->validate = ['comment' => 'notBlank']; + $model->Attachment->validate = ['attachment' => 'notBlank']; + $model->Attachment->bindModel(['belongsTo' => ['Comment']]); $result = $model->saveAll( - array( - 'Comment' => array( + [ + 'Comment' => [ 'comment' => '', 'article_id' => 1, 'user_id' => 1 - ), - 'Attachment' => array('attachment' => '') - ), - array('validate' => 'first') + ], + 'Attachment' => ['attachment' => ''] + ], + ['validate' => 'first'] ); $this->assertEquals(false, $result); - $expected = array( - 'comment' => array('This field cannot be left blank'), - 'Attachment' => array( - 'attachment' => array('This field cannot be left blank') - ) - ); + $expected = [ + 'comment' => ['This field cannot be left blank'], + 'Attachment' => [ + 'attachment' => ['This field cannot be left blank'] + ] + ]; $this->assertEquals($expected, $model->validationErrors); $this->assertEquals($expected['Attachment'], $model->Attachment->validationErrors); } @@ -3562,71 +3562,71 @@ public function testSaveAllAtomic() { $this->loadFixtures('Article', 'User', 'Comment'); $TestModel = new Article(); - $result = $TestModel->saveAll(array( - 'Article' => array( + $result = $TestModel->saveAll([ + 'Article' => [ 'title' => 'Post with Author', 'body' => 'This post will be saved with an author', 'user_id' => 2 - ), - 'Comment' => array( - array('comment' => 'First new comment', 'user_id' => 2)) - ), array('atomic' => false)); + ], + 'Comment' => [ + ['comment' => 'First new comment', 'user_id' => 2]] + ], ['atomic' => false]); - $this->assertSame($result, array('Article' => true, 'Comment' => array(true))); + $this->assertSame($result, ['Article' => true, 'Comment' => [true]]); - $result = $TestModel->saveAll(array( - array( + $result = $TestModel->saveAll([ + [ 'id' => '1', 'title' => 'Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N' - ), - array( + ], + [ 'id' => '2', 'title' => 'Just update the title' - ), - array( + ], + [ 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'user_id' => 2 - ) - ), array('atomic' => false)); - $this->assertSame($result, array(true, true, true)); - - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + ] + ], ['atomic' => false]); + $this->assertSame($result, [true, true, true]); + + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1 - ), - array( + ], + [ 'comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2 - )) - ), array('validate' => true, 'atomic' => false)); - $this->assertSame($result, array('Article' => true, 'Comment' => array(true, true))); + ]] + ], ['validate' => true, 'atomic' => false]); + $this->assertSame($result, ['Article' => true, 'Comment' => [true, true]]); - $TestModel->validate = array( + $TestModel->validate = [ 'title' => 'notBlank', 'author_id' => 'numeric' - ); - $result = $TestModel->saveAll(array( - array( + ]; + $result = $TestModel->saveAll([ + [ 'id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y' - ), - array( + ], + [ 'id' => '2', 'title' => '', 'body' => 'Trying to get away with an empty title' - ) - ), array('validate' => true, 'atomic' => false)); - $this->assertSame(array(true, false), $result); + ] + ], ['validate' => true, 'atomic' => false]); + $this->assertSame([true, false], $result); } /** @@ -3637,99 +3637,99 @@ public function testSaveAllAtomic() { public function testSaveAllDeepAssociated() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->hasAndBelongsToMany = array(); - - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => 'newuser', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), array('deep' => true)); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->hasAndBelongsToMany = []; + + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => 'newuser', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], ['deep' => true]); $this->assertTrue($result); $result = $TestModel->findById(2); - $expected = array( + $expected = [ 'First Comment for Second Article', 'Second Comment for Second Article', 'First new comment', 'Second new comment' - ); + ]; $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment'); $this->assertEquals($expected, $result); - $result = $TestModel->Comment->User->field('id', array('user' => 'newuser', 'password' => 'newuserpass')); + $result = $TestModel->Comment->User->field('id', ['user' => 'newuser', 'password' => 'newuserpass']); $this->assertEquals(5, $result); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => 'deepsaved')) - ) - ), array('deep' => true)); + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => 'deepsaved']] + ] + ], ['deep' => true]); $this->assertTrue($result); $result = $TestModel->findById(2); - $expected = array( + $expected = [ 'First Comment for Second Article', 'Second Comment for Second Article', 'First new comment', 'Second new comment', 'Third new comment', 'Fourth new comment' - ); + ]; $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment'); $this->assertEquals($expected, $result); - $result = $TestModel->Comment->Attachment->field('id', array('attachment' => 'deepsaved')); + $result = $TestModel->Comment->Attachment->field('id', ['attachment' => 'deepsaved']); $this->assertEquals(2, $result); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'First comment deepsave insert', 'published' => 'Y', 'user_id' => 5, - 'Article' => array( + 'Article' => [ 'title' => 'First Article deepsave insert', 'body' => 'First Article Body deepsave insert', - 'User' => array( + 'User' => [ 'user' => '', 'password' => 'magic' - ), - ), - ) - ); + ], + ], + ] + ]; $TestModel->Comment->Attachment->create(); - $result = $TestModel->Comment->Attachment->saveAll($data, array('deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['deep' => true]); $this->assertFalse($result); - $expected = array('User' => array('user' => array('This field cannot be left blank'))); + $expected = ['User' => ['user' => ['This field cannot be left blank']]]; $this->assertEquals($expected, $TestModel->validationErrors); $data['Comment']['Article']['User']['user'] = 'deepsave'; $TestModel->Comment->Attachment->create(); - $result = $TestModel->Comment->Attachment->saveAll($data, array('deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['deep' => true]); $this->assertTrue($result); $result = $TestModel->Comment->Attachment->findById($TestModel->Comment->Attachment->id); - $expected = array( - 'Attachment' => array( + $expected = [ + 'Attachment' => [ 'id' => '3', 'comment_id' => '11', 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'id' => '11', 'article_id' => '4', 'user_id' => '5', 'comment' => 'First comment deepsave insert', 'published' => 'Y', - ) - ); + ] + ]; unset($result['Attachment']['created'], $result['Attachment']['updated']); $this->assertEquals($expected['Attachment'], $result['Attachment']); @@ -3737,29 +3737,29 @@ public function testSaveAllDeepAssociated() { $this->assertEquals($expected['Comment'], $result['Comment']); $result = $TestModel->findById($result['Comment']['article_id']); - $expected = array( - 'Article' => array( + $expected = [ + 'Article' => [ 'id' => '4', 'user_id' => '6', 'title' => 'First Article deepsave insert', 'body' => 'First Article Body deepsave insert', 'published' => 'N', - ), - 'User' => array( + ], + 'User' => [ 'id' => '6', 'user' => 'deepsave', 'password' => 'magic', - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '11', 'article_id' => '4', 'user_id' => '5', 'comment' => 'First comment deepsave insert', 'published' => 'Y', - ) - ) - ); + ] + ] + ]; unset( $result['Article']['created'], $result['Article']['updated'], $result['User']['created'], $result['User']['updated'], @@ -3777,73 +3777,73 @@ public function testSaveAllDeepAssociated() { public function testSaveAllDeepMany() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->hasAndBelongsToMany = array(); - - $data = array( - array( - 'Article' => array('id' => 1), - 'Comment' => array( - array('comment' => 'First comment deepsaved article 1', 'published' => 'Y', 'User' => array('user' => 'savemany', 'password' => 'manysaved')), - array('comment' => 'Second comment deepsaved article 1', 'published' => 'Y', 'user_id' => 2) - ) - ), - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First comment deepsaved article 2', 'published' => 'Y', 'User' => array('user' => 'savemore', 'password' => 'moresaved')), - array('comment' => 'Second comment deepsaved article 2', 'published' => 'Y', 'user_id' => 2) - ) - ) - ); - $result = $TestModel->saveAll($data, array('deep' => true)); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->hasAndBelongsToMany = []; + + $data = [ + [ + 'Article' => ['id' => 1], + 'Comment' => [ + ['comment' => 'First comment deepsaved article 1', 'published' => 'Y', 'User' => ['user' => 'savemany', 'password' => 'manysaved']], + ['comment' => 'Second comment deepsaved article 1', 'published' => 'Y', 'user_id' => 2] + ] + ], + [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First comment deepsaved article 2', 'published' => 'Y', 'User' => ['user' => 'savemore', 'password' => 'moresaved']], + ['comment' => 'Second comment deepsaved article 2', 'published' => 'Y', 'user_id' => 2] + ] + ] + ]; + $result = $TestModel->saveAll($data, ['deep' => true]); $this->assertTrue($result); - $data = array( - array( + $data = [ + [ 'id' => 1, 'body' => '', - 'Comment' => array( - array('comment' => '', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'manysaved')), - array('comment' => 'Second comment deepsaved article 1', 'published' => 'Y', 'user_id' => 2) - ) - ), - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First comment deepsaved article 2', 'published' => 'Y', 'User' => array('user' => 'savemore', 'password' => '')), - array('comment' => '', 'published' => 'Y', 'user_id' => 2) - ) - ) - ); + 'Comment' => [ + ['comment' => '', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'manysaved']], + ['comment' => 'Second comment deepsaved article 1', 'published' => 'Y', 'user_id' => 2] + ] + ], + [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First comment deepsaved article 2', 'published' => 'Y', 'User' => ['user' => 'savemore', 'password' => '']], + ['comment' => '', 'published' => 'Y', 'user_id' => 2] + ] + ] + ]; $TestModel->Comment->validate['comment'] = 'notBlank'; - $result = $TestModel->saveAll($data, array('deep' => true)); + $result = $TestModel->saveAll($data, ['deep' => true]); $this->assertFalse($result); - $expected = array( - 0 => array( - 'body' => array('This field cannot be left blank'), - 'Comment' => array( - 0 => array( - 'comment' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ), - 1 => array( - 'Comment' => array( - 0 => array( - 'User' => array( - 'password' => array('This field cannot be left blank') - ) - ), - 1 => array( - 'comment' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 0 => [ + 'body' => ['This field cannot be left blank'], + 'Comment' => [ + 0 => [ + 'comment' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ], + 1 => [ + 'Comment' => [ + 0 => [ + 'User' => [ + 'password' => ['This field cannot be left blank'] + ] + ], + 1 => [ + 'comment' => ['This field cannot be left blank'] + ] + ] + ] + ]; $result = $TestModel->validationErrors; $this->assertSame($expected, $result); } @@ -3856,298 +3856,298 @@ public function testSaveAllDeepMany() { public function testSaveAllDeepValidateOnly() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->hasAndBelongsToMany = array(); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->hasAndBelongsToMany = []; $TestModel->Comment->Attachment->validate['attachment'] = 'notBlank'; $TestModel->Comment->validate['comment'] = 'notBlank'; $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => 'newuser', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), - array('validate' => 'only', 'deep' => true) + [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => 'newuser', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], + ['validate' => 'only', 'deep' => true] ); $this->assertTrue($result); $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), - array('validate' => 'only', 'deep' => true) + [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], + ['validate' => 'only', 'deep' => true] ); $this->assertFalse($result); $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => 'newuser', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), - array('validate' => 'only', 'atomic' => false, 'deep' => true) - ); - $expected = array( + [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => 'newuser', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], + ['validate' => 'only', 'atomic' => false, 'deep' => true] + ); + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, true - ) - ); + ] + ]; $this->assertSame($expected, $result); $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), - array('validate' => 'only', 'atomic' => false, 'deep' => true) - ); - $expected = array( + [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], + ['validate' => 'only', 'atomic' => false, 'deep' => true] + ); + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ false, true - ) - ); + ] + ]; $this->assertSame($expected, $result); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => 'deepsaved')) - ) - ), - array('validate' => 'only', 'deep' => true) + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => 'deepsaved']] + ] + ], + ['validate' => 'only', 'deep' => true] ); $this->assertTrue($result); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => '')) - ) - ), - array('validate' => 'only', 'deep' => true) + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => '']] + ] + ], + ['validate' => 'only', 'deep' => true] ); $this->assertFalse($result); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => 'deepsave')) - ) - ), - array('validate' => 'only', 'atomic' => false, 'deep' => true) + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => 'deepsave']] + ] + ], + ['validate' => 'only', 'atomic' => false, 'deep' => true] ); - $expected = array( + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, true - ) - ); + ] + ]; $this->assertSame($expected, $result); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => '')) - ) - ), - array('validate' => 'only', 'atomic' => false, 'deep' => true) + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => '']] + ] + ], + ['validate' => 'only', 'atomic' => false, 'deep' => true] ); - $expected = array( + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, false - ) - ); + ] + ]; $this->assertSame($expected, $result); - $expected = array( - 'Comment' => array( - 1 => array( - 'Attachment' => array( - 'attachment' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'Comment' => [ + 1 => [ + 'Attachment' => [ + 'attachment' => ['This field cannot be left blank'] + ] + ] + ] + ]; $result = $TestModel->validationErrors; $this->assertSame($expected, $result); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'First comment deepsave insert', 'published' => 'Y', 'user_id' => 5, - 'Article' => array( + 'Article' => [ 'title' => 'First Article deepsave insert', 'body' => 'First Article Body deepsave insert', - 'User' => array( + 'User' => [ 'user' => 'deepsave', 'password' => 'magic' - ), - ), - ) - ); + ], + ], + ] + ]; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertTrue($result); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); - $expected = array( + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); + $expected = [ 'Attachment' => true, 'Comment' => true - ); + ]; $this->assertSame($expected, $result); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'First comment deepsave insert', 'published' => 'Y', 'user_id' => 5, - 'Article' => array( + 'Article' => [ 'title' => 'First Article deepsave insert', 'body' => 'First Article Body deepsave insert', - 'User' => array( + 'User' => [ 'user' => '', 'password' => 'magic' - ), - ), - ) - ); + ], + ], + ] + ]; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array( - 'Comment' => array( - 'Article' => array( - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'Comment' => [ + 'Article' => [ + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ]; $this->assertSame($expected, $result); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); - $expected = array( + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); + $expected = [ 'Attachment' => true, 'Comment' => false - ); + ]; $this->assertEquals($expected, $result); $data['Comment']['Article']['body'] = ''; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array( - 'Comment' => array( - 'Article' => array( - 'body' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'Comment' => [ + 'Article' => [ + 'body' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ]; $this->assertSame($expected, $result); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); - $expected = array( + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); + $expected = [ 'Attachment' => true, 'Comment' => false - ); + ]; $this->assertEquals($expected, $result); $data['Comment']['comment'] = ''; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array( - 'Comment' => array( - 'comment' => array('This field cannot be left blank'), - 'Article' => array( - 'body' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'Comment' => [ + 'comment' => ['This field cannot be left blank'], + 'Article' => [ + 'body' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ]; $this->assertSame($expected, $result); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); - $expected = array( + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); + $expected = [ 'Attachment' => true, 'Comment' => false - ); + ]; $this->assertEquals($expected, $result); $data['Attachment']['attachment'] = ''; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => true)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => true]); $this->assertFalse($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array( - 'attachment' => array('This field cannot be left blank'), - 'Comment' => array( - 'comment' => array('This field cannot be left blank'), - 'Article' => array( - 'body' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ) - ); + $expected = [ + 'attachment' => ['This field cannot be left blank'], + 'Comment' => [ + 'comment' => ['This field cannot be left blank'], + 'Article' => [ + 'body' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ] + ]; $this->assertSame($expected, $result); $result = $TestModel->Comment->validationErrors; - $expected = array( - 'comment' => array('This field cannot be left blank'), - 'Article' => array( - 'body' => array('This field cannot be left blank'), - 'User' => array( - 'user' => array('This field cannot be left blank') - ) - ) - ); + $expected = [ + 'comment' => ['This field cannot be left blank'], + 'Article' => [ + 'body' => ['This field cannot be left blank'], + 'User' => [ + 'user' => ['This field cannot be left blank'] + ] + ] + ]; $this->assertSame($expected, $result); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => true)); - $expected = array( + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => true]); + $expected = [ 'Attachment' => false, 'Comment' => false - ); + ]; $this->assertEquals($expected, $result); } @@ -4160,79 +4160,79 @@ public function testSaveAllDeepValidateOnly() { public function testSaveAllNotDeepAssociated() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->hasAndBelongsToMany = array(); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->hasAndBelongsToMany = []; - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => 'First new comment', 'published' => 'Y', 'user_id' => 2, - 'User' => array('user' => 'newuser', 'password' => 'newuserpass') - ), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), array('deep' => false)); + 'User' => ['user' => 'newuser', 'password' => 'newuserpass'] + ], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], ['deep' => false]); $this->assertTrue($result); - $result = $TestModel->Comment->User->field('id', array('user' => 'newuser', 'password' => 'newuserpass')); + $result = $TestModel->Comment->User->field('id', ['user' => 'newuser', 'password' => 'newuserpass']); $this->assertFalse($result); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 4), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => 'deepsaved')) - ) - ), array('deep' => false)); + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 4], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => 'deepsaved']] + ] + ], ['deep' => false]); $this->assertTrue($result); - $result = $TestModel->Comment->Attachment->field('id', array('attachment' => 'deepsaved')); + $result = $TestModel->Comment->Attachment->field('id', ['attachment' => 'deepsaved']); $this->assertFalse($result); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'First comment deepsave insert', 'published' => 'Y', 'user_id' => 4, 'article_id' => 1, - 'Article' => array( + 'Article' => [ 'title' => 'First Article deepsave insert', 'body' => 'First Article Body deepsave insert', - 'User' => array( + 'User' => [ 'user' => 'deepsave', 'password' => 'magic' - ), - ), - ) - ); + ], + ], + ] + ]; $expected = $TestModel->User->find('count'); $TestModel->Comment->Attachment->create(); - $result = $TestModel->Comment->Attachment->saveAll($data, array('deep' => false)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['deep' => false]); $this->assertTrue($result); $result = $TestModel->User->find('count'); $this->assertEquals($expected, $result); $result = $TestModel->Comment->Attachment->findById($TestModel->Comment->Attachment->id); - $expected = array( - 'Attachment' => array( + $expected = [ + 'Attachment' => [ 'id' => '2', 'comment_id' => '11', 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'id' => '11', 'article_id' => 1, 'user_id' => '4', 'comment' => 'First comment deepsave insert', 'published' => 'Y', - ) - ); + ] + ]; unset($result['Attachment']['created'], $result['Attachment']['updated']); $this->assertEquals($expected['Attachment'], $result['Attachment']); @@ -4249,53 +4249,53 @@ public function testSaveAllNotDeepAssociated() { public function testSaveAllNotDeepMany() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->hasAndBelongsToMany = array(); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->hasAndBelongsToMany = []; - $data = array( - array( + $data = [ + [ 'id' => 1, 'body' => '', - 'Comment' => array( - array('comment' => '', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'manysaved')), - array('comment' => 'Second comment deepsaved article 1', 'published' => 'Y', 'user_id' => 2) - ) - ), - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First comment deepsaved article 2', 'published' => 'Y', 'User' => array('user' => 'savemore', 'password' => '')), - array('comment' => '', 'published' => 'Y', 'user_id' => 2) - ) - ) - ); + 'Comment' => [ + ['comment' => '', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'manysaved']], + ['comment' => 'Second comment deepsaved article 1', 'published' => 'Y', 'user_id' => 2] + ] + ], + [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First comment deepsaved article 2', 'published' => 'Y', 'User' => ['user' => 'savemore', 'password' => '']], + ['comment' => '', 'published' => 'Y', 'user_id' => 2] + ] + ] + ]; $TestModel->Comment->validate['comment'] = 'notBlank'; - $result = $TestModel->saveAll($data, array('deep' => false)); + $result = $TestModel->saveAll($data, ['deep' => false]); $this->assertFalse($result); - $expected = array( - 0 => array( - 'body' => array('This field cannot be left blank') - ) - ); + $expected = [ + 0 => [ + 'body' => ['This field cannot be left blank'] + ] + ]; $result = $TestModel->validationErrors; $this->assertSame($expected, $result); - $data = array( - array( - 'Article' => array('id' => 1, 'body' => 'Ignore invalid comment'), - 'Comment' => array( - array('comment' => '', 'published' => 'Y', 'user_id' => 2) - ) - ), - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => '', 'published' => 'Y', 'user_id' => 2) - ) - ) - ); - $result = $TestModel->saveAll($data, array('deep' => false)); + $data = [ + [ + 'Article' => ['id' => 1, 'body' => 'Ignore invalid comment'], + 'Comment' => [ + ['comment' => '', 'published' => 'Y', 'user_id' => 2] + ] + ], + [ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => '', 'published' => 'Y', 'user_id' => 2] + ] + ] + ]; + $result = $TestModel->saveAll($data, ['deep' => false]); $this->assertTrue($result); } /** @@ -4307,137 +4307,137 @@ public function testSaveAllNotDeepMany() { public function testSaveAllNotDeepValidateOnly() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->hasAndBelongsToMany = array(); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->hasAndBelongsToMany = []; $TestModel->Comment->Attachment->validate['attachment'] = 'notBlank'; $TestModel->Comment->validate['comment'] = 'notBlank'; $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2, 'body' => ''), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), - array('validate' => 'only', 'deep' => false) + [ + 'Article' => ['id' => 2, 'body' => ''], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], + ['validate' => 'only', 'deep' => false] ); $this->assertFalse($result); - $expected = array('body' => array('This field cannot be left blank')); + $expected = ['body' => ['This field cannot be left blank']]; $result = $TestModel->validationErrors; $this->assertSame($expected, $result); $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2, 'body' => 'Ignore invalid user data'), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), - array('validate' => 'only', 'deep' => false) + [ + 'Article' => ['id' => 2, 'body' => 'Ignore invalid user data'], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], + ['validate' => 'only', 'deep' => false] ); $this->assertTrue($result); $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2, 'body' => 'Ignore invalid user data'), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'User' => array('user' => '', 'password' => 'newuserpass')), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ), - array('validate' => 'only', 'atomic' => false, 'deep' => false) - ); - $expected = array( + [ + 'Article' => ['id' => 2, 'body' => 'Ignore invalid user data'], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'User' => ['user' => '', 'password' => 'newuserpass']], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ], + ['validate' => 'only', 'atomic' => false, 'deep' => false] + ); + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, true - ) - ); + ] + ]; $this->assertSame($expected, $result); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2, 'body' => 'Ignore invalid attachment data'), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => '')) - ) - ), - array('validate' => 'only', 'deep' => false) + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2, 'body' => 'Ignore invalid attachment data'], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => '']] + ] + ], + ['validate' => 'only', 'deep' => false] ); $this->assertTrue($result); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2, 'body' => 'Ignore invalid attachment data'), - 'Comment' => array( - array('comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5), - array('comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => array('attachment' => '')) - ) - ), - array('validate' => 'only', 'atomic' => false, 'deep' => false) + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2, 'body' => 'Ignore invalid attachment data'], + 'Comment' => [ + ['comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 5], + ['comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 2, 'Attachment' => ['attachment' => '']] + ] + ], + ['validate' => 'only', 'atomic' => false, 'deep' => false] ); - $expected = array( + $expected = [ 'Article' => true, - 'Comment' => array( + 'Comment' => [ true, true - ) - ); + ] + ]; $this->assertSame($expected, $result); - $expected = array(); + $expected = []; $result = $TestModel->validationErrors; $this->assertSame($expected, $result); - $data = array( - 'Attachment' => array( + $data = [ + 'Attachment' => [ 'attachment' => 'deepsave insert', - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'First comment deepsave insert', 'published' => 'Y', 'user_id' => 5, - 'Article' => array( + 'Article' => [ 'title' => 'First Article deepsave insert ignored', 'body' => 'First Article Body deepsave insert', - 'User' => array( + 'User' => [ 'user' => '', 'password' => 'magic' - ), - ), - ) - ); + ], + ], + ] + ]; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => false)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => false]); $this->assertTrue($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array(); + $expected = []; $this->assertSame($expected, $result); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => false)); - $expected = array( + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => false]); + $expected = [ 'Attachment' => true, 'Comment' => true - ); + ]; $this->assertEquals($expected, $result); $data['Comment']['Article']['body'] = ''; - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'deep' => false)); + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'deep' => false]); $this->assertTrue($result); $result = $TestModel->Comment->Attachment->validationErrors; - $expected = array(); + $expected = []; $this->assertSame($expected, $result); - $result = $TestModel->Comment->Attachment->saveAll($data, array('validate' => 'only', 'atomic' => false, 'deep' => false)); - $expected = array( + $result = $TestModel->Comment->Attachment->saveAll($data, ['validate' => 'only', 'atomic' => false, 'deep' => false]); + $expected = [ 'Attachment' => true, 'Comment' => true - ); + ]; $this->assertEquals($expected, $result); } @@ -4449,74 +4449,74 @@ public function testSaveAllNotDeepValidateOnly() { public function testSaveAllHasMany() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); - $TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC'); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - )); + $TestModel->hasMany['Comment']['order'] = ['Comment.created' => 'ASC']; + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; + + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]); $this->assertFalse(empty($result)); $result = $TestModel->findById(2); - $expected = array( + $expected = [ 'First Comment for Second Article', 'Second Comment for Second Article', 'First new comment', 'Second new comment' - ); + ]; $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment'); $this->assertEquals($expected, $result); $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 1 - ))), - array('atomic' => false) + ]]], + ['atomic' => false] ); $this->assertFalse(empty($result)); $result = $TestModel->findById(2); - $expected = array( + $expected = [ 'First Comment for Second Article', 'Second Comment for Second Article', 'First new comment', 'Second new comment', 'Third new comment' - ); + ]; $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment'); $this->assertEquals($expected, $result); $TestModel->beforeSaveReturn = false; $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 1 - ))), - array('atomic' => false) + ]]], + ['atomic' => false] ); - $this->assertEquals(array('Article' => false), $result); + $this->assertEquals(['Article' => false], $result); $result = $TestModel->findById(2); - $expected = array( + $expected = [ 'First Comment for Second Article', 'Second Comment for Second Article', 'First new comment', 'Second new comment', 'Third new comment' - ); + ]; $result = Hash::extract(Hash::sort($result['Comment'], '{n}.id', 'ASC'), '{n}.comment'); $this->assertEquals($expected, $result); } @@ -4529,35 +4529,35 @@ public function testSaveAllHasMany() { public function testSaveAllHasManyValidation() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notBlank'); - - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => '', 'published' => 'Y', 'user_id' => 1), - ) - ), array('validate' => true)); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; + $TestModel->Comment->validate = ['comment' => 'notBlank']; + + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => '', 'published' => 'Y', 'user_id' => 1], + ] + ], ['validate' => true]); $this->assertFalse($result); - $expected = array('Comment' => array( - array('comment' => array('This field cannot be left blank')) - )); + $expected = ['Comment' => [ + ['comment' => ['This field cannot be left blank']] + ]]; $this->assertEquals($expected, $TestModel->validationErrors); - $expected = array( - array('comment' => array('This field cannot be left blank')) - ); + $expected = [ + ['comment' => ['This field cannot be left blank']] + ]; $this->assertEquals($expected, $TestModel->Comment->validationErrors); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => '', 'published' => 'Y', 'user_id' => 1 - )) - ), array('validate' => 'first')); + ]] + ], ['validate' => 'first']); $this->assertFalse($result); } @@ -4570,56 +4570,56 @@ public function testSaveAllManyRowsTransactionNoRollback() { $this->loadFixtures('Post'); $Post = new TestPost(); - $Post->validate = array( - 'title' => array('rule' => array('notBlank')) - ); + $Post->validate = [ + 'title' => ['rule' => ['notBlank']] + ]; // If validation error occurs, rollback() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->once())->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => '') - ); - $Post->saveAll($data, array('atomic' => true, 'validate' => true)); + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => ''] + ]; + $Post->saveAll($data, ['atomic' => true, 'validate' => true]); // If exception thrown, rollback() should be called too. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->once())->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post', 'body' => $db->expression('PDO_EXCEPTION()')) - ); + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post', 'body' => $db->expression('PDO_EXCEPTION()')] + ]; try { - $Post->saveAll($data, array('atomic' => true, 'validate' => true)); + $Post->saveAll($data, ['atomic' => true, 'validate' => true]); $this->fail('No exception thrown'); - } catch (PDOException $e) { + } catch (PDOException) { } // Otherwise, commit() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->once())->method('commit'); $db->expects($this->never())->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post') - ); - $Post->saveAll($data, array('atomic' => true, 'validate' => true)); + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post'] + ]; + $Post->saveAll($data, ['atomic' => true, 'validate' => true]); } /** @@ -4631,12 +4631,12 @@ public function testSaveAllAssociatedTransactionNoRollback() { $this->loadFixtures('Post', 'Author'); $Post = new TestPost(); - $Post->Author->validate = array( - 'user' => array('rule' => array('notBlank')) - ); + $Post->Author->validate = [ + 'user' => ['rule' => ['notBlank']] + ]; // If validation error occurs, rollback() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->once())->method('rollback'); @@ -4644,21 +4644,21 @@ public function testSaveAllAssociatedTransactionNoRollback() { $Post->setDataSourceObject($db); $Post->Author->setDataSourceObject($db); - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'title' => 'New post', 'body' => 'Content', 'published' => 'Y' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => '', 'password' => "sekret" - ) - ); - $Post->saveAll($data, array('validate' => true)); + ] + ]; + $Post->saveAll($data, ['validate' => true]); // If exception thrown, rollback() should be called too. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->once())->method('rollback'); @@ -4666,26 +4666,26 @@ public function testSaveAllAssociatedTransactionNoRollback() { $Post->setDataSourceObject($db); $Post->Author->setDataSourceObject($db); - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'title' => 'New post', 'body' => $db->expression('PDO_EXCEPTION()'), 'published' => 'Y' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'New user', 'password' => "sekret" - ) - ); + ] + ]; try { - $Post->saveAll($data, array('validate' => true)); + $Post->saveAll($data, ['validate' => true]); $this->fail('No exception thrown'); - } catch (PDOException $e) { + } catch (PDOException) { } // Otherwise, commit() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->once())->method('commit'); $db->expects($this->never())->method('rollback'); @@ -4693,18 +4693,18 @@ public function testSaveAllAssociatedTransactionNoRollback() { $Post->setDataSourceObject($db); $Post->Author->setDataSourceObject($db); - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'title' => 'New post', 'body' => 'Content', 'published' => 'Y' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'New user', 'password' => "sekret" - ) - ); - $Post->saveAll($data, array('validate' => true)); + ] + ]; + $Post->saveAll($data, ['validate' => true]); } /** @@ -4716,11 +4716,11 @@ public function testSaveAllNestedSaveAll() { $this->loadFixtures('Sample'); $TransactionTestModel = new TransactionTestModel(); - $data = array( - array('apple_id' => 1, 'name' => 'sample5'), - ); + $data = [ + ['apple_id' => 1, 'name' => 'sample5'], + ]; - $this->assertTrue($TransactionTestModel->saveAll($data, array('atomic' => true))); + $this->assertTrue($TransactionTestModel->saveAll($data, ['atomic' => true])); } /** @@ -4732,17 +4732,17 @@ public function testSaveAllTransaction() { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment'); $TestModel = new Post(); - $TestModel->validate = array('title' => 'notBlank'); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post'), - array('author_id' => 1, 'title' => '') - ); + $TestModel->validate = ['title' => 'notBlank']; + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post'], + ['author_id' => 1, 'title' => ''] + ]; $this->assertFalse($TestModel->saveAll($data)); - $result = $TestModel->find('all', array('recursive' => -1)); - $expected = array( - array('Post' => array( + $result = $TestModel->find('all', ['recursive' => -1]); + $expected = [ + ['Post' => [ 'id' => '1', 'author_id' => 1, 'title' => 'First Post', @@ -4750,8 +4750,8 @@ public function testSaveAllTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array('Post' => array( + ]], + ['Post' => [ 'id' => '2', 'author_id' => 3, 'title' => 'Second Post', @@ -4759,8 +4759,8 @@ public function testSaveAllTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - )), - array('Post' => array( + ]], + ['Post' => [ 'id' => '3', 'author_id' => 1, 'title' => 'Third Post', @@ -4768,12 +4768,12 @@ public function testSaveAllTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ))); + ]]]; if (count($result) != 3) { // Database doesn't support transactions - $expected[] = array( - 'Post' => array( + $expected[] = [ + 'Post' => [ 'id' => '4', 'author_id' => 1, 'title' => 'New Fourth Post', @@ -4781,10 +4781,10 @@ public function testSaveAllTransaction() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date() - )); + ]]; - $expected[] = array( - 'Post' => array( + $expected[] = [ + 'Post' => [ 'id' => '5', 'author_id' => 1, 'title' => 'New Fifth Post', @@ -4792,7 +4792,7 @@ public function testSaveAllTransaction() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date() - )); + ]]; $this->assertEquals($expected, $result); // Skip the rest of the transactional tests @@ -4801,16 +4801,16 @@ public function testSaveAllTransaction() { $this->assertEquals($expected, $result); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => ''), - array('author_id' => 1, 'title' => 'New Sixth Post') - ); + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => ''], + ['author_id' => 1, 'title' => 'New Sixth Post'] + ]; $this->assertFalse($TestModel->saveAll($data)); - $result = $TestModel->find('all', array('recursive' => -1)); - $expected = array( - array('Post' => array( + $result = $TestModel->find('all', ['recursive' => -1]); + $expected = [ + ['Post' => [ 'id' => '1', 'author_id' => 1, 'title' => 'First Post', @@ -4818,8 +4818,8 @@ public function testSaveAllTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array('Post' => array( + ]], + ['Post' => [ 'id' => '2', 'author_id' => 3, 'title' => 'Second Post', @@ -4827,8 +4827,8 @@ public function testSaveAllTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - )), - array('Post' => array( + ]], + ['Post' => [ 'id' => '3', 'author_id' => 1, 'title' => 'Third Post', @@ -4836,12 +4836,12 @@ public function testSaveAllTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ))); + ]]]; if (count($result) != 3) { // Database doesn't support transactions - $expected[] = array( - 'Post' => array( + $expected[] = [ + 'Post' => [ 'id' => '4', 'author_id' => 1, 'title' => 'New Fourth Post', @@ -4849,10 +4849,10 @@ public function testSaveAllTransaction() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date() - )); + ]]; - $expected[] = array( - 'Post' => array( + $expected[] = [ + 'Post' => [ 'id' => '5', 'author_id' => 1, 'title' => 'Third Post', @@ -4860,61 +4860,61 @@ public function testSaveAllTransaction() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date() - )); + ]]; } $this->assertEquals($expected, $result); - $TestModel->validate = array('title' => 'notBlank'); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post'), - array('author_id' => 1, 'title' => 'New Sixth Post') - ); + $TestModel->validate = ['title' => 'notBlank']; + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post'], + ['author_id' => 1, 'title' => 'New Sixth Post'] + ]; $this->assertTrue($TestModel->saveAll($data)); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'recursive' => -1, - 'fields' => array('author_id', 'title', 'body', 'published'), - 'order' => array('Post.created' => 'ASC') - )); + 'fields' => ['author_id', 'title', 'body', 'published'], + 'order' => ['Post.created' => 'ASC'] + ]); - $expected = array( - array('Post' => array( + $expected = [ + ['Post' => [ 'author_id' => 1, 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 3, 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 1, 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 1, 'title' => 'New Fourth Post', 'body' => '', 'published' => 'N' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 1, 'title' => 'New Fifth Post', 'body' => '', 'published' => 'N' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 1, 'title' => 'New Sixth Post', 'body' => '', 'published' => 'N' - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -4927,47 +4927,47 @@ public function testSaveAllValidation() { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment'); $TestModel = new Post(); - $data = array( - array( + $data = [ + [ 'id' => '1', 'title' => 'Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N' - ), - array( + ], + [ 'id' => '2', 'title' => 'Just update the title' - ), - array( + ], + [ 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'author_id' => 2 - )); + ]]; $this->assertTrue($TestModel->saveAll($data)); - $result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC')); - $expected = array( - array( - 'Post' => array( + $result = $TestModel->find('all', ['recursive' => -1, 'order' => 'Post.id ASC']); + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '1', 'title' => 'Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N', 'created' => '2007-03-18 10:39:23' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '2', 'author_id' => '3', 'title' => 'Just update the title', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '3', 'author_id' => '1', 'title' => 'Third Post', @@ -4975,15 +4975,15 @@ public function testSaveAllValidation() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '4', 'author_id' => '2', 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'published' => 'N' - ))); + ]]]; $this->assertEquals(static::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['created']); @@ -4992,24 +4992,24 @@ public function testSaveAllValidation() { unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); - $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); - $data = array( - array( + $TestModel->validate = ['title' => 'notBlank', 'author_id' => 'numeric']; + $data = [ + [ 'id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y' - ), - array( + ], + [ 'id' => '2', 'title' => '', 'body' => 'Trying to get away with an empty title' - )); + ]]; $result = $TestModel->saveAll($data); $this->assertFalse($result); - $result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC')); - $errors = array(1 => array('title' => array('This field cannot be left blank'))); + $result = $TestModel->find('all', ['recursive' => -1, 'order' => 'Post.id ASC']); + $errors = [1 => ['title' => ['This field cannot be left blank']]]; $transactionWorked = Set::matches('/Post[1][title=Baleeted First Post]', $result); if (!$transactionWorked) { $this->assertTrue(Set::matches('/Post[1][title=Un-Baleeted First Post]', $result)); @@ -5018,46 +5018,46 @@ public function testSaveAllValidation() { $this->assertEquals($errors, $TestModel->validationErrors); - $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); - $data = array( - array( + $TestModel->validate = ['title' => 'notBlank', 'author_id' => 'numeric']; + $data = [ + [ 'id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y' - ), - array( + ], + [ 'id' => '2', 'title' => '', 'body' => 'Trying to get away with an empty title' - )); - $result = $TestModel->saveAll($data, array('validate' => true, 'atomic' => false)); - $this->assertEquals(array(true, false), $result); - $result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC')); - $errors = array(1 => array('title' => array('This field cannot be left blank'))); - $expected = array( - array( - 'Post' => array( + ]]; + $result = $TestModel->saveAll($data, ['validate' => true, 'atomic' => false]); + $this->assertEquals([true, false], $result); + $result = $TestModel->find('all', ['recursive' => -1, 'order' => 'Post.id ASC']); + $errors = [1 => ['title' => ['This field cannot be left blank']]]; + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y', 'created' => '2007-03-18 10:39:23' - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '2', 'author_id' => '3', 'title' => 'Just update the title', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23' - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '3', 'author_id' => '1', 'title' => 'Third Post', @@ -5065,18 +5065,18 @@ public function testSaveAllValidation() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '4', 'author_id' => '2', 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'published' => 'N' - ) - ) - ); + ] + ] + ]; $this->assertEquals(static::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['updated']); @@ -5089,21 +5089,21 @@ public function testSaveAllValidation() { $this->assertEquals($expected, $result); $this->assertEquals($errors, $TestModel->validationErrors); - $data = array( - array( + $data = [ + [ 'id' => '1', 'title' => 'Re-Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N' - ), - array( + ], + [ 'id' => '2', 'title' => '', 'body' => 'Trying to get away with an empty title' - )); - $this->assertFalse($TestModel->saveAll($data, array('validate' => 'first'))); + ]]; + $this->assertFalse($TestModel->saveAll($data, ['validate' => 'first'])); - $result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC')); + $result = $TestModel->find('all', ['recursive' => -1, 'order' => 'Post.id ASC']); unset( $result[0]['Post']['updated'], $result[1]['Post']['updated'], $result[3]['Post']['updated'], $result[3]['Post']['created'] @@ -5120,48 +5120,48 @@ public function testSaveAllValidation() { public function testSaveAllValidationOnly() { $this->loadFixtures('Comment', 'Attachment'); $TestModel = new Comment(); - $TestModel->Attachment->validate = array('attachment' => 'notBlank'); + $TestModel->Attachment->validate = ['attachment' => 'notBlank']; - $data = array( - 'Comment' => array( + $data = [ + 'Comment' => [ 'comment' => 'This is the comment' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => '' - ) - ); + ] + ]; - $result = $TestModel->saveAll($data, array('validate' => 'only')); + $result = $TestModel->saveAll($data, ['validate' => 'only']); $this->assertFalse($result); $TestModel = new Article(); - $TestModel->validate = array('title' => 'notBlank'); + $TestModel->validate = ['title' => 'notBlank']; $result = $TestModel->saveAll( - array( - 0 => array('title' => ''), - 1 => array('title' => 'title 1'), - 2 => array('title' => 'title 2'), - ), - array('validate' => 'only') + [ + 0 => ['title' => ''], + 1 => ['title' => 'title 1'], + 2 => ['title' => 'title 2'], + ], + ['validate' => 'only'] ); $this->assertFalse($result); - $expected = array( - 0 => array('title' => array('This field cannot be left blank')), - ); + $expected = [ + 0 => ['title' => ['This field cannot be left blank']], + ]; $this->assertEquals($expected, $TestModel->validationErrors); $result = $TestModel->saveAll( - array( - 0 => array('title' => 'title 0'), - 1 => array('title' => ''), - 2 => array('title' => 'title 2'), - ), - array('validate' => 'only') + [ + 0 => ['title' => 'title 0'], + 1 => ['title' => ''], + 2 => ['title' => 'title 2'], + ], + ['validate' => 'only'] ); $this->assertFalse($result); - $expected = array( - 1 => array('title' => array('This field cannot be left blank')), - ); + $expected = [ + 1 => ['title' => ['This field cannot be left blank']], + ]; $this->assertEquals($expected, $TestModel->validationErrors); } @@ -5175,43 +5175,43 @@ public function testSaveAllValidateFirst() { $model = new Article(); $model->deleteAll(true); - $model->Comment->validate = array('comment' => 'notBlank'); - $result = $model->saveAll(array( - 'Article' => array( + $model->Comment->validate = ['comment' => 'notBlank']; + $result = $model->saveAll([ + 'Article' => [ 'title' => 'Post with Author', 'body' => 'This post will be saved author' - ), - 'Comment' => array( - array('comment' => 'First new comment'), - array('comment' => '') - ) - ), array('validate' => 'first')); + ], + 'Comment' => [ + ['comment' => 'First new comment'], + ['comment' => ''] + ] + ], ['validate' => 'first']); $this->assertFalse($result); $result = $model->find('all'); - $this->assertSame(array(), $result); - $expected = array('Comment' => array( - 1 => array('comment' => array('This field cannot be left blank')) - )); + $this->assertSame([], $result); + $expected = ['Comment' => [ + 1 => ['comment' => ['This field cannot be left blank']] + ]]; $this->assertEquals($expected['Comment'], $model->Comment->validationErrors); $this->assertSame($model->Comment->find('count'), 0); $result = $model->saveAll( - array( - 'Article' => array( + [ + 'Article' => [ 'title' => 'Post with Author', 'body' => 'This post will be saved with an author', 'user_id' => 2 - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'comment' => 'Only new comment', 'user_id' => 2 - ))), - array('validate' => 'first') + ]]], + ['validate' => 'first'] ); $this->assertTrue($result); @@ -5222,17 +5222,17 @@ public function testSaveAllValidateFirst() { $this->assertEquals(4, $result[0]); $model->deleteAll(true); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'title' => 'Post with Author saveAlled from comment', 'body' => 'This post will be saved with an author', 'user_id' => 2 - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'Only new comment', 'user_id' => 2 - )); + ]]; - $result = $model->Comment->saveAll($data, array('validate' => 'first')); + $result = $model->Comment->saveAll($data, ['validate' => 'first']); $this->assertFalse(empty($result)); $result = $model->find('all'); @@ -5251,55 +5251,55 @@ public function testSaveAllValidateFirst() { public function testSaveAllValidateFirstAtomicFalse() { $this->loadFixtures('Something'); $Something = new Something(); - $invalidData = array( - array( + $invalidData = [ + [ 'title' => 'foo', 'body' => 'bar', 'published' => 'baz', - ), - array( + ], + [ 'body' => 3, 'published' => 'sd', - ), - ); + ], + ]; $Something->create(); - $Something->validate = array( - 'title' => array( + $Something->validate = [ + 'title' => [ 'rule' => 'alphaNumeric', 'required' => true, - ), - 'body' => array( + ], + 'body' => [ 'rule' => 'alphaNumeric', 'required' => true, 'allowEmpty' => true, - ), - ); - $result = $Something->saveAll($invalidData, array( + ], + ]; + $result = $Something->saveAll($invalidData, [ 'atomic' => false, 'validate' => 'first', - )); - $expected = array(true, false); + ]); + $expected = [true, false]; $this->assertEquals($expected, $result); $Something = new Something(); - $validData = array( - array( + $validData = [ + [ 'title' => 'title value', 'body' => 'body value', 'published' => 'baz', - ), - array( + ], + [ 'title' => 'valid', 'body' => 'this body', 'published' => 'sd', - ), - ); + ], + ]; $Something->create(); - $result = $Something->saveAll($validData, array( + $result = $Something->saveAll($validData, [ 'atomic' => false, 'validate' => 'first', - )); - $expected = array(true, true); + ]); + $expected = [true, true]; $this->assertEquals($expected, $result); } @@ -5311,71 +5311,71 @@ public function testSaveAllValidateFirstAtomicFalse() { public function testSaveAllHasManyValidationOnly() { $this->loadFixtures('Article', 'Comment', 'Attachment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notBlank'); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; + $TestModel->Comment->validate = ['comment' => 'notBlank']; $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'id' => 1, 'comment' => '', 'published' => 'Y', - 'user_id' => 1), - array( + 'user_id' => 1], + [ 'id' => 2, 'comment' => 'comment', 'published' => 'Y', 'user_id' => 1 - ))), - array('validate' => 'only') + ]]], + ['validate' => 'only'] ); $this->assertFalse($result); $result = $TestModel->saveAll( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'id' => 1, 'comment' => '', 'published' => 'Y', 'user_id' => 1 - ), - array( + ], + [ 'id' => 2, 'comment' => 'comment', 'published' => 'Y', 'user_id' => 1 - ), - array( + ], + [ 'id' => 3, 'comment' => '', 'published' => 'Y', 'user_id' => 1 - ))), - array( + ]]], + [ 'validate' => 'only', 'atomic' => false - )); - $expected = array( + ]); + $expected = [ 'Article' => true, - 'Comment' => array(false, true, false) - ); + 'Comment' => [false, true, false] + ]; $this->assertSame($expected, $result); - $expected = array('Comment' => array( - 0 => array('comment' => array('This field cannot be left blank')), - 2 => array('comment' => array('This field cannot be left blank')) - )); + $expected = ['Comment' => [ + 0 => ['comment' => ['This field cannot be left blank']], + 2 => ['comment' => ['This field cannot be left blank']] + ]]; $this->assertEquals($expected, $TestModel->validationErrors); - $expected = array( - 0 => array('comment' => array('This field cannot be left blank')), - 2 => array('comment' => array('This field cannot be left blank')) - ); + $expected = [ + 0 => ['comment' => ['This field cannot be left blank']], + 2 => ['comment' => ['This field cannot be left blank']] + ]; $this->assertEquals($expected, $TestModel->Comment->validationErrors); } @@ -5386,19 +5386,19 @@ public function testSaveAllHasManyValidationOnly() { */ public function testSaveAllWithSet() { $this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag'); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => 1, 'title' => 'Article Has and belongs to Many Tags' - ), - 'Tag' => array( - 'Tag' => array(1, 2) - ), - 'Comment' => array( - array( + ], + 'Tag' => [ + 'Tag' => [1, 2] + ], + 'Comment' => [ + [ 'comment' => 'Article comment', 'user_id' => 1 - ))); + ]]]; $Article = new Article(); $Article->set($data); $result = $Article->saveAll(); @@ -5415,7 +5415,7 @@ public function testSaveAllEmptyData() { $this->loadFixtures('Article', 'ProductUpdateAll', 'Comment', 'Attachment'); $model = new Article(); - $result = $model->saveAll(array(), array('validate' => 'first')); + $result = $model->saveAll([], ['validate' => 'first']); $this->assertFalse(empty($result)); $model = new ProductUpdateAll(); @@ -5436,31 +5436,31 @@ public function testSaveAssociated() { $this->assertEquals(3, count($result)); $this->assertFalse(isset($result[3])); - $TestModel->saveAssociated(array( - 'Post' => array( + $TestModel->saveAssociated([ + 'Post' => [ 'title' => 'Post with Author', 'body' => 'This post will be saved with an author' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'bob', 'password' => '5f4dcc3b5aa765d61d8327deb882cf90' - ))); + ]]); - $result = $TestModel->find('all', array('order' => array('Post.id ' => 'ASC'))); - $expected = array( - 'Post' => array( + $result = $TestModel->find('all', ['order' => ['Post.id ' => 'ASC']]); + $expected = [ + 'Post' => [ 'id' => '4', 'author_id' => '5', 'title' => 'Post with Author', 'body' => 'This post will be saved with an author', 'published' => 'N' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '5', 'user' => 'bob', 'password' => '5f4dcc3b5aa765d61d8327deb882cf90', 'test' => 'working' - )); + ]]; $this->assertEquals(static::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Author']['created']); @@ -5473,36 +5473,36 @@ public function testSaveAssociated() { $this->assertEquals(4, count($result)); $TestModel = new Comment(); - $result = $TestModel->saveAssociated(array( - 'Comment' => array( + $result = $TestModel->saveAssociated([ + 'Comment' => [ 'article_id' => 2, 'user_id' => 2, 'comment' => 'New comment with attachment', 'published' => 'Y' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => 'some_file.tgz' - ))); + ]]); $this->assertFalse(empty($result)); $result = $TestModel->find('all'); - $expected = array( + $expected = [ 'id' => '7', 'article_id' => '2', 'user_id' => '2', 'comment' => 'New comment with attachment', 'published' => 'Y' - ); + ]; $this->assertEquals(static::date(), $result[6]['Comment']['updated']); $this->assertEquals(static::date(), $result[6]['Comment']['created']); unset($result[6]['Comment']['updated'], $result[6]['Comment']['created']); $this->assertEquals($expected, $result[6]['Comment']); - $expected = array( + $expected = [ 'id' => '2', 'comment_id' => '7', 'attachment' => 'some_file.tgz' - ); + ]; $this->assertEquals(static::date(), $result[6]['Attachment']['updated']); $this->assertEquals(static::date(), $result[6]['Attachment']['created']); unset($result[6]['Attachment']['updated'], $result[6]['Attachment']['created']); @@ -5518,39 +5518,39 @@ public function testSaveAssociated() { public function testSaveAssociatedAtomicFalseValidateFirstWithErrors() { $this->loadFixtures('Comment', 'Article', 'User'); $Article = ClassRegistry::init('Article'); - $Article->Comment->validator()->add('comment', array( - array('rule' => 'notBlank') - )); + $Article->Comment->validator()->add('comment', [ + ['rule' => 'notBlank'] + ]); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => 1, 'title' => 'Foo', 'body' => 'text', 'published' => 'N' - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'user_id' => 1, 'comment' => '', 'published' => 'N', - ) - ), - ); + ] + ], + ]; $Article->saveAssociated( $data, - array('validate' => 'first', 'atomic' => false) + ['validate' => 'first', 'atomic' => false] ); $result = $Article->validationErrors; - $expected = array( - 'Comment' => array( - array( - 'comment' => array('This field cannot be left blank') - ) - ) - ); + $expected = [ + 'Comment' => [ + [ + 'comment' => ['This field cannot be left blank'] + ] + ] + ]; $this->assertEquals($expected, $result); } @@ -5563,47 +5563,47 @@ public function testSaveMany() { $this->loadFixtures('Post'); $TestModel = new Post(); $TestModel->deleteAll(true); - $this->assertEquals(array(), $TestModel->find('all')); + $this->assertEquals([], $TestModel->find('all')); // SQLite seems to reset the PK counter when that happens, so we need this to make the tests pass $this->db->truncate($TestModel); - $TestModel->saveMany(array( - array( + $TestModel->saveMany([ + [ 'title' => 'Multi-record post 1', 'body' => 'First multi-record post', 'author_id' => 2 - ), - array( + ], + [ 'title' => 'Multi-record post 2', 'body' => 'Second multi-record post', 'author_id' => 2 - ))); + ]]); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'recursive' => -1, 'order' => 'Post.id ASC' - )); - $expected = array( - array( - 'Post' => array( + ]); + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '2', 'title' => 'Multi-record post 1', 'body' => 'First multi-record post', 'published' => 'N' - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '2', 'author_id' => '2', 'title' => 'Multi-record post 2', 'body' => 'Second multi-record post', 'published' => 'N' - ) - ) - ); + ] + ] + ]; $this->assertEquals(static::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[0]['Post']['created']); $this->assertEquals(static::date(), $result[1]['Post']['updated']); @@ -5622,11 +5622,11 @@ public function testSaveManyValidateFalse() { $this->loadFixtures('Post'); $TestModel = new Post(); $TestModel->deleteAll(true); - $data = array( - array('id' => 1, 'author_id' => 1, 'title' => 'hi'), - array('id' => 2, 'author_id' => 1, 'title' => 'bye') - ); - $result = $TestModel->saveAll($data, array('validate' => false)); + $data = [ + ['id' => 1, 'author_id' => 1, 'title' => 'hi'], + ['id' => 2, 'author_id' => 1, 'title' => 'bye'] + ]; + $result = $TestModel->saveAll($data, ['validate' => false]); $this->assertTrue($result); } @@ -5637,21 +5637,21 @@ public function testSaveManyValidateFalse() { */ public function testSaveAssociatedHabtm() { $this->loadFixtures('Article', 'Tag', 'Comment', 'User', 'ArticlesTag'); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'user_id' => 1, 'title' => 'Article Has and belongs to Many Tags' - ), - 'Tag' => array( - 'Tag' => array(1, 2) - ), - 'Comment' => array( - array( + ], + 'Tag' => [ + 'Tag' => [1, 2] + ], + 'Comment' => [ + [ 'comment' => 'Article comment', 'user_id' => 1 - ) - ) - ); + ] + ] + ]; $Article = new Article(); $result = $Article->saveAssociated($data); $this->assertFalse(empty($result)); @@ -5671,19 +5671,19 @@ public function testSaveAssociatedHabtm() { public function testSaveAssociatedHabtmWithExtraJoinTableFields() { $this->loadFixtures('Something', 'SomethingElse', 'JoinThing'); - $data = array( - 'Something' => array( + $data = [ + 'Something' => [ 'id' => 4, 'title' => 'Extra Fields', 'body' => 'Extra Fields Body', 'published' => '1' - ), - 'SomethingElse' => array( - array('something_else_id' => 1, 'doomed' => '1'), - array('something_else_id' => 2, 'doomed' => '0'), - array('something_else_id' => 3, 'doomed' => '1') - ) - ); + ], + 'SomethingElse' => [ + ['something_else_id' => 1, 'doomed' => '1'], + ['something_else_id' => 2, 'doomed' => '0'], + ['something_else_id' => 3, 'doomed' => '1'] + ] + ]; $Something = new Something(); $result = $Something->saveAssociated($data); @@ -5714,47 +5714,47 @@ public function testSaveAssociatedHabtmWithExtraJoinTableFields() { public function testSaveAssociatedHasOne() { $model = new Comment(); $model->deleteAll(true); - $this->assertEquals(array(), $model->find('all')); + $this->assertEquals([], $model->find('all')); $model->Attachment->deleteAll(true); - $this->assertEquals(array(), $model->Attachment->find('all')); + $this->assertEquals([], $model->Attachment->find('all')); - $this->assertTrue($model->saveAssociated(array( - 'Comment' => array( + $this->assertTrue($model->saveAssociated([ + 'Comment' => [ 'comment' => 'Comment with attachment', 'article_id' => 1, 'user_id' => 1 - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => 'some_file.zip' - )))); - $result = $model->find('all', array('fields' => array( + ]])); + $result = $model->find('all', ['fields' => [ 'Comment.id', 'Comment.comment', 'Attachment.id', 'Attachment.comment_id', 'Attachment.attachment' - ))); - $expected = array(array( - 'Comment' => array( + ]]); + $expected = [[ + 'Comment' => [ 'id' => '1', 'comment' => 'Comment with attachment' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'id' => '1', 'comment_id' => '1', 'attachment' => 'some_file.zip' - ))); + ]]]; $this->assertEquals($expected, $result); - $model->Attachment->bindModel(array('belongsTo' => array('Comment')), false); - $data = array( - 'Comment' => array( + $model->Attachment->bindModel(['belongsTo' => ['Comment']], false); + $data = [ + 'Comment' => [ 'comment' => 'Comment with attachment', 'article_id' => 1, 'user_id' => 1 - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => 'some_file.zip' - )); - $this->assertTrue($model->saveAssociated($data, array('validate' => 'first'))); + ]]; + $this->assertTrue($model->saveAssociated($data, ['validate' => 'first'])); } /** @@ -5765,34 +5765,34 @@ public function testSaveAssociatedHasOne() { public function testSaveAssociatedBelongsTo() { $model = new Comment(); $model->deleteAll(true); - $this->assertEquals(array(), $model->find('all')); + $this->assertEquals([], $model->find('all')); $model->Article->deleteAll(true); - $this->assertEquals(array(), $model->Article->find('all')); + $this->assertEquals([], $model->Article->find('all')); - $this->assertTrue($model->saveAssociated(array( - 'Comment' => array( + $this->assertTrue($model->saveAssociated([ + 'Comment' => [ 'comment' => 'Article comment', 'article_id' => 1, 'user_id' => 1 - ), - 'Article' => array( + ], + 'Article' => [ 'title' => 'Model Associations 101', 'user_id' => 1 - )))); - $result = $model->find('all', array('fields' => array( + ]])); + $result = $model->find('all', ['fields' => [ 'Comment.id', 'Comment.comment', 'Comment.article_id', 'Article.id', 'Article.title' - ))); - $expected = array(array( - 'Comment' => array( + ]]); + $expected = [[ + 'Comment' => [ 'id' => '1', 'article_id' => '1', 'comment' => 'Article comment' - ), - 'Article' => array( + ], + 'Article' => [ 'id' => '1', 'title' => 'Model Associations 101' - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -5804,36 +5804,36 @@ public function testSaveAssociatedBelongsTo() { public function testSaveAssociatedHasOneValidation() { $model = new Comment(); $model->deleteAll(true); - $this->assertEquals(array(), $model->find('all')); + $this->assertEquals([], $model->find('all')); $model->Attachment->deleteAll(true); - $this->assertEquals(array(), $model->Attachment->find('all')); + $this->assertEquals([], $model->Attachment->find('all')); - $model->validate = array('comment' => 'notBlank'); - $model->Attachment->validate = array('attachment' => 'notBlank'); - $model->Attachment->bindModel(array('belongsTo' => array('Comment'))); + $model->validate = ['comment' => 'notBlank']; + $model->Attachment->validate = ['attachment' => 'notBlank']; + $model->Attachment->bindModel(['belongsTo' => ['Comment']]); $result = $model->saveAssociated( - array( - 'Comment' => array( + [ + 'Comment' => [ 'comment' => '', 'article_id' => 1, 'user_id' => 1 - ), - 'Attachment' => array('attachment' => '') - ) + ], + 'Attachment' => ['attachment' => ''] + ] ); $this->assertFalse($result); - $expected = array( - 'comment' => array( + $expected = [ + 'comment' => [ 'This field cannot be left blank' - ), - 'Attachment' => array( - 'attachment' => array( + ], + 'Attachment' => [ + 'attachment' => [ 'This field cannot be left blank' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $model->validationErrors); $this->assertEquals($expected['Attachment'], $model->Attachment->validationErrors); } @@ -5847,33 +5847,33 @@ public function testSaveAssociatedAtomic() { $this->loadFixtures('Article', 'User'); $TestModel = new Article(); - $result = $TestModel->saveAssociated(array( - 'Article' => array( + $result = $TestModel->saveAssociated([ + 'Article' => [ 'title' => 'Post with Author', 'body' => 'This post will be saved with an author', 'user_id' => 2 - ), - 'Comment' => array( - array('comment' => 'First new comment', 'user_id' => 2)) - ), array('atomic' => false)); + ], + 'Comment' => [ + ['comment' => 'First new comment', 'user_id' => 2]] + ], ['atomic' => false]); - $this->assertSame($result, array('Article' => true, 'Comment' => array(true))); + $this->assertSame($result, ['Article' => true, 'Comment' => [true]]); - $result = $TestModel->saveAssociated(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + $result = $TestModel->saveAssociated([ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1 - ), - array( + ], + [ 'comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2 - )) - ), array('validate' => true, 'atomic' => false)); - $this->assertSame($result, array('Article' => true, 'Comment' => array(true, true))); + ]] + ], ['validate' => true, 'atomic' => false]); + $this->assertSame($result, ['Article' => true, 'Comment' => [true, true]]); } /** @@ -5885,41 +5885,41 @@ public function testSaveManyAtomic() { $this->loadFixtures('Article', 'User'); $TestModel = new Article(); - $result = $TestModel->saveMany(array( - array( + $result = $TestModel->saveMany([ + [ 'id' => '1', 'title' => 'Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N' - ), - array( + ], + [ 'id' => '2', 'title' => 'Just update the title' - ), - array( + ], + [ 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'user_id' => 2 - ) - ), array('atomic' => false)); - $this->assertSame($result, array(true, true, true)); + ] + ], ['atomic' => false]); + $this->assertSame($result, [true, true, true]); - $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); - $result = $TestModel->saveMany(array( - array( + $TestModel->validate = ['title' => 'notBlank', 'author_id' => 'numeric']; + $result = $TestModel->saveMany([ + [ 'id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y' - ), - array( + ], + [ 'id' => '2', 'title' => '', 'body' => 'Trying to get away with an empty title' - ) - ), array('validate' => true, 'atomic' => false)); + ] + ], ['validate' => true, 'atomic' => false]); - $this->assertSame(array(true, false), $result); + $this->assertSame([true, false], $result); } /** @@ -5930,71 +5930,71 @@ public function testSaveManyAtomic() { public function testSaveAssociatedHasMany() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - - $result = $TestModel->saveAssociated(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - )); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; + + $result = $TestModel->saveAssociated([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]); $this->assertFalse(empty($result)); $result = $TestModel->findById(2); - $expected = array( + $expected = [ 'First Comment for Second Article', 'Second Comment for Second Article', 'First new comment', 'Second new comment' - ); + ]; $this->assertEquals($expected, Hash::extract($result['Comment'], '{n}.comment')); $result = $TestModel->saveAssociated( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => 'Third new comment', 'published' => 'Y', 'user_id' => 1 - ))), - array('atomic' => false) + ]]], + ['atomic' => false] ); $this->assertFalse(empty($result)); $result = $TestModel->findById(2); - $expected = array( + $expected = [ 'First Comment for Second Article', 'Second Comment for Second Article', 'First new comment', 'Second new comment', 'Third new comment' - ); + ]; $this->assertEquals($expected, Hash::extract($result['Comment'], '{n}.comment')); $TestModel->beforeSaveReturn = false; $result = $TestModel->saveAssociated( - array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => 'Fourth new comment', 'published' => 'Y', 'user_id' => 1 - ))), - array('atomic' => false) + ]]], + ['atomic' => false] ); - $this->assertEquals(array('Article' => false), $result); + $this->assertEquals(['Article' => false], $result); $result = $TestModel->findById(2); - $expected = array( + $expected = [ 'First Comment for Second Article', 'Second Comment for Second Article', 'First new comment', 'Second new comment', 'Third new comment' - ); + ]; $this->assertEquals($expected, Hash::extract($result['Comment'], '{n}.comment')); } @@ -6006,28 +6006,28 @@ public function testSaveAssociatedHasMany() { public function testSaveAssociatedHasManyEmpty() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->validate = $TestModel->Comment->validate = array('user_id' => array('notBlank' => array('rule' => 'notBlank', 'required' => true))); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; + $TestModel->validate = $TestModel->Comment->validate = ['user_id' => ['notBlank' => ['rule' => 'notBlank', 'required' => true]]]; //empty hasMany data is ignored in save - $result = $TestModel->saveAssociated(array( - 'Article' => array('title' => 'title', 'user_id' => 1), - 'Comment' => array() - ), array('validate' => true)); + $result = $TestModel->saveAssociated([ + 'Article' => ['title' => 'title', 'user_id' => 1], + 'Comment' => [] + ], ['validate' => true]); $this->assertTrue($result); - $result = $TestModel->saveAssociated(array( - 'Article' => array('title' => 'title', 'user_id' => 1), - 'Comment' => array() - ), array('validate' => true, 'atomic' => false)); - $this->assertEquals(array('Article' => true), $result); + $result = $TestModel->saveAssociated([ + 'Article' => ['title' => 'title', 'user_id' => 1], + 'Comment' => [] + ], ['validate' => true, 'atomic' => false]); + $this->assertEquals(['Article' => true], $result); //empty primary data is not ignored - $result = $TestModel->saveAssociated(array('Article' => array()), array('validate' => true)); + $result = $TestModel->saveAssociated(['Article' => []], ['validate' => true]); $this->assertFalse($result); - $result = $TestModel->saveAssociated(array('Article' => array()), array('validate' => true, 'atomic' => false)); - $this->assertEquals(array('Article' => false), $result); + $result = $TestModel->saveAssociated(['Article' => []], ['validate' => true, 'atomic' => false]); + $this->assertEquals(['Article' => false], $result); } /** @@ -6038,35 +6038,35 @@ public function testSaveAssociatedHasManyEmpty() { public function testSaveAssociatedHasManyValidation() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notBlank'); - - $result = $TestModel->saveAssociated(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array('comment' => '', 'published' => 'Y', 'user_id' => 1), - ) - ), array('validate' => true)); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; + $TestModel->Comment->validate = ['comment' => 'notBlank']; + + $result = $TestModel->saveAssociated([ + 'Article' => ['id' => 2], + 'Comment' => [ + ['comment' => '', 'published' => 'Y', 'user_id' => 1], + ] + ], ['validate' => true]); $this->assertFalse($result); - $expected = array('Comment' => array( - array('comment' => array('This field cannot be left blank')) - )); + $expected = ['Comment' => [ + ['comment' => ['This field cannot be left blank']] + ]]; $this->assertEquals($expected, $TestModel->validationErrors); - $expected = array( - array('comment' => array('This field cannot be left blank')) - ); + $expected = [ + ['comment' => ['This field cannot be left blank']] + ]; $this->assertEquals($expected, $TestModel->Comment->validationErrors); - $result = $TestModel->saveAssociated(array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + $result = $TestModel->saveAssociated([ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'comment' => '', 'published' => 'Y', 'user_id' => 1 - )) - ), array('validate' => 'first')); + ]] + ], ['validate' => 'first']); $this->assertFalse($result); } @@ -6079,56 +6079,56 @@ public function testSaveManyTransactionNoRollback() { $this->loadFixtures('Post'); $Post = new TestPost(); - $Post->validate = array( - 'title' => array('rule' => array('notBlank')) - ); + $Post->validate = [ + 'title' => ['rule' => ['notBlank']] + ]; // If validation error occurs, rollback() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->once())->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => '') - ); - $Post->saveMany($data, array('validate' => true)); + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => ''] + ]; + $Post->saveMany($data, ['validate' => true]); // If exception thrown, rollback() should be called too. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->once())->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post', 'body' => $db->expression('PDO_EXCEPTION()')) - ); + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post', 'body' => $db->expression('PDO_EXCEPTION()')] + ]; try { - $Post->saveMany($data, array('validate' => true)); + $Post->saveMany($data, ['validate' => true]); $this->fail('No exception thrown'); - } catch (PDOException $e) { + } catch (PDOException) { } // Otherwise, commit() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->once())->method('commit'); $db->expects($this->never())->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post') - ); - $Post->saveMany($data, array('validate' => true)); + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post'] + ]; + $Post->saveMany($data, ['validate' => true]); } /** @@ -6140,12 +6140,12 @@ public function testSaveAssociatedTransactionNoRollback() { $this->loadFixtures('Post', 'Author'); $Post = new TestPost(); - $Post->Author->validate = array( - 'user' => array('rule' => array('notBlank')) - ); + $Post->Author->validate = [ + 'user' => ['rule' => ['notBlank']] + ]; // If validation error occurs, rollback() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->once())->method('rollback'); @@ -6153,21 +6153,21 @@ public function testSaveAssociatedTransactionNoRollback() { $Post->setDataSourceObject($db); $Post->Author->setDataSourceObject($db); - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'title' => 'New post', 'body' => 'Content', 'published' => 'Y' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => '', 'password' => "sekret" - ) - ); - $Post->saveAssociated($data, array('validate' => true, 'atomic' => true)); + ] + ]; + $Post->saveAssociated($data, ['validate' => true, 'atomic' => true]); // If exception thrown, commit() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->once())->method('rollback'); @@ -6175,26 +6175,26 @@ public function testSaveAssociatedTransactionNoRollback() { $Post->setDataSourceObject($db); $Post->Author->setDataSourceObject($db); - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'title' => 'New post', 'body' => $db->expression('PDO_EXCEPTION()'), 'published' => 'Y' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'New user', 'password' => "sekret" - ) - ); + ] + ]; try { - $Post->saveAssociated($data, array('validate' => true, 'atomic' => true)); + $Post->saveAssociated($data, ['validate' => true, 'atomic' => true]); $this->fail('No exception thrown'); - } catch (PDOException $e) { + } catch (PDOException) { } // Otherwise, commit() should be called. - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->once())->method('begin')->will($this->returnValue(true)); $db->expects($this->once())->method('commit'); $db->expects($this->never())->method('rollback'); @@ -6202,18 +6202,18 @@ public function testSaveAssociatedTransactionNoRollback() { $Post->setDataSourceObject($db); $Post->Author->setDataSourceObject($db); - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'title' => 'New post', 'body' => 'Content', 'published' => 'Y' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'New user', 'password' => "sekret" - ) - ); - $Post->saveAssociated($data, array('validate' => true, 'atomic' => true)); + ] + ]; + $Post->saveAssociated($data, ['validate' => true, 'atomic' => true]); } /** @@ -6225,11 +6225,11 @@ public function testSaveManyNestedSaveMany() { $this->loadFixtures('Sample'); $TransactionManyTestModel = new TransactionManyTestModel(); - $data = array( - array('apple_id' => 1, 'name' => 'sample5'), - ); + $data = [ + ['apple_id' => 1, 'name' => 'sample5'], + ]; - $this->assertTrue($TransactionManyTestModel->saveMany($data, array('atomic' => true))); + $this->assertTrue($TransactionManyTestModel->saveMany($data, ['atomic' => true])); } /** @@ -6241,17 +6241,17 @@ public function testSaveManyTransaction() { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment'); $TestModel = new Post(); - $TestModel->validate = array('title' => 'notBlank'); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post'), - array('author_id' => 1, 'title' => '') - ); + $TestModel->validate = ['title' => 'notBlank']; + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post'], + ['author_id' => 1, 'title' => ''] + ]; $this->assertFalse($TestModel->saveMany($data)); - $result = $TestModel->find('all', array('recursive' => -1)); - $expected = array( - array('Post' => array( + $result = $TestModel->find('all', ['recursive' => -1]); + $expected = [ + ['Post' => [ 'id' => '1', 'author_id' => 1, 'title' => 'First Post', @@ -6259,8 +6259,8 @@ public function testSaveManyTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array('Post' => array( + ]], + ['Post' => [ 'id' => '2', 'author_id' => 3, 'title' => 'Second Post', @@ -6268,8 +6268,8 @@ public function testSaveManyTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - )), - array('Post' => array( + ]], + ['Post' => [ 'id' => '3', 'author_id' => 1, 'title' => 'Third Post', @@ -6277,27 +6277,27 @@ public function testSaveManyTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ))); + ]]]; if (count($result) != 3) { // Database doesn't support transactions - $expected[] = array( - 'Post' => array( + $expected[] = [ + 'Post' => [ 'id' => '4', 'author_id' => 1, 'title' => 'New Fourth Post', 'body' => null, 'published' => 'N' - )); + ]]; - $expected[] = array( - 'Post' => array( + $expected[] = [ + 'Post' => [ 'id' => '5', 'author_id' => 1, 'title' => 'New Fifth Post', 'body' => null, 'published' => 'N', - )); + ]]; $this->assertEquals(static::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['updated']); @@ -6312,16 +6312,16 @@ public function testSaveManyTransaction() { $this->assertEquals($expected, $result); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => ''), - array('author_id' => 1, 'title' => 'New Sixth Post') - ); + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => ''], + ['author_id' => 1, 'title' => 'New Sixth Post'] + ]; $this->assertFalse($TestModel->saveMany($data)); - $result = $TestModel->find('all', array('recursive' => -1)); - $expected = array( - array('Post' => array( + $result = $TestModel->find('all', ['recursive' => -1]); + $expected = [ + ['Post' => [ 'id' => '1', 'author_id' => 1, 'title' => 'First Post', @@ -6329,8 +6329,8 @@ public function testSaveManyTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31' - )), - array('Post' => array( + ]], + ['Post' => [ 'id' => '2', 'author_id' => 3, 'title' => 'Second Post', @@ -6338,8 +6338,8 @@ public function testSaveManyTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31' - )), - array('Post' => array( + ]], + ['Post' => [ 'id' => '3', 'author_id' => 1, 'title' => 'Third Post', @@ -6347,27 +6347,27 @@ public function testSaveManyTransaction() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - ))); + ]]]; if (count($result) != 3) { // Database doesn't support transactions - $expected[] = array( - 'Post' => array( + $expected[] = [ + 'Post' => [ 'id' => '4', 'author_id' => 1, 'title' => 'New Fourth Post', 'body' => 'Third Post Body', 'published' => 'N' - )); + ]]; - $expected[] = array( - 'Post' => array( + $expected[] = [ + 'Post' => [ 'id' => '5', 'author_id' => 1, 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'N' - )); + ]]; $this->assertEquals(static::date(), $result[3]['Post']['created']); $this->assertEquals(static::date(), $result[3]['Post']['updated']); $this->assertEquals(static::date(), $result[4]['Post']['created']); @@ -6377,57 +6377,57 @@ public function testSaveManyTransaction() { } $this->assertEquals($expected, $result); - $TestModel->validate = array('title' => 'notBlank'); - $data = array( - array('author_id' => 1, 'title' => 'New Fourth Post'), - array('author_id' => 1, 'title' => 'New Fifth Post'), - array('author_id' => 1, 'title' => 'New Sixth Post') - ); + $TestModel->validate = ['title' => 'notBlank']; + $data = [ + ['author_id' => 1, 'title' => 'New Fourth Post'], + ['author_id' => 1, 'title' => 'New Fifth Post'], + ['author_id' => 1, 'title' => 'New Sixth Post'] + ]; $this->assertTrue($TestModel->saveMany($data)); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'recursive' => -1, - 'fields' => array('author_id', 'title', 'body', 'published'), - 'order' => array('Post.created' => 'ASC') - )); + 'fields' => ['author_id', 'title', 'body', 'published'], + 'order' => ['Post.created' => 'ASC'] + ]); - $expected = array( - array('Post' => array( + $expected = [ + ['Post' => [ 'author_id' => 1, 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 3, 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 1, 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 1, 'title' => 'New Fourth Post', 'body' => '', 'published' => 'N' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 1, 'title' => 'New Fifth Post', 'body' => '', 'published' => 'N' - )), - array('Post' => array( + ]], + ['Post' => [ 'author_id' => 1, 'title' => 'New Sixth Post', 'body' => '', 'published' => 'N' - ))); + ]]]; $this->assertEquals($expected, $result); } @@ -6440,49 +6440,49 @@ public function testSaveManyValidation() { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment'); $TestModel = new Post(); - $data = array( - array( + $data = [ + [ 'id' => '1', 'title' => 'Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N' - ), - array( + ], + [ 'id' => '2', 'title' => 'Just update the title' - ), - array( + ], + [ 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'author_id' => 2 - )); + ]]; $this->assertTrue($TestModel->saveMany($data)); - $result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC')); - $expected = array( - array( - 'Post' => array( + $result = $TestModel->find('all', ['recursive' => -1, 'order' => 'Post.id ASC']); + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '1', 'title' => 'Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N', 'created' => '2007-03-18 10:39:23' - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '2', 'author_id' => '3', 'title' => 'Just update the title', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23' - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '3', 'author_id' => '1', 'title' => 'Third Post', @@ -6490,17 +6490,17 @@ public function testSaveManyValidation() { 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31' - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '4', 'author_id' => '2', 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'published' => 'N' - ) - ) - ); + ] + ] + ]; $this->assertEquals(static::date(), $result[0]['Post']['updated']); $this->assertEquals(static::date(), $result[1]['Post']['updated']); @@ -6510,24 +6510,24 @@ public function testSaveManyValidation() { unset($result[3]['Post']['created'], $result[3]['Post']['updated']); $this->assertEquals($expected, $result); - $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); - $data = array( - array( + $TestModel->validate = ['title' => 'notBlank', 'author_id' => 'numeric']; + $data = [ + [ 'id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y' - ), - array( + ], + [ 'id' => '2', 'title' => '', 'body' => 'Trying to get away with an empty title' - )); + ]]; $result = $TestModel->saveMany($data); $this->assertFalse($result); - $result = $TestModel->find('all', array('recursive' => -1, 'order' => 'Post.id ASC')); - $errors = array(1 => array('title' => array('This field cannot be left blank'))); + $result = $TestModel->find('all', ['recursive' => -1, 'order' => 'Post.id ASC']); + $errors = [1 => ['title' => ['This field cannot be left blank']]]; $transactionWorked = Set::matches('/Post[1][title=Baleeted First Post]', $result); if (!$transactionWorked) { $this->assertTrue(Set::matches('/Post[1][title=Un-Baleeted First Post]', $result)); @@ -6536,83 +6536,83 @@ public function testSaveManyValidation() { $this->assertEquals($errors, $TestModel->validationErrors); - $TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric'); - $data = array( - array( + $TestModel->validate = ['title' => 'notBlank', 'author_id' => 'numeric']; + $data = [ + [ 'id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y' - ), - array( + ], + [ 'id' => '2', 'title' => '', 'body' => 'Trying to get away with an empty title' - )); - $result = $TestModel->saveMany($data, array('validate' => true, 'atomic' => false)); - $this->assertEquals(array(true, false), $result); + ]]; + $result = $TestModel->saveMany($data, ['validate' => true, 'atomic' => false]); + $this->assertEquals([true, false], $result); - $result = $TestModel->find('all', array( - 'fields' => array('id', 'author_id', 'title', 'body', 'published'), + $result = $TestModel->find('all', [ + 'fields' => ['id', 'author_id', 'title', 'body', 'published'], 'recursive' => -1, 'order' => 'Post.id ASC' - )); - $errors = array(1 => array('title' => array('This field cannot be left blank'))); - $expected = array( - array( - 'Post' => array( + ]); + $errors = [1 => ['title' => ['This field cannot be left blank']]]; + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '1', 'title' => 'Un-Baleeted First Post', 'body' => 'Not Baleeted!', 'published' => 'Y', - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '2', 'author_id' => '3', 'title' => 'Just update the title', 'body' => 'Second Post Body', 'published' => 'Y', - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '3', 'author_id' => '1', 'title' => 'Third Post', 'body' => 'Third Post Body', 'published' => 'Y', - )), - array( - 'Post' => array( + ]], + [ + 'Post' => [ 'id' => '4', 'author_id' => '2', 'title' => 'Creating a fourth post', 'body' => 'Fourth post body', 'published' => 'N', - ))); + ]]]; $this->assertEquals($expected, $result); $this->assertEquals($errors, $TestModel->validationErrors); - $data = array( - array( + $data = [ + [ 'id' => '1', 'title' => 'Re-Baleeted First Post', 'body' => 'Baleeted!', 'published' => 'N' - ), - array( + ], + [ 'id' => '2', 'title' => '', 'body' => 'Trying to get away with an empty title' - )); - $this->assertFalse($TestModel->saveMany($data, array('validate' => 'first'))); + ]]; + $this->assertFalse($TestModel->saveMany($data, ['validate' => 'first'])); - $result = $TestModel->find('all', array( - 'fields' => array('id', 'author_id', 'title', 'body', 'published'), + $result = $TestModel->find('all', [ + 'fields' => ['id', 'author_id', 'title', 'body', 'published'], 'recursive' => -1, 'order' => 'Post.id ASC' - )); + ]); $this->assertEquals($expected, $result); $this->assertEquals($errors, $TestModel->validationErrors); } @@ -6624,29 +6624,29 @@ public function testSaveManyValidation() { */ public function testValidateMany() { $TestModel = new Article(); - $TestModel->validate = array('title' => 'notBlank'); - $data = array( - 0 => array('title' => ''), - 1 => array('title' => 'title 1'), - 2 => array('title' => 'title 2'), - ); + $TestModel->validate = ['title' => 'notBlank']; + $data = [ + 0 => ['title' => ''], + 1 => ['title' => 'title 1'], + 2 => ['title' => 'title 2'], + ]; $result = $TestModel->validateMany($data); $this->assertFalse($result); - $expected = array( - 0 => array('title' => array('This field cannot be left blank')), - ); + $expected = [ + 0 => ['title' => ['This field cannot be left blank']], + ]; $this->assertEquals($expected, $TestModel->validationErrors); - $data = array( - 0 => array('title' => 'title 0'), - 1 => array('title' => ''), - 2 => array('title' => 'title 2'), - ); + $data = [ + 0 => ['title' => 'title 0'], + 1 => ['title' => ''], + 2 => ['title' => 'title 2'], + ]; $result = $TestModel->validateMany($data); $this->assertFalse($result); - $expected = array( - 1 => array('title' => array('This field cannot be left blank')), - ); + $expected = [ + 1 => ['title' => ['This field cannot be left blank']], + ]; $this->assertEquals($expected, $TestModel->validationErrors); } @@ -6660,43 +6660,43 @@ public function testSaveAssociatedValidateFirst() { $model = new Article(); $model->deleteAll(true); - $model->Comment->validate = array('comment' => 'notBlank'); - $result = $model->saveAssociated(array( - 'Article' => array( + $model->Comment->validate = ['comment' => 'notBlank']; + $result = $model->saveAssociated([ + 'Article' => [ 'title' => 'Post with Author', 'body' => 'This post will be saved author' - ), - 'Comment' => array( - array('comment' => 'First new comment'), - array('comment' => '') - ) - ), array('validate' => 'first')); + ], + 'Comment' => [ + ['comment' => 'First new comment'], + ['comment' => ''] + ] + ], ['validate' => 'first']); $this->assertFalse($result); $result = $model->find('all'); - $this->assertSame(array(), $result); - $expected = array('Comment' => array( - 1 => array('comment' => array('This field cannot be left blank')) - )); + $this->assertSame([], $result); + $expected = ['Comment' => [ + 1 => ['comment' => ['This field cannot be left blank']] + ]]; $this->assertEquals($expected['Comment'], $model->Comment->validationErrors); $this->assertSame($model->Comment->find('count'), 0); $result = $model->saveAssociated( - array( - 'Article' => array( + [ + 'Article' => [ 'title' => 'Post with Author', 'body' => 'This post will be saved with an author', 'user_id' => 2 - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'comment' => 'Only new comment', 'user_id' => 2 - ))), - array('validate' => 'first') + ]]], + ['validate' => 'first'] ); $this->assertTrue($result); @@ -6707,17 +6707,17 @@ public function testSaveAssociatedValidateFirst() { $this->assertEquals(4, $result[0]); $model->deleteAll(true); - $data = array( - 'Article' => array( + $data = [ + 'Article' => [ 'title' => 'Post with Author saveAlled from comment', 'body' => 'This post will be saved with an author', 'user_id' => 2 - ), - 'Comment' => array( + ], + 'Comment' => [ 'comment' => 'Only new comment', 'user_id' => 2 - )); + ]]; - $result = $model->Comment->saveAssociated($data, array('validate' => 'first')); + $result = $model->Comment->saveAssociated($data, ['validate' => 'first']); $this->assertFalse(empty($result)); $result = $model->find('all'); @@ -6735,55 +6735,55 @@ public function testSaveAssociatedValidateFirst() { */ public function testSaveManyValidateFirstAtomicFalse() { $Something = new Something(); - $invalidData = array( - array( + $invalidData = [ + [ 'title' => 'foo', 'body' => 'bar', 'published' => 'baz', - ), - array( + ], + [ 'body' => 3, 'published' => 'sd', - ), - ); + ], + ]; $Something->create(); - $Something->validate = array( - 'title' => array( + $Something->validate = [ + 'title' => [ 'rule' => 'alphaNumeric', 'required' => true, - ), - 'body' => array( + ], + 'body' => [ 'rule' => 'alphaNumeric', 'required' => true, 'allowEmpty' => true, - ), - ); - $result = $Something->saveMany($invalidData, array( + ], + ]; + $result = $Something->saveMany($invalidData, [ 'atomic' => false, 'validate' => 'first', - )); - $expected = array(true, false); + ]); + $expected = [true, false]; $this->assertEquals($expected, $result); $Something = new Something(); - $validData = array( - array( + $validData = [ + [ 'title' => 'title value', 'body' => 'body value', 'published' => 'baz', - ), - array( + ], + [ 'title' => 'valid', 'body' => 'this body', 'published' => 'sd', - ), - ); + ], + ]; $Something->create(); - $result = $Something->saveMany($validData, array( + $result = $Something->saveMany($validData, [ 'atomic' => false, 'validate' => 'first', - )); - $expected = array(true, true); + ]); + $expected = [true, true]; $this->assertEquals($expected, $result); } @@ -6795,82 +6795,82 @@ public function testSaveManyValidateFirstAtomicFalse() { public function testValidateAssociated() { $this->loadFixtures('Attachment', 'Article', 'Comment'); $TestModel = new Comment(); - $TestModel->Attachment->validate = array('attachment' => 'notBlank'); + $TestModel->Attachment->validate = ['attachment' => 'notBlank']; - $data = array( - 'Comment' => array( + $data = [ + 'Comment' => [ 'comment' => 'This is the comment' - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => '' - ) - ); + ] + ]; $result = $TestModel->validateAssociated($data); $this->assertFalse($result); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); - $TestModel->Comment->validate = array('comment' => 'notBlank'); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; + $TestModel->Comment->validate = ['comment' => 'notBlank']; - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'id' => 1, 'comment' => '', 'published' => 'Y', - 'user_id' => 1), - array( + 'user_id' => 1], + [ 'id' => 2, 'comment' => 'comment', 'published' => 'Y', 'user_id' => 1 - ))); + ]]]; $result = $TestModel->validateAssociated($data); $this->assertFalse($result); - $data = array( - 'Article' => array('id' => 2), - 'Comment' => array( - array( + $data = [ + 'Article' => ['id' => 2], + 'Comment' => [ + [ 'id' => 1, 'comment' => '', 'published' => 'Y', 'user_id' => 1 - ), - array( + ], + [ 'id' => 2, 'comment' => 'comment', 'published' => 'Y', 'user_id' => 1 - ), - array( + ], + [ 'id' => 3, 'comment' => '', 'published' => 'Y', 'user_id' => 1 - ))); - $result = $TestModel->validateAssociated($data, array( + ]]]; + $result = $TestModel->validateAssociated($data, [ 'atomic' => false - )); - $expected = array( + ]); + $expected = [ 'Article' => true, - 'Comment' => array(false, true, false) - ); + 'Comment' => [false, true, false] + ]; $this->assertSame($expected, $result); - $expected = array('Comment' => array( - 0 => array('comment' => array('This field cannot be left blank')), - 2 => array('comment' => array('This field cannot be left blank')) - )); + $expected = ['Comment' => [ + 0 => ['comment' => ['This field cannot be left blank']], + 2 => ['comment' => ['This field cannot be left blank']] + ]]; $this->assertEquals($expected, $TestModel->validationErrors); - $expected = array( - 0 => array('comment' => array('This field cannot be left blank')), - 2 => array('comment' => array('This field cannot be left blank')) - ); + $expected = [ + 0 => ['comment' => ['This field cannot be left blank']], + 2 => ['comment' => ['This field cannot be left blank']] + ]; $this->assertEquals($expected, $TestModel->Comment->validationErrors); } @@ -6884,11 +6884,11 @@ public function testSaveManyEmptyData() { $this->loadFixtures('Article', 'ProductUpdateAll', 'Comment', 'Attachment'); $model = new Article(); - $result = $model->saveMany(array(), array('validate' => true)); + $result = $model->saveMany([], ['validate' => true]); $this->assertFalse(empty($result)); $model = new ProductUpdateAll(); - $result = $model->saveMany(array()); + $result = $model->saveMany([]); $this->assertFalse($result); } @@ -6902,11 +6902,11 @@ public function testSaveAssociatedEmptyData() { $this->loadFixtures('Article', 'ProductUpdateAll', 'Comment', 'Attachment'); $model = new Article(); - $result = $model->saveAssociated(array(), array('validate' => true)); + $result = $model->saveAssociated([], ['validate' => true]); $this->assertFalse(empty($result)); $model = new ProductUpdateAll(); - $result = $model->saveAssociated(array()); + $result = $model->saveAssociated([]); $this->assertFalse($result); } @@ -6920,19 +6920,19 @@ public function testSaveAssociatedExpressionObjects() { $TestModel = new Post(); $db = $TestModel->getDataSource(); - $TestModel->saveAssociated(array( - 'Post' => array( + $TestModel->saveAssociated([ + 'Post' => [ 'title' => $db->expression("(SELECT 'Post with Author')"), 'body' => 'This post will be saved with an author' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'bob', 'password' => '5f4dcc3b5aa765d61d8327deb882cf90' - )), array('atomic' => false)); + ]], ['atomic' => false]); - $result = $TestModel->find('first', array( - 'order' => array('Post.id ' => 'DESC') - )); + $result = $TestModel->find('first', [ + 'order' => ['Post.id ' => 'DESC'] + ]); $this->assertEquals('Post with Author', $result['Post']['title']); } @@ -6945,24 +6945,24 @@ public function testUpdateWithCalculation() { $this->loadFixtures('DataTest'); $model = new DataTest(); $model->deleteAll(true); - $result = $model->saveMany(array( - array('count' => 5, 'float' => 1.1), - array('count' => 3, 'float' => 1.2), - array('count' => 4, 'float' => 1.3), - array('count' => 1, 'float' => 2.0), - )); + $result = $model->saveMany([ + ['count' => 5, 'float' => 1.1], + ['count' => 3, 'float' => 1.2], + ['count' => 4, 'float' => 1.3], + ['count' => 1, 'float' => 2.0], + ]); $this->assertFalse(empty($result)); - $result = Hash::extract($model->find('all', array('fields' => 'count')), '{n}.DataTest.count'); - $this->assertEquals(array(5, 3, 4, 1), $result); + $result = Hash::extract($model->find('all', ['fields' => 'count']), '{n}.DataTest.count'); + $this->assertEquals([5, 3, 4, 1], $result); - $this->assertTrue($model->updateAll(array('count' => 'count + 2'))); - $result = Hash::extract($model->find('all', array('fields' => 'count')), '{n}.DataTest.count'); - $this->assertEquals(array(7, 5, 6, 3), $result); + $this->assertTrue($model->updateAll(['count' => 'count + 2'])); + $result = Hash::extract($model->find('all', ['fields' => 'count']), '{n}.DataTest.count'); + $this->assertEquals([7, 5, 6, 3], $result); - $this->assertTrue($model->updateAll(array('DataTest.count' => 'DataTest.count - 1'))); - $result = Hash::extract($model->find('all', array('fields' => 'count')), '{n}.DataTest.count'); - $this->assertEquals(array(6, 4, 5, 2), $result); + $this->assertTrue($model->updateAll(['DataTest.count' => 'DataTest.count - 1'])); + $result = Hash::extract($model->find('all', ['fields' => 'count']), '{n}.DataTest.count'); + $this->assertEquals([6, 4, 5, 2], $result); } /** @@ -6973,36 +6973,36 @@ public function testUpdateWithCalculation() { public function testToggleBoolFields() { $this->loadFixtures('CounterCacheUser', 'CounterCachePost'); $Post = new CounterCachePost(); - $Post->unbindModel(array('belongsTo' => array('User')), true); + $Post->unbindModel(['belongsTo' => ['User']], true); - $true = array('Post' => array('published' => true, 'id' => 2)); - $false = array('Post' => array('published' => false, 'id' => 2)); - $fields = array('Post.published', 'Post.id'); - $updateConditions = array('Post.id' => 2); + $true = ['Post' => ['published' => true, 'id' => 2]]; + $false = ['Post' => ['published' => false, 'id' => 2]]; + $fields = ['Post.published', 'Post.id']; + $updateConditions = ['Post.id' => 2]; // check its true - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); + $result = $Post->find('first', ['conditions' => $updateConditions, 'fields' => $fields]); $this->assertEquals($true, $result); // Testing without the alias - $this->assertTrue($Post->updateAll(array('published' => 'NOT published'), $updateConditions)); - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); + $this->assertTrue($Post->updateAll(['published' => 'NOT published'], $updateConditions)); + $result = $Post->find('first', ['conditions' => $updateConditions, 'fields' => $fields]); $this->assertEquals($false, $result); - $this->assertTrue($Post->updateAll(array('published' => 'NOT published'), $updateConditions)); - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); + $this->assertTrue($Post->updateAll(['published' => 'NOT published'], $updateConditions)); + $result = $Post->find('first', ['conditions' => $updateConditions, 'fields' => $fields]); $this->assertEquals($true, $result); $db = ConnectionManager::getDataSource('test'); $alias = $db->name('Post.published'); // Testing with the alias - $this->assertTrue($Post->updateAll(array('Post.published' => "NOT $alias"), $updateConditions)); - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); + $this->assertTrue($Post->updateAll(['Post.published' => "NOT $alias"], $updateConditions)); + $result = $Post->find('first', ['conditions' => $updateConditions, 'fields' => $fields]); $this->assertEquals($false, $result); - $this->assertTrue($Post->updateAll(array('Post.published' => "NOT $alias"), $updateConditions)); - $result = $Post->find('first', array('conditions' => $updateConditions, 'fields' => $fields)); + $this->assertTrue($Post->updateAll(['Post.published' => "NOT $alias"], $updateConditions)); + $result = $Post->find('first', ['conditions' => $updateConditions, 'fields' => $fields]); $this->assertEquals($true, $result); } @@ -7015,56 +7015,56 @@ public function testFindAllForeignKey() { $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll'); $ProductUpdateAll = new ProductUpdateAll(); - $conditions = array('Group.name' => 'group one'); + $conditions = ['Group.name' => 'group one']; - $ProductUpdateAll->bindModel(array( - 'belongsTo' => array( - 'Group' => array('className' => 'GroupUpdateAll') - ) - )); + $ProductUpdateAll->bindModel([ + 'belongsTo' => [ + 'Group' => ['className' => 'GroupUpdateAll'] + ] + ]); - $ProductUpdateAll->belongsTo = array( - 'Group' => array('className' => 'GroupUpdateAll', 'foreignKey' => 'group_id') - ); + $ProductUpdateAll->belongsTo = [ + 'Group' => ['className' => 'GroupUpdateAll', 'foreignKey' => 'group_id'] + ]; $results = $ProductUpdateAll->find('all', compact('conditions')); $this->assertTrue(!empty($results)); - $ProductUpdateAll->bindModel(array('belongsTo' => array('Group'))); - $ProductUpdateAll->belongsTo = array( - 'Group' => array( + $ProductUpdateAll->bindModel(['belongsTo' => ['Group']]); + $ProductUpdateAll->belongsTo = [ + 'Group' => [ 'className' => 'GroupUpdateAll', 'foreignKey' => false, 'conditions' => 'ProductUpdateAll.groupcode = Group.code' - )); + ]]; $resultsFkFalse = $ProductUpdateAll->find('all', compact('conditions')); $this->assertTrue(!empty($resultsFkFalse)); - $expected = array( - '0' => array( - 'ProductUpdateAll' => array( + $expected = [ + '0' => [ + 'ProductUpdateAll' => [ 'id' => 1, 'name' => 'product one', 'groupcode' => 120, - 'group_id' => 1), - 'Group' => array( + 'group_id' => 1], + 'Group' => [ 'id' => 1, 'name' => 'group one', - 'code' => 120) - ), - '1' => array( - 'ProductUpdateAll' => array( + 'code' => 120] + ], + '1' => [ + 'ProductUpdateAll' => [ 'id' => 2, 'name' => 'product two', 'groupcode' => 120, - 'group_id' => 1), - 'Group' => array( + 'group_id' => 1], + 'Group' => [ 'id' => 1, 'name' => 'group one', - 'code' => 120) - ) + 'code' => 120] + ] - ); + ]; $this->assertEquals($expected, $results); $this->assertEquals($expected, $resultsFkFalse); } @@ -7079,7 +7079,7 @@ public function testUpdateAllEmptyValues() { $this->loadFixtures('Author', 'Post'); $model = new Author(); - $result = $model->updateAll(array('user' => '""')); + $result = $model->updateAll(['user' => '""']); $this->assertTrue($result); } @@ -7094,38 +7094,38 @@ public function testUpdateAllWithJoins() { $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll'); $ProductUpdateAll = new ProductUpdateAll(); - $conditions = array('Group.name' => 'group one'); + $conditions = ['Group.name' => 'group one']; - $ProductUpdateAll->bindModel(array('belongsTo' => array( - 'Group' => array('className' => 'GroupUpdateAll'))) + $ProductUpdateAll->bindModel(['belongsTo' => [ + 'Group' => ['className' => 'GroupUpdateAll']]] ); - $ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions); - $results = $ProductUpdateAll->find('all', array( - 'conditions' => array('ProductUpdateAll.name' => 'new product') - )); - $expected = array( - '0' => array( - 'ProductUpdateAll' => array( + $ProductUpdateAll->updateAll(['name' => "'new product'"], $conditions); + $results = $ProductUpdateAll->find('all', [ + 'conditions' => ['ProductUpdateAll.name' => 'new product'] + ]); + $expected = [ + '0' => [ + 'ProductUpdateAll' => [ 'id' => 1, 'name' => 'new product', 'groupcode' => 120, - 'group_id' => 1), - 'Group' => array( + 'group_id' => 1], + 'Group' => [ 'id' => 1, 'name' => 'group one', - 'code' => 120) - ), - '1' => array( - 'ProductUpdateAll' => array( + 'code' => 120] + ], + '1' => [ + 'ProductUpdateAll' => [ 'id' => 2, 'name' => 'new product', 'groupcode' => 120, - 'group_id' => 1), - 'Group' => array( + 'group_id' => 1], + 'Group' => [ 'id' => 1, 'name' => 'group one', - 'code' => 120))); + 'code' => 120]]]; $this->assertEquals($expected, $results); } @@ -7141,44 +7141,44 @@ public function testUpdateAllWithoutForeignKey() { $this->loadFixtures('ProductUpdateAll', 'GroupUpdateAll'); $ProductUpdateAll = new ProductUpdateAll(); - $conditions = array('Group.name' => 'group one'); + $conditions = ['Group.name' => 'group one']; - $ProductUpdateAll->bindModel(array('belongsTo' => array( - 'Group' => array('className' => 'GroupUpdateAll') - ))); + $ProductUpdateAll->bindModel(['belongsTo' => [ + 'Group' => ['className' => 'GroupUpdateAll'] + ]]); - $ProductUpdateAll->belongsTo = array( - 'Group' => array( + $ProductUpdateAll->belongsTo = [ + 'Group' => [ 'className' => 'GroupUpdateAll', 'foreignKey' => false, 'conditions' => 'ProductUpdateAll.groupcode = Group.code' - ) - ); - - $ProductUpdateAll->updateAll(array('name' => "'new product'"), $conditions); - $resultsFkFalse = $ProductUpdateAll->find('all', array('conditions' => array('ProductUpdateAll.name' => 'new product'))); - $expected = array( - '0' => array( - 'ProductUpdateAll' => array( + ] + ]; + + $ProductUpdateAll->updateAll(['name' => "'new product'"], $conditions); + $resultsFkFalse = $ProductUpdateAll->find('all', ['conditions' => ['ProductUpdateAll.name' => 'new product']]); + $expected = [ + '0' => [ + 'ProductUpdateAll' => [ 'id' => 1, 'name' => 'new product', 'groupcode' => 120, - 'group_id' => 1), - 'Group' => array( + 'group_id' => 1], + 'Group' => [ 'id' => 1, 'name' => 'group one', - 'code' => 120) - ), - '1' => array( - 'ProductUpdateAll' => array( + 'code' => 120] + ], + '1' => [ + 'ProductUpdateAll' => [ 'id' => 2, 'name' => 'new product', 'groupcode' => 120, - 'group_id' => 1), - 'Group' => array( + 'group_id' => 1], + 'Group' => [ 'id' => 1, 'name' => 'group one', - 'code' => 120))); + 'code' => 120]]]; $this->assertEquals($expected, $resultsFkFalse); } @@ -7193,10 +7193,10 @@ public function testWriteFloatAsGerman() { $this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available."); $model = new DataTest(); - $result = $model->save(array( + $result = $model->save([ 'count' => 1, 'float' => 3.14593 - )); + ]); $this->assertTrue((bool)$result); setlocale(LC_NUMERIC, $restore); } @@ -7210,12 +7210,12 @@ public function testPkInReturnArrayForCreate() { $this->loadFixtures('Article'); $TestModel = new Article(); - $data = array('Article' => array( + $data = ['Article' => [ 'user_id' => '1', 'title' => 'Fourth Article', 'body' => 'Fourth Article Body', 'published' => 'Y' - )); + ]]; $result = $TestModel->save($data); $this->assertSame($result['Article']['id'], $TestModel->id); } @@ -7234,27 +7234,27 @@ public function testSaveAllFieldListValidateBelongsTo() { $this->assertFalse(isset($result[3])); // test belongsTo - $fieldList = array( - 'Post' => array('title'), - 'Author' => array('user') - ); - $data = array( - 'Post' => array( + $fieldList = [ + 'Post' => ['title'], + 'Author' => ['user'] + ]; + $data = [ + 'Post' => [ 'title' => 'Post without body', 'body' => 'This will not be saved', - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'bob', 'test' => 'This will not be saved', - )); - $TestModel->saveAll($data, array('fieldList' => $fieldList)); + ]]; + $TestModel->saveAll($data, ['fieldList' => $fieldList]); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'order' => 'Post.id ASC', - )); - $expected = array( - 'Post' => array( + ]); + $expected = [ + 'Post' => [ 'id' => '4', 'author_id' => '5', 'title' => 'Post without body', @@ -7262,62 +7262,62 @@ public function testSaveAllFieldListValidateBelongsTo() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date(), - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '5', 'user' => 'bob', 'password' => null, 'created' => static::date(), 'updated' => static::date(), 'test' => 'working', - ), - ); + ], + ]; $this->assertEquals($expected, $result[3]); $this->assertEquals(4, count($result)); $this->assertEquals('', $result[3]['Post']['body']); $this->assertEquals('working', $result[3]['Author']['test']); - $fieldList = array( - 'Post' => array('title') - ); - $data = array( - 'Post' => array( + $fieldList = [ + 'Post' => ['title'] + ]; + $data = [ + 'Post' => [ 'title' => 'Post without body 2', 'body' => 'This will not be saved' - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'jack' - ) - ); - $TestModel->saveAll($data, array('fieldList' => $fieldList)); - $result = $TestModel->find('all', array( + ] + ]; + $TestModel->saveAll($data, ['fieldList' => $fieldList]); + $result = $TestModel->find('all', [ 'order' => 'Post.id ASC', - )); + ]); $this->assertNull($result[4]['Post']['body']); - $fieldList = array( - 'Author' => array('password') - ); - $data = array( - 'Post' => array( + $fieldList = [ + 'Author' => ['password'] + ]; + $data = [ + 'Post' => [ 'id' => '5', 'title' => 'Post title', 'body' => 'Post body' - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '6', 'user' => 'will not change', 'password' => 'foobar' - ) - ); - $result = $TestModel->saveAll($data, array('fieldList' => $fieldList)); + ] + ]; + $result = $TestModel->saveAll($data, ['fieldList' => $fieldList]); $this->assertTrue($result); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'order' => 'Post.id ASC', - )); - $expected = array( - 'Post' => array( + ]); + $expected = [ + 'Post' => [ 'id' => '5', 'author_id' => '6', 'title' => 'Post title', @@ -7325,41 +7325,41 @@ public function testSaveAllFieldListValidateBelongsTo() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date() - ), - 'Author' => array( + ], + 'Author' => [ 'id' => '6', 'user' => 'jack', 'password' => 'foobar', 'created' => static::date(), 'updated' => static::date(), 'test' => 'working' - ), - ); + ], + ]; $this->assertEquals($expected, $result[4]); // test multirecord $this->db->truncate($TestModel); - $fieldList = array('title', 'author_id'); - $TestModel->saveAll(array( - array( + $fieldList = ['title', 'author_id']; + $TestModel->saveAll([ + [ 'title' => 'Multi-record post 1', 'body' => 'First multi-record post', 'author_id' => 2 - ), - array( + ], + [ 'title' => 'Multi-record post 2', 'body' => 'Second multi-record post', 'author_id' => 2 - )), array('fieldList' => $fieldList)); + ]], ['fieldList' => $fieldList]); - $result = $TestModel->find('all', array( + $result = $TestModel->find('all', [ 'recursive' => -1, 'order' => 'Post.id ASC' - )); - $expected = array( - array( - 'Post' => array( + ]); + $expected = [ + [ + 'Post' => [ 'id' => '1', 'author_id' => '2', 'title' => 'Multi-record post 1', @@ -7367,10 +7367,10 @@ public function testSaveAllFieldListValidateBelongsTo() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date() - ) - ), - array( - 'Post' => array( + ] + ], + [ + 'Post' => [ 'id' => '2', 'author_id' => '2', 'title' => 'Multi-record post 2', @@ -7378,9 +7378,9 @@ public function testSaveAllFieldListValidateBelongsTo() { 'published' => 'N', 'created' => static::date(), 'updated' => static::date() - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); } @@ -7392,42 +7392,42 @@ public function testSaveAllFieldListValidateBelongsTo() { public function testSaveAllFieldListHasMany() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; $this->db->truncate($TestModel); $this->db->truncate(new Comment()); - $data = array( - 'Article' => array('title' => 'I will not save'), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1), - array('comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2) - ) - ); + $data = [ + 'Article' => ['title' => 'I will not save'], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1], + ['comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2] + ] + ]; - $fieldList = array( - 'Article' => array('id'), - 'Comment' => array('article_id', 'user_id') - ); - $TestModel->saveAll($data, array('fieldList' => $fieldList)); + $fieldList = [ + 'Article' => ['id'], + 'Comment' => ['article_id', 'user_id'] + ]; + $TestModel->saveAll($data, ['fieldList' => $fieldList]); $result = $TestModel->find('all'); $this->assertEquals('', $result[0]['Article']['title']); $this->assertEquals('', $result[0]['Comment'][0]['comment']); $this->assertEquals('', $result[0]['Comment'][1]['comment']); - $fieldList = array( - 'Article' => array('id'), - 'Comment' => array('user_id') - ); - $TestModel->saveAll($data, array('fieldList' => $fieldList)); + $fieldList = [ + 'Article' => ['id'], + 'Comment' => ['user_id'] + ]; + $TestModel->saveAll($data, ['fieldList' => $fieldList]); $result = $TestModel->find('all'); $this->assertEquals('', $result[1]['Article']['title']); $this->assertEquals(2, count($result[1]['Comment'])); - $TestModel->whitelist = array('id'); - $TestModel->Comment->whitelist = array('user_id'); + $TestModel->whitelist = ['id']; + $TestModel->Comment->whitelist = ['user_id']; $TestModel->saveAll($data); $result = $TestModel->find('all'); @@ -7444,29 +7444,29 @@ public function testSaveAllFieldListHasOne() { $this->loadFixtures('Attachment', 'Comment', 'Article', 'User'); $TestModel = new Comment(); - $TestModel->validate = array('comment' => 'notBlank'); - $TestModel->Attachment->validate = array('attachment' => 'notBlank'); + $TestModel->validate = ['comment' => 'notBlank']; + $TestModel->Attachment->validate = ['attachment' => 'notBlank']; - $record = array( - 'Comment' => array( + $record = [ + 'Comment' => [ 'user_id' => 1, 'article_id' => 1, 'comment' => '', - ), - 'Attachment' => array( + ], + 'Attachment' => [ 'attachment' => '' - ) - ); - $result = $TestModel->saveAll($record, array('validate' => 'only')); + ] + ]; + $result = $TestModel->saveAll($record, ['validate' => 'only']); $this->assertFalse($result); - $fieldList = array( - 'Comment' => array('id', 'article_id', 'user_id'), - 'Attachment' => array('comment_id') - ); - $result = $TestModel->saveAll($record, array( + $fieldList = [ + 'Comment' => ['id', 'article_id', 'user_id'], + 'Attachment' => ['comment_id'] + ]; + $result = $TestModel->saveAll($record, [ 'fieldList' => $fieldList, 'validate' => 'only' - )); + ]); $this->assertTrue($result); $this->assertEmpty($TestModel->validationErrors); } @@ -7479,48 +7479,48 @@ public function testSaveAllFieldListHasOne() { public function testSaveAllFieldListHasOneAddFkToWhitelist() { $this->loadFixtures('ArticleFeatured', 'Featured'); $Article = new ArticleFeatured(); - $Article->belongsTo = $Article->hasMany = array(); - $Article->Featured->validate = array('end_date' => 'notBlank'); + $Article->belongsTo = $Article->hasMany = []; + $Article->Featured->validate = ['end_date' => 'notBlank']; - $record = array( - 'ArticleFeatured' => array( + $record = [ + 'ArticleFeatured' => [ 'user_id' => 1, 'title' => 'First Article', 'body' => '', 'published' => 'Y' - ), - 'Featured' => array( + ], + 'Featured' => [ 'category_id' => 1, 'end_date' => '' - ) - ); - $result = $Article->saveAll($record, array('validate' => 'only')); + ] + ]; + $result = $Article->saveAll($record, ['validate' => 'only']); $this->assertFalse($result); - $expected = array( - 'body' => array( + $expected = [ + 'body' => [ 'This field cannot be left blank' - ), - 'Featured' => array( - 'end_date' => array( + ], + 'Featured' => [ + 'end_date' => [ 'This field cannot be left blank' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $Article->validationErrors); - $fieldList = array( - 'ArticleFeatured' => array('user_id', 'title'), - 'Featured' => array('category_id') - ); + $fieldList = [ + 'ArticleFeatured' => ['user_id', 'title'], + 'Featured' => ['category_id'] + ]; - $result = $Article->saveAll($record, array( + $result = $Article->saveAll($record, [ 'fieldList' => $fieldList, 'validate' => 'first' - )); + ]); $this->assertTrue($result); $this->assertEmpty($Article->validationErrors); $Article->recursive = 0; - $result = $Article->find('first', array('order' => array('ArticleFeatured.created' => 'DESC'))); + $result = $Article->find('first', ['order' => ['ArticleFeatured.created' => 'DESC']]); $this->assertSame($result['ArticleFeatured']['id'], $result['Featured']['article_featured_id']); } @@ -7532,7 +7532,7 @@ public function testSaveAllFieldListHasOneAddFkToWhitelist() { public function testSaveAllDeepFieldListValidateBelongsTo() { $this->loadFixtures('Post', 'Author', 'Comment', 'Attachment', 'Article', 'User'); $TestModel = new Post(); - $TestModel->Author->bindModel(array('hasMany' => array('Comment' => array('foreignKey' => 'user_id'))), false); + $TestModel->Author->bindModel(['hasMany' => ['Comment' => ['foreignKey' => 'user_id']]], false); $TestModel->recursive = 2; $result = $TestModel->find('all'); @@ -7540,34 +7540,34 @@ public function testSaveAllDeepFieldListValidateBelongsTo() { $this->assertFalse(isset($result[3])); // test belongsTo - $fieldList = array( - 'Post' => array('title', 'author_id'), - 'Author' => array('user'), - 'Comment' => array('comment') - ); - $TestModel->saveAll(array( - 'Post' => array( + $fieldList = [ + 'Post' => ['title', 'author_id'], + 'Author' => ['user'], + 'Comment' => ['comment'] + ]; + $TestModel->saveAll([ + 'Post' => [ 'title' => 'Post without body', 'body' => 'This will not be saved', - ), - 'Author' => array( + ], + 'Author' => [ 'user' => 'bob', 'test' => 'This will not be saved', - 'Comment' => array( - array('id' => 5, 'comment' => 'I am still published', 'published' => 'N')) + 'Comment' => [ + ['id' => 5, 'comment' => 'I am still published', 'published' => 'N']] - )), array('fieldList' => $fieldList, 'deep' => true)); + ]], ['fieldList' => $fieldList, 'deep' => true]); - $result = $TestModel->Author->Comment->find('first', array( - 'conditions' => array('Comment.id' => 5), - 'fields' => array('comment', 'published') - )); - $expected = array( - 'Comment' => array( + $result = $TestModel->Author->Comment->find('first', [ + 'conditions' => ['Comment.id' => 5], + 'fields' => ['comment', 'published'] + ]); + $expected = [ + 'Comment' => [ 'comment' => 'I am still published', 'published' => 'Y' - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -7579,38 +7579,38 @@ public function testSaveAllDeepFieldListValidateBelongsTo() { public function testSaveAllDeepFieldListHasMany() { $this->loadFixtures('Article', 'Comment', 'User'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; $this->db->truncate($TestModel); $this->db->truncate(new Comment()); - $fieldList = array( - 'Article' => array('id'), - 'Comment' => array('article_id', 'user_id'), - 'User' => array('user') - ); - - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2, 'title' => 'I will not save'), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1), - array( + $fieldList = [ + 'Article' => ['id'], + 'Comment' => ['article_id', 'user_id'], + 'User' => ['user'] + ]; + + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2, 'title' => 'I will not save'], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1], + [ 'comment' => 'Second new comment', 'published' => 'Y', 'user_id' => 2, - 'User' => array('user' => 'nopassword', 'password' => 'not saved') - ) - ) - ), array('fieldList' => $fieldList, 'deep' => true)); - - $result = $TestModel->Comment->User->find('first', array( - 'conditions' => array('User.user' => 'nopassword'), - 'fields' => array('user', 'password') - )); - $expected = array( - 'User' => array( + 'User' => ['user' => 'nopassword', 'password' => 'not saved'] + ] + ] + ], ['fieldList' => $fieldList, 'deep' => true]); + + $result = $TestModel->Comment->User->find('first', [ + 'conditions' => ['User.user' => 'nopassword'], + 'fields' => ['user', 'password'] + ]); + $expected = [ + 'User' => [ 'user' => 'nopassword', 'password' => '' - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -7622,47 +7622,47 @@ public function testSaveAllDeepFieldListHasMany() { public function testSaveAllDeepHasManyBelongsTo() { $this->loadFixtures('Article', 'Comment', 'User'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array(); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = []; $this->db->truncate($TestModel); $this->db->truncate(new Comment()); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2, 'title' => 'The title'), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1), - array( + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2, 'title' => 'The title'], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1], + [ 'comment' => 'belongsto', 'published' => 'Y', - 'User' => array('user' => 'findme', 'password' => 'somepass') - ) - ) - ), array('deep' => true)); - - $result = $TestModel->Comment->User->find('first', array( - 'conditions' => array('User.user' => 'findme'), - 'fields' => array('id', 'user', 'password') - )); - $expected = array( - 'User' => array( + 'User' => ['user' => 'findme', 'password' => 'somepass'] + ] + ] + ], ['deep' => true]); + + $result = $TestModel->Comment->User->find('first', [ + 'conditions' => ['User.user' => 'findme'], + 'fields' => ['id', 'user', 'password'] + ]); + $expected = [ + 'User' => [ 'id' => 5, 'user' => 'findme', 'password' => 'somepass', - ) - ); + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->Comment->find('first', array( - 'conditions' => array('Comment.user_id' => 5), - 'fields' => array('id', 'comment', 'published', 'user_id') - )); - $expected = array( - 'Comment' => array( + $result = $TestModel->Comment->find('first', [ + 'conditions' => ['Comment.user_id' => 5], + 'fields' => ['id', 'comment', 'published', 'user_id'] + ]); + $expected = [ + 'Comment' => [ 'id' => 2, 'comment' => 'belongsto', 'published' => 'Y', 'user_id' => 5 - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -7674,51 +7674,51 @@ public function testSaveAllDeepHasManyBelongsTo() { public function testSaveAllDeepHasManyHasMany() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = array(); - $TestModel->Comment->unbindModel(array('hasOne' => array('Attachment')), false); - $TestModel->Comment->bindModel(array('hasMany' => array('Attachment')), false); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = []; + $TestModel->Comment->unbindModel(['hasOne' => ['Attachment']], false); + $TestModel->Comment->bindModel(['hasMany' => ['Attachment']], false); $this->db->truncate($TestModel); $this->db->truncate(new Comment()); $this->db->truncate(new Attachment()); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2, 'title' => 'The title'), - 'Comment' => array( - array('comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1), - array( + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2, 'title' => 'The title'], + 'Comment' => [ + ['comment' => 'First new comment', 'published' => 'Y', 'user_id' => 1], + [ 'comment' => 'hasmany', 'published' => 'Y', 'user_id' => 5, - 'Attachment' => array( - array('attachment' => 'first deep attachment'), - array('attachment' => 'second deep attachment'), - ) - ) - ) - ), array('deep' => true)); - - $result = $TestModel->Comment->find('first', array( - 'conditions' => array('Comment.comment' => 'hasmany'), - 'fields' => array('id', 'comment', 'published', 'user_id'), + 'Attachment' => [ + ['attachment' => 'first deep attachment'], + ['attachment' => 'second deep attachment'], + ] + ] + ] + ], ['deep' => true]); + + $result = $TestModel->Comment->find('first', [ + 'conditions' => ['Comment.comment' => 'hasmany'], + 'fields' => ['id', 'comment', 'published', 'user_id'], 'recursive' => -1 - )); - $expected = array( - 'Comment' => array( + ]); + $expected = [ + 'Comment' => [ 'id' => 2, 'comment' => 'hasmany', 'published' => 'Y', 'user_id' => 5 - ) - ); + ] + ]; $this->assertEquals($expected, $result); - $result = $TestModel->Comment->Attachment->find('all', array( - 'fields' => array('attachment', 'comment_id'), - 'order' => array('Attachment.id' => 'ASC') - )); - $expected = array( - array('Attachment' => array('attachment' => 'first deep attachment', 'comment_id' => 2)), - array('Attachment' => array('attachment' => 'second deep attachment', 'comment_id' => 2)), - ); + $result = $TestModel->Comment->Attachment->find('all', [ + 'fields' => ['attachment', 'comment_id'], + 'order' => ['Attachment.id' => 'ASC'] + ]); + $expected = [ + ['Attachment' => ['attachment' => 'first deep attachment', 'comment_id' => 2]], + ['Attachment' => ['attachment' => 'second deep attachment', 'comment_id' => 2]], + ]; $this->assertEquals($expected, $result); } @@ -7730,30 +7730,30 @@ public function testSaveAllDeepHasManyHasMany() { public function testSaveAllDeepOrderHasManyHasMany() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = array(); - $TestModel->Comment->unbindModel(array('hasOne' => array('Attachment')), false); - $TestModel->Comment->bindModel(array('hasMany' => array('Attachment')), false); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = []; + $TestModel->Comment->unbindModel(['hasOne' => ['Attachment']], false); + $TestModel->Comment->bindModel(['hasMany' => ['Attachment']], false); $this->db->truncate($TestModel); $this->db->truncate(new Comment()); $this->db->truncate(new Attachment()); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 2, 'title' => 'Comment has its data after Attachment'), - 'Comment' => array( - array( - 'Attachment' => array( - array('attachment' => 'attachment should be created with comment_id'), - array('attachment' => 'comment should be created with article_id'), - ), + $result = $TestModel->saveAll([ + 'Article' => ['id' => 2, 'title' => 'Comment has its data after Attachment'], + 'Comment' => [ + [ + 'Attachment' => [ + ['attachment' => 'attachment should be created with comment_id'], + ['attachment' => 'comment should be created with article_id'], + ], 'comment' => 'after associated data', 'user_id' => 1 - ) - ) - ), array('deep' => true)); - $result = $TestModel->Comment->find('first', array( - 'conditions' => array('Comment.article_id' => 2), - )); + ] + ] + ], ['deep' => true]); + $result = $TestModel->Comment->find('first', [ + 'conditions' => ['Comment.article_id' => 2], + ]); $this->assertEquals(2, $result['Comment']['article_id']); $this->assertEquals(2, count($result['Attachment'])); @@ -7769,29 +7769,29 @@ public function testSaveAllDeepEmptyHasManyHasMany() { $this->loadFixtures('Article', 'Comment', 'User', 'Attachment'); $TestModel = new Article(); - $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = array(); - $TestModel->Comment->unbindModel(array('hasOne' => array('Attachment')), false); - $TestModel->Comment->bindModel(array('hasMany' => array('Attachment')), false); + $TestModel->belongsTo = $TestModel->hasAndBelongsToMany = $TestModel->Comment->belongsTo = []; + $TestModel->Comment->unbindModel(['hasOne' => ['Attachment']], false); + $TestModel->Comment->bindModel(['hasMany' => ['Attachment']], false); $this->db->truncate($TestModel); $this->db->truncate(new Comment()); $this->db->truncate(new Attachment()); - $result = $TestModel->saveAll(array( - 'Article' => array('id' => 3, 'user_id' => 1, 'title' => 'Comment has no data'), - 'Comment' => array( - array( + $result = $TestModel->saveAll([ + 'Article' => ['id' => 3, 'user_id' => 1, 'title' => 'Comment has no data'], + 'Comment' => [ + [ 'user_id' => 1, - 'Attachment' => array( - array('attachment' => 'attachment should be created with comment_id'), - array('attachment' => 'comment should be created with article_id'), - ), - ) - ) - ), array('deep' => true)); - $result = $TestModel->Comment->find('first', array( - 'conditions' => array('Comment.article_id' => 3), - )); + 'Attachment' => [ + ['attachment' => 'attachment should be created with comment_id'], + ['attachment' => 'comment should be created with article_id'], + ], + ] + ] + ], ['deep' => true]); + $result = $TestModel->Comment->find('first', [ + 'conditions' => ['Comment.article_id' => 3], + ]); $this->assertEquals(3, $result['Comment']['article_id']); $this->assertEquals(2, count($result['Attachment'])); @@ -7804,24 +7804,24 @@ public function testSaveAllDeepEmptyHasManyHasMany() { */ public function testSaveManyBooleanFields() { $this->loadFixtures('Item', 'Syfile', 'Image'); - $data = array( - array( - 'Item' => array( + $data = [ + [ + 'Item' => [ 'name' => 'testing', 'syfile_id' => 1, 'published' => false - ) - ), - array( - 'Item' => array( + ] + ], + [ + 'Item' => [ 'name' => 'testing 2', 'syfile_id' => 1, 'published' => true - ) - ), - ); + ] + ], + ]; $item = ClassRegistry::init('Item'); - $result = $item->saveMany($data, array('atomic' => false)); + $result = $item->saveMany($data, ['atomic' => false]); $this->assertCount(2, $result, '2 records should have been saved.'); $this->assertTrue($result[0], 'Both should have succeded'); @@ -7836,35 +7836,35 @@ public function testSaveManyBooleanFields() { public function testSaveManyDeepHasManyValidationFailure() { $this->loadFixtures('Article', 'Comment'); $TestModel = new Article(); - $TestModel->Comment->validate = array( - 'comment' => array( - 'notBlank' => array( - 'rule' => array('notBlank'), - ) - ) - ); - - $result = $TestModel->saveMany(array( - array( + $TestModel->Comment->validate = [ + 'comment' => [ + 'notBlank' => [ + 'rule' => ['notBlank'], + ] + ] + ]; + + $result = $TestModel->saveMany([ + [ 'user_id' => 1, 'title' => 'New Article', 'body' => 'This article contains a invalid comment', - 'Comment' => array( - array( + 'Comment' => [ + [ 'user_id' => 1, 'comment' => '' - ) - ) - ) - ), array('deep' => true)); + ] + ] + ] + ], ['deep' => true]); $this->assertFalse($result); - $this->assertEquals(array( - array( - 'Comment' => array( - array('comment' => array('notBlank')) - ) - ) - ), $TestModel->validationErrors); + $this->assertEquals([ + [ + 'Comment' => [ + ['comment' => ['notBlank']] + ] + ] + ], $TestModel->validationErrors); } /** @@ -7875,38 +7875,38 @@ public function testSaveManyDeepHasManyValidationFailure() { public function testSaveAssociatedDeepHasOneHasManyValidateTrueValidationFailure() { $this->loadFixtures('User', 'Article', 'Comment'); $TestModel = new UserHasOneArticle(); - $TestModel->Article->Comment->validate = array( - 'comment' => array( - 'notBlank' => array( - 'rule' => array('notBlank'), - ) - ) - ); - - $result = $TestModel->saveAssociated(array( - 'User' => array( + $TestModel->Article->Comment->validate = [ + 'comment' => [ + 'notBlank' => [ + 'rule' => ['notBlank'], + ] + ] + ]; + + $result = $TestModel->saveAssociated([ + 'User' => [ 'user' => 'hiromi', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', - ), - 'Article' => array( + ], + 'Article' => [ 'title' => 'Article with User', 'body' => 'This article will be saved with an user and contains a invalid comment', - 'Comment' => array( - array( + 'Comment' => [ + [ 'user_id' => 1, 'comment' => '' - ) - ) - ) - ), array('deep' => true, 'validate' => true)); + ] + ] + ] + ], ['deep' => true, 'validate' => true]); $this->assertFalse($result); - $this->assertEquals(array( - 'Article' => array( - 'Comment' => array( - array('comment' => array('notBlank')) - ) - ) - ), $TestModel->validationErrors); + $this->assertEquals([ + 'Article' => [ + 'Comment' => [ + ['comment' => ['notBlank']] + ] + ] + ], $TestModel->validationErrors); } /** @@ -7917,37 +7917,37 @@ public function testSaveAssociatedDeepHasOneHasManyValidateTrueValidationFailure public function testSaveAssociatedDeepBelongsToHasManyValidateTrueValidationFailure() { $this->loadFixtures('ArticlesTag', 'Article', 'Comment'); $TestModel = new ArticlesTagBelongsToArticle(); - $TestModel->Article->Comment->validate = array( - 'comment' => array( - 'notBlank' => array( - 'rule' => array('notBlank'), - ) - ) - ); - - $result = $TestModel->saveAssociated(array( - 'ArticlesTagBelongsToArticle' => array( + $TestModel->Article->Comment->validate = [ + 'comment' => [ + 'notBlank' => [ + 'rule' => ['notBlank'], + ] + ] + ]; + + $result = $TestModel->saveAssociated([ + 'ArticlesTagBelongsToArticle' => [ 'tag_id' => 1, - ), - 'Article' => array( + ], + 'Article' => [ 'title' => 'Article with User', 'body' => 'This article will be saved with an user and contains a invalid comment', - 'Comment' => array( - array( + 'Comment' => [ + [ 'user_id' => 1, 'comment' => '' - ) - ) - ) - ), array('deep' => true, 'validate' => true)); + ] + ] + ] + ], ['deep' => true, 'validate' => true]); $this->assertFalse($result); - $this->assertEquals(array( - 'Article' => array( - 'Comment' => array( - array('comment' => array('notBlank')) - ) - ) - ), $TestModel->validationErrors); + $this->assertEquals([ + 'Article' => [ + 'Comment' => [ + ['comment' => ['notBlank']] + ] + ] + ], $TestModel->validationErrors); } /** @@ -7957,19 +7957,19 @@ public function testSaveAssociatedDeepBelongsToHasManyValidateTrueValidationFail */ public function testSaveAssociatedHasOneBooleanFields() { $this->loadFixtures('Item', 'Syfile', 'Image'); - $data = array( - 'Syfile' => array( + $data = [ + 'Syfile' => [ 'image_id' => 1, 'name' => 'Some file', - ), - 'Item' => array( + ], + 'Item' => [ 'name' => 'testing', 'published' => false - ), - ); + ], + ]; $syfile = ClassRegistry::init('Syfile'); - $syfile->bindModel(array('hasOne' => array('Item')), false); - $result = $syfile->saveAssociated($data, array('atomic' => false)); + $syfile->bindModel(['hasOne' => ['Item']], false); + $result = $syfile->saveAssociated($data, ['atomic' => false]); $this->assertCount(2, $result, '2 records should have been saved.'); $this->assertTrue($result['Syfile'], 'Both should have succeded'); @@ -7983,26 +7983,26 @@ public function testSaveAssociatedHasOneBooleanFields() { */ public function testSaveAssociatedBelongsToBooleanFields() { $this->loadFixtures('Item', 'Syfile', 'Image'); - $data = array( - 'Syfile' => array( + $data = [ + 'Syfile' => [ 'image_id' => 1, 'name' => 'Some file', - ), - 'Item' => array( + ], + 'Item' => [ 'name' => 'testing', 'syfile_id' => 2, 'published' => false - ), - ); + ], + ]; $item = ClassRegistry::init('Item'); - $item->bindModel(array( - 'belongsTo' => array( - 'Item' => array( + $item->bindModel([ + 'belongsTo' => [ + 'Item' => [ 'foreignKey' => 'image_id' - ) - ) - ), false); - $result = $item->saveAssociated($data, array('atomic' => false)); + ] + ] + ], false); + $result = $item->saveAssociated($data, ['atomic' => false]); $this->assertCount(2, $result, '2 records should have been saved.'); $this->assertTrue($result['Syfile'], 'Both should have succeded'); @@ -8017,10 +8017,10 @@ public function testSaveAssociatedBelongsToBooleanFields() { public function testUpdateAllBoolean() { $this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio'); $TestModel = new Item(); - $result = $TestModel->updateAll(array('published' => true)); + $result = $TestModel->updateAll(['published' => true]); $this->assertTrue($result); - $result = $TestModel->find('first', array('fields' => array('id', 'published'))); + $result = $TestModel->find('first', ['fields' => ['id', 'published']]); $this->assertEquals(true, $result['Item']['published']); } @@ -8033,11 +8033,11 @@ public function testUpdateAllBooleanConditions() { $this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio'); $TestModel = new Item(); - $result = $TestModel->updateAll(array('published' => true), array('Item.id' => 1)); + $result = $TestModel->updateAll(['published' => true], ['Item.id' => 1]); $this->assertTrue($result); - $result = $TestModel->find('first', array( - 'fields' => array('id', 'published'), - 'conditions' => array('Item.id' => 1))); + $result = $TestModel->find('first', [ + 'fields' => ['id', 'published'], + 'conditions' => ['Item.id' => 1]]); $this->assertEquals(true, $result['Item']['published']); } @@ -8050,11 +8050,11 @@ public function testUpdateBoolean() { $this->loadFixtures('Item', 'Syfile', 'Portfolio', 'Image', 'ItemsPortfolio'); $TestModel = new Item(); - $result = $TestModel->save(array('published' => true, 'id' => 1)); + $result = $TestModel->save(['published' => true, 'id' => 1]); $this->assertTrue((bool)$result); - $result = $TestModel->find('first', array( - 'fields' => array('id', 'published'), - 'conditions' => array('Item.id' => 1))); + $result = $TestModel->find('first', [ + 'fields' => ['id', 'published'], + 'conditions' => ['Item.id' => 1]]); $this->assertEquals(true, $result['Item']['published']); } @@ -8066,7 +8066,7 @@ public function testUpdateBoolean() { public function testClear() { $this->loadFixtures('Bid'); $model = ClassRegistry::init('Bid'); - $model->set(array('name' => 'Testing', 'message_id' => 3)); + $model->set(['name' => 'Testing', 'message_id' => 3]); $this->assertTrue(isset($model->data['Bid']['name'])); $this->assertTrue($model->clear()); $this->assertFalse(isset($model->data['Bid']['name'])); @@ -8085,28 +8085,28 @@ public function testSafeUpdateMode() { $User = ClassRegistry::init('User'); $this->assertFalse($User->__safeUpdateMode); - $User->getEventManager()->attach(array($this, 'deleteMe'), 'Model.beforeSave'); + $User->getEventManager()->attach([$this, 'deleteMe'], 'Model.beforeSave'); $User->id = 1; - $User->set(array('user' => 'nobody')); + $User->set(['user' => 'nobody']); $User->save(); - $users = $User->find('list', array('fields' => 'User.user')); + $users = $User->find('list', ['fields' => 'User.user']); - $expected = array( + $expected = [ 2 => 'nate', 3 => 'larry', 4 => 'garrett', - ); + ]; $this->assertEquals($expected, $users); $this->assertFalse($User->__safeUpdateMode); $User->id = 2; - $User->set(array('user' => $User->getDataSource()->expression('PDO_EXCEPTION()'))); + $User->set(['user' => $User->getDataSource()->expression('PDO_EXCEPTION()')]); try { $User->save(null, false); $this->fail('No exception thrown'); - } catch (PDOException $e) { + } catch (PDOException) { $this->assertFalse($User->__safeUpdateMode); } } @@ -8119,7 +8119,7 @@ public function testSafeUpdateMode() { */ public function deleteMe($event) { $Model = $event->subject; - $Model->getDataSource()->delete($Model, array($Model->alias . '.' . $Model->primaryKey => $Model->id)); + $Model->getDataSource()->delete($Model, [$Model->alias . '.' . $Model->primaryKey => $Model->id]); } /** @@ -8132,10 +8132,10 @@ public function deleteMe($event) { * @param array $methods Configurable method names. * @return DboSource */ - protected function _getMockDboSource($methods = array()) { + protected function _getMockDboSource($methods = []) { $testDb = ConnectionManager::getDataSource('test'); - $passthrough = array_diff(array('value', 'begin', 'rollback', 'commit', 'describe', 'lastInsertId', 'execute'), $methods); + $passthrough = array_diff(['value', 'begin', 'rollback', 'commit', 'describe', 'lastInsertId', 'execute'], $methods); $methods = array_merge($methods, $passthrough); if (!in_array('connect', $methods)) { @@ -8150,7 +8150,7 @@ protected function _getMockDboSource($methods = array()) { foreach ($passthrough as $method) { $db->expects($this->any()) ->method($method) - ->will($this->returnCallback(array($testDb, $method))); + ->will($this->returnCallback([$testDb, $method])); } return $db; @@ -8164,56 +8164,56 @@ protected function _getMockDboSource($methods = array()) { public function testTransactionOnNestedSaveMany() { $this->loadFixtures('Post'); $Post = new TestPost(); - $Post->getEventManager()->attach(array($this, 'nestedSaveMany'), 'Model.afterSave'); + $Post->getEventManager()->attach([$this, 'nestedSaveMany'], 'Model.afterSave'); // begin -> [ begin -> commit ] -> commit - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->exactly(2))->method('begin')->will($this->returnValue(true)); $db->expects($this->exactly(2))->method('commit'); $db->expects($this->never())->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'Outer Post'), - ); - $Post->dataForAfterSave = array( - array('author_id' => 1, 'title' => 'Inner Post'), - ); + $data = [ + ['author_id' => 1, 'title' => 'Outer Post'], + ]; + $Post->dataForAfterSave = [ + ['author_id' => 1, 'title' => 'Inner Post'], + ]; $this->assertTrue($Post->saveMany($data)); // begin -> [ begin(false) ] -> commit - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->at(0))->method('begin')->will($this->returnValue(true)); $db->expects($this->at(1))->method('begin')->will($this->returnValue(false)); $db->expects($this->once())->method('commit'); $db->expects($this->never())->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'Outer Post'), - ); - $Post->dataForAfterSave = array( - array('author_id' => 1, 'title' => 'Inner Post'), - ); + $data = [ + ['author_id' => 1, 'title' => 'Outer Post'], + ]; + $Post->dataForAfterSave = [ + ['author_id' => 1, 'title' => 'Inner Post'], + ]; $this->assertTrue($Post->saveMany($data)); // begin -> [ begin -> rollback ] -> rollback - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->exactly(2))->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->exactly(2))->method('rollback'); $Post->setDataSourceObject($db); - $data = array( - array('author_id' => 1, 'title' => 'Outer Post'), - ); - $Post->dataForAfterSave = array( - array('author_id' => 1, 'title' => 'Inner Post', 'body' => $db->expression('PDO_EXCEPTION()')), - ); + $data = [ + ['author_id' => 1, 'title' => 'Outer Post'], + ]; + $Post->dataForAfterSave = [ + ['author_id' => 1, 'title' => 'Inner Post', 'body' => $db->expression('PDO_EXCEPTION()')], + ]; try { $Post->saveMany($data); $this->fail('No exception thrown'); - } catch(Exception $e) { + } catch(Exception) { } } @@ -8226,76 +8226,76 @@ public function testTransactionOnNestedSaveAssociated() { $this->loadFixtures('Author', 'Post'); $Author = new TestAuthor(); - $Author->getEventManager()->attach(array($this, 'nestedSaveAssociated'), 'Model.afterSave'); + $Author->getEventManager()->attach([$this, 'nestedSaveAssociated'], 'Model.afterSave'); // begin -> [ begin -> commit ] -> commit - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->exactly(2))->method('begin')->will($this->returnValue(true)); $db->expects($this->exactly(2))->method('commit'); $db->expects($this->never())->method('rollback'); $Author->setDataSourceObject($db); $Author->Post->setDataSourceObject($db); - $data = array( - 'Author' => array('user' => 'outer'), - 'Post' => array( - array('title' => 'Outer Post'), - ) - ); - $Author->dataForAfterSave = array( - 'Author' => array('user' => 'inner'), - 'Post' => array( - array('title' => 'Inner Post'), - ) - ); + $data = [ + 'Author' => ['user' => 'outer'], + 'Post' => [ + ['title' => 'Outer Post'], + ] + ]; + $Author->dataForAfterSave = [ + 'Author' => ['user' => 'inner'], + 'Post' => [ + ['title' => 'Inner Post'], + ] + ]; $this->assertTrue($Author->saveAssociated($data)); // begin -> [ begin(false) ] -> commit - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->at(0))->method('begin')->will($this->returnValue(true)); $db->expects($this->at(1))->method('begin')->will($this->returnValue(false)); $db->expects($this->once())->method('commit'); $db->expects($this->never())->method('rollback'); $Author->setDataSourceObject($db); $Author->Post->setDataSourceObject($db); - $data = array( - 'Author' => array('user' => 'outer'), - 'Post' => array( - array('title' => 'Outer Post'), - ) - ); - $Author->dataForAfterSave = array( - 'Author' => array('user' => 'inner'), - 'Post' => array( - array('title' => 'Inner Post'), - ) - ); + $data = [ + 'Author' => ['user' => 'outer'], + 'Post' => [ + ['title' => 'Outer Post'], + ] + ]; + $Author->dataForAfterSave = [ + 'Author' => ['user' => 'inner'], + 'Post' => [ + ['title' => 'Inner Post'], + ] + ]; $this->assertTrue($Author->saveAssociated($data)); // begin -> [ begin -> rollback ] -> rollback - $db = $this->_getMockDboSource(array('begin', 'commit', 'rollback')); + $db = $this->_getMockDboSource(['begin', 'commit', 'rollback']); $db->expects($this->exactly(2))->method('begin')->will($this->returnValue(true)); $db->expects($this->never())->method('commit'); $db->expects($this->exactly(2))->method('rollback'); $Author->setDataSourceObject($db); $Author->Post->setDataSourceObject($db); - $data = array( - 'Author' => array('user' => 'outer'), - 'Post' => array( - array('title' => 'Outer Post'), - ) - ); - $Author->dataForAfterSave = array( - 'Author' => array('user' => 'inner', 'password' => $db->expression('PDO_EXCEPTION()')), - 'Post' => array( - array('title' => 'Inner Post'), - ) - ); + $data = [ + 'Author' => ['user' => 'outer'], + 'Post' => [ + ['title' => 'Outer Post'], + ] + ]; + $Author->dataForAfterSave = [ + 'Author' => ['user' => 'inner', 'password' => $db->expression('PDO_EXCEPTION()')], + 'Post' => [ + ['title' => 'Inner Post'], + ] + ]; try { $Author->saveAssociated($data); $this->fail('No exception thrown'); - } catch(Exception $e) { + } catch(Exception) { } } @@ -8307,7 +8307,7 @@ public function testTransactionOnNestedSaveAssociated() { */ public function nestedSaveMany($event) { $Model = $event->subject; - $Model->saveMany($Model->dataForAfterSave, array('callbacks' => false)); + $Model->saveMany($Model->dataForAfterSave, ['callbacks' => false]); } /** @@ -8318,6 +8318,6 @@ public function nestedSaveMany($event) { */ public function nestedSaveAssociated($event) { $Model = $event->subject; - $Model->saveAssociated($Model->dataForAfterSave, array('callbacks' => false)); + $Model->saveAssociated($Model->dataForAfterSave, ['callbacks' => false]); } } diff --git a/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php b/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php index 39c4db3886..de5ac297d4 100644 --- a/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php +++ b/lib/Cake/Test/Case/Model/Validator/CakeValidationRuleTest.php @@ -58,17 +58,17 @@ public function myTestRule3() { * @return void */ public function testIsValid() { - $def = array('rule' => 'notBlank', 'message' => 'Can not be empty'); - $data = array( + $def = ['rule' => 'notBlank', 'message' => 'Can not be empty']; + $data = [ 'fieldName' => '' - ); - $methods = array(); + ]; + $methods = []; $Rule = new CakeValidationRule($def); $Rule->process('fieldName', $data, $methods); $this->assertFalse($Rule->isValid()); - $data = array('fieldName' => 'not empty'); + $data = ['fieldName' => 'not empty']; $Rule->process('fieldName', $data, $methods); $this->assertTrue($Rule->isValid()); } @@ -79,21 +79,21 @@ public function testIsValid() { * @return void */ public function testCustomMethods() { - $def = array('rule' => 'myTestRule'); - $data = array( + $def = ['rule' => 'myTestRule']; + $data = [ 'fieldName' => 'some data' - ); - $methods = array('mytestrule' => array($this, 'myTestRule')); + ]; + $methods = ['mytestrule' => [$this, 'myTestRule']]; $Rule = new CakeValidationRule($def); $Rule->process('fieldName', $data, $methods); $this->assertFalse($Rule->isValid()); - $methods = array('mytestrule' => array($this, 'myTestRule2')); + $methods = ['mytestrule' => [$this, 'myTestRule2']]; $Rule->process('fieldName', $data, $methods); $this->assertTrue($Rule->isValid()); - $methods = array('mytestrule' => array($this, 'myTestRule3')); + $methods = ['mytestrule' => [$this, 'myTestRule3']]; $Rule->process('fieldName', $data, $methods); $this->assertFalse($Rule->isValid()); } @@ -106,11 +106,11 @@ public function testCustomMethods() { public function testCustomMethodMissingError() { $this->expectWarning(); $this->expectWarningMessage('Could not find validation handler totallyMissing for fieldName'); - $def = array('rule' => array('totallyMissing')); - $data = array( + $def = ['rule' => ['totallyMissing']]; + $data = [ 'fieldName' => 'some data' - ); - $methods = array('mytestrule' => array($this, 'myTestRule')); + ]; + $methods = ['mytestrule' => [$this, 'myTestRule']]; $Rule = new CakeValidationRule($def); $Rule->process('fieldName', $data, $methods); @@ -122,19 +122,19 @@ public function testCustomMethodMissingError() { * @return void */ public function testIsRequired() { - $def = array('rule' => 'notBlank', 'required' => true); + $def = ['rule' => 'notBlank', 'required' => true]; $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isRequired()); - $def = array('rule' => 'notBlank', 'required' => false); + $def = ['rule' => 'notBlank', 'required' => false]; $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isRequired()); - $def = array('rule' => 'notBlank', 'required' => 'create'); + $def = ['rule' => 'notBlank', 'required' => 'create']; $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isRequired()); - $def = array('rule' => 'notBlank', 'required' => 'update'); + $def = ['rule' => 'notBlank', 'required' => 'update']; $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isRequired()); @@ -148,22 +148,22 @@ public function testIsRequired() { * @return void */ public function testIsEmptyAllowed() { - $def = array('rule' => 'aRule', 'allowEmpty' => true); + $def = ['rule' => 'aRule', 'allowEmpty' => true]; $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isEmptyAllowed()); - $def = array('rule' => 'aRule', 'allowEmpty' => false); + $def = ['rule' => 'aRule', 'allowEmpty' => false]; $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isEmptyAllowed()); - $def = array('rule' => 'notBlank', 'allowEmpty' => false, 'on' => 'update'); + $def = ['rule' => 'notBlank', 'allowEmpty' => false, 'on' => 'update']; $Rule = new CakeValidationRule($def); $this->assertTrue($Rule->isEmptyAllowed()); $Rule->isUpdate(true); $this->assertFalse($Rule->isEmptyAllowed()); - $def = array('rule' => 'notBlank', 'allowEmpty' => false, 'on' => 'create'); + $def = ['rule' => 'notBlank', 'allowEmpty' => false, 'on' => 'create']; $Rule = new CakeValidationRule($def); $this->assertFalse($Rule->isEmptyAllowed()); @@ -177,16 +177,16 @@ public function testIsEmptyAllowed() { * @return void */ public function testCheckRequiredWhenRequiredAndAllowEmpty() { - $Rule = $this->getMock('CakeValidationRule', array('isRequired')); + $Rule = $this->getMock('CakeValidationRule', ['isRequired']); $Rule->expects($this->any()) ->method('isRequired') ->will($this->returnValue(true)); $Rule->allowEmpty = true; $fieldname = 'field'; - $data = array( + $data = [ $fieldname => null - ); + ]; $this->assertFalse($Rule->checkRequired($fieldname, $data), "A null but present field should not fail requirement check if allowEmpty is true"); diff --git a/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php b/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php index 73a2a2da3a..867ad6f4c3 100644 --- a/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php +++ b/lib/Cake/Test/Case/Model/Validator/CakeValidationSetTest.php @@ -42,13 +42,13 @@ public function setUp() : void { */ public function testValidate() { $Field = new CakeValidationSet('title', 'notBlank'); - $data = array( + $data = [ 'title' => '', 'body' => 'a body' - ); + ]; $result = $Field->validate($data); - $expected = array('This field cannot be left blank'); + $expected = ['This field cannot be left blank']; $this->assertEquals($expected, $result); $Field = new CakeValidationSet('body', 'notBlank'); @@ -56,24 +56,24 @@ public function testValidate() { $result = $Field->validate($data); $this->assertEmpty($result); - $Field = new CakeValidationSet('nothere', array( - 'notBlank' => array( + $Field = new CakeValidationSet('nothere', [ + 'notBlank' => [ 'rule' => 'notBlank', 'required' => true - ) - )); + ] + ]); $result = $Field->validate($data); - $expected = array('notBlank'); + $expected = ['notBlank']; $this->assertEquals($expected, $result); - $Field = new CakeValidationSet('body', array( - 'inList' => array( - 'rule' => array('inList', array('test')) - ) - )); + $Field = new CakeValidationSet('body', [ + 'inList' => [ + 'rule' => ['inList', ['test']] + ] + ]); $result = $Field->validate($data); - $expected = array('inList'); + $expected = ['inList']; $this->assertEquals($expected, $result); } @@ -83,7 +83,7 @@ public function testValidate() { * @return void */ public function testGetRule() { - $rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty')); + $rules = ['notBlank' => ['rule' => 'notBlank', 'message' => 'Can not be empty']]; $Field = new CakeValidationSet('title', $rules); $result = $Field->getRule('notBlank'); $this->assertInstanceOf('CakeValidationRule', $result); @@ -101,11 +101,11 @@ public function testGetRule() { * @return void */ public function testGetRules() { - $rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty')); + $rules = ['notBlank' => ['rule' => 'notBlank', 'message' => 'Can not be empty']]; $Field = new CakeValidationSet('title', $rules); $result = $Field->getRules(); - $this->assertEquals(array('notBlank'), array_keys($result)); + $this->assertEquals(['notBlank'], array_keys($result)); $this->assertInstanceOf('CakeValidationRule', $result['notBlank']); } @@ -115,23 +115,23 @@ public function testGetRules() { * @return void */ public function testSetRule() { - $rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty')); + $rules = ['notBlank' => ['rule' => 'notBlank', 'message' => 'Can not be empty']]; $Field = new CakeValidationSet('title', $rules); $Rule = new CakeValidationRule($rules['notBlank']); $this->assertEquals($Rule, $Field->getRule('notBlank')); - $rules = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email')); + $rules = ['validEmail' => ['rule' => 'email', 'message' => 'Invalid email']]; $Rule = new CakeValidationRule($rules['validEmail']); $Field->setRule('validEmail', $Rule); $result = $Field->getRules(); - $this->assertEquals(array('notBlank', 'validEmail'), array_keys($result)); + $this->assertEquals(['notBlank', 'validEmail'], array_keys($result)); - $rules = array('validEmail' => array('rule' => 'email', 'message' => 'Other message')); + $rules = ['validEmail' => ['rule' => 'email', 'message' => 'Other message']]; $Rule = new CakeValidationRule($rules['validEmail']); $Field->setRule('validEmail', $Rule); $result = $Field->getRules(); - $this->assertEquals(array('notBlank', 'validEmail'), array_keys($result)); + $this->assertEquals(['notBlank', 'validEmail'], array_keys($result)); $result = $Field->getRule('validEmail'); $this->assertInstanceOf('CakeValidationRule', $result); $this->assertEquals('email', $result->rule); @@ -148,32 +148,32 @@ public function testSetRule() { * @return void */ public function testSetRules() { - $rule = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty')); + $rule = ['notBlank' => ['rule' => 'notBlank', 'message' => 'Can not be empty']]; $Field = new CakeValidationSet('title', $rule); $RuleEmpty = new CakeValidationRule($rule['notBlank']); - $rule = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email')); + $rule = ['validEmail' => ['rule' => 'email', 'message' => 'Invalid email']]; $RuleEmail = new CakeValidationRule($rule['validEmail']); - $rules = array('validEmail' => $RuleEmail); + $rules = ['validEmail' => $RuleEmail]; $Field->setRules($rules, false); $result = $Field->getRules(); - $this->assertEquals(array('validEmail'), array_keys($result)); + $this->assertEquals(['validEmail'], array_keys($result)); - $Field->setRules(array('validEmail' => $rule), false); + $Field->setRules(['validEmail' => $rule], false); $result = $Field->getRules(); - $this->assertEquals(array('validEmail'), array_keys($result)); + $this->assertEquals(['validEmail'], array_keys($result)); $this->assertTrue(array_pop($result) instanceof CakeValidationRule); - $rules = array('notBlank' => $RuleEmpty); + $rules = ['notBlank' => $RuleEmpty]; $Field->setRules($rules, true); $result = $Field->getRules(); - $this->assertEquals(array('validEmail', 'notBlank'), array_keys($result)); + $this->assertEquals(['validEmail', 'notBlank'], array_keys($result)); - $rules = array('notBlank' => array('rule' => 'notBlank')); + $rules = ['notBlank' => ['rule' => 'notBlank']]; $Field->setRules($rules, true); $result = $Field->getRules(); - $this->assertEquals(array('validEmail', 'notBlank'), array_keys($result)); + $this->assertEquals(['validEmail', 'notBlank'], array_keys($result)); $this->assertTrue(array_pop($result) instanceof CakeValidationRule); $this->assertTrue(array_pop($result) instanceof CakeValidationRule); } @@ -184,11 +184,11 @@ public function testSetRules() { * @return void */ public function testArrayAccessGet() { - $Set = new CakeValidationSet('title', array( - 'notBlank' => array('rule' => 'notBlank', 'required' => true), - 'numeric' => array('rule' => 'numeric'), - 'other' => array('rule' => array('other', 1)), - )); + $Set = new CakeValidationSet('title', [ + 'notBlank' => ['rule' => 'notBlank', 'required' => true], + 'numeric' => ['rule' => 'numeric'], + 'other' => ['rule' => ['other', 1]], + ]); $rule = $Set['notBlank']; $this->assertInstanceOf('CakeValidationRule', $rule); @@ -200,7 +200,7 @@ public function testArrayAccessGet() { $rule = $Set['other']; $this->assertInstanceOf('CakeValidationRule', $rule); - $this->assertEquals(array('other', 1), $rule->rule); + $this->assertEquals(['other', 1], $rule->rule); } /** @@ -209,11 +209,11 @@ public function testArrayAccessGet() { * @return void */ public function testArrayAccessExists() { - $Set = new CakeValidationSet('title', array( - 'notBlank' => array('rule' => 'notBlank', 'required' => true), - 'numeric' => array('rule' => 'numeric'), - 'other' => array('rule' => array('other', 1)), - )); + $Set = new CakeValidationSet('title', [ + 'notBlank' => ['rule' => 'notBlank', 'required' => true], + 'numeric' => ['rule' => 'numeric'], + 'other' => ['rule' => ['other', 1]], + ]); $this->assertTrue(isset($Set['notBlank'])); $this->assertTrue(isset($Set['numeric'])); @@ -227,18 +227,18 @@ public function testArrayAccessExists() { * @return void */ public function testArrayAccessSet() { - $Set = new CakeValidationSet('title', array( - 'notBlank' => array('rule' => 'notBlank', 'required' => true), - )); + $Set = new CakeValidationSet('title', [ + 'notBlank' => ['rule' => 'notBlank', 'required' => true], + ]); $this->assertFalse(isset($Set['other'])); - $Set['other'] = array('rule' => array('other', 1)); + $Set['other'] = ['rule' => ['other', 1]]; $rule = $Set['other']; $this->assertInstanceOf('CakeValidationRule', $rule); - $this->assertEquals(array('other', 1), $rule->rule); + $this->assertEquals(['other', 1], $rule->rule); $this->assertFalse(isset($Set['numeric'])); - $Set['numeric'] = new CakeValidationRule(array('rule' => 'numeric')); + $Set['numeric'] = new CakeValidationRule(['rule' => 'numeric']); $rule = $Set['numeric']; $this->assertInstanceOf('CakeValidationRule', $rule); $this->assertEquals('numeric', $rule->rule); @@ -250,11 +250,11 @@ public function testArrayAccessSet() { * @return void */ public function testArrayAccessUnset() { - $Set = new CakeValidationSet('title', array( - 'notBlank' => array('rule' => 'notBlank', 'required' => true), - 'numeric' => array('rule' => 'numeric'), - 'other' => array('rule' => array('other', 1)), - )); + $Set = new CakeValidationSet('title', [ + 'notBlank' => ['rule' => 'notBlank', 'required' => true], + 'numeric' => ['rule' => 'numeric'], + 'other' => ['rule' => ['other', 1]], + ]); unset($Set['notBlank']); $this->assertFalse(isset($Set['notBlank'])); @@ -272,11 +272,11 @@ public function testArrayAccessUnset() { * @return void */ public function testIterator() { - $Set = new CakeValidationSet('title', array( - 'notBlank' => array('rule' => 'notBlank', 'required' => true), - 'numeric' => array('rule' => 'numeric'), - 'other' => array('rule' => array('other', 1)), - )); + $Set = new CakeValidationSet('title', [ + 'notBlank' => ['rule' => 'notBlank', 'required' => true], + 'numeric' => ['rule' => 'numeric'], + 'other' => ['rule' => ['other', 1]], + ]); $i = 0; foreach ($Set as $name => $rule) { @@ -301,11 +301,11 @@ public function testIterator() { * @return void */ public function testCount() { - $Set = new CakeValidationSet('title', array( - 'notBlank' => array('rule' => 'notBlank', 'required' => true), - 'numeric' => array('rule' => 'numeric'), - 'other' => array('rule' => array('other', 1)), - )); + $Set = new CakeValidationSet('title', [ + 'notBlank' => ['rule' => 'notBlank', 'required' => true], + 'numeric' => ['rule' => 'numeric'], + 'other' => ['rule' => ['other', 1]], + ]); $this->assertCount(3, $Set); unset($Set['other']); @@ -318,11 +318,11 @@ public function testCount() { * @return void */ public function testRemoveRule() { - $Set = new CakeValidationSet('title', array( - 'notBlank' => array('rule' => 'notBlank', 'required' => true), - 'numeric' => array('rule' => 'numeric'), - 'other' => array('rule' => array('other', 1)), - )); + $Set = new CakeValidationSet('title', [ + 'notBlank' => ['rule' => 'notBlank', 'required' => true], + 'numeric' => ['rule' => 'numeric'], + 'other' => ['rule' => ['other', 1]], + ]); $Set->removeRule('notBlank'); $this->assertFalse(isset($Set['notBlank'])); diff --git a/lib/Cake/Test/Case/Model/models.php b/lib/Cake/Test/Case/Model/models.php index babc5e7ff3..b5e234f700 100644 --- a/lib/Cake/Test/Case/Model/models.php +++ b/lib/Cake/Test/Case/Model/models.php @@ -32,7 +32,7 @@ class AppModel extends Model { * * @var array */ - public $findMethods = array('published' => true); + public $findMethods = ['published' => true]; /** * useDbConfig property @@ -46,7 +46,7 @@ class AppModel extends Model { * * @return array */ - protected function _findPublished($state, $query, $results = array()) { + protected function _findPublished($state, $query, $results = []) { if ($state === 'before') { $query['conditions']['published'] = 'Y'; return $query; @@ -82,14 +82,14 @@ class Test extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'notes' => array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'notes' => ['type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } @@ -119,14 +119,14 @@ class TestAlias extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'notes' => array('type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '1', 'length' => '8', 'key' => 'primary'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'notes' => ['type' => 'text', 'null' => '1', 'default' => 'write some notes here', 'length' => ''], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } /** @@ -155,14 +155,14 @@ class TestValidate extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'title' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'body' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => ''), - 'number' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'modified' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'title' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'body' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => ''], + 'number' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'modified' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; /** * validateNumber method @@ -172,7 +172,7 @@ class TestValidate extends CakeTestModel { * @return void */ public function validateNumber($value, $options) { - $options += array('min' => 0, 'max' => 100); + $options += ['min' => 0, 'max' => 100]; $valid = ($value['number'] >= $options['min'] && $value['number'] <= $options['max']); return $valid; } @@ -184,7 +184,7 @@ public function validateNumber($value, $options) { * @return void */ public function validateTitle($value) { - return (!empty($value) && strpos(strtolower($value['title']), 'title-') === 0); + return (!empty($value) && str_starts_with(strtolower($value['title']), 'title-')); } } @@ -208,7 +208,7 @@ class User extends CakeTestModel { * * @var array */ - public $validate = array('user' => 'notBlank', 'password' => 'notBlank'); + public $validate = ['user' => 'notBlank', 'password' => 'notBlank']; /** * beforeFind() callback used to run ContainableBehaviorTest::testLazyLoad() @@ -246,32 +246,32 @@ class Article extends CakeTestModel { * * @var array */ - public $belongsTo = array('User'); + public $belongsTo = ['User']; /** * hasMany property * * @var array */ - public $hasMany = array('Comment' => array('dependent' => true)); + public $hasMany = ['Comment' => ['dependent' => true]]; /** * hasAndBelongsToMany property * * @var array */ - public $hasAndBelongsToMany = array('Tag'); + public $hasAndBelongsToMany = ['Tag']; /** * validate property * * @var array */ - public $validate = array( + public $validate = [ 'user_id' => 'numeric', - 'title' => array('required' => false, 'rule' => 'notBlank'), - 'body' => array('required' => false, 'rule' => 'notBlank'), - ); + 'title' => ['required' => false, 'rule' => 'notBlank'], + 'body' => ['required' => false, 'rule' => 'notBlank'], + ]; /** * beforeSaveReturn property @@ -285,7 +285,7 @@ class Article extends CakeTestModel { * * @return void */ - public function beforeSave($options = array()) { + public function beforeSave($options = []) { return $this->beforeSaveReturn; } @@ -318,7 +318,7 @@ class BeforeDeleteComment extends CakeTestModel { public function beforeDelete($cascade = true) { $db = $this->getDataSource(); - $db->delete($this, array($this->alias . '.' . $this->primaryKey => array(1, 3))); + $db->delete($this, [$this->alias . '.' . $this->primaryKey => [1, 3]]); return true; } @@ -373,7 +373,7 @@ class Article10 extends CakeTestModel { * * @var array */ - public $hasMany = array('Comment' => array('dependent' => true, 'exclusive' => true)); + public $hasMany = ['Comment' => ['dependent' => true, 'exclusive' => true]]; } @@ -396,35 +396,35 @@ class ArticleFeatured extends CakeTestModel { * * @var array */ - public $belongsTo = array('User', 'Category'); + public $belongsTo = ['User', 'Category']; /** * hasOne property * * @var array */ - public $hasOne = array('Featured'); + public $hasOne = ['Featured']; /** * hasMany property * * @var array */ - public $hasMany = array('Comment' => array('className' => 'Comment', 'dependent' => true)); + public $hasMany = ['Comment' => ['className' => 'Comment', 'dependent' => true]]; /** * hasAndBelongsToMany property * * @var array */ - public $hasAndBelongsToMany = array('Tag'); + public $hasAndBelongsToMany = ['Tag']; /** * validate property * * @var array */ - public $validate = array('user_id' => 'numeric', 'title' => 'notBlank', 'body' => 'notBlank'); + public $validate = ['user_id' => 'numeric', 'title' => 'notBlank', 'body' => 'notBlank']; } @@ -447,7 +447,7 @@ class Featured extends CakeTestModel { * * @var array */ - public $belongsTo = array('ArticleFeatured', 'Category'); + public $belongsTo = ['ArticleFeatured', 'Category']; } /** @@ -514,14 +514,14 @@ class Comment extends CakeTestModel { * * @var array */ - public $belongsTo = array('Article', 'User'); + public $belongsTo = ['Article', 'User']; /** * hasOne property * * @var array */ - public $hasOne = array('Attachment' => array('dependent' => true)); + public $hasOne = ['Attachment' => ['dependent' => true]]; } /** @@ -557,7 +557,7 @@ class ModifiedComment extends CakeTestModel { * * @var array */ - public $belongsTo = array('Article'); + public $belongsTo = ['Article']; /** * afterFind callback @@ -569,7 +569,7 @@ public function afterFind($results, $primary = false) { $results[0]['Comment']['callback'] = 'Fire'; } if ($this->remove) { - return array(); + return []; } return $results; } @@ -602,7 +602,7 @@ class AgainModifiedComment extends CakeTestModel { * * @var array */ - public $belongsTo = array('Article'); + public $belongsTo = ['Article']; /** * afterFind callback @@ -630,9 +630,9 @@ class MergeVarPluginAppModel extends AppModel { * * @var array */ - public $actsAs = array( + public $actsAs = [ 'Containable' - ); + ]; } /** @@ -647,9 +647,9 @@ class MergeVarPluginPost extends MergeVarPluginAppModel { * * @var array */ - public $actsAs = array( + public $actsAs = [ 'Tree' - ); + ]; /** * useTable parameter @@ -671,9 +671,9 @@ class MergeVarPluginComment extends MergeVarPluginAppModel { * * @var array */ - public $actsAs = array( - 'Containable' => array('some_settings') - ); + public $actsAs = [ + 'Containable' => ['some_settings'] + ]; /** * useTable parameter @@ -702,7 +702,7 @@ class Attachment extends CakeTestModel { * * @var array */ - public $belongsTo = array('Comment'); + public $belongsTo = ['Comment']; } /** @@ -780,7 +780,7 @@ class CategoryThread extends CakeTestModel { * * @var array */ - public $belongsTo = array('ParentCategory' => array('className' => 'CategoryThread', 'foreignKey' => 'parent_id')); + public $belongsTo = ['ParentCategory' => ['className' => 'CategoryThread', 'foreignKey' => 'parent_id']]; } /** @@ -802,28 +802,28 @@ class Apple extends CakeTestModel { * * @var array */ - public $validate = array('name' => 'notBlank'); + public $validate = ['name' => 'notBlank']; /** * hasOne property * * @var array */ - public $hasOne = array('Sample'); + public $hasOne = ['Sample']; /** * hasMany property * * @var array */ - public $hasMany = array('Child' => array('className' => 'Apple', 'dependent' => true)); + public $hasMany = ['Child' => ['className' => 'Apple', 'dependent' => true]]; /** * belongsTo property * * @var array */ - public $belongsTo = array('Parent' => array('className' => 'Apple', 'foreignKey' => 'apple_id')); + public $belongsTo = ['Parent' => ['className' => 'Apple', 'foreignKey' => 'apple_id']]; } /** @@ -911,7 +911,7 @@ class Home extends CakeTestModel { * * @var array */ - public $belongsTo = array('AnotherArticle', 'Advertisement'); + public $belongsTo = ['AnotherArticle', 'Advertisement']; } /** @@ -933,7 +933,7 @@ class Post extends CakeTestModel { * * @var array */ - public $belongsTo = array('Author'); + public $belongsTo = ['Author']; /** * @param array $queryData @@ -977,7 +977,7 @@ class Author extends CakeTestModel { * * @var array */ - public $hasMany = array('Post'); + public $hasMany = ['Post']; /** * afterFind method @@ -1040,7 +1040,7 @@ class Project extends CakeTestModel { * * @var array */ - public $hasMany = array('Thread'); + public $hasMany = ['Thread']; } /** @@ -1062,14 +1062,14 @@ class Thread extends CakeTestModel { * * @var array */ - public $belongsTo = array('Project'); + public $belongsTo = ['Project']; /** * hasMany property * * @var array */ - public $hasMany = array('Message'); + public $hasMany = ['Message']; } /** @@ -1091,7 +1091,7 @@ class Message extends CakeTestModel { * * @var array */ - public $hasOne = array('Bid'); + public $hasOne = ['Bid']; } /** @@ -1113,7 +1113,7 @@ class Bid extends CakeTestModel { * * @var array */ - public $belongsTo = array('Message'); + public $belongsTo = ['Message']; } /** @@ -1142,12 +1142,12 @@ class BiddingMessage extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'Bidding' => array( + public $belongsTo = [ + 'Bidding' => [ 'foreignKey' => false, - 'conditions' => array('BiddingMessage.bidding = Bidding.bid') - ) - ); + 'conditions' => ['BiddingMessage.bidding = Bidding.bid'] + ] + ]; } /** @@ -1169,13 +1169,13 @@ class Bidding extends CakeTestModel { * * @var array */ - public $hasOne = array( - 'BiddingMessage' => array( + public $hasOne = [ + 'BiddingMessage' => [ 'foreignKey' => false, - 'conditions' => array('BiddingMessage.bidding = Bidding.bid'), + 'conditions' => ['BiddingMessage.bidding = Bidding.bid'], 'dependent' => true - ) - ); + ] + ]; } /** @@ -1197,7 +1197,7 @@ class NodeAfterFind extends CakeTestModel { * * @var array */ - public $validate = array('name' => 'notBlank'); + public $validate = ['name' => 'notBlank']; /** * useTable property @@ -1211,21 +1211,21 @@ class NodeAfterFind extends CakeTestModel { * * @var array */ - public $hasOne = array('Sample' => array('className' => 'NodeAfterFindSample')); + public $hasOne = ['Sample' => ['className' => 'NodeAfterFindSample']]; /** * hasMany property * * @var array */ - public $hasMany = array('Child' => array('className' => 'NodeAfterFind', 'dependent' => true)); + public $hasMany = ['Child' => ['className' => 'NodeAfterFind', 'dependent' => true]]; /** * belongsTo property * * @var array */ - public $belongsTo = array('Parent' => array('className' => 'NodeAfterFind', 'foreignKey' => 'apple_id')); + public $belongsTo = ['Parent' => ['className' => 'NodeAfterFind', 'foreignKey' => 'apple_id']]; /** * afterFind method @@ -1287,7 +1287,7 @@ class NodeNoAfterFind extends CakeTestModel { * * @var array */ - public $validate = array('name' => 'notBlank'); + public $validate = ['name' => 'notBlank']; /** * useTable property @@ -1301,21 +1301,21 @@ class NodeNoAfterFind extends CakeTestModel { * * @var array */ - public $hasOne = array('Sample' => array('className' => 'NodeAfterFindSample')); + public $hasOne = ['Sample' => ['className' => 'NodeAfterFindSample']]; /** * hasMany property * * @var array */ - public $hasMany = array('Child' => array('className' => 'NodeAfterFind', 'dependent' => true)); + public $hasMany = ['Child' => ['className' => 'NodeAfterFind', 'dependent' => true]]; /** * belongsTo property * * @var array */ - public $belongsTo = array('Parent' => array('className' => 'NodeAfterFind', 'foreignKey' => 'apple_id')); + public $belongsTo = ['Parent' => ['className' => 'NodeAfterFind', 'foreignKey' => 'apple_id']]; } /** @@ -1337,15 +1337,15 @@ class Node extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array( - 'ParentNode' => array( + public $hasAndBelongsToMany = [ + 'ParentNode' => [ 'className' => 'Node', 'joinTable' => 'dependency', 'with' => 'Dependency', 'foreignKey' => 'child_id', 'associationForeignKey' => 'parent_id', - ) - ); + ] + ]; } /** @@ -1389,7 +1389,7 @@ class ModelA extends CakeTestModel { * * @var array */ - public $hasMany = array('ModelB', 'ModelC'); + public $hasMany = ['ModelB', 'ModelC']; } /** @@ -1418,7 +1418,7 @@ class ModelB extends CakeTestModel { * * @var array */ - public $hasMany = array('ModelD'); + public $hasMany = ['ModelD']; } /** @@ -1447,7 +1447,7 @@ class ModelC extends CakeTestModel { * * @var array */ - public $hasMany = array('ModelD'); + public $hasMany = ['ModelD']; } /** @@ -1491,7 +1491,7 @@ class Something extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('SomethingElse' => array('with' => array('JoinThing' => array('doomed')))); + public $hasAndBelongsToMany = ['SomethingElse' => ['with' => ['JoinThing' => ['doomed']]]]; } /** @@ -1513,7 +1513,7 @@ class SomethingElse extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('Something' => array('with' => 'JoinThing')); + public $hasAndBelongsToMany = ['Something' => ['with' => 'JoinThing']]; /** * afterFind callBack @@ -1552,7 +1552,7 @@ class JoinThing extends CakeTestModel { * * @var array */ - public $belongsTo = array('Something', 'SomethingElse'); + public $belongsTo = ['Something', 'SomethingElse']; /** * afterFind callBack @@ -1591,7 +1591,7 @@ class Portfolio extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('Item'); + public $hasAndBelongsToMany = ['Item']; } /** @@ -1613,14 +1613,14 @@ class Item extends CakeTestModel { * * @var array */ - public $belongsTo = array('Syfile' => array('counterCache' => true)); + public $belongsTo = ['Syfile' => ['counterCache' => true]]; /** * hasAndBelongsToMany property * * @var array */ - public $hasAndBelongsToMany = array('Portfolio' => array('unique' => false)); + public $hasAndBelongsToMany = ['Portfolio' => ['unique' => false]]; } /** @@ -1657,7 +1657,7 @@ class Syfile extends CakeTestModel { * * @var array */ - public $belongsTo = array('Image'); + public $belongsTo = ['Image']; } /** @@ -1694,25 +1694,25 @@ class DeviceType extends CakeTestModel { * * @var array */ - public $order = array('DeviceType.order' => 'ASC'); + public $order = ['DeviceType.order' => 'ASC']; /** * belongsTo property * * @var array */ - public $belongsTo = array( + public $belongsTo = [ 'DeviceTypeCategory', 'FeatureSet', 'ExteriorTypeCategory', - 'Image' => array('className' => 'Document'), - 'Extra1' => array('className' => 'Document'), - 'Extra2' => array('className' => 'Document')); + 'Image' => ['className' => 'Document'], + 'Extra1' => ['className' => 'Document'], + 'Extra2' => ['className' => 'Document']]; /** * hasMany property * * @var array */ - public $hasMany = array('Device' => array('order' => array('Device.id' => 'ASC'))); + public $hasMany = ['Device' => ['order' => ['Device.id' => 'ASC']]]; } /** @@ -1764,7 +1764,7 @@ class ExteriorTypeCategory extends CakeTestModel { * * @var array */ - public $belongsTo = array('Image' => array('className' => 'Device')); + public $belongsTo = ['Image' => ['className' => 'Device']]; } /** @@ -1786,7 +1786,7 @@ class Document extends CakeTestModel { * * @var array */ - public $belongsTo = array('DocumentDirectory'); + public $belongsTo = ['DocumentDirectory']; } /** @@ -1868,7 +1868,7 @@ class JoinA extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('JoinB', 'JoinC'); + public $hasAndBelongsToMany = ['JoinB', 'JoinC']; } /** @@ -1890,7 +1890,7 @@ class JoinB extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('JoinA'); + public $hasAndBelongsToMany = ['JoinA']; } /** @@ -1912,7 +1912,7 @@ class JoinC extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('JoinA'); + public $hasAndBelongsToMany = ['JoinA']; } /** @@ -1941,14 +1941,14 @@ class ThePaper extends CakeTestModel { * * @var array */ - public $hasOne = array('Itself' => array('className' => 'ThePaper', 'foreignKey' => 'apple_id')); + public $hasOne = ['Itself' => ['className' => 'ThePaper', 'foreignKey' => 'apple_id']]; /** * hasAndBelongsToMany property * * @var array */ - public $hasAndBelongsToMany = array('Monkey' => array('joinTable' => 'the_paper_monkies', 'order' => 'id')); + public $hasAndBelongsToMany = ['Monkey' => ['joinTable' => 'the_paper_monkies', 'order' => 'id']]; } /** @@ -1999,9 +1999,9 @@ class AssociationTest1 extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('AssociationTest2' => array( + public $hasAndBelongsToMany = ['AssociationTest2' => [ 'unique' => false, 'joinTable' => 'join_as_join_bs', 'foreignKey' => false - )); + ]]; } /** @@ -2030,9 +2030,9 @@ class AssociationTest2 extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('AssociationTest1' => array( + public $hasAndBelongsToMany = ['AssociationTest1' => [ 'unique' => false, 'joinTable' => 'join_as_join_bs' - )); + ]]; } /** @@ -2079,7 +2079,7 @@ class CallbackPostTestModel extends CakeTestModel { * * @return bool */ - public function beforeSave($options = array()) { + public function beforeSave($options = []) { return $this->beforeSaveReturn; } @@ -2090,7 +2090,7 @@ public function beforeSave($options = array()) { * @return bool True if validate operation should continue, false to abort * @see Model::save() */ - public function beforeValidate($options = array()) { + public function beforeValidate($options = []) { return $this->beforeValidateReturn; } @@ -2198,22 +2198,22 @@ class ValidationTest1 extends CakeTestModel { * * @var array */ - protected $_schema = array(); + protected $_schema = []; /** * validate property * * @var array */ - public $validate = array( + public $validate = [ 'title' => 'notBlank', 'published' => 'customValidationMethod', - 'body' => array( + 'body' => [ 'notBlank', '/^.{5,}$/s' => 'no matchy', '/^[0-9A-Za-z \\.]{1,}$/s' - ) - ); + ] + ]; /** * customValidationMethod method @@ -2284,15 +2284,15 @@ class ValidationTest2 extends CakeTestModel { * * @var array */ - public $validate = array( + public $validate = [ 'title' => 'notBlank', 'published' => 'customValidationMethod', - 'body' => array( + 'body' => [ 'notBlank', '/^.{5,}$/s' => 'no matchy', '/^[0-9A-Za-z \\.]{1,}$/s' - ) - ); + ] + ]; /** * customValidationMethod method @@ -2310,7 +2310,7 @@ public function customValidationMethod($data) { * @return void */ public function schema($field = false) { - return array(); + return []; } } @@ -2334,16 +2334,16 @@ class Person extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'Mother' => array( + public $belongsTo = [ + 'Mother' => [ 'className' => 'Person', 'foreignKey' => 'mother_id' - ), - 'Father' => array( + ], + 'Father' => [ 'className' => 'Person', 'foreignKey' => 'father_id' - ) - ); + ] + ]; } /** @@ -2402,14 +2402,14 @@ class Story extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('Tag' => array('foreignKey' => 'story')); + public $hasAndBelongsToMany = ['Tag' => ['foreignKey' => 'story']]; /** * validate property * * @var array */ - public $validate = array('title' => 'notBlank'); + public $validate = ['title' => 'notBlank']; } /** @@ -2431,13 +2431,13 @@ class Cd extends CakeTestModel { * * @var array */ - public $hasOne = array( - 'OverallFavorite' => array( + public $hasOne = [ + 'OverallFavorite' => [ 'foreignKey' => 'model_id', 'dependent' => true, - 'conditions' => array('model_type' => 'Cd') - ) - ); + 'conditions' => ['model_type' => 'Cd'] + ] + ]; } @@ -2460,13 +2460,13 @@ class Book extends CakeTestModel { * * @var array */ - public $hasOne = array( - 'OverallFavorite' => array( + public $hasOne = [ + 'OverallFavorite' => [ 'foreignKey' => 'model_id', 'dependent' => true, 'conditions' => 'OverallFavorite.model_type = \'Book\'' - ) - ); + ] + ]; } @@ -2504,7 +2504,7 @@ class MyUser extends CakeTestModel { * * @var string */ - public $hasAndBelongsToMany = array('MyCategory'); + public $hasAndBelongsToMany = ['MyCategory']; } /** @@ -2526,7 +2526,7 @@ class MyCategory extends CakeTestModel { * * @var string */ - public $hasAndBelongsToMany = array('MyProduct', 'MyUser'); + public $hasAndBelongsToMany = ['MyProduct', 'MyUser']; } /** @@ -2548,7 +2548,7 @@ class MyProduct extends CakeTestModel { * * @var string */ - public $hasAndBelongsToMany = array('MyCategory'); + public $hasAndBelongsToMany = ['MyCategory']; } /** @@ -2600,7 +2600,7 @@ class NumberTree extends CakeTestModel { * * @var array */ - public $actsAs = array('Tree'); + public $actsAs = ['Tree']; /** * initialize method @@ -2617,9 +2617,9 @@ public function initialize($levelLimit = 3, $childLimit = 3, $currentLevel = nul if (!$parentId) { $db = ConnectionManager::getDataSource($this->useDbConfig); $db->truncate($this->table); - $this->save(array($this->name => array('name' => '1. Root'))); + $this->save([$this->name => ['name' => '1. Root']]); $this->initialize($levelLimit, $childLimit, 1, $this->id, '1', $hierarchal); - $this->create(array()); + $this->create([]); } if (!$currentLevel || $currentLevel > $levelLimit) { @@ -2628,7 +2628,7 @@ public function initialize($levelLimit = 3, $childLimit = 3, $currentLevel = nul for ($i = 1; $i <= $childLimit; $i++) { $name = $prefix . '.' . $i; - $data = array($this->name => array('name' => $name)); + $data = [$this->name => ['name' => $name]]; $this->create($data); if ($hierarchal) { @@ -2664,7 +2664,7 @@ class NumberTreeTwo extends NumberTree { * * @var array */ - public $actsAs = array(); + public $actsAs = []; } /** @@ -2696,13 +2696,13 @@ class UnconventionalTree extends NumberTree { */ public $name = 'UnconventionalTree'; - public $actsAs = array( - 'Tree' => array( + public $actsAs = [ + 'Tree' => [ 'parent' => 'join', 'left' => 'left', 'right' => 'right' - ) - ); + ] + ]; } @@ -2740,7 +2740,7 @@ class Campaign extends CakeTestModel { * * @var array */ - public $hasMany = array('Ad' => array('fields' => array('id', 'campaign_id', 'name'))); + public $hasMany = ['Ad' => ['fields' => ['id', 'campaign_id', 'name']]]; } /** @@ -2762,14 +2762,14 @@ class Ad extends CakeTestModel { * * @var array */ - public $actsAs = array('Tree'); + public $actsAs = ['Tree']; /** * belongsTo property * * @var array */ - public $belongsTo = array('Campaign'); + public $belongsTo = ['Campaign']; } /** @@ -2791,14 +2791,14 @@ class AfterTree extends NumberTree { * * @var array */ - public $actsAs = array('Tree'); + public $actsAs = ['Tree']; /** * @param bool $created * @param array $options * @return void */ - public function afterSave($created, $options = array()) { + public function afterSave($created, $options = []) { if ($created && isset($this->data['AfterTree'])) { $this->data['AfterTree']['name'] = 'Six and One Half Changed in AfterTree::afterSave() but not in database'; } @@ -2839,7 +2839,7 @@ class Content extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('Account' => array('className' => 'Account', 'with' => 'ContentAccount', 'joinTable' => 'ContentAccounts', 'foreignKey' => 'iContentId', 'associationForeignKey', 'iAccountId')); + public $hasAndBelongsToMany = ['Account' => ['className' => 'Account', 'with' => 'ContentAccount', 'joinTable' => 'ContentAccounts', 'foreignKey' => 'iContentId', 'associationForeignKey', 'iAccountId']]; } /** @@ -2920,15 +2920,15 @@ class Basket extends CakeTestModel { public $name = 'Basket'; - public $belongsTo = array( - 'FilmFile' => array( + public $belongsTo = [ + 'FilmFile' => [ 'className' => 'FilmFile', 'foreignKey' => 'object_id', 'conditions' => "Basket.type = 'file'", 'fields' => '', 'order' => '' - ) - ); + ] + ]; } @@ -2951,20 +2951,20 @@ class TestPluginArticle extends CakeTestModel { * * @var array */ - public $belongsTo = array('User'); + public $belongsTo = ['User']; /** * hasMany property * * @var array */ - public $hasMany = array( - 'TestPluginComment' => array( + public $hasMany = [ + 'TestPluginComment' => [ 'className' => 'TestPlugin.TestPluginComment', 'foreignKey' => 'article_id', 'dependent' => true - ) - ); + ] + ]; } /** @@ -2986,16 +2986,16 @@ class TestPluginComment extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'TestPluginArticle' => array( + public $belongsTo = [ + 'TestPluginArticle' => [ 'className' => 'TestPlugin.TestPluginArticle', 'foreignKey' => 'article_id', - ), + ], 'TestPlugin.User', - 'TestPlugin.Source' => array( + 'TestPlugin.Source' => [ 'foreignKey' => 'source_id' - ) - ); + ] + ]; } /** @@ -3017,7 +3017,7 @@ class Uuidportfolio extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('Uuiditem'); + public $hasAndBelongsToMany = ['Uuiditem']; } /** @@ -3039,7 +3039,7 @@ class Uuiditem extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('Uuidportfolio' => array('with' => 'UuiditemsUuidportfolioNumericid')); + public $hasAndBelongsToMany = ['Uuidportfolio' => ['with' => 'UuiditemsUuidportfolioNumericid']]; } @@ -3092,7 +3092,7 @@ class Uuidnativeportfolio extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array('Uuidnativeitem'); + public $hasAndBelongsToMany = ['Uuidnativeitem']; } /** @@ -3114,10 +3114,10 @@ class Uuidnativeitem extends CakeTestModel { * * @var array */ - public $hasAndBelongsToMany = array( - 'Uuidnativeportfolio' => array( + public $hasAndBelongsToMany = [ + 'Uuidnativeportfolio' => [ 'with' => 'UuidnativeitemsUuidnativeportfolioNumericid' - )); + ]]; } @@ -3236,7 +3236,7 @@ class TranslatedItem extends CakeTestModel { * * @var array */ - public $actsAs = array('Translate' => array('content', 'title')); + public $actsAs = ['Translate' => ['content', 'title']]; /** * translateModel property @@ -3249,13 +3249,13 @@ class TranslatedItem extends CakeTestModel { class TranslatedItemLeftJoin extends TranslatedItem { - public $actsAs = array( - 'Translate' => array( + public $actsAs = [ + 'Translate' => [ 'content', 'title', 'joinType' => 'LEFT', - ) - ); + ] + ]; } /** @@ -3284,7 +3284,7 @@ class TranslatedItem2 extends CakeTestModel { * * @var array */ - public $actsAs = array('Translate' => array('content', 'title')); + public $actsAs = ['Translate' => ['content', 'title']]; /** * translateModel property @@ -3328,7 +3328,7 @@ class TranslatedItemWithTable extends CakeTestModel { * * @var array */ - public $actsAs = array('Translate' => array('content', 'title')); + public $actsAs = ['Translate' => ['content', 'title']]; /** * translateModel property @@ -3402,7 +3402,7 @@ class TranslatedArticle extends CakeTestModel { * * @var array */ - public $actsAs = array('Translate' => array('title', 'body')); + public $actsAs = ['Translate' => ['title', 'body']]; /** * translateModel property @@ -3416,14 +3416,14 @@ class TranslatedArticle extends CakeTestModel { * * @var array */ - public $belongsTo = array('User'); + public $belongsTo = ['User']; /** * hasMany property * * @var array */ - public $hasMany = array('TranslatedItem'); + public $hasMany = ['TranslatedItem']; } @@ -3433,12 +3433,12 @@ class CounterCacheUser extends CakeTestModel { public $alias = 'User'; - public $hasMany = array( - 'Post' => array( + public $hasMany = [ + 'Post' => [ 'className' => 'CounterCachePost', 'foreignKey' => 'user_id' - ) - ); + ] + ]; } class CounterCachePost extends CakeTestModel { @@ -3447,13 +3447,13 @@ class CounterCachePost extends CakeTestModel { public $alias = 'Post'; - public $belongsTo = array( - 'User' => array( + public $belongsTo = [ + 'User' => [ 'className' => 'CounterCacheUser', 'foreignKey' => 'user_id', 'counterCache' => true - ) - ); + ] + ]; } class CounterCacheUserNonstandardPrimaryKey extends CakeTestModel { @@ -3464,12 +3464,12 @@ class CounterCacheUserNonstandardPrimaryKey extends CakeTestModel { public $primaryKey = 'uid'; - public $hasMany = array( - 'Post' => array( + public $hasMany = [ + 'Post' => [ 'className' => 'CounterCachePostNonstandardPrimaryKey', 'foreignKey' => 'uid' - ) - ); + ] + ]; } @@ -3481,13 +3481,13 @@ class CounterCachePostNonstandardPrimaryKey extends CakeTestModel { public $primaryKey = 'pid'; - public $belongsTo = array( - 'User' => array( + public $belongsTo = [ + 'User' => [ 'className' => 'CounterCacheUserNonstandardPrimaryKey', 'foreignKey' => 'uid', 'counterCache' => true - ) - ); + ] + ]; } @@ -3497,14 +3497,14 @@ class ArticleB extends CakeTestModel { public $useTable = 'articles'; - public $hasAndBelongsToMany = array( - 'TagB' => array( + public $hasAndBelongsToMany = [ + 'TagB' => [ 'className' => 'TagB', 'joinTable' => 'articles_tags', 'foreignKey' => 'article_id', 'associationForeignKey' => 'tag_id' - ) - ); + ] + ]; } @@ -3514,14 +3514,14 @@ class TagB extends CakeTestModel { public $useTable = 'tags'; - public $hasAndBelongsToMany = array( - 'ArticleB' => array( + public $hasAndBelongsToMany = [ + 'ArticleB' => [ 'className' => 'ArticleB', 'joinTable' => 'articles_tags', 'foreignKey' => 'tag_id', 'associationForeignKey' => 'article_id' - ) - ); + ] + ]; } @@ -3529,15 +3529,15 @@ class Fruit extends CakeTestModel { public $name = 'Fruit'; - public $hasAndBelongsToMany = array( - 'UuidTag' => array( + public $hasAndBelongsToMany = [ + 'UuidTag' => [ 'className' => 'UuidTag', 'joinTable' => 'fruits_uuid_tags', 'foreignKey' => 'fruit_id', 'associationForeignKey' => 'uuid_tag_id', 'with' => 'FruitsUuidTag' - ) - ); + ] + ]; } @@ -3547,16 +3547,16 @@ class FruitsUuidTag extends CakeTestModel { public $primaryKey = false; - public $belongsTo = array( - 'UuidTag' => array( + public $belongsTo = [ + 'UuidTag' => [ 'className' => 'UuidTag', 'foreignKey' => 'uuid_tag_id', - ), - 'Fruit' => array( + ], + 'Fruit' => [ 'className' => 'Fruit', 'foreignKey' => 'fruit_id', - ) - ); + ] + ]; } @@ -3564,15 +3564,15 @@ class UuidTag extends CakeTestModel { public $name = 'UuidTag'; - public $hasAndBelongsToMany = array( - 'Fruit' => array( + public $hasAndBelongsToMany = [ + 'Fruit' => [ 'className' => 'Fruit', 'joinTable' => 'fruits_uuid_tags', 'foreign_key' => 'uuid_tag_id', 'associationForeignKey' => 'fruit_id', 'with' => 'FruitsUuidTag' - ) - ); + ] + ]; } @@ -3582,14 +3582,14 @@ class FruitNoWith extends CakeTestModel { public $useTable = 'fruits'; - public $hasAndBelongsToMany = array( - 'UuidTag' => array( + public $hasAndBelongsToMany = [ + 'UuidTag' => [ 'className' => 'UuidTagNoWith', 'joinTable' => 'fruits_uuid_tags', 'foreignKey' => 'fruit_id', 'associationForeignKey' => 'uuid_tag_id', - ) - ); + ] + ]; } @@ -3599,14 +3599,14 @@ class UuidTagNoWith extends CakeTestModel { public $useTable = 'uuid_tags'; - public $hasAndBelongsToMany = array( - 'Fruit' => array( + public $hasAndBelongsToMany = [ + 'Fruit' => [ 'className' => 'FruitNoWith', 'joinTable' => 'fruits_uuid_tags', 'foreign_key' => 'uuid_tag_id', 'associationForeignKey' => 'fruit_id', - ) - ); + ] + ]; } @@ -3632,11 +3632,11 @@ class TransactionTestModel extends CakeTestModel { public $useTable = 'samples'; - public function afterSave($created, $options = array()) { - $data = array( - array('apple_id' => 1, 'name' => 'sample6'), - ); - $this->saveAll($data, array('atomic' => true, 'callbacks' => false)); + public function afterSave($created, $options = []) { + $data = [ + ['apple_id' => 1, 'name' => 'sample6'], + ]; + $this->saveAll($data, ['atomic' => true, 'callbacks' => false]); } } @@ -3647,11 +3647,11 @@ class TransactionManyTestModel extends CakeTestModel { public $useTable = 'samples'; - public function afterSave($created, $options = array()) { - $data = array( - array('apple_id' => 1, 'name' => 'sample6'), - ); - $this->saveMany($data, array('atomic' => true, 'callbacks' => false)); + public function afterSave($created, $options = []) { + $data = [ + ['apple_id' => 1, 'name' => 'sample6'], + ]; + $this->saveMany($data, ['atomic' => true, 'callbacks' => false]); } } @@ -3662,9 +3662,9 @@ class Site extends CakeTestModel { public $useTable = 'sites'; - public $hasAndBelongsToMany = array( - 'Domain' => array('unique' => 'keepExisting'), - ); + public $hasAndBelongsToMany = [ + 'Domain' => ['unique' => 'keepExisting'], + ]; } class Domain extends CakeTestModel { @@ -3673,9 +3673,9 @@ class Domain extends CakeTestModel { public $useTable = 'domains'; - public $hasAndBelongsToMany = array( - 'Site' => array('unique' => 'keepExisting'), - ); + public $hasAndBelongsToMany = [ + 'Site' => ['unique' => 'keepExisting'], + ]; } /** @@ -3704,26 +3704,26 @@ class TestModel extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), - 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => '155'), - 'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'client_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'login' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'passwd' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'addr_1' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'addr_2' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'], + 'zip_code' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'city' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'country' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'phone' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'fax' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'url' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'comments' => ['type' => 'text', 'null' => '1', 'default' => '', 'length' => '155'], + 'last_login' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; /** * find method @@ -3735,7 +3735,7 @@ class TestModel extends CakeTestModel { * @return void */ public function find($conditions = null, $fields = null, $order = null, $recursive = null) { - return array($conditions, $fields); + return [$conditions, $fields]; } /** @@ -3830,37 +3830,37 @@ class TestModel4 extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'TestModel4Parent' => array( + public $belongsTo = [ + 'TestModel4Parent' => [ 'className' => 'TestModel4', 'foreignKey' => 'parent_id' - ) - ); + ] + ]; /** * hasOne property * * @var array */ - public $hasOne = array( - 'TestModel5' => array( + public $hasOne = [ + 'TestModel5' => [ 'className' => 'TestModel5', 'foreignKey' => 'test_model4_id' - ) - ); + ] + ]; /** * hasAndBelongsToMany property * * @var array */ - public $hasAndBelongsToMany = array('TestModel7' => array( + public $hasAndBelongsToMany = ['TestModel7' => [ 'className' => 'TestModel7', 'joinTable' => 'test_model4_test_model7', 'foreignKey' => 'test_model4_id', 'associationForeignKey' => 'test_model7_id', 'with' => 'TestModel4TestModel7' - )); + ]]; /** * schema method @@ -3869,12 +3869,12 @@ class TestModel4 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } return $this->_schema; } @@ -3916,10 +3916,10 @@ class TestModel4TestModel7 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model7_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8') - ); + $this->_schema = [ + 'test_model4_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'test_model7_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'] + ]; } return $this->_schema; } @@ -3959,20 +3959,20 @@ class TestModel5 extends CakeTestModel { * * @var array */ - public $belongsTo = array('TestModel4' => array( + public $belongsTo = ['TestModel4' => [ 'className' => 'TestModel4', 'foreignKey' => 'test_model4_id' - )); + ]]; /** * hasMany property * * @var array */ - public $hasMany = array('TestModel6' => array( + public $hasMany = ['TestModel6' => [ 'className' => 'TestModel6', 'foreignKey' => 'test_model5_id' - )); + ]]; /** * schema method @@ -3981,13 +3981,13 @@ class TestModel5 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model4_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'test_model4_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } return $this->_schema; } @@ -4027,12 +4027,12 @@ class TestModel6 extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'TestModel5' => array( + public $belongsTo = [ + 'TestModel5' => [ 'className' => 'TestModel5', 'foreignKey' => 'test_model5_id' - ) - ); + ] + ]; /** * schema method @@ -4041,13 +4041,13 @@ class TestModel6 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model5_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'test_model5_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } return $this->_schema; } @@ -4089,12 +4089,12 @@ class TestModel7 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } return $this->_schema; } @@ -4134,13 +4134,13 @@ class TestModel8 extends CakeTestModel { * * @var array */ - public $hasOne = array( - 'TestModel9' => array( + public $hasOne = [ + 'TestModel9' => [ 'className' => 'TestModel9', 'foreignKey' => 'test_model8_id', 'conditions' => 'TestModel9.name != \'mariano\'' - ) - ); + ] + ]; /** * schema method @@ -4149,13 +4149,13 @@ class TestModel8 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model9_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'test_model9_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } return $this->_schema; } @@ -4195,13 +4195,13 @@ class TestModel9 extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'TestModel8' => array( + public $belongsTo = [ + 'TestModel8' => [ 'className' => 'TestModel8', 'foreignKey' => 'test_model8_id', 'conditions' => 'TestModel8.name != \'larry\'' - ) - ); + ] + ]; /** * schema method @@ -4210,13 +4210,13 @@ class TestModel9 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'test_model8_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'test_model8_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '11'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } return $this->_schema; } @@ -4256,14 +4256,14 @@ class Level extends CakeTestModel { * * @var array */ - public $hasMany = array( - 'Group' => array( + public $hasMany = [ + 'Group' => [ 'className' => 'Group' - ), - 'User2' => array( + ], + 'User2' => [ 'className' => 'User2' - ) - ); + ] + ]; /** * schema method @@ -4272,10 +4272,10 @@ class Level extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'name' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => '20'], + ]; } return $this->_schema; } @@ -4315,14 +4315,14 @@ class Group extends CakeTestModel { * * @var array */ - public $belongsTo = array('Level'); + public $belongsTo = ['Level']; /** * hasMany property * * @var array */ - public $hasMany = array('Category2', 'User2'); + public $hasMany = ['Category2', 'User2']; /** * schema method @@ -4331,11 +4331,11 @@ class Group extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'level_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'level_id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'name' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => '20'], + ]; } return $this->_schema; } @@ -4375,25 +4375,25 @@ class User2 extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'Group' => array( + public $belongsTo = [ + 'Group' => [ 'className' => 'Group' - ), - 'Level' => array( + ], + 'Level' => [ 'className' => 'Level' - ) - ); + ] + ]; /** * hasMany property * * @var array */ - public $hasMany = array( - 'Article2' => array( + public $hasMany = [ + 'Article2' => [ 'className' => 'Article2' - ), - ); + ], + ]; /** * schema method @@ -4402,12 +4402,12 @@ class User2 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'group_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'level_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'group_id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'level_id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'name' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => '20'], + ]; } return $this->_schema; } @@ -4447,33 +4447,33 @@ class Category2 extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'Group' => array( + public $belongsTo = [ + 'Group' => [ 'className' => 'Group', 'foreignKey' => 'group_id' - ), - 'ParentCat' => array( + ], + 'ParentCat' => [ 'className' => 'Category2', 'foreignKey' => 'parent_id' - ) - ); + ] + ]; /** * hasMany property * * @var array */ - public $hasMany = array( - 'ChildCat' => array( + public $hasMany = [ + 'ChildCat' => [ 'className' => 'Category2', 'foreignKey' => 'parent_id' - ), - 'Article2' => array( + ], + 'Article2' => [ 'className' => 'Article2', 'order' => 'Article2.published_date DESC', 'foreignKey' => 'category_id', - 'limit' => '3') - ); + 'limit' => '3'] + ]; /** * schema method @@ -4482,15 +4482,15 @@ class Category2 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'group_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'parent_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'icon' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'description' => array('type' => 'text', 'null' => false, 'default' => '', 'length' => null), - - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'], + 'group_id' => ['type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'], + 'parent_id' => ['type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'], + 'name' => ['type' => 'string', 'null' => false, 'default' => '', 'length' => '255'], + 'icon' => ['type' => 'string', 'null' => false, 'default' => '', 'length' => '255'], + 'description' => ['type' => 'text', 'null' => false, 'default' => '', 'length' => null], + + ]; } return $this->_schema; } @@ -4530,10 +4530,10 @@ class Article2 extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'Category2' => array('className' => 'Category2'), - 'User2' => array('className' => 'User2') - ); + public $belongsTo = [ + 'Category2' => ['className' => 'Category2'], + 'User2' => ['className' => 'User2'] + ]; /** * schema method @@ -4542,27 +4542,27 @@ class Article2 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'rate_count' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'rate_sum' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'viewed' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'version' => array('type' => 'string', 'null' => true, 'default' => '', 'length' => '45'), - 'title' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '200'), - 'intro' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), - 'comments' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '4'), - 'body' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), - 'isdraft' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), - 'allow_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'), - 'moderate_comments' => array('type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'), - 'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), - 'multipage' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), - 'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null), - 'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'], + 'category_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'user_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'rate_count' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'rate_sum' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'viewed' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'version' => ['type' => 'string', 'null' => true, 'default' => '', 'length' => '45'], + 'title' => ['type' => 'string', 'null' => false, 'default' => '', 'length' => '200'], + 'intro' => ['text' => 'string', 'null' => true, 'default' => '', 'length' => null], + 'comments' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '4'], + 'body' => ['text' => 'string', 'null' => true, 'default' => '', 'length' => null], + 'isdraft' => ['type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'], + 'allow_comments' => ['type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'], + 'moderate_comments' => ['type' => 'boolean', 'null' => false, 'default' => '1', 'length' => '1'], + 'published' => ['type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'], + 'multipage' => ['type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'], + 'published_date' => ['type' => 'datetime', 'null' => true, 'default' => '', 'length' => null], + 'created' => ['type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null], + 'modified' => ['type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null] + ]; } return $this->_schema; } @@ -4604,13 +4604,13 @@ class CategoryFeatured2 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'parent_id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'), - 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'icon' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'description' => array('text' => 'string', 'null' => false, 'default' => '', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'], + 'parent_id' => ['type' => 'integer', 'null' => false, 'default' => '', 'length' => '10'], + 'name' => ['type' => 'string', 'null' => false, 'default' => '', 'length' => '255'], + 'icon' => ['type' => 'string', 'null' => false, 'default' => '', 'length' => '255'], + 'description' => ['text' => 'string', 'null' => false, 'default' => '', 'length' => null] + ]; } return $this->_schema; } @@ -4650,11 +4650,11 @@ class Featured2 extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'CategoryFeatured2' => array( + public $belongsTo = [ + 'CategoryFeatured2' => [ 'className' => 'CategoryFeatured2' - ) - ); + ] + ]; /** * schema method @@ -4663,12 +4663,12 @@ class Featured2 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'article_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'category_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20') - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'article_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'category_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'name' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => '20'] + ]; } return $this->_schema; } @@ -4701,7 +4701,7 @@ class Comment2 extends CakeTestModel { * * @var array */ - public $belongsTo = array('ArticleFeatured2', 'User2'); + public $belongsTo = ['ArticleFeatured2', 'User2']; /** * useTable property @@ -4717,12 +4717,12 @@ class Comment2 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'article_featured_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'name' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20') - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'article_featured_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'user_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'name' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => '20'] + ]; } return $this->_schema; } @@ -4762,28 +4762,28 @@ class ArticleFeatured2 extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'CategoryFeatured2' => array('className' => 'CategoryFeatured2'), - 'User2' => array('className' => 'User2') - ); + public $belongsTo = [ + 'CategoryFeatured2' => ['className' => 'CategoryFeatured2'], + 'User2' => ['className' => 'User2'] + ]; /** * hasOne property * * @var array */ - public $hasOne = array( - 'Featured2' => array('className' => 'Featured2') - ); + public $hasOne = [ + 'Featured2' => ['className' => 'Featured2'] + ]; /** * hasMany property * * @var array */ - public $hasMany = array( - 'Comment2' => array('className' => 'Comment2', 'dependent' => true) - ); + public $hasMany = [ + 'Comment2' => ['className' => 'Comment2', 'dependent' => true] + ]; /** * schema method @@ -4792,17 +4792,17 @@ class ArticleFeatured2 extends CakeTestModel { */ public function schema($field = false) { if (!isset($this->_schema)) { - $this->_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'), - 'category_featured_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'user_id' => array('type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'), - 'title' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => '20'), - 'body' => array('text' => 'string', 'null' => true, 'default' => '', 'length' => null), - 'published' => array('type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'), - 'published_date' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null), - 'created' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null), - 'modified' => array('type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null) - ); + $this->_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => null, 'length' => '10'], + 'category_featured_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'user_id' => ['type' => 'integer', 'null' => false, 'default' => '0', 'length' => '10'], + 'title' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => '20'], + 'body' => ['text' => 'string', 'null' => true, 'default' => '', 'length' => null], + 'published' => ['type' => 'boolean', 'null' => false, 'default' => '0', 'length' => '1'], + 'published_date' => ['type' => 'datetime', 'null' => true, 'default' => '', 'length' => null], + 'created' => ['type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null], + 'modified' => ['type' => 'datetime', 'null' => false, 'default' => '0000-00-00 00:00:00', 'length' => null] + ]; } return $this->_schema; } @@ -4862,26 +4862,26 @@ public function findAll($conditions = null, $fields = null, $order = null, $recu * @return void */ public function schema($field = false) { - return array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'), - 'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'), - 'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''), - 'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + return [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'client_id' => ['type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'login' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'passwd' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'addr_1' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'addr_2' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'], + 'zip_code' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'city' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'country' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'phone' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'fax' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'url' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'], + 'comments' => ['type' => 'text', 'null' => '1', 'default' => '', 'length' => ''], + 'last_login' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } } @@ -4919,38 +4919,38 @@ class ScaffoldMock extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'User' => array( + public $belongsTo = [ + 'User' => [ 'className' => 'ScaffoldUser', 'foreignKey' => 'user_id', - ) - ); + ] + ]; /** * hasMany property * * @var array */ - public $hasMany = array( - 'Comment' => array( + public $hasMany = [ + 'Comment' => [ 'className' => 'ScaffoldComment', 'foreignKey' => 'article_id', - ) - ); + ] + ]; /** * hasAndBelongsToMany property * * @var string */ - public $hasAndBelongsToMany = array( - 'ScaffoldTag' => array( + public $hasAndBelongsToMany = [ + 'ScaffoldTag' => [ 'className' => 'ScaffoldTag', 'foreignKey' => 'something_id', 'associationForeignKey' => 'something_else_id', 'joinTable' => 'join_things' - ) - ); + ] + ]; } @@ -4973,12 +4973,12 @@ class ScaffoldUser extends CakeTestModel { * * @var array */ - public $hasMany = array( - 'Article' => array( + public $hasMany = [ + 'Article' => [ 'className' => 'ScaffoldMock', 'foreignKey' => 'article_id', - ) - ); + ] + ]; } /** @@ -5000,12 +5000,12 @@ class ScaffoldComment extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'Article' => array( + public $belongsTo = [ + 'Article' => [ 'className' => 'ScaffoldMock', 'foreignKey' => 'article_id', - ) - ); + ] + ]; } /** @@ -5031,12 +5031,12 @@ class ScaffoldTag extends CakeTestModel { */ class Player extends CakeTestModel { - public $hasAndBelongsToMany = array( - 'Guild' => array( + public $hasAndBelongsToMany = [ + 'Guild' => [ 'with' => 'GuildsPlayer', 'unique' => true, - ), - ); + ], + ]; } @@ -5047,12 +5047,12 @@ class Player extends CakeTestModel { */ class Guild extends CakeTestModel { - public $hasAndBelongsToMany = array( - 'Player' => array( + public $hasAndBelongsToMany = [ + 'Player' => [ 'with' => 'GuildsPlayer', 'unique' => true, - ), - ); + ], + ]; } @@ -5065,10 +5065,10 @@ class GuildsPlayer extends CakeTestModel { public $useDbConfig = 'test2'; - public $belongsTo = array( + public $belongsTo = [ 'Player', 'Guild', - ); + ]; } /** @@ -5080,9 +5080,9 @@ class Armor extends CakeTestModel { public $useDbConfig = 'test2'; - public $hasAndBelongsToMany = array( - 'Player' => array('with' => 'ArmorsPlayer'), - ); + public $hasAndBelongsToMany = [ + 'Player' => ['with' => 'ArmorsPlayer'], + ]; } /** @@ -5115,21 +5115,21 @@ class CustomArticle extends AppModel { * * @var array */ - public $findMethods = array('unPublished' => true); + public $findMethods = ['unPublished' => true]; /** * belongsTo property * * @var array */ - public $belongsTo = array('User'); + public $belongsTo = ['User']; /** * _findUnPublished custom find * * @return array */ - protected function _findUnPublished($state, $query, $results = array()) { + protected function _findUnPublished($state, $query, $results = []) { if ($state === 'before') { $query['conditions']['published'] = 'N'; return $query; @@ -5144,7 +5144,7 @@ protected function _findUnPublished($state, $query, $results = array()) { * @return bool True if validate operation should continue, false to abort * @see Model::save() */ - public function beforeValidate($options = array()) { + public function beforeValidate($options = []) { $this->data[$this->alias]['title'] = 'foo'; if ($this->findMethods['unPublished'] === true) { $this->findMethods['unPublished'] = false; @@ -5174,15 +5174,15 @@ class Example extends AppModel { * * @var array */ - protected $_schema = array( - 'filefield' => array( + protected $_schema = [ + 'filefield' => [ 'type' => 'string', 'length' => 254, 'default' => null, 'null' => true, 'comment' => null - ), - ); + ], + ]; } @@ -5205,7 +5205,7 @@ class UserHasOneArticle extends AppModel { * * @var array */ - public $hasOne = array('Article'); + public $hasOne = ['Article']; } @@ -5229,6 +5229,6 @@ class ArticlesTagBelongsToArticle extends CakeTestModel { * * @var array */ - public $belongsTo = array('Article'); + public $belongsTo = ['Article']; } diff --git a/lib/Cake/Test/Case/Network/CakeRequestTest.php b/lib/Cake/Test/Case/Network/CakeRequestTest.php index 6324d381f4..b416f7ac5f 100644 --- a/lib/Cake/Test/Case/Network/CakeRequestTest.php +++ b/lib/Cake/Test/Case/Network/CakeRequestTest.php @@ -96,7 +96,7 @@ public function tearDown() : void { */ public function testHeaderDetector() { $request = new CakeRequest('some/path'); - $request->addDetector('host', array('header' => array('host' => 'cakephp.org'))); + $request->addDetector('host', ['header' => ['host' => 'cakephp.org']]); $_SERVER['HTTP_HOST'] = 'cakephp.org'; $this->assertTrue($request->is('host')); @@ -139,9 +139,9 @@ public function testAcceptHeaderDetector() { * @return void */ public function testNoAutoParseConstruction() { - $_GET = array( + $_GET = [ 'one' => 'param' - ); + ]; $request = new CakeRequest(null, false); $this->assertFalse(isset($request->query['one'])); } @@ -167,17 +167,17 @@ public function testContentType() { * @return void */ public function testConstructionGetParsing() { - $_GET = array( + $_GET = [ 'one' => 'param', 'two' => 'banana' - ); + ]; $request = new CakeRequest('some/path'); $this->assertEquals($request->query, $_GET); - $_GET = array( + $_GET = [ 'one' => 'param', 'two' => 'banana', - ); + ]; $request = new CakeRequest('some/path'); $this->assertEquals($request->query, $_GET); $this->assertEquals('some/path', $request->url); @@ -189,9 +189,9 @@ public function testConstructionGetParsing() { * @return void */ public function testQueryStringParsingFromInputUrl() { - $_GET = array(); + $_GET = []; $request = new CakeRequest('some/path?one=something&two=else'); - $expected = array('one' => 'something', 'two' => 'else'); + $expected = ['one' => 'something', 'two' => 'else']; $this->assertEquals($expected, $request->query); $this->assertEquals('some/path', $request->url); $this->assertStringEndsWith('/some/path?one=something&two=else', $request->here()); @@ -232,8 +232,8 @@ public function testQueryStringAndNamedParams() { */ public function testAddParams() { $request = new CakeRequest('some/path'); - $request->params = array('controller' => 'posts', 'action' => 'view'); - $result = $request->addParams(array('plugin' => null, 'action' => 'index')); + $request->params = ['controller' => 'posts', 'action' => 'view']; + $result = $request->addParams(['plugin' => null, 'action' => 'index']); $this->assertSame($result, $request, 'Method did not return itself. %s'); @@ -250,9 +250,9 @@ public function testAddParams() { public function testAddPaths() { $request = new CakeRequest('some/path'); $request->webroot = '/some/path/going/here/'; - $result = $request->addPaths(array( + $result = $request->addPaths([ 'random' => '/something', 'webroot' => '/', 'here' => '/', 'base' => '/base_dir' - )); + ]); $this->assertSame($result, $request, 'Method did not return itself. %s'); @@ -268,47 +268,47 @@ public function testAddPaths() { * @return void */ public function testPostParsing() { - $_POST = array('data' => array( - 'Article' => array('title') - )); + $_POST = ['data' => [ + 'Article' => ['title'] + ]]; $request = new CakeRequest('some/path'); $this->assertEquals($_POST['data'], $request->data); - $_POST = array('one' => 1, 'two' => 'three'); + $_POST = ['one' => 1, 'two' => 'three']; $request = new CakeRequest('some/path'); $this->assertEquals($_POST, $request->data); - $_POST = array( - 'data' => array( - 'Article' => array('title' => 'Testing'), - ), + $_POST = [ + 'data' => [ + 'Article' => ['title' => 'Testing'], + ], 'action' => 'update' - ); + ]; $request = new CakeRequest('some/path'); - $expected = array( - 'Article' => array('title' => 'Testing'), + $expected = [ + 'Article' => ['title' => 'Testing'], 'action' => 'update' - ); + ]; $this->assertEquals($expected, $request->data); - $_POST = array('data' => array( - 'Article' => array('title'), - 'Tag' => array('Tag' => array(1, 2)) - )); + $_POST = ['data' => [ + 'Article' => ['title'], + 'Tag' => ['Tag' => [1, 2]] + ]]; $request = new CakeRequest('some/path'); $this->assertEquals($_POST['data'], $request->data); - $_POST = array('data' => array( - 'Article' => array('title' => 'some title'), - 'Tag' => array('Tag' => array(1, 2)) - )); + $_POST = ['data' => [ + 'Article' => ['title' => 'some title'], + 'Tag' => ['Tag' => [1, 2]] + ]]; $request = new CakeRequest('some/path'); $this->assertEquals($_POST['data'], $request->data); - $_POST = array( - 'a' => array(1, 2), - 'b' => array(1, 2) - ); + $_POST = [ + 'a' => [1, 2], + 'b' => [1, 2] + ]; $request = new CakeRequest('some/path'); $this->assertEquals($_POST, $request->data); } @@ -322,59 +322,59 @@ public function testPutParsing() { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - $data = array('data' => array( - 'Article' => array('title') - )); + $data = ['data' => [ + 'Article' => ['title'] + ]]; - $request = $this->getMock('TestCakeRequest', array('_readInput')); + $request = $this->getMock('TestCakeRequest', ['_readInput']); $request->expects($this->at(0))->method('_readInput') ->will($this->returnValue('data[Article][]=title')); $request->reConstruct(); $this->assertEquals($data['data'], $request->data); - $data = array('one' => 1, 'two' => 'three'); - $request = $this->getMock('TestCakeRequest', array('_readInput')); + $data = ['one' => 1, 'two' => 'three']; + $request = $this->getMock('TestCakeRequest', ['_readInput']); $request->expects($this->at(0))->method('_readInput') ->will($this->returnValue('one=1&two=three')); $request->reConstruct(); $this->assertEquals($data, $request->data); - $request = $this->getMock('TestCakeRequest', array('_readInput')); + $request = $this->getMock('TestCakeRequest', ['_readInput']); $request->expects($this->at(0))->method('_readInput') ->will($this->returnValue('data[Article][title]=Testing&action=update')); $request->reConstruct(); - $expected = array( - 'Article' => array('title' => 'Testing'), + $expected = [ + 'Article' => ['title' => 'Testing'], 'action' => 'update' - ); + ]; $this->assertEquals($expected, $request->data); $_SERVER['REQUEST_METHOD'] = 'DELETE'; - $data = array('data' => array( - 'Article' => array('title'), - 'Tag' => array('Tag' => array(1, 2)) - )); - $request = $this->getMock('TestCakeRequest', array('_readInput')); + $data = ['data' => [ + 'Article' => ['title'], + 'Tag' => ['Tag' => [1, 2]] + ]]; + $request = $this->getMock('TestCakeRequest', ['_readInput']); $request->expects($this->at(0))->method('_readInput') ->will($this->returnValue('data[Article][]=title&Tag[Tag][]=1&Tag[Tag][]=2')); $request->reConstruct(); $this->assertEquals($data['data'], $request->data); - $data = array('data' => array( - 'Article' => array('title' => 'some title'), - 'Tag' => array('Tag' => array(1, 2)) - )); - $request = $this->getMock('TestCakeRequest', array('_readInput')); + $data = ['data' => [ + 'Article' => ['title' => 'some title'], + 'Tag' => ['Tag' => [1, 2]] + ]]; + $request = $this->getMock('TestCakeRequest', ['_readInput']); $request->expects($this->at(0))->method('_readInput') ->will($this->returnValue('data[Article][title]=some%20title&Tag[Tag][]=1&Tag[Tag][]=2')); $request->reConstruct(); $this->assertEquals($data['data'], $request->data); - $data = array( - 'a' => array(1, 2), - 'b' => array(1, 2) - ); - $request = $this->getMock('TestCakeRequest', array('_readInput')); + $data = [ + 'a' => [1, 2], + 'b' => [1, 2] + ]; + $request = $this->getMock('TestCakeRequest', ['_readInput']); $request->expects($this->at(0))->method('_readInput') ->will($this->returnValue('a[]=1&a[]=2&b[]=1&b[]=2')); $request->reConstruct(); @@ -390,12 +390,12 @@ public function testPutParsingJSON() { $_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['CONTENT_TYPE'] = 'application/json'; - $request = $this->getMock('TestCakeRequest', array('_readInput')); + $request = $this->getMock('TestCakeRequest', ['_readInput']); $request->expects($this->at(0))->method('_readInput') ->will($this->returnValue('{"Article":["title"]}')); $request->reConstruct(); $result = $request->input('json_decode', true); - $this->assertEquals(array('title'), $result['Article']); + $this->assertEquals(['title'], $result['Article']); } /** @@ -404,267 +404,267 @@ public function testPutParsingJSON() { * @return void */ public function testFilesParsing() { - $_FILES = array( - 'data' => array( - 'name' => array( - 'File' => array( - array('data' => 'cake_sqlserver_patch.patch'), - array('data' => 'controller.diff'), - array('data' => ''), - array('data' => ''), - ), - 'Post' => array('attachment' => 'jquery-1.2.1.js'), - ), - 'type' => array( - 'File' => array( - array('data' => ''), - array('data' => ''), - array('data' => ''), - array('data' => ''), - ), - 'Post' => array('attachment' => 'application/x-javascript'), - ), - 'tmp_name' => array( - 'File' => array( - array('data' => '/private/var/tmp/phpy05Ywj'), - array('data' => '/private/var/tmp/php7MBztY'), - array('data' => ''), - array('data' => ''), - ), - 'Post' => array('attachment' => '/private/var/tmp/phpEwlrIo'), - ), - 'error' => array( - 'File' => array( - array('data' => 0), - array('data' => 0), - array('data' => 4), - array('data' => 4) - ), - 'Post' => array('attachment' => 0) - ), - 'size' => array( - 'File' => array( - array('data' => 6271), - array('data' => 350), - array('data' => 0), - array('data' => 0), - ), - 'Post' => array('attachment' => 80469) - ), - ) - ); + $_FILES = [ + 'data' => [ + 'name' => [ + 'File' => [ + ['data' => 'cake_sqlserver_patch.patch'], + ['data' => 'controller.diff'], + ['data' => ''], + ['data' => ''], + ], + 'Post' => ['attachment' => 'jquery-1.2.1.js'], + ], + 'type' => [ + 'File' => [ + ['data' => ''], + ['data' => ''], + ['data' => ''], + ['data' => ''], + ], + 'Post' => ['attachment' => 'application/x-javascript'], + ], + 'tmp_name' => [ + 'File' => [ + ['data' => '/private/var/tmp/phpy05Ywj'], + ['data' => '/private/var/tmp/php7MBztY'], + ['data' => ''], + ['data' => ''], + ], + 'Post' => ['attachment' => '/private/var/tmp/phpEwlrIo'], + ], + 'error' => [ + 'File' => [ + ['data' => 0], + ['data' => 0], + ['data' => 4], + ['data' => 4] + ], + 'Post' => ['attachment' => 0] + ], + 'size' => [ + 'File' => [ + ['data' => 6271], + ['data' => 350], + ['data' => 0], + ['data' => 0], + ], + 'Post' => ['attachment' => 80469] + ], + ] + ]; $request = new CakeRequest('some/path'); - $expected = array( - 'File' => array( - array( - 'data' => array( + $expected = [ + 'File' => [ + [ + 'data' => [ 'name' => 'cake_sqlserver_patch.patch', 'type' => '', 'tmp_name' => '/private/var/tmp/phpy05Ywj', 'error' => 0, 'size' => 6271, - ) - ), - array( - 'data' => array( + ] + ], + [ + 'data' => [ 'name' => 'controller.diff', 'type' => '', 'tmp_name' => '/private/var/tmp/php7MBztY', 'error' => 0, 'size' => 350, - ) - ), - array( - 'data' => array( + ] + ], + [ + 'data' => [ 'name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0, - ) - ), - array( - 'data' => array( + ] + ], + [ + 'data' => [ 'name' => '', 'type' => '', 'tmp_name' => '', 'error' => 4, 'size' => 0, - ) - ), - ), - 'Post' => array( - 'attachment' => array( + ] + ], + ], + 'Post' => [ + 'attachment' => [ 'name' => 'jquery-1.2.1.js', 'type' => 'application/x-javascript', 'tmp_name' => '/private/var/tmp/phpEwlrIo', 'error' => 0, 'size' => 80469, - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $request->data); - $_FILES = array( - 'data' => array( - 'name' => array( - 'Document' => array( - 1 => array( + $_FILES = [ + 'data' => [ + 'name' => [ + 'Document' => [ + 1 => [ 'birth_cert' => 'born on.txt', 'passport' => 'passport.txt', 'drivers_license' => 'ugly pic.jpg' - ), - 2 => array( + ], + 2 => [ 'birth_cert' => 'aunt betty.txt', 'passport' => 'betty-passport.txt', 'drivers_license' => 'betty-photo.jpg' - ), - ), - ), - 'type' => array( - 'Document' => array( - 1 => array( + ], + ], + ], + 'type' => [ + 'Document' => [ + 1 => [ 'birth_cert' => 'application/octet-stream', 'passport' => 'application/octet-stream', 'drivers_license' => 'application/octet-stream', - ), - 2 => array( + ], + 2 => [ 'birth_cert' => 'application/octet-stream', 'passport' => 'application/octet-stream', 'drivers_license' => 'application/octet-stream', - ) - ) - ), - 'tmp_name' => array( - 'Document' => array( - 1 => array( + ] + ] + ], + 'tmp_name' => [ + 'Document' => [ + 1 => [ 'birth_cert' => '/private/var/tmp/phpbsUWfH', 'passport' => '/private/var/tmp/php7f5zLt', 'drivers_license' => '/private/var/tmp/phpMXpZgT', - ), - 2 => array( + ], + 2 => [ 'birth_cert' => '/private/var/tmp/php5kHZt0', 'passport' => '/private/var/tmp/phpnYkOuM', 'drivers_license' => '/private/var/tmp/php9Rq0P3', - ) - ) - ), - 'error' => array( - 'Document' => array( - 1 => array( + ] + ] + ], + 'error' => [ + 'Document' => [ + 1 => [ 'birth_cert' => 0, 'passport' => 0, 'drivers_license' => 0, - ), - 2 => array( + ], + 2 => [ 'birth_cert' => 0, 'passport' => 0, 'drivers_license' => 0, - ) - ) - ), - 'size' => array( - 'Document' => array( - 1 => array( + ] + ] + ], + 'size' => [ + 'Document' => [ + 1 => [ 'birth_cert' => 123, 'passport' => 458, 'drivers_license' => 875, - ), - 2 => array( + ], + 2 => [ 'birth_cert' => 876, 'passport' => 976, 'drivers_license' => 9783, - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $request = new CakeRequest('some/path'); - $expected = array( - 'Document' => array( - 1 => array( - 'birth_cert' => array( + $expected = [ + 'Document' => [ + 1 => [ + 'birth_cert' => [ 'name' => 'born on.txt', 'tmp_name' => '/private/var/tmp/phpbsUWfH', 'error' => 0, 'size' => 123, 'type' => 'application/octet-stream', - ), - 'passport' => array( + ], + 'passport' => [ 'name' => 'passport.txt', 'tmp_name' => '/private/var/tmp/php7f5zLt', 'error' => 0, 'size' => 458, 'type' => 'application/octet-stream', - ), - 'drivers_license' => array( + ], + 'drivers_license' => [ 'name' => 'ugly pic.jpg', 'tmp_name' => '/private/var/tmp/phpMXpZgT', 'error' => 0, 'size' => 875, 'type' => 'application/octet-stream', - ), - ), - 2 => array( - 'birth_cert' => array( + ], + ], + 2 => [ + 'birth_cert' => [ 'name' => 'aunt betty.txt', 'tmp_name' => '/private/var/tmp/php5kHZt0', 'error' => 0, 'size' => 876, 'type' => 'application/octet-stream', - ), - 'passport' => array( + ], + 'passport' => [ 'name' => 'betty-passport.txt', 'tmp_name' => '/private/var/tmp/phpnYkOuM', 'error' => 0, 'size' => 976, 'type' => 'application/octet-stream', - ), - 'drivers_license' => array( + ], + 'drivers_license' => [ 'name' => 'betty-photo.jpg', 'tmp_name' => '/private/var/tmp/php9Rq0P3', 'error' => 0, 'size' => 9783, 'type' => 'application/octet-stream', - ), - ), - ) - ); + ], + ], + ] + ]; $this->assertEquals($expected, $request->data); - $_FILES = array( - 'data' => array( - 'name' => array('birth_cert' => 'born on.txt'), - 'type' => array('birth_cert' => 'application/octet-stream'), - 'tmp_name' => array('birth_cert' => '/private/var/tmp/phpbsUWfH'), - 'error' => array('birth_cert' => 0), - 'size' => array('birth_cert' => 123) - ) - ); + $_FILES = [ + 'data' => [ + 'name' => ['birth_cert' => 'born on.txt'], + 'type' => ['birth_cert' => 'application/octet-stream'], + 'tmp_name' => ['birth_cert' => '/private/var/tmp/phpbsUWfH'], + 'error' => ['birth_cert' => 0], + 'size' => ['birth_cert' => 123] + ] + ]; $request = new CakeRequest('some/path'); - $expected = array( - 'birth_cert' => array( + $expected = [ + 'birth_cert' => [ 'name' => 'born on.txt', 'type' => 'application/octet-stream', 'tmp_name' => '/private/var/tmp/phpbsUWfH', 'error' => 0, 'size' => 123 - ) - ); + ] + ]; $this->assertEquals($expected, $request->data); - $_FILES = array( - 'something' => array( + $_FILES = [ + 'something' => [ 'name' => 'something.txt', 'type' => 'text/plain', 'tmp_name' => '/some/file', 'error' => 0, 'size' => 123 - ) - ); + ] + ]; $request = new CakeRequest('some/path'); $this->assertEquals($request->params['form'], $_FILES); } @@ -675,15 +675,15 @@ public function testFilesParsing() { * @return void */ public function testFilesZeroithIndex() { - $_FILES = array( - 0 => array( + $_FILES = [ + 0 => [ 'name' => 'cake_sqlserver_patch.patch', 'type' => 'text/plain', 'tmp_name' => '/private/var/tmp/phpy05Ywj', 'error' => 0, 'size' => 6271, - ), - ); + ], + ]; $request = new CakeRequest('some/path'); $this->assertEquals($_FILES, $request->params['form']); @@ -695,11 +695,11 @@ public function testFilesZeroithIndex() { * @return void */ public function testMethodOverrides() { - $_POST = array('_method' => 'POST'); + $_POST = ['_method' => 'POST']; $request = new CakeRequest('some/path'); $this->assertEquals(env('REQUEST_METHOD'), 'POST'); - $_POST = array('_method' => 'DELETE'); + $_POST = ['_method' => 'DELETE']; $request = new CakeRequest('some/path'); $this->assertEquals(env('REQUEST_METHOD'), 'DELETE'); @@ -836,13 +836,13 @@ public function testIsJsonAndXml() { $request = new CakeRequest('some/path'); $_SERVER['HTTP_ACCEPT'] = 'application/json, text/plain, */*'; - $this->assertTrue($request->is(array('json'))); + $this->assertTrue($request->is(['json'])); $_SERVER['HTTP_ACCEPT'] = 'application/xml, text/plain, */*'; - $this->assertTrue($request->is(array('xml'))); + $this->assertTrue($request->is(['xml'])); $_SERVER['HTTP_ACCEPT'] = 'text/xml, */*'; - $this->assertTrue($request->is(array('xml'))); + $this->assertTrue($request->is(['xml'])); } /** @@ -854,13 +854,13 @@ public function testIsMultiple() { $request = new CakeRequest('some/path'); $_SERVER['REQUEST_METHOD'] = 'GET'; - $this->assertTrue($request->is(array('get', 'post'))); + $this->assertTrue($request->is(['get', 'post'])); $_SERVER['REQUEST_METHOD'] = 'POST'; - $this->assertTrue($request->is(array('get', 'post'))); + $this->assertTrue($request->is(['get', 'post'])); $_SERVER['REQUEST_METHOD'] = 'PUT'; - $this->assertFalse($request->is(array('get', 'post'))); + $this->assertFalse($request->is(['get', 'post'])); } /** @@ -874,9 +874,9 @@ public function testIsAll() { $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; $_SERVER['REQUEST_METHOD'] = 'GET'; - $this->assertTrue($request->isAll(array('ajax', 'get'))); - $this->assertFalse($request->isAll(array('post', 'get'))); - $this->assertFalse($request->isAll(array('ajax', 'post'))); + $this->assertTrue($request->isAll(['ajax', 'get'])); + $this->assertFalse($request->isAll(['post', 'get'])); + $this->assertFalse($request->isAll(['ajax', 'post'])); } /** @@ -929,16 +929,16 @@ public function testSubdomain() { $_SERVER['HTTP_HOST'] = 'something.example.com'; $request = new CakeRequest('some/path'); - $this->assertEquals(array('something'), $request->subdomains()); + $this->assertEquals(['something'], $request->subdomains()); $_SERVER['HTTP_HOST'] = 'www.something.example.com'; - $this->assertEquals(array('www', 'something'), $request->subdomains()); + $this->assertEquals(['www', 'something'], $request->subdomains()); $_SERVER['HTTP_HOST'] = 'www.something.example.co.uk'; - $this->assertEquals(array('www', 'something'), $request->subdomains(2)); + $this->assertEquals(['www', 'something'], $request->subdomains(2)); $_SERVER['HTTP_HOST'] = 'example.co.uk'; - $this->assertEquals(array(), $request->subdomains(2)); + $this->assertEquals([], $request->subdomains(2)); } /** @@ -1026,7 +1026,7 @@ public function testIsSsl() { */ public function testMagicget() { $request = new CakeRequest('some/path'); - $request->params = array('controller' => 'posts', 'action' => 'view', 'plugin' => 'blogs'); + $request->params = ['controller' => 'posts', 'action' => 'view', 'plugin' => 'blogs']; $this->assertEquals('posts', $request->controller); $this->assertEquals('view', $request->action); @@ -1041,12 +1041,12 @@ public function testMagicget() { */ public function testMagicisset() { $request = new CakeRequest('some/path'); - $request->params = array( + $request->params = [ 'controller' => 'posts', 'action' => 'view', 'plugin' => 'blogs', - 'named' => array() - ); + 'named' => [] + ]; $this->assertTrue(isset($request->controller)); $this->assertFalse(isset($request->notthere)); @@ -1061,7 +1061,7 @@ public function testMagicisset() { */ public function testArrayAccess() { $request = new CakeRequest('some/path'); - $request->params = array('controller' => 'posts', 'action' => 'view', 'plugin' => 'blogs'); + $request->params = ['controller' => 'posts', 'action' => 'view', 'plugin' => 'blogs']; $this->assertEquals('posts', $request['controller']); @@ -1081,7 +1081,7 @@ public function testArrayAccess() { $request = new CakeRequest('some/path?one=something&two=else'); $this->assertTrue(isset($request['url']['one'])); - $request->data = array('Post' => array('title' => 'something')); + $request->data = ['Post' => ['title' => 'something']]; $this->assertEquals('something', $request['data']['Post']['title']); } @@ -1092,7 +1092,7 @@ public function testArrayAccess() { */ public function testAddDetector() { $request = new CakeRequest('some/path'); - $request->addDetector('compare', array('env' => 'TEST_VAR', 'value' => 'something')); + $request->addDetector('compare', ['env' => 'TEST_VAR', 'value' => 'something']); $_SERVER['TEST_VAR'] = 'something'; $this->assertTrue($request->is('compare'), 'Value match failed.'); @@ -1100,7 +1100,7 @@ public function testAddDetector() { $_SERVER['TEST_VAR'] = 'wrong'; $this->assertFalse($request->is('compare'), 'Value mis-match failed.'); - $request->addDetector('compareCamelCase', array('env' => 'TEST_VAR', 'value' => 'foo')); + $request->addDetector('compareCamelCase', ['env' => 'TEST_VAR', 'value' => 'foo']); $_SERVER['TEST_VAR'] = 'foo'; $this->assertTrue($request->is('compareCamelCase'), 'Value match failed.'); @@ -1112,23 +1112,23 @@ public function testAddDetector() { $this->assertFalse($request->is('comparecamelcase'), 'detectors should be case insensitive'); $this->assertFalse($request->is('COMPARECAMELCASE'), 'detectors should be case insensitive'); - $request->addDetector('banana', array('env' => 'TEST_VAR', 'pattern' => '/^ban.*$/')); + $request->addDetector('banana', ['env' => 'TEST_VAR', 'pattern' => '/^ban.*$/']); $_SERVER['TEST_VAR'] = 'banana'; $this->assertTrue($request->isBanana()); $_SERVER['TEST_VAR'] = 'wrong value'; $this->assertFalse($request->isBanana()); - $request->addDetector('mobile', array('options' => array('Imagination'))); + $request->addDetector('mobile', ['options' => ['Imagination']]); $_SERVER['HTTP_USER_AGENT'] = 'Imagination land'; $this->assertTrue($request->isMobile()); $_SERVER['HTTP_USER_AGENT'] = 'iPhone 3.0'; $this->assertTrue($request->isMobile()); - $request->addDetector('callme', array('env' => 'TEST_VAR', 'callback' => array($this, 'detectCallback'))); + $request->addDetector('callme', ['env' => 'TEST_VAR', 'callback' => [$this, 'detectCallback']]); - $request->addDetector('index', array('param' => 'action', 'value' => 'index')); + $request->addDetector('index', ['param' => 'action', 'value' => 'index']); $request->params['action'] = 'index'; $this->assertTrue($request->isIndex()); @@ -1141,7 +1141,7 @@ public function testAddDetector() { $request->return = false; $this->assertFalse($request->isCallMe()); - $request->addDetector('extension', array('param' => 'ext', 'options' => array('pdf', 'png', 'txt'))); + $request->addDetector('extension', ['param' => 'ext', 'options' => ['pdf', 'png', 'txt']]); $request->params['ext'] = 'pdf'; $this->assertTrue($request->is('extension')); @@ -1188,9 +1188,9 @@ public function testAccepts() { $request = new CakeRequest('/', false); $result = $request->accepts(); - $expected = array( + $expected = [ 'text/xml', 'application/xhtml+xml', 'text/html', 'text/plain', 'image/png', 'application/xml' - ); + ]; $this->assertEquals($expected, $result, 'Content types differ.'); $result = $request->accepts('text/html'); @@ -1209,9 +1209,9 @@ public function testAcceptWithWhitespace() { $_SERVER['HTTP_ACCEPT'] = 'text/xml , text/html , text/plain,image/png'; $request = new CakeRequest('/', false); $result = $request->accepts(); - $expected = array( + $expected = [ 'text/xml', 'text/html', 'text/plain', 'image/png' - ); + ]; $this->assertEquals($expected, $result, 'Content types differ.'); $this->assertTrue($request->accepts('text/html')); @@ -1226,7 +1226,7 @@ public function testAcceptWithQvalueSorting() { $_SERVER['HTTP_ACCEPT'] = 'text/html;q=0.8,application/json;q=0.7,application/xml;q=1.0'; $request = new CakeRequest('/', false); $result = $request->accepts(); - $expected = array('application/xml', 'text/html', 'application/json'); + $expected = ['application/xml', 'text/html', 'application/json']; $this->assertEquals($expected, $result); } @@ -1239,11 +1239,11 @@ public function testParseAcceptWithQValue() { $_SERVER['HTTP_ACCEPT'] = 'text/html;q=0.8,application/json;q=0.7,application/xml;q=1.0,image/png'; $request = new CakeRequest('/', false); $result = $request->parseAccept(); - $expected = array( - '1.0' => array('application/xml', 'image/png'), - '0.8' => array('text/html'), - '0.7' => array('application/json'), - ); + $expected = [ + '1.0' => ['application/xml', 'image/png'], + '0.8' => ['text/html'], + '0.7' => ['application/json'], + ]; $this->assertEquals($expected, $result); } @@ -1257,9 +1257,9 @@ public function testParseAcceptNoQValues() { $request = new CakeRequest('/', false); $result = $request->parseAccept(); - $expected = array( - '1.0' => array('application/json', 'text/plain', '*/*'), - ); + $expected = [ + '1.0' => ['application/json', 'text/plain', '*/*'], + ]; $this->assertEquals($expected, $result); } @@ -1273,9 +1273,9 @@ public function testParseAcceptIgnoreAcceptExtensions() { $request = new CakeRequest('/', false); $result = $request->parseAccept(); - $expected = array( - '1.0' => array('application/json', 'text/plain', '*/*'), - ); + $expected = [ + '1.0' => ['application/json', 'text/plain', '*/*'], + ]; $this->assertEquals($expected, $result); } @@ -1290,11 +1290,11 @@ public function testParseAcceptInvalidSyntax() { $_SERVER['HTTP_ACCEPT'] = 'text/html,application/xhtml+xml,application/xml;image/png,image/jpeg,image/*;q=0.9,*/*;q=0.8'; $request = new CakeRequest('/', false); $result = $request->parseAccept(); - $expected = array( - '1.0' => array('text/html', 'application/xhtml+xml', 'application/xml', 'image/jpeg'), - '0.9' => array('image/*'), - '0.8' => array('*/*'), - ); + $expected = [ + '1.0' => ['text/html', 'application/xhtml+xml', 'application/xml', 'image/jpeg'], + '0.9' => ['image/*'], + '0.8' => ['*/*'], + ]; $this->assertEquals($expected, $result); } @@ -1488,12 +1488,12 @@ public function testBaseUrlWithNoModRewrite() { $_SERVER['PHP_SELF'] = '/cake/index.php/posts/index'; $_SERVER['REQUEST_URI'] = '/cake/index.php/posts/index'; - Configure::write('App', array( + Configure::write('App', [ 'dir' => APP_DIR, 'webroot' => WEBROOT_DIR, 'base' => false, 'baseUrl' => '/cake/index.php' - )); + ]); $request = new CakeRequest(); $this->assertEquals('/cake/index.php', $request->base); @@ -1610,21 +1610,21 @@ public function testBaseUrlNoRewriteWebrootIndex() { * @return void */ public function testGetParamsWithDot() { - $_GET = array(); + $_GET = []; $_GET['/posts/index/add_add'] = ''; $_SERVER['PHP_SELF'] = '/app/webroot/index.php'; $_SERVER['REQUEST_URI'] = '/posts/index/add.add'; $request = new CakeRequest(); $this->assertEquals('', $request->base); - $this->assertEquals(array(), $request->query); + $this->assertEquals([], $request->query); - $_GET = array(); + $_GET = []; $_GET['/cake_dev/posts/index/add_add'] = ''; $_SERVER['PHP_SELF'] = '/cake_dev/app/webroot/index.php'; $_SERVER['REQUEST_URI'] = '/cake_dev/posts/index/add.add'; $request = new CakeRequest(); $this->assertEquals('/cake_dev', $request->base); - $this->assertEquals(array(), $request->query); + $this->assertEquals([], $request->query); } /** @@ -1633,21 +1633,21 @@ public function testGetParamsWithDot() { * @return void */ public function testGetParamWithUrlencodedElement() { - $_GET = array(); + $_GET = []; $_GET['/posts/add/∂∂'] = ''; $_SERVER['PHP_SELF'] = '/app/webroot/index.php'; $_SERVER['REQUEST_URI'] = '/posts/add/%E2%88%82%E2%88%82'; $request = new CakeRequest(); $this->assertEquals('', $request->base); - $this->assertEquals(array(), $request->query); + $this->assertEquals([], $request->query); - $_GET = array(); + $_GET = []; $_GET['/cake_dev/posts/add/∂∂'] = ''; $_SERVER['PHP_SELF'] = '/cake_dev/app/webroot/index.php'; $_SERVER['REQUEST_URI'] = '/cake_dev/posts/add/%E2%88%82%E2%88%82'; $request = new CakeRequest(); $this->assertEquals('/cake_dev', $request->base); - $this->assertEquals(array(), $request->query); + $this->assertEquals([], $request->query); } /** @@ -1656,17 +1656,17 @@ public function testGetParamWithUrlencodedElement() { * @return array Environment array */ public static function environmentGenerator() { - return array( - array( + return [ + [ 'IIS - No rewrite base path', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'SCRIPT_NAME' => '/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', @@ -1678,49 +1678,49 @@ public static function environmentGenerator() { 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/index.php', - ), - ), - array( + ], + ], + [ 'base' => '/index.php', 'webroot' => '/app/webroot/', 'url' => '' - ), - ), - array( + ], + ], + [ 'IIS - No rewrite with path, no PHP_SELF', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/index.php?', 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'QUERY_STRING' => '/posts/add', 'REQUEST_URI' => '/index.php?/posts/add', 'PHP_SELF' => '', 'URL' => '/index.php?/posts/add', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', - 'argv' => array('/posts/add'), + 'argv' => ['/posts/add'], 'argc' => 1 - ), - ), - array( + ], + ], + [ 'url' => 'posts/add', 'base' => '/index.php?', 'webroot' => '/app/webroot/' - ) - ), - array( + ] + ], + [ 'IIS - No rewrite sub dir 2', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot', - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '', @@ -1729,27 +1729,27 @@ public static function environmentGenerator() { 'SCRIPT_FILENAME' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/site/index.php', - 'argv' => array(), + 'argv' => [], 'argc' => 0 - ), - ), - array( + ], + ], + [ 'url' => '', 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/' - ), - ), - array( + ], + ], + [ 'IIS - No rewrite sub dir 2 with path', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot' - ), - 'GET' => array('/posts/add' => ''), - 'SERVER' => array( + ], + 'GET' => ['/posts/add' => ''], + 'SERVER' => [ 'SCRIPT_NAME' => '/site/index.php', 'PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot', 'QUERY_STRING' => '/posts/add', @@ -1758,26 +1758,26 @@ public static function environmentGenerator() { 'ORIG_PATH_TRANSLATED' => 'C:\\Inetpub\\wwwroot\\site\\index.php', 'DOCUMENT_ROOT' => 'C:\\Inetpub\\wwwroot', 'PHP_SELF' => '/site/index.php/posts/add', - 'argv' => array('/posts/add'), + 'argv' => ['/posts/add'], 'argc' => 1 - ), - ), - array( + ], + ], + [ 'url' => 'posts/add', 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/' - ) - ), - array( + ] + ], + [ 'Apache - No rewrite, document root set to webroot, requesting path', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'QUERY_STRING' => '', @@ -1785,24 +1785,24 @@ public static function environmentGenerator() { 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '/posts/index', 'PHP_SELF' => '/index.php/posts/index', - ), - ), - array( + ], + ], + [ 'url' => 'posts/index', 'base' => '/index.php', 'webroot' => '/' - ), - ), - array( + ], + ], + [ 'Apache - No rewrite, document root set to webroot, requesting root', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/index.php', 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', 'QUERY_STRING' => '', @@ -1810,24 +1810,24 @@ public static function environmentGenerator() { 'SCRIPT_NAME' => '/index.php', 'PATH_INFO' => '', 'PHP_SELF' => '/index.php', - ), - ), - array( + ], + ], + [ 'url' => '', 'base' => '/index.php', 'webroot' => '/' - ), - ), - array( + ], + ], + [ 'Apache - No rewrite, document root set above top level cake dir, requesting path', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', @@ -1835,49 +1835,49 @@ public static function environmentGenerator() { 'SCRIPT_NAME' => '/site/index.php', 'PATH_INFO' => '/posts/index', 'PHP_SELF' => '/site/index.php/posts/index', - ), - ), - array( + ], + ], + [ 'url' => 'posts/index', 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/', - ), - ), - array( + ], + ], + [ 'Apache - No rewrite, document root set above top level cake dir, request root, no PATH_INFO', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', 'REQUEST_URI' => '/site/index.php/', 'SCRIPT_NAME' => '/site/index.php', 'PHP_SELF' => '/site/index.php/', - ), - ), - array( + ], + ], + [ 'url' => '', 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/', - ), - ), - array( + ], + ], + [ 'Apache - No rewrite, document root set above top level cake dir, request path, with GET', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => '/site/index.php', 'dir' => 'app', 'webroot' => 'webroot' - ), - 'GET' => array('a' => 'b', 'c' => 'd'), - 'SERVER' => array( + ], + 'GET' => ['a' => 'b', 'c' => 'd'], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', @@ -1886,49 +1886,49 @@ public static function environmentGenerator() { 'PATH_INFO' => '/posts/index', 'PHP_SELF' => '/site/index.php/posts/index', 'QUERY_STRING' => 'a=b&c=d' - ), - ), - array( - 'urlParams' => array('a' => 'b', 'c' => 'd'), + ], + ], + [ + 'urlParams' => ['a' => 'b', 'c' => 'd'], 'url' => 'posts/index', 'base' => '/site/index.php', 'webroot' => '/site/app/webroot/', - ), - ), - array( + ], + ], + [ 'Apache - w/rewrite, document root set above top level cake dir, request root, no PATH_INFO', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => false, 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', 'REQUEST_URI' => '/site/', 'SCRIPT_NAME' => '/site/app/webroot/index.php', 'PHP_SELF' => '/site/app/webroot/index.php', - ), - ), - array( + ], + ], + [ 'url' => '', 'base' => '/site', 'webroot' => '/site/', - ), - ), - array( + ], + ], + [ 'Apache - w/rewrite, document root above top level cake dir, request root, no PATH_INFO/REQUEST_URI', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => false, 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', @@ -1936,24 +1936,24 @@ public static function environmentGenerator() { 'PHP_SELF' => '/site/app/webroot/index.php', 'PATH_INFO' => null, 'REQUEST_URI' => null, - ), - ), - array( + ], + ], + [ 'url' => '', 'base' => '/site', 'webroot' => '/site/', - ), - ), - array( + ], + ], + [ 'Apache - w/rewrite, document root set to webroot, request root, no PATH_INFO/REQUEST_URI', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => false, 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', @@ -1961,49 +1961,49 @@ public static function environmentGenerator() { 'PHP_SELF' => '/index.php', 'PATH_INFO' => null, 'REQUEST_URI' => null, - ), - ), - array( + ], + ], + [ 'url' => '', 'base' => '', 'webroot' => '/', - ), - ), - array( + ], + ], + [ 'Apache - w/rewrite, document root set above top level cake dir, request root, absolute REQUEST_URI', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => false, 'dir' => 'app', 'webroot' => 'webroot' - ), - 'SERVER' => array( + ], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/index.php', 'REQUEST_URI' => '/site/posts/index', 'SCRIPT_NAME' => '/site/app/webroot/index.php', 'PHP_SELF' => '/site/app/webroot/index.php', - ), - ), - array( + ], + ], + [ 'url' => 'posts/index', 'base' => '/site', 'webroot' => '/site/', - ), - ), - array( + ], + ], + [ 'Nginx - w/rewrite, document root set to webroot, request root, no PATH_INFO', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => false, 'dir' => 'app', 'webroot' => 'webroot' - ), - 'GET' => array('/posts/add' => ''), - 'SERVER' => array( + ], + 'GET' => ['/posts/add' => ''], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents/site/app/webroot', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', @@ -2012,26 +2012,26 @@ public static function environmentGenerator() { 'PHP_SELF' => '/index.php', 'PATH_INFO' => null, 'REQUEST_URI' => '/posts/add', - ), - ), - array( + ], + ], + [ 'url' => 'posts/add', 'base' => '', 'webroot' => '/', - 'urlParams' => array() - ), - ), - array( + 'urlParams' => [] + ], + ], + [ 'Nginx - w/rewrite, document root set above top level cake dir, request root, no PATH_INFO, base parameter set', - array( - 'App' => array( + [ + 'App' => [ 'base' => false, 'baseUrl' => false, 'dir' => 'app', 'webroot' => 'webroot' - ), - 'GET' => array('/site/posts/add' => ''), - 'SERVER' => array( + ], + 'GET' => ['/site/posts/add' => ''], + 'SERVER' => [ 'SERVER_NAME' => 'localhost', 'DOCUMENT_ROOT' => '/Library/WebServer/Documents', 'SCRIPT_FILENAME' => '/Library/WebServer/Documents/site/app/webroot/index.php', @@ -2040,16 +2040,16 @@ public static function environmentGenerator() { 'PHP_SELF' => '/site/app/webroot/index.php', 'PATH_INFO' => null, 'REQUEST_URI' => '/site/posts/add', - ), - ), - array( + ], + ], + [ 'url' => 'posts/add', 'base' => '/site', 'webroot' => '/site/', - 'urlParams' => array() - ), - ), - ); + 'urlParams' => [] + ], + ], + ]; } /** @@ -2062,7 +2062,7 @@ public static function environmentGenerator() { * @return void */ public function testEnvironmentDetection($name, $env, $expected) { - $_GET = array(); + $_GET = []; $this->_loadEnvironment($env); $request = new CakeRequest(); @@ -2080,7 +2080,7 @@ public function testEnvironmentDetection($name, $env, $expected) { * @return void */ public function testQuery() { - $_GET = array(); + $_GET = []; $_GET['foo'] = 'bar'; $request = new CakeRequest(); @@ -2098,13 +2098,13 @@ public function testQuery() { * @return void */ public function testQueryWithArray() { - $_GET = array(); - $_GET['test'] = array('foo', 'bar'); + $_GET = []; + $_GET['test'] = ['foo', 'bar']; $request = new CakeRequest(); $result = $request->query('test'); - $this->assertEquals(array('foo', 'bar'), $result); + $this->assertEquals(['foo', 'bar'], $result); $result = $request->query('test.1'); $this->assertEquals('bar', $result); @@ -2119,11 +2119,11 @@ public function testQueryWithArray() { * @return void */ public function testDataReading() { - $_POST['data'] = array( - 'Model' => array( + $_POST['data'] = [ + 'Model' => [ 'field' => 'value' - ) - ); + ] + ]; $request = new CakeRequest('posts/index'); $result = $request->data('Model'); $this->assertEquals($_POST['data']['Model'], $result); @@ -2138,11 +2138,11 @@ public function testDataReading() { * @return void */ public function testDataWriting() { - $_POST['data'] = array( - 'Model' => array( + $_POST['data'] = [ + 'Model' => [ 'field' => 'value' - ) - ); + ] + ]; $request = new CakeRequest('posts/index'); $result = $request->data('Model.new_value', 'new value'); $this->assertSame($result, $request, 'Return was not $this'); @@ -2182,18 +2182,18 @@ public function testDataWritingFalsey() { */ public function testParamReading($toRead, $expected) { $request = new CakeRequest('/'); - $request->addParams(array( + $request->addParams([ 'action' => 'index', 'foo' => 'bar', - 'baz' => array( - 'a' => array( + 'baz' => [ + 'a' => [ 'b' => 'c', - ), - ), + ], + ], 'admin' => true, 'truthy' => 1, 'zero' => '0', - )); + ]); $this->assertEquals($expected, $request->param($toRead)); } @@ -2203,40 +2203,40 @@ public function testParamReading($toRead, $expected) { * @return array */ public function paramReadingDataProvider() { - return array( - array( + return [ + [ 'action', 'index', - ), - array( + ], + [ 'baz', - array( - 'a' => array( + [ + 'a' => [ 'b' => 'c', - ), - ), - ), - array( + ], + ], + ], + [ 'baz.a.b', 'c', - ), - array( + ], + [ 'does_not_exist', false, - ), - array( + ], + [ 'admin', true, - ), - array( + ], + [ 'truthy', 1, - ), - array( + ], + [ 'zero', '0', - ), - ); + ], + ]; } /** @@ -2246,9 +2246,9 @@ public function paramReadingDataProvider() { */ public function testParamWriting() { $request = new CakeRequest('/'); - $request->addParams(array( + $request->addParams([ 'action' => 'index', - )); + ]); $this->assertInstanceOf('CakeRequest', $request->param('some', 'thing'), 'Method has not returned $this'); @@ -2278,22 +2278,22 @@ public function testAcceptLanguage() { // Weird language $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'inexistent,en-ca'; $result = CakeRequest::acceptLanguage(); - $this->assertEquals(array('inexistent', 'en-ca'), $result, 'Languages do not match'); + $this->assertEquals(['inexistent', 'en-ca'], $result, 'Languages do not match'); // No qualifier $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx,en_ca'; $result = CakeRequest::acceptLanguage(); - $this->assertEquals(array('es-mx', 'en-ca'), $result, 'Languages do not match'); + $this->assertEquals(['es-mx', 'en-ca'], $result, 'Languages do not match'); // With qualifier $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en-US,en;q=0.8,pt-BR;q=0.6,pt;q=0.4'; $result = CakeRequest::acceptLanguage(); - $this->assertEquals(array('en-us', 'en', 'pt-br', 'pt'), $result, 'Languages do not match'); + $this->assertEquals(['en-us', 'en', 'pt-br', 'pt'], $result, 'Languages do not match'); // With spaces $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'da, en-gb;q=0.8, en;q=0.7'; $result = CakeRequest::acceptLanguage(); - $this->assertEquals(array('da', 'en-gb', 'en'), $result, 'Languages do not match'); + $this->assertEquals(['da', 'en-gb', 'en'], $result, 'Languages do not match'); // Checking if requested $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'es_mx,en_ca'; @@ -2319,7 +2319,7 @@ public function testAcceptLanguage() { */ public function testHere() { Configure::write('App.base', '/base_path'); - $_GET = array('test' => 'value'); + $_GET = ['test' => 'value']; $request = new CakeRequest('/posts/add/1/name:value'); $result = $request->here(); @@ -2343,7 +2343,7 @@ public function testHere() { */ public function testHereWithSpaceInUrl() { Configure::write('App.base', ''); - $_GET = array('/admin/settings/settings/prefix/Access_Control' => ''); + $_GET = ['/admin/settings/settings/prefix/Access_Control' => '']; $request = new CakeRequest('/admin/settings/settings/prefix/Access%20Control'); $result = $request->here(); @@ -2372,7 +2372,7 @@ public function testSetInput() { * @return void */ public function testInput() { - $request = $this->getMock('CakeRequest', array('_readInput')); + $request = $this->getMock('CakeRequest', ['_readInput']); $request->expects($this->once())->method('_readInput') ->will($this->returnValue('I came from stdin')); @@ -2386,12 +2386,12 @@ public function testInput() { * @return void */ public function testInputDecode() { - $request = $this->getMock('CakeRequest', array('_readInput')); + $request = $this->getMock('CakeRequest', ['_readInput']); $request->expects($this->once())->method('_readInput') ->will($this->returnValue('{"name":"value"}')); $result = $request->input('json_decode'); - $this->assertEquals(array('name' => 'value'), (array)$result); + $this->assertEquals(['name' => 'value'], (array)$result); } /** @@ -2407,11 +2407,11 @@ public function testInputDecodeExtraParams() { XML; - $request = $this->getMock('CakeRequest', array('_readInput')); + $request = $this->getMock('CakeRequest', ['_readInput']); $request->expects($this->once())->method('_readInput') ->will($this->returnValue($xml)); - $result = $request->input('Xml::build', array('return' => 'domdocument')); + $result = $request->input('Xml::build', ['return' => 'domdocument']); $this->assertInstanceOf('DOMDocument', $result); $this->assertEquals( 'Test', @@ -2426,21 +2426,21 @@ public function testInputDecodeExtraParams() { */ public function testIsRequested() { $request = new CakeRequest('/posts/index'); - $request->addParams(array( + $request->addParams([ 'controller' => 'posts', 'action' => 'index', 'plugin' => null, 'requested' => 1 - )); + ]); $this->assertTrue($request->is('requested')); $this->assertTrue($request->isRequested()); $request = new CakeRequest('/posts/index'); - $request->addParams(array( + $request->addParams([ 'controller' => 'posts', 'action' => 'index', 'plugin' => null, - )); + ]); $this->assertFalse($request->is('requested')); $this->assertFalse($request->isRequested()); } @@ -2454,10 +2454,10 @@ public function testAllowMethod() { $_SERVER['REQUEST_METHOD'] = 'PUT'; $request = new CakeRequest('/posts/edit/1'); - $this->assertTrue($request->allowMethod(array('put'))); + $this->assertTrue($request->allowMethod(['put'])); // BC check - $this->assertTrue($request->onlyAllow(array('put'))); + $this->assertTrue($request->onlyAllow(['put'])); $_SERVER['REQUEST_METHOD'] = 'DELETE'; $this->assertTrue($request->allowMethod('post', 'delete')); @@ -2479,7 +2479,7 @@ public function testAllowMethodException() { $request->allowMethod('POST', 'DELETE'); $this->fail('An expected exception has not been raised.'); } catch (MethodNotAllowedException $e) { - $this->assertEquals(array('Allow' => 'POST, DELETE'), $e->responseHeader()); + $this->assertEquals(['Allow' => 'POST, DELETE'], $e->responseHeader()); } $this->expectException('MethodNotAllowedException'); @@ -2493,12 +2493,12 @@ public function testAllowMethodException() { * @return void */ public function testMethodOverrideEmptyData() { - $_POST = array('_method' => 'GET', 'foo' => 'bar'); + $_POST = ['_method' => 'GET', 'foo' => 'bar']; $_SERVER['REQUEST_METHOD'] = 'PUT'; $request = new CakeRequest('/posts/edit/1'); $this->assertEmpty($request->data); - $_POST = array('foo' => 'bar'); + $_POST = ['foo' => 'bar']; $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'GET'; $request = new CakeRequest('/posts/edit/1'); $this->assertEmpty($request->data); diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index 5fdcb6192b..1dc7a1802d 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -56,27 +56,27 @@ public function testConstruct() { $this->assertEquals('text/html', $response->type()); $this->assertEquals(200, $response->statusCode()); - $options = array( + $options = [ 'body' => 'This is the body', 'charset' => 'my-custom-charset', 'type' => 'mp3', 'status' => '203' - ); + ]; $response = new CakeResponse($options); $this->assertEquals('This is the body', $response->body()); $this->assertEquals('my-custom-charset', $response->charset()); $this->assertEquals('audio/mpeg', $response->type()); $this->assertEquals(203, $response->statusCode()); - $options = array( + $options = [ 'body' => 'This is the body', 'charset' => 'my-custom-charset', 'type' => 'mp3', 'status' => '422', - 'statusCodes' => array( + 'statusCodes' => [ 422 => 'Unprocessable Entity' - ) - ); + ] + ]; $response = new CakeResponse($options); $this->assertEquals($options['body'], $response->body()); $this->assertEquals($options['charset'], $response->charset()); @@ -143,7 +143,7 @@ public function testType() { $this->assertEquals('application/vnd.wap.xhtml+xml', $response->type('xhtml-mobile')); $this->assertEquals('text/csv', $response->type('csv')); - $response->type(array('keynote' => 'application/keynote', 'bat' => 'application/bat')); + $response->type(['keynote' => 'application/keynote', 'bat' => 'application/bat']); $this->assertEquals('application/keynote', $response->type('keynote')); $this->assertEquals('application/bat', $response->type('bat')); @@ -157,49 +157,49 @@ public function testType() { */ public function testHeader() { $response = new CakeResponse(); - $headers = array(); + $headers = []; $this->assertEquals($headers, $response->header()); $response->header('Location', 'http://example.com'); - $headers += array('Location' => 'http://example.com'); + $headers += ['Location' => 'http://example.com']; $this->assertEquals($headers, $response->header()); // Headers with the same name are overwritten $response->header('Location', 'http://example2.com'); - $headers = array('Location' => 'http://example2.com'); + $headers = ['Location' => 'http://example2.com']; $this->assertEquals($headers, $response->header()); $response->header('Date', null); - $headers += array('Date' => null); + $headers += ['Date' => null]; $this->assertEquals($headers, $response->header()); - $response->header(array('WWW-Authenticate' => 'Negotiate')); - $headers += array('WWW-Authenticate' => 'Negotiate'); + $response->header(['WWW-Authenticate' => 'Negotiate']); + $headers += ['WWW-Authenticate' => 'Negotiate']; $this->assertEquals($headers, $response->header()); - $response->header(array('WWW-Authenticate' => 'Not-Negotiate')); + $response->header(['WWW-Authenticate' => 'Not-Negotiate']); $headers['WWW-Authenticate'] = 'Not-Negotiate'; $this->assertEquals($headers, $response->header()); - $response->header(array('Age' => 12, 'Allow' => 'GET, HEAD')); - $headers += array('Age' => 12, 'Allow' => 'GET, HEAD'); + $response->header(['Age' => 12, 'Allow' => 'GET, HEAD']); + $headers += ['Age' => 12, 'Allow' => 'GET, HEAD']; $this->assertEquals($headers, $response->header()); // String headers are allowed $response->header('Content-Language: da'); - $headers += array('Content-Language' => 'da'); + $headers += ['Content-Language' => 'da']; $this->assertEquals($headers, $response->header()); $response->header('Content-Language: da'); - $headers += array('Content-Language' => 'da'); + $headers += ['Content-Language' => 'da']; $this->assertEquals($headers, $response->header()); - $response->header(array('Content-Encoding: gzip', 'Vary: *', 'Pragma' => 'no-cache')); - $headers += array('Content-Encoding' => 'gzip', 'Vary' => '*', 'Pragma' => 'no-cache'); + $response->header(['Content-Encoding: gzip', 'Vary: *', 'Pragma' => 'no-cache']); + $headers += ['Content-Encoding' => 'gzip', 'Vary' => '*', 'Pragma' => 'no-cache']; $this->assertEquals($headers, $response->header()); - $response->header('Access-Control-Allow-Origin', array('domain1', 'domain2')); - $headers += array('Access-Control-Allow-Origin' => array('domain1', 'domain2')); + $response->header('Access-Control-Allow-Origin', ['domain1', 'domain2']); + $headers += ['Access-Control-Allow-Origin' => ['domain1', 'domain2']]; $this->assertEquals($headers, $response->header()); } @@ -209,12 +209,12 @@ public function testHeader() { * @return void */ public function testSend() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); - $response->header(array( + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent', '_setCookies']); + $response->header([ 'Content-Language' => 'es', 'WWW-Authenticate' => 'Negotiate', - 'Access-Control-Allow-Origin' => array('domain1', 'domain2'), - )); + 'Access-Control-Allow-Origin' => ['domain1', 'domain2'], + ]); $response->body('the response body'); $response->expects($this->once())->method('_sendContent')->with('the response body'); $response->expects($this->at(0))->method('_setCookies'); @@ -241,13 +241,13 @@ public function testSend() { * @return array */ public static function charsetTypeProvider() { - return array( - array('mp3', 'audio/mpeg'), - array('js', 'application/javascript; charset=UTF-8'), - array('json', 'application/json; charset=UTF-8'), - array('xml', 'application/xml; charset=UTF-8'), - array('txt', 'text/plain; charset=UTF-8'), - ); + return [ + ['mp3', 'audio/mpeg'], + ['js', 'application/javascript; charset=UTF-8'], + ['json', 'application/json; charset=UTF-8'], + ['xml', 'application/xml; charset=UTF-8'], + ['txt', 'text/plain; charset=UTF-8'], + ]; } /** @@ -257,7 +257,7 @@ public static function charsetTypeProvider() { * @return void */ public function testSendChangingContentType($original, $expected) { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent', '_setCookies']); $response->type($original); $response->body('the response body'); $response->expects($this->once())->method('_sendContent')->with('the response body'); @@ -277,7 +277,7 @@ public function testSendChangingContentType($original, $expected) { * @return void */ public function testSendChangingContentTypeWithoutCharset() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent', '_setCookies']); $response->type('js'); $response->charset(''); @@ -299,7 +299,7 @@ public function testSendChangingContentTypeWithoutCharset() { * @return void */ public function testSendWithLocation() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', '_setCookies')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent', '_setCookies']); $response->header('Location', 'http://www.example.com'); $response->expects($this->at(0))->method('_setCookies'); $response->expects($this->at(1)) @@ -318,11 +318,11 @@ public function testSendWithLocation() { */ public function testDisableCache() { $response = new CakeResponse(); - $expected = array( + $expected = [ 'Expires' => 'Mon, 26 Jul 1997 05:00:00 GMT', 'Last-Modified' => gmdate("D, d M Y H:i:s") . " GMT", 'Cache-Control' => 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0' - ); + ]; $response->disableCache(); $this->assertEquals($expected, $response->header()); } @@ -337,36 +337,36 @@ public function testCache() { $since = time(); $time = new DateTime('+1 day', new DateTimeZone('UTC')); $response->expires('+1 day'); - $expected = array( + $expected = [ 'Date' => gmdate("D, j M Y G:i:s ", $since) . 'GMT', 'Last-Modified' => gmdate("D, j M Y H:i:s ", $since) . 'GMT', 'Expires' => $time->format('D, j M Y H:i:s') . ' GMT', 'Cache-Control' => 'public, max-age=' . ($time->format('U') - time()) - ); + ]; $response->cache($since); $this->assertEquals($expected, $response->header()); $response = new CakeResponse(); $since = time(); $time = '+5 day'; - $expected = array( + $expected = [ 'Date' => gmdate("D, j M Y G:i:s ", $since) . 'GMT', 'Last-Modified' => gmdate("D, j M Y H:i:s ", $since) . 'GMT', 'Expires' => gmdate("D, j M Y H:i:s", strtotime($time)) . " GMT", 'Cache-Control' => 'public, max-age=' . (strtotime($time) - time()) - ); + ]; $response->cache($since, $time); $this->assertEquals($expected, $response->header()); $response = new CakeResponse(); $since = time(); $time = time(); - $expected = array( + $expected = [ 'Date' => gmdate("D, j M Y G:i:s ", $since) . 'GMT', 'Last-Modified' => gmdate("D, j M Y H:i:s ", $since) . 'GMT', 'Expires' => gmdate("D, j M Y H:i:s", $time) . " GMT", 'Cache-Control' => 'public, max-age=0' - ); + ]; $response->cache($since, $time); $this->assertEquals($expected, $response->header()); } @@ -411,38 +411,38 @@ public function testHttpCodes() { $this->assertEquals(41, count($result)); $result = $response->httpCodes(100); - $expected = array(100 => 'Continue'); + $expected = [100 => 'Continue']; $this->assertEquals($expected, $result); - $codes = array( + $codes = [ 381 => 'Unicorn Moved', 555 => 'Unexpected Minotaur' - ); + ]; $result = $response->httpCodes($codes); $this->assertTrue($result); $this->assertEquals(43, count($response->httpCodes())); $result = $response->httpCodes(381); - $expected = array(381 => 'Unicorn Moved'); + $expected = [381 => 'Unicorn Moved']; $this->assertEquals($expected, $result); - $codes = array(404 => 'Sorry Bro'); + $codes = [404 => 'Sorry Bro']; $result = $response->httpCodes($codes); $this->assertTrue($result); $this->assertEquals(43, count($response->httpCodes())); $result = $response->httpCodes(404); - $expected = array(404 => 'Sorry Bro'); + $expected = [404 => 'Sorry Bro']; $this->assertEquals($expected, $result); //Throws exception - $response->httpCodes(array( + $response->httpCodes([ 0 => 'Nothing Here', -1 => 'Reverse Infinity', 12345 => 'Universal Password', 'Hello' => 'World' - )); + ]); } /** @@ -452,9 +452,9 @@ public function testHttpCodes() { */ public function testDownload() { $response = new CakeResponse(); - $expected = array( + $expected = [ 'Content-Disposition' => 'attachment; filename="myfile.mp3"' - ); + ]; $response->download('myfile.mp3'); $this->assertEquals($expected, $response->header()); } @@ -471,8 +471,8 @@ public function testMapType() { $this->assertEquals('xml', $response->mapType('text/xml')); $this->assertEquals('html', $response->mapType('*/*')); $this->assertEquals('csv', $response->mapType('application/vnd.ms-excel')); - $expected = array('json', 'xhtml', 'css'); - $result = $response->mapType(array('application/json', 'application/xhtml+xml', 'text/css')); + $expected = ['json', 'xhtml', 'css']; + $result = $response->mapType(['application/json', 'application/xhtml+xml', 'text/css']); $this->assertEquals($expected, $result); } @@ -520,7 +520,7 @@ public function testOutputCompressed() { * @return void */ public function testSendContentLength() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->body('the response body'); $response->expects($this->once())->method('_sendContent')->with('the response body'); $response->expects($this->at(0)) @@ -531,7 +531,7 @@ public function testSendContentLength() { ->method('_sendHeader')->with('Content-Length', strlen('the response body')); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $body = '長い長い長いSubjectの場合はfoldingするのが正しいんだけどいったいどうなるんだろう?'; $response->body($body); $response->expects($this->once())->method('_sendContent')->with($body); @@ -543,7 +543,7 @@ public function testSendContentLength() { ->method('_sendHeader')->with('Content-Length', 116); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', 'outputCompressed')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent', 'outputCompressed']); $body = '長い長い長いSubjectの場合はfoldingするのが正しいんだけどいったいどうなるんだろう?'; $response->body($body); $response->expects($this->once())->method('outputCompressed')->will($this->returnValue(true)); @@ -551,7 +551,7 @@ public function testSendContentLength() { $response->expects($this->exactly(2))->method('_sendHeader'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent', 'outputCompressed')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent', 'outputCompressed']); $body = 'hwy'; $response->body($body); $response->header('Content-Length', 1); @@ -561,7 +561,7 @@ public function testSendContentLength() { ->method('_sendHeader')->with('Content-Length', 1); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $body = 'content'; $response->statusCode(301); $response->body($body); @@ -570,10 +570,10 @@ public function testSendContentLength() { $response->send(); ob_start(); - $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $goofyOutput = 'I am goofily sending output in the controller'; echo $goofyOutput; - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $body = '長い長い長いSubjectの場合はfoldingするのが正しいんだけどいったいどうなるんだろう?'; $response->body($body); $response->expects($this->once())->method('_sendContent')->with($body); @@ -593,7 +593,7 @@ public function testSendContentLength() { * @return void */ public function testProtocol() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->protocol('HTTP/1.0'); $this->assertEquals('HTTP/1.0', $response->protocol()); $response->expects($this->at(0)) @@ -607,14 +607,14 @@ public function testProtocol() { * @return void */ public function testLength() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->length(100); $this->assertEquals(100, $response->length()); $response->expects($this->at(1)) ->method('_sendHeader')->with('Content-Length', 100); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->length(false); $this->assertFalse($response->length()); $response->expects($this->exactly(2)) @@ -628,7 +628,7 @@ public function testLength() { * @return void */ public function testUnmodifiedContent() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->body('This is a body'); $response->statusCode(204); $response->expects($this->once()) @@ -636,14 +636,14 @@ public function testUnmodifiedContent() { $response->send(); $this->assertFalse(array_key_exists('Content-Type', $response->header())); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->body('This is a body'); $response->statusCode(304); $response->expects($this->once()) ->method('_sendContent')->with(''); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->body('This is a body'); $response->statusCode(200); $response->expects($this->once()) @@ -657,7 +657,7 @@ public function testUnmodifiedContent() { * @return void */ public function testExpires() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $now = new DateTime('now', new DateTimeZone('America/Los_Angeles')); $response->expires($now); $now->setTimeZone(new DateTimeZone('UTC')); @@ -666,7 +666,7 @@ public function testExpires() { ->method('_sendHeader')->with('Expires', $now->format('D, j M Y H:i:s') . ' GMT'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $now = time(); $response->expires($now); $this->assertEquals(gmdate('D, j M Y H:i:s', $now) . ' GMT', $response->expires()); @@ -674,7 +674,7 @@ public function testExpires() { ->method('_sendHeader')->with('Expires', gmdate('D, j M Y H:i:s', $now) . ' GMT'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $time = new DateTime('+1 day', new DateTimeZone('UTC')); $response->expires('+1 day'); $this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->expires()); @@ -689,7 +689,7 @@ public function testExpires() { * @return void */ public function testModified() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $now = new DateTime('now', new DateTimeZone('America/Los_Angeles')); $response->modified($now); $now->setTimeZone(new DateTimeZone('UTC')); @@ -698,7 +698,7 @@ public function testModified() { ->method('_sendHeader')->with('Last-Modified', $now->format('D, j M Y H:i:s') . ' GMT'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $now = time(); $response->modified($now); $this->assertEquals(gmdate('D, j M Y H:i:s', $now) . ' GMT', $response->modified()); @@ -706,7 +706,7 @@ public function testModified() { ->method('_sendHeader')->with('Last-Modified', gmdate('D, j M Y H:i:s', $now) . ' GMT'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $time = new DateTime('+1 day', new DateTimeZone('UTC')); $response->modified('+1 day'); $this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified()); @@ -721,7 +721,7 @@ public function testModified() { * @return void */ public function testSharable() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $this->assertNull($response->sharable()); $response->sharable(true); $headers = $response->header(); @@ -730,7 +730,7 @@ public function testSharable() { ->method('_sendHeader')->with('Cache-Control', 'public'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->sharable(false); $headers = $response->header(); $this->assertEquals('private', $headers['Cache-Control']); @@ -738,7 +738,7 @@ public function testSharable() { ->method('_sendHeader')->with('Cache-Control', 'private'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->sharable(true); $headers = $response->header(); $this->assertEquals('public', $headers['Cache-Control']); @@ -770,7 +770,7 @@ public function testSharable() { * @return void */ public function testMaxAge() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $this->assertNull($response->maxAge()); $response->maxAge(3600); $this->assertEquals(3600, $response->maxAge()); @@ -780,7 +780,7 @@ public function testMaxAge() { ->method('_sendHeader')->with('Cache-Control', 'max-age=3600'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->maxAge(3600); $response->sharable(false); $headers = $response->header(); @@ -796,7 +796,7 @@ public function testMaxAge() { * @return void */ public function testSharedMaxAge() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $this->assertNull($response->maxAge()); $response->sharedMaxAge(3600); $this->assertEquals(3600, $response->sharedMaxAge()); @@ -806,7 +806,7 @@ public function testSharedMaxAge() { ->method('_sendHeader')->with('Cache-Control', 's-maxage=3600'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->sharedMaxAge(3600); $response->sharable(true); $headers = $response->header(); @@ -822,7 +822,7 @@ public function testSharedMaxAge() { * @return void */ public function testMustRevalidate() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $this->assertFalse($response->mustRevalidate()); $response->mustRevalidate(true); $this->assertTrue($response->mustRevalidate()); @@ -834,7 +834,7 @@ public function testMustRevalidate() { $response->mustRevalidate(false); $this->assertFalse($response->mustRevalidate()); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->sharedMaxAge(3600); $response->mustRevalidate(true); $headers = $response->header(); @@ -850,19 +850,19 @@ public function testMustRevalidate() { * @return void */ public function testVary() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->vary('Accept-encoding'); - $this->assertEquals(array('Accept-encoding'), $response->vary()); + $this->assertEquals(['Accept-encoding'], $response->vary()); $response->expects($this->at(1)) ->method('_sendHeader')->with('Vary', 'Accept-encoding'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); - $response->vary(array('Accept-language', 'Accept-encoding')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); + $response->vary(['Accept-language', 'Accept-encoding']); $response->expects($this->at(1)) ->method('_sendHeader')->with('Vary', 'Accept-language, Accept-encoding'); $response->send(); - $this->assertEquals(array('Accept-language', 'Accept-encoding'), $response->vary()); + $this->assertEquals(['Accept-language', 'Accept-encoding'], $response->vary()); } /** @@ -871,14 +871,14 @@ public function testVary() { * @return void */ public function testEtag() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->etag('something'); $this->assertEquals('"something"', $response->etag()); $response->expects($this->at(1)) ->method('_sendHeader')->with('Etag', '"something"'); $response->send(); - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->etag('something', true); $this->assertEquals('W/"something"', $response->etag()); $response->expects($this->at(1)) @@ -892,7 +892,7 @@ public function testEtag() { * @return void */ public function testNotModified() { - $response = $this->getMock('CakeResponse', array('_sendHeader', '_sendContent')); + $response = $this->getMock('CakeResponse', ['_sendHeader', '_sendContent']); $response->body('something'); $response->statusCode(200); $response->length(100); @@ -911,7 +911,7 @@ public function testNotModified() { */ public function testCheckNotModifiedByEtagStar() { $_SERVER['HTTP_IF_NONE_MATCH'] = '*'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', ['notModified']); $response->etag('something'); $response->expects($this->once())->method('notModified'); $response->checkNotModified(new CakeRequest); @@ -924,7 +924,7 @@ public function testCheckNotModifiedByEtagStar() { */ public function testCheckNotModifiedByEtagExact() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', ['notModified']); $response->etag('something', true); $response->expects($this->once())->method('notModified'); $this->assertTrue($response->checkNotModified(new CakeRequest)); @@ -938,7 +938,7 @@ public function testCheckNotModifiedByEtagExact() { public function testCheckNotModifiedByEtagAndTime() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', ['notModified']); $response->etag('something', true); $response->modified('2012-01-01 00:00:00'); $response->expects($this->once())->method('notModified'); @@ -953,7 +953,7 @@ public function testCheckNotModifiedByEtagAndTime() { public function testCheckNotModifiedByEtagAndTimeMismatch() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', ['notModified']); $response->etag('something', true); $response->modified('2012-01-01 00:00:01'); $response->expects($this->never())->method('notModified'); @@ -968,7 +968,7 @@ public function testCheckNotModifiedByEtagAndTimeMismatch() { public function testCheckNotModifiedByEtagMismatch() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something-else", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', ['notModified']); $response->etag('something', true); $response->modified('2012-01-01 00:00:00'); $response->expects($this->never())->method('notModified'); @@ -982,7 +982,7 @@ public function testCheckNotModifiedByEtagMismatch() { */ public function testCheckNotModifiedByTime() { $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', ['notModified']); $response->modified('2012-01-01 00:00:00'); $response->expects($this->once())->method('notModified'); $this->assertTrue($response->checkNotModified(new CakeRequest)); @@ -996,7 +996,7 @@ public function testCheckNotModifiedByTime() { public function testCheckNotModifiedNoHints() { $_SERVER['HTTP_IF_NONE_MATCH'] = 'W/"something", "other"'; $_SERVER['HTTP_IF_MODIFIED_SINCE'] = '2012-01-01 00:00:00'; - $response = $this->getMock('CakeResponse', array('notModified')); + $response = $this->getMock('CakeResponse', ['notModified']); $response->expects($this->never())->method('notModified'); $this->assertFalse($response->checkNotModified(new CakeRequest)); } @@ -1008,31 +1008,31 @@ public function testCheckNotModifiedNoHints() { */ public function testCookieSettings() { $response = new CakeResponse(); - $cookie = array( + $cookie = [ 'name' => 'CakeTestCookie[Testing]' - ); + ]; $response->cookie($cookie); - $expected = array( + $expected = [ 'name' => 'CakeTestCookie[Testing]', 'value' => '', 'expire' => 0, 'path' => '/', 'domain' => '', 'secure' => false, - 'httpOnly' => false); + 'httpOnly' => false]; $result = $response->cookie('CakeTestCookie[Testing]'); $this->assertEquals($expected, $result); - $cookie = array( + $cookie = [ 'name' => 'CakeTestCookie[Testing2]', 'value' => '[a,b,c]', 'expire' => 1000, 'path' => '/test', 'secure' => true - ); + ]; $response->cookie($cookie); - $expected = array( - 'CakeTestCookie[Testing]' => array( + $expected = [ + 'CakeTestCookie[Testing]' => [ 'name' => 'CakeTestCookie[Testing]', 'value' => '', 'expire' => 0, @@ -1040,8 +1040,8 @@ public function testCookieSettings() { 'domain' => '', 'secure' => false, 'httpOnly' => false - ), - 'CakeTestCookie[Testing2]' => array( + ], + 'CakeTestCookie[Testing2]' => [ 'name' => 'CakeTestCookie[Testing2]', 'value' => '[a,b,c]', 'expire' => 1000, @@ -1049,8 +1049,8 @@ public function testCookieSettings() { 'domain' => '', 'secure' => true, 'httpOnly' => false - ) - ); + ] + ]; $result = $response->cookie(); $this->assertEquals($expected, $result); @@ -1058,8 +1058,8 @@ public function testCookieSettings() { $cookie = $expected['CakeTestCookie[Testing]']; $cookie['value'] = 'test'; $response->cookie($cookie); - $expected = array( - 'CakeTestCookie[Testing]' => array( + $expected = [ + 'CakeTestCookie[Testing]' => [ 'name' => 'CakeTestCookie[Testing]', 'value' => 'test', 'expire' => 0, @@ -1067,8 +1067,8 @@ public function testCookieSettings() { 'domain' => '', 'secure' => false, 'httpOnly' => false - ), - 'CakeTestCookie[Testing2]' => array( + ], + 'CakeTestCookie[Testing2]' => [ 'name' => 'CakeTestCookie[Testing2]', 'value' => '[a,b,c]', 'expire' => 1000, @@ -1076,8 +1076,8 @@ public function testCookieSettings() { 'domain' => '', 'secure' => true, 'httpOnly' => false - ) - ); + ] + ]; $result = $response->cookie(); $this->assertEquals($expected, $result); @@ -1100,21 +1100,21 @@ public function testCookieSettings() { public function testCors($request, $origin, $domains, $methods, $headers, $expectedOrigin, $expectedMethods = false, $expectedHeaders = false) { $_SERVER['HTTP_ORIGIN'] = $origin; - $response = $this->getMock('CakeResponse', array('header')); + $response = $this->getMock('CakeResponse', ['header']); $method = $response->expects(!$expectedOrigin ? $this->never() : $this->at(0))->method('header'); - $expectedOrigin && $method->with('Access-Control-Allow-Origin', $expectedOrigin ? $expectedOrigin : $this->anything()); + $expectedOrigin && $method->with('Access-Control-Allow-Origin', $expectedOrigin ?: $this->anything()); $i = 1; if ($expectedMethods) { $response->expects($this->at($i++)) ->method('header') - ->with('Access-Control-Allow-Methods', $expectedMethods ? $expectedMethods : $this->anything()); + ->with('Access-Control-Allow-Methods', $expectedMethods ?: $this->anything()); } if ($expectedHeaders) { $response->expects($this->at($i++)) ->method('header') - ->with('Access-Control-Allow-Headers', $expectedHeaders ? $expectedHeaders : $this->anything()); + ->with('Access-Control-Allow-Headers', $expectedHeaders ?: $this->anything()); } $response->cors($request, $domains, $methods, $headers); @@ -1129,34 +1129,34 @@ public function testCors($request, $origin, $domains, $methods, $headers, $expec public function corsData() { $fooRequest = new CakeRequest(); - $secureRequest = $this->getMock('CakeRequest', array('is')); + $secureRequest = $this->getMock('CakeRequest', ['is']); $secureRequest->expects($this->any()) ->method('is') ->with('ssl') ->will($this->returnValue(true)); - return array( - array($fooRequest, null, '*', '', '', false, false), - array($fooRequest, 'http://www.foo.com', '*', '', '', '*', false), - array($fooRequest, 'http://www.foo.com', 'www.foo.com', '', '', 'http://www.foo.com', false), - array($fooRequest, 'http://www.foo.com', '*.foo.com', '', '', 'http://www.foo.com', false), - array($fooRequest, 'http://www.foo.com', 'http://*.foo.com', '', '', 'http://www.foo.com', false), - array($fooRequest, 'http://www.foo.com', 'https://www.foo.com', '', '', false, false), - array($fooRequest, 'http://www.foo.com', 'https://*.foo.com', '', '', false, false), - array($fooRequest, 'http://www.foo.com', array('*.bar.com', '*.foo.com'), '', '', 'http://www.foo.com', false), - - array($secureRequest, 'https://www.bar.com', 'www.bar.com', '', '', 'https://www.bar.com', false), - array($secureRequest, 'https://www.bar.com', 'http://www.bar.com', '', '', false, false), - array($secureRequest, 'https://www.bar.com', '*.bar.com', '', '', 'https://www.bar.com', false), - - array($fooRequest, 'http://www.foo.com', '*', 'GET', '', '*', 'GET'), - array($fooRequest, 'http://www.foo.com', '*.foo.com', 'GET', '', 'http://www.foo.com', 'GET'), - array($fooRequest, 'http://www.foo.com', '*.foo.com', array('GET', 'POST'), '', 'http://www.foo.com', 'GET, POST'), - - array($fooRequest, 'http://www.foo.com', '*', '', 'X-CakePHP', '*', false, 'X-CakePHP'), - array($fooRequest, 'http://www.foo.com', '*', '', array('X-CakePHP', 'X-MyApp'), '*', false, 'X-CakePHP, X-MyApp'), - array($fooRequest, 'http://www.foo.com', '*', array('GET', 'OPTIONS'), array('X-CakePHP', 'X-MyApp'), '*', 'GET, OPTIONS', 'X-CakePHP, X-MyApp'), - ); + return [ + [$fooRequest, null, '*', '', '', false, false], + [$fooRequest, 'http://www.foo.com', '*', '', '', '*', false], + [$fooRequest, 'http://www.foo.com', 'www.foo.com', '', '', 'http://www.foo.com', false], + [$fooRequest, 'http://www.foo.com', '*.foo.com', '', '', 'http://www.foo.com', false], + [$fooRequest, 'http://www.foo.com', 'http://*.foo.com', '', '', 'http://www.foo.com', false], + [$fooRequest, 'http://www.foo.com', 'https://www.foo.com', '', '', false, false], + [$fooRequest, 'http://www.foo.com', 'https://*.foo.com', '', '', false, false], + [$fooRequest, 'http://www.foo.com', ['*.bar.com', '*.foo.com'], '', '', 'http://www.foo.com', false], + + [$secureRequest, 'https://www.bar.com', 'www.bar.com', '', '', 'https://www.bar.com', false], + [$secureRequest, 'https://www.bar.com', 'http://www.bar.com', '', '', false, false], + [$secureRequest, 'https://www.bar.com', '*.bar.com', '', '', 'https://www.bar.com', false], + + [$fooRequest, 'http://www.foo.com', '*', 'GET', '', '*', 'GET'], + [$fooRequest, 'http://www.foo.com', '*.foo.com', 'GET', '', 'http://www.foo.com', 'GET'], + [$fooRequest, 'http://www.foo.com', '*.foo.com', ['GET', 'POST'], '', 'http://www.foo.com', 'GET, POST'], + + [$fooRequest, 'http://www.foo.com', '*', '', 'X-CakePHP', '*', false, 'X-CakePHP'], + [$fooRequest, 'http://www.foo.com', '*', '', ['X-CakePHP', 'X-MyApp'], '*', false, 'X-CakePHP, X-MyApp'], + [$fooRequest, 'http://www.foo.com', '*', ['GET', 'OPTIONS'], ['X-CakePHP', 'X-MyApp'], '*', 'GET, OPTIONS', 'X-CakePHP, X-MyApp'], + ]; } /** @@ -1213,7 +1213,7 @@ public function testFileWithDotsInFilename() { * @return void */ public function testFile() { - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', '_sendHeader', @@ -1221,7 +1221,7 @@ public function testFile() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->exactly(1)) ->method('type') @@ -1258,10 +1258,10 @@ public function testFile() { * @return void */ public function testFileWithUnknownFileTypeGeneric() { - $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; + $currentUserAgent = $_SERVER['HTTP_USER_AGENT'] ?? null; $_SERVER['HTTP_USER_AGENT'] = 'Some generic browser'; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', 'download', @@ -1270,7 +1270,7 @@ public function testFileWithUnknownFileTypeGeneric() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->exactly(1)) ->method('type') @@ -1318,10 +1318,10 @@ public function testFileWithUnknownFileTypeGeneric() { * @return void */ public function testFileWithUnknownFileTypeOpera() { - $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; + $currentUserAgent = $_SERVER['HTTP_USER_AGENT'] ?? null; $_SERVER['HTTP_USER_AGENT'] = 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.8.99 Version/11.10'; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', 'download', @@ -1330,7 +1330,7 @@ public function testFileWithUnknownFileTypeOpera() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->at(0)) ->method('type') @@ -1382,10 +1382,10 @@ public function testFileWithUnknownFileTypeOpera() { * @return void */ public function testFileWithUnknownFileTypeIE() { - $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; + $currentUserAgent = $_SERVER['HTTP_USER_AGENT'] ?? null; $_SERVER['HTTP_USER_AGENT'] = 'Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; Media Center PC 4.0; SLCC1; .NET CLR 3.0.04320)'; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', 'download', @@ -1394,7 +1394,7 @@ public function testFileWithUnknownFileTypeIE() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->at(0)) ->method('type') @@ -1428,9 +1428,9 @@ public function testFileWithUnknownFileTypeIE() { ->method('_isActive') ->will($this->returnValue(true)); - $response->file(CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'no_section.ini', array( + $response->file(CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'no_section.ini', [ 'name' => 'config.ini' - )); + ]); ob_start(); $result = $response->send(); @@ -1447,10 +1447,10 @@ public function testFileWithUnknownFileTypeIE() { * @return void */ public function testFileWithUnknownFileNoDownload() { - $currentUserAgent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : null; + $currentUserAgent = $_SERVER['HTTP_USER_AGENT'] ?? null; $_SERVER['HTTP_USER_AGENT'] = 'Some generic browser'; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', 'download', @@ -1459,7 +1459,7 @@ public function testFileWithUnknownFileNoDownload() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->exactly(1)) ->method('type') @@ -1473,9 +1473,9 @@ public function testFileWithUnknownFileNoDownload() { $response->expects($this->never()) ->method('download'); - $response->file(CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'no_section.ini', array( + $response->file(CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'no_section.ini', [ 'download' => false - )); + ]); if ($currentUserAgent !== null) { $_SERVER['HTTP_USER_AGENT'] = $currentUserAgent; @@ -1488,7 +1488,7 @@ public function testFileWithUnknownFileNoDownload() { * @return void */ public function testConnectionAbortedOnBuffering() { - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', 'download', @@ -1497,7 +1497,7 @@ public function testConnectionAbortedOnBuffering() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->any()) ->method('type') @@ -1523,7 +1523,7 @@ public function testConnectionAbortedOnBuffering() { * @return void */ public function testFileUpperExtension() { - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', 'download', @@ -1532,7 +1532,7 @@ public function testFileUpperExtension() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->any()) ->method('type') @@ -1552,7 +1552,7 @@ public function testFileUpperExtension() { * @return void */ public function testFileExtensionNotSet() { - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', 'download', @@ -1561,7 +1561,7 @@ public function testFileExtensionNotSet() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->any()) ->method('type') @@ -1581,22 +1581,22 @@ public function testFileExtensionNotSet() { * @return array */ public static function rangeProvider() { - return array( + return [ // suffix-byte-range - array( + [ 'bytes=-25', 25, 'bytes 13-37/38' - ), + ], - array( + [ 'bytes=0-', 38, 'bytes 0-37/38' - ), - array( + ], + [ 'bytes=10-', 28, 'bytes 10-37/38' - ), - array( + ], + [ 'bytes=10-20', 11, 'bytes 10-20/38' - ), - ); + ], + ]; } /** @@ -1607,14 +1607,14 @@ public static function rangeProvider() { */ public function testFileRangeOffsets($range, $length, $offsetResponse) { $_SERVER['HTTP_RANGE'] = $range; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', '_sendHeader', '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->at(1)) ->method('header') @@ -1630,10 +1630,10 @@ public function testFileRangeOffsets($range, $length, $offsetResponse) { $response->expects($this->at(4)) ->method('header') - ->with(array( + ->with([ 'Content-Length' => $length, 'Content-Range' => $offsetResponse, - )); + ]); $response->expects($this->any()) ->method('_isActive') @@ -1641,7 +1641,7 @@ public function testFileRangeOffsets($range, $length, $offsetResponse) { $response->file( CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS . 'test_asset.css', - array('download' => true) + ['download' => true] ); ob_start(); @@ -1656,7 +1656,7 @@ public function testFileRangeOffsets($range, $length, $offsetResponse) { */ public function testFileRange() { $_SERVER['HTTP_RANGE'] = 'bytes=8-25'; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', '_sendHeader', @@ -1664,7 +1664,7 @@ public function testFileRange() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->exactly(1)) ->method('type') @@ -1685,10 +1685,10 @@ public function testFileRange() { $response->expects($this->at(4)) ->method('header') - ->with(array( + ->with([ 'Content-Length' => 18, 'Content-Range' => 'bytes 8-25/38', - )); + ]); $response->expects($this->once())->method('_clearBuffer'); @@ -1698,7 +1698,7 @@ public function testFileRange() { $response->file( CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS . 'test_asset.css', - array('download' => true) + ['download' => true] ); ob_start(); @@ -1715,20 +1715,20 @@ public function testFileRange() { * @return array */ public function invalidFileRangeProvider() { - return array( + return [ // malformed range - array( + [ 'bytes=0,38' - ), + ], // malformed punctuation - array( + [ 'bytes: 0 - 32' - ), - array( + ], + [ 'garbage: poo - poo' - ), - ); + ], + ]; } /** @@ -1739,23 +1739,23 @@ public function invalidFileRangeProvider() { */ public function testFileRangeInvalid($range) { $_SERVER['HTTP_RANGE'] = $range; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ '_sendHeader', '_isActive', - )); + ]); $response->file( CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS . 'test_asset.css', - array('download' => true) + ['download' => true] ); - $expected = array( + $expected = [ 'Content-Disposition' => 'attachment; filename="test_asset.css"', 'Content-Transfer-Encoding' => 'binary', 'Accept-Ranges' => 'bytes', 'Content-Range' => 'bytes 0-37/38', 'Content-Length' => 38, - ); + ]; $this->assertEquals($expected, $response->header()); } @@ -1766,22 +1766,22 @@ public function testFileRangeInvalid($range) { */ public function testFileRangeReversed() { $_SERVER['HTTP_RANGE'] = 'bytes=30-5'; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ '_sendHeader', '_isActive', - )); + ]); $response->file( CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS . 'test_asset.css', - array('download' => true) + ['download' => true] ); - $expected = array( + $expected = [ 'Content-Disposition' => 'attachment; filename="test_asset.css"', 'Content-Transfer-Encoding' => 'binary', 'Accept-Ranges' => 'bytes', 'Content-Range' => 'bytes 0-37/38', - ); + ]; $this->assertEquals($expected, $response->header()); $this->assertEquals(416, $response->statusCode()); } @@ -1794,14 +1794,14 @@ public function testFileRangeReversed() { */ public function testFileRangeOffsetsNoDownload($range, $length, $offsetResponse) { $_SERVER['HTTP_RANGE'] = $range; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', '_sendHeader', '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->at(1)) ->method('header') @@ -1809,10 +1809,10 @@ public function testFileRangeOffsetsNoDownload($range, $length, $offsetResponse) $response->expects($this->at(2)) ->method('header') - ->with(array( + ->with([ 'Content-Length' => $length, 'Content-Range' => $offsetResponse, - )); + ]); $response->expects($this->any()) ->method('_isActive') @@ -1820,7 +1820,7 @@ public function testFileRangeOffsetsNoDownload($range, $length, $offsetResponse) $response->file( CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS . 'test_asset.css', - array('download' => false) + ['download' => false] ); ob_start(); @@ -1835,7 +1835,7 @@ public function testFileRangeOffsetsNoDownload($range, $length, $offsetResponse) */ public function testFileRangeNoDownload() { $_SERVER['HTTP_RANGE'] = 'bytes=8-25'; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', '_sendHeader', @@ -1843,7 +1843,7 @@ public function testFileRangeNoDownload() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->exactly(1)) ->method('type') @@ -1856,10 +1856,10 @@ public function testFileRangeNoDownload() { $response->expects($this->at(2)) ->method('header') - ->with(array( + ->with([ 'Content-Length' => 18, 'Content-Range' => 'bytes 8-25/38', - )); + ]); $response->expects($this->once())->method('_clearBuffer'); @@ -1869,7 +1869,7 @@ public function testFileRangeNoDownload() { $response->file( CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS . 'test_asset.css', - array('download' => false) + ['download' => false] ); ob_start(); @@ -1887,7 +1887,7 @@ public function testFileRangeNoDownload() { */ public function testFileRangeInvalidNoDownload() { $_SERVER['HTTP_RANGE'] = 'bytes=30-2'; - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', '_sendHeader', @@ -1895,7 +1895,7 @@ public function testFileRangeInvalidNoDownload() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->at(1)) ->method('header') @@ -1903,13 +1903,13 @@ public function testFileRangeInvalidNoDownload() { $response->expects($this->at(2)) ->method('header') - ->with(array( + ->with([ 'Content-Range' => 'bytes 0-37/38', - )); + ]); $response->file( CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS . 'css' . DS . 'test_asset.css', - array('download' => false) + ['download' => false] ); $this->assertEquals(416, $response->statusCode()); diff --git a/lib/Cake/Test/Case/Network/CakeSocketTest.php b/lib/Cake/Test/Case/Network/CakeSocketTest.php index 41651df9c5..8eba4069cc 100644 --- a/lib/Cake/Test/Case/Network/CakeSocketTest.php +++ b/lib/Cake/Test/Case/Network/CakeSocketTest.php @@ -32,7 +32,7 @@ class CakeSocketTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->Socket = new CakeSocket(array('timeout' => 1)); + $this->Socket = new CakeSocket(['timeout' => 1]); } /** @@ -53,21 +53,21 @@ public function tearDown() : void { public function testConstruct() { $this->Socket = new CakeSocket(); $config = $this->Socket->config; - $this->assertSame($config, array( + $this->assertSame($config, [ 'persistent' => false, 'host' => 'localhost', 'protocol' => 'tcp', 'port' => 80, 'timeout' => 30, 'cryptoType' => 'tls', - )); + ]); $this->Socket->reset(); - $this->Socket->__construct(array('host' => 'foo-bar')); + $this->Socket->__construct(['host' => 'foo-bar']); $config['host'] = 'foo-bar'; $this->assertSame($this->Socket->config, $config); - $this->Socket = new CakeSocket(array('host' => 'www.cakephp.org', 'port' => 23, 'protocol' => 'udp')); + $this->Socket = new CakeSocket(['host' => 'www.cakephp.org', 'port' => 23, 'protocol' => 'udp']); $config = $this->Socket->config; $config['host'] = 'www.cakephp.org'; @@ -93,11 +93,11 @@ public function testSocketConnection() { $this->assertTrue($this->Socket->connected); $this->Socket->disconnect(); - $config = array('persistent' => true); + $config = ['persistent' => true]; $this->Socket = new CakeSocket($config); $this->Socket->connect(); $this->assertTrue($this->Socket->connected); - } catch (SocketException $e) { + } catch (SocketException) { $this->markTestSkipped('Cannot test network, skipping.'); } } @@ -108,10 +108,10 @@ public function testSocketConnection() { * @return array */ public static function invalidConnections() { - return array( - array(array('host' => 'invalid.host', 'port' => 9999, 'timeout' => 1)), - array(array('host' => '127.0.0.1', 'port' => '70000', 'timeout' => 1)) - ); + return [ + [['host' => 'invalid.host', 'port' => 9999, 'timeout' => 1]], + [['host' => '127.0.0.1', 'port' => '70000', 'timeout' => 1]] + ]; } /** @@ -140,13 +140,13 @@ public function testSocketHost() { $this->assertEquals(null, $this->Socket->lastError()); $this->assertTrue(in_array('127.0.0.1', $this->Socket->addresses())); - $this->Socket = new CakeSocket(array('host' => '127.0.0.1')); + $this->Socket = new CakeSocket(['host' => '127.0.0.1']); $this->Socket->connect(); $this->assertEquals('127.0.0.1', $this->Socket->address()); $this->assertEquals(gethostbyaddr('127.0.0.1'), $this->Socket->host()); $this->assertEquals(null, $this->Socket->lastError()); $this->assertTrue(in_array('127.0.0.1', $this->Socket->addresses())); - } catch (SocketException $e) { + } catch (SocketException) { $this->markTestSkipped('Cannot test network, skipping.'); } } @@ -160,7 +160,7 @@ public function testSocketWriting() { try { $request = "GET / HTTP/1.1\r\nConnection: close\r\n\r\n"; $this->assertTrue((bool)$this->Socket->write($request)); - } catch (SocketException $e) { + } catch (SocketException) { $this->markTestSkipped('Cannot test network, skipping.'); } } @@ -171,17 +171,17 @@ public function testSocketWriting() { * @return void */ public function testSocketReading() { - $this->Socket = new CakeSocket(array('timeout' => 5)); + $this->Socket = new CakeSocket(['timeout' => 5]); try { $this->Socket->connect(); $this->assertEquals(null, $this->Socket->read(26)); - $config = array('host' => 'google.com', 'port' => 80, 'timeout' => 1); + $config = ['host' => 'google.com', 'port' => 80, 'timeout' => 1]; $this->Socket = new CakeSocket($config); $this->assertTrue($this->Socket->connect()); $this->assertEquals(null, $this->Socket->read(26)); $this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError()); - } catch (SocketException $e) { + } catch (SocketException) { $this->markTestSkipped('Cannot test network, skipping.'); } } @@ -192,16 +192,16 @@ public function testSocketReading() { * @return void */ public function testTimeOutConnection() { - $config = array('host' => '127.0.0.1', 'timeout' => 0.5); + $config = ['host' => '127.0.0.1', 'timeout' => 0.5]; $this->Socket = new CakeSocket($config); try { $this->assertTrue($this->Socket->connect()); - $config = array('host' => '127.0.0.1', 'timeout' => 0.00001); + $config = ['host' => '127.0.0.1', 'timeout' => 0.00001]; $this->Socket = new CakeSocket($config); $this->assertFalse($this->Socket->read(1024 * 1024)); $this->assertEquals('2: ' . __d('cake_dev', 'Connection timed out'), $this->Socket->lastError()); - } catch (SocketException $e) { + } catch (SocketException) { $this->markTestSkipped('Cannot test network, skipping.'); } } @@ -223,16 +223,16 @@ public function testLastError() { * @return void */ public function testReset() { - $config = array( + $config = [ 'persistent' => true, 'host' => '127.0.0.1', 'protocol' => 'udp', 'port' => 80, 'timeout' => 20 - ); + ]; $anotherSocket = new CakeSocket($config); $anotherSocket->reset(); - $this->assertEquals(array(), $anotherSocket->config); + $this->assertEquals([], $anotherSocket->config); } /** @@ -243,7 +243,7 @@ public function testReset() { public function testEnableCryptoSocketExceptionNoSsl() { $this->expectException(SocketException::class); $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.'); - $configNoSslOrTls = array('host' => 'localhost', 'port' => 80, 'timeout' => 0.1); + $configNoSslOrTls = ['host' => 'localhost', 'port' => 80, 'timeout' => 0.1]; // testing exception on no ssl socket server for ssl and tls methods $this->Socket = new CakeSocket($configNoSslOrTls); @@ -258,7 +258,7 @@ public function testEnableCryptoSocketExceptionNoSsl() { */ public function testEnableCryptoSocketExceptionNoTls() { $this->expectException(SocketException::class); - $configNoSslOrTls = array('host' => 'localhost', 'port' => 80, 'timeout' => 0.1); + $configNoSslOrTls = ['host' => 'localhost', 'port' => 80, 'timeout' => 0.1]; // testing exception on no ssl socket server for ssl and tls methods $this->Socket = new CakeSocket($configNoSslOrTls); @@ -273,13 +273,13 @@ public function testEnableCryptoSocketExceptionNoTls() { */ public function testConnectProtocolInHost() { $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.'); - $configSslTls = array('host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 5); + $configSslTls = ['host' => 'ssl://smtp.gmail.com', 'port' => 465, 'timeout' => 5]; $socket = new CakeSocket($configSslTls); try { $socket->connect(); $this->assertEquals('smtp.gmail.com', $socket->config['host']); $this->assertEquals('ssl', $socket->config['protocol']); - } catch (SocketException $e) { + } catch (SocketException) { $this->markTestSkipped('Cannot test network, skipping.'); } } @@ -291,11 +291,11 @@ public function testConnectProtocolInHost() { */ protected function _connectSocketToSslTls() { $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.'); - $configSslTls = array('host' => 'smtp.gmail.com', 'port' => 465, 'timeout' => 5); + $configSslTls = ['host' => 'smtp.gmail.com', 'port' => 465, 'timeout' => 5]; $this->Socket = new CakeSocket($configSslTls); try { $this->Socket->connect(); - } catch (SocketException $e) { + } catch (SocketException) { $this->markTestSkipped('Cannot test network, skipping.'); } } @@ -384,14 +384,14 @@ public function testEnableCryptoEnableStatus() { */ public function testGetContext() { $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.'); - $config = array( + $config = [ 'host' => 'smtp.gmail.com', 'port' => 465, 'timeout' => 5, - 'context' => array( - 'ssl' => array('capture_peer' => true) - ) - ); + 'context' => [ + 'ssl' => ['capture_peer' => true] + ] + ]; $this->Socket = new CakeSocket($config); $this->Socket->connect(); $result = $this->Socket->context(); @@ -405,7 +405,7 @@ public function testGetContext() { */ public function testConfigContext() { $this->skipIf(!extension_loaded('openssl'), 'OpenSSL is not enabled cannot test SSL.'); - $config = array( + $config = [ 'host' => 'smtp.gmail.com', 'port' => 465, 'timeout' => 5, @@ -413,7 +413,7 @@ public function testConfigContext() { 'ssl_allow_self_signed' => false, 'ssl_verify_depth' => 5, 'ssl_verify_host' => true, - ); + ]; $this->Socket = new CakeSocket($config); $this->Socket->connect(); diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 0bd0607fc1..5427a46eb3 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -36,7 +36,7 @@ class TestCakeEmail extends CakeEmail { /** * Config */ - protected $_config = array(); + protected $_config = []; /** * Wrap to protected method @@ -95,37 +95,37 @@ class TestEmailConfig { * * @var array */ - public $default = array( + public $default = [ 'subject' => 'Default Subject', - ); + ]; /** * test config * * @var array */ - public $test = array( - 'from' => array('some@example.com' => 'My website'), - 'to' => array('test@example.com' => 'Testname'), + public $test = [ + 'from' => ['some@example.com' => 'My website'], + 'to' => ['test@example.com' => 'Testname'], 'subject' => 'Test mail subject', 'transport' => 'Debug', 'theme' => 'TestTheme', - 'helpers' => array('Html', 'Form'), - ); + 'helpers' => ['Html', 'Form'], + ]; /** * test config 2 * * @var array */ - public $test2 = array( - 'from' => array('some@example.com' => 'My website'), - 'to' => array('test@example.com' => 'Testname'), + public $test2 = [ + 'from' => ['some@example.com' => 'My website'], + 'to' => ['test@example.com' => 'Testname'], 'subject' => 'Test mail subject', 'transport' => 'Smtp', 'host' => 'cakephp.org', 'timeout' => 60 - ); + ]; } @@ -161,9 +161,9 @@ public function setUp() : void { $this->CakeEmail = new TestCakeEmail(); - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); } /** @@ -195,25 +195,25 @@ public function testDefaultConfig() { * @return void */ public function testFrom() { - $this->assertSame(array(), $this->CakeEmail->from()); + $this->assertSame([], $this->CakeEmail->from()); $this->CakeEmail->from('cake@cakephp.org'); - $expected = array('cake@cakephp.org' => 'cake@cakephp.org'); + $expected = ['cake@cakephp.org' => 'cake@cakephp.org']; $this->assertSame($expected, $this->CakeEmail->from()); - $this->CakeEmail->from(array('cake@cakephp.org')); + $this->CakeEmail->from(['cake@cakephp.org']); $this->assertSame($expected, $this->CakeEmail->from()); $this->CakeEmail->from('cake@cakephp.org', 'CakePHP'); - $expected = array('cake@cakephp.org' => 'CakePHP'); + $expected = ['cake@cakephp.org' => 'CakePHP']; $this->assertSame($expected, $this->CakeEmail->from()); - $result = $this->CakeEmail->from(array('cake@cakephp.org' => 'CakePHP')); + $result = $this->CakeEmail->from(['cake@cakephp.org' => 'CakePHP']); $this->assertSame($expected, $this->CakeEmail->from()); $this->assertSame($this->CakeEmail, $result); $this->expectException('SocketException'); - $this->CakeEmail->from(array('cake@cakephp.org' => 'CakePHP', 'fail@cakephp.org' => 'From can only be one address')); + $this->CakeEmail->from(['cake@cakephp.org' => 'CakePHP', 'fail@cakephp.org' => 'From can only be one address']); } /** @@ -222,9 +222,9 @@ public function testFrom() { * @return void */ public function testFromWithColonsAndQuotes() { - $address = array( + $address = [ 'info@example.com' => '70:20:00 " Forum' - ); + ]; $this->CakeEmail->from($address); $this->assertEquals($address, $this->CakeEmail->from()); $this->CakeEmail->to('info@example.com') @@ -242,18 +242,18 @@ public function testFromWithColonsAndQuotes() { */ public function testSender() { $this->CakeEmail->reset(); - $this->assertSame(array(), $this->CakeEmail->sender()); + $this->assertSame([], $this->CakeEmail->sender()); $this->CakeEmail->sender('cake@cakephp.org', 'Name'); - $expected = array('cake@cakephp.org' => 'Name'); + $expected = ['cake@cakephp.org' => 'Name']; $this->assertSame($expected, $this->CakeEmail->sender()); - $headers = $this->CakeEmail->getHeaders(array('from' => true, 'sender' => true)); + $headers = $this->CakeEmail->getHeaders(['from' => true, 'sender' => true]); $this->assertFalse($headers['From']); $this->assertSame('Name ', $headers['Sender']); $this->CakeEmail->from('cake@cakephp.org', 'CakePHP'); - $headers = $this->CakeEmail->getHeaders(array('from' => true, 'sender' => true)); + $headers = $this->CakeEmail->getHeaders(['from' => true, 'sender' => true]); $this->assertSame('CakePHP ', $headers['From']); $this->assertSame('', $headers['Sender']); } @@ -264,43 +264,43 @@ public function testSender() { * @return void */ public function testTo() { - $this->assertSame(array(), $this->CakeEmail->to()); + $this->assertSame([], $this->CakeEmail->to()); $result = $this->CakeEmail->to('cake@cakephp.org'); - $expected = array('cake@cakephp.org' => 'cake@cakephp.org'); + $expected = ['cake@cakephp.org' => 'cake@cakephp.org']; $this->assertSame($expected, $this->CakeEmail->to()); $this->assertSame($this->CakeEmail, $result); $this->CakeEmail->to('cake@cakephp.org', 'CakePHP'); - $expected = array('cake@cakephp.org' => 'CakePHP'); + $expected = ['cake@cakephp.org' => 'CakePHP']; $this->assertSame($expected, $this->CakeEmail->to()); $this->CakeEmail->to('cake@cake_php.org', 'CakePHPUnderscore'); - $expected = array('cake@cake_php.org' => 'CakePHPUnderscore'); + $expected = ['cake@cake_php.org' => 'CakePHPUnderscore']; $this->assertSame($expected, $this->CakeEmail->to()); - $list = array( + $list = [ 'root@localhost' => 'root', 'bjørn@hammeröath.com' => 'Bjorn', 'cake.php@cakephp.org' => 'Cake PHP', 'cake-php@googlegroups.com' => 'Cake Groups', 'root@cakephp.org' - ); + ]; $this->CakeEmail->to($list); - $expected = array( + $expected = [ 'root@localhost' => 'root', 'bjørn@hammeröath.com' => 'Bjorn', 'cake.php@cakephp.org' => 'Cake PHP', 'cake-php@googlegroups.com' => 'Cake Groups', 'root@cakephp.org' => 'root@cakephp.org' - ); + ]; $this->assertSame($expected, $this->CakeEmail->to()); $this->CakeEmail->addTo('jrbasso@cakephp.org'); $this->CakeEmail->addTo('mark_story@cakephp.org', 'Mark Story'); $this->CakeEmail->addTo('foobar@ætdcadsl.dk'); - $result = $this->CakeEmail->addTo(array('phpnut@cakephp.org' => 'PhpNut', 'jose_zap@cakephp.org')); - $expected = array( + $result = $this->CakeEmail->addTo(['phpnut@cakephp.org' => 'PhpNut', 'jose_zap@cakephp.org']); + $expected = [ 'root@localhost' => 'root', 'bjørn@hammeröath.com' => 'Bjorn', 'cake.php@cakephp.org' => 'Cake PHP', @@ -311,7 +311,7 @@ public function testTo() { 'foobar@ætdcadsl.dk' => 'foobar@ætdcadsl.dk', 'phpnut@cakephp.org' => 'PhpNut', 'jose_zap@cakephp.org' => 'jose_zap@cakephp.org' - ); + ]; $this->assertSame($expected, $this->CakeEmail->to()); $this->assertSame($this->CakeEmail, $result); } @@ -322,13 +322,13 @@ public function testTo() { * @return array */ public static function invalidEmails() { - return array( - array(1.0), - array(''), - array('string'), - array(''), - array(array('ok@cakephp.org', 1.0, '', 'string')) - ); + return [ + [1.0], + [''], + ['string'], + [''], + [['ok@cakephp.org', 1.0, '', 'string']] + ]; } /** @@ -381,7 +381,7 @@ public function testEmailPattern() { */ public function testConfigEmailPattern() { $regex = '/.+@.+\..+/i'; - $email = new CakeEmail(array('emailPattern' => $regex)); + $email = new CakeEmail(['emailPattern' => $regex]); $this->assertSame($regex, $email->emailPattern()); } @@ -394,38 +394,38 @@ public function testCustomEmailValidation() { $regex = '/^[\.a-z0-9!#$%&\'*+\/=?^_`{|}~-]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]{2,6}$/i'; $this->CakeEmail->emailPattern($regex)->to('pass.@example.com'); - $this->assertSame(array( + $this->assertSame([ 'pass.@example.com' => 'pass.@example.com', - ), $this->CakeEmail->to()); + ], $this->CakeEmail->to()); $this->CakeEmail->addTo('pass..old.docomo@example.com'); - $this->assertSame(array( + $this->assertSame([ 'pass.@example.com' => 'pass.@example.com', 'pass..old.docomo@example.com' => 'pass..old.docomo@example.com', - ), $this->CakeEmail->to()); + ], $this->CakeEmail->to()); $this->CakeEmail->reset(); - $emails = array( + $emails = [ 'pass.@example.com', 'pass..old.docomo@example.com' - ); - $additionalEmails = array( + ]; + $additionalEmails = [ '.extend.@example.com', '.docomo@example.com' - ); + ]; $this->CakeEmail->emailPattern($regex)->to($emails); - $this->assertSame(array( + $this->assertSame([ 'pass.@example.com' => 'pass.@example.com', 'pass..old.docomo@example.com' => 'pass..old.docomo@example.com', - ), $this->CakeEmail->to()); + ], $this->CakeEmail->to()); $this->CakeEmail->addTo($additionalEmails); - $this->assertSame(array( + $this->assertSame([ 'pass.@example.com' => 'pass.@example.com', 'pass..old.docomo@example.com' => 'pass..old.docomo@example.com', '.extend.@example.com' => '.extend.@example.com', '.docomo@example.com' => '.docomo@example.com', - ), $this->CakeEmail->to()); + ], $this->CakeEmail->to()); } /** @@ -452,32 +452,32 @@ public function testUnsetEmailPattern() { * @return void */ public function testFormatAddress() { - $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'cake@cakephp.org')); - $expected = array('cake@cakephp.org'); + $result = $this->CakeEmail->formatAddress(['cake@cakephp.org' => 'cake@cakephp.org']); + $expected = ['cake@cakephp.org']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'cake@cakephp.org', 'php@cakephp.org' => 'php@cakephp.org')); - $expected = array('cake@cakephp.org', 'php@cakephp.org'); + $result = $this->CakeEmail->formatAddress(['cake@cakephp.org' => 'cake@cakephp.org', 'php@cakephp.org' => 'php@cakephp.org']); + $expected = ['cake@cakephp.org', 'php@cakephp.org']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'CakePHP', 'php@cakephp.org' => 'Cake')); - $expected = array('CakePHP ', 'Cake '); + $result = $this->CakeEmail->formatAddress(['cake@cakephp.org' => 'CakePHP', 'php@cakephp.org' => 'Cake']); + $expected = ['CakePHP ', 'Cake ']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array('me@example.com' => '"Last" First')); - $expected = array('"\"Last\" First" '); + $result = $this->CakeEmail->formatAddress(['me@example.com' => '"Last" First']); + $expected = ['"\"Last\" First" ']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array('me@example.com' => 'Last First')); - $expected = array('Last First '); + $result = $this->CakeEmail->formatAddress(['me@example.com' => 'Last First']); + $expected = ['Last First ']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'ÄÖÜTest')); - $expected = array('=?UTF-8?B?w4TDlsOcVGVzdA==?= '); + $result = $this->CakeEmail->formatAddress(['cake@cakephp.org' => 'ÄÖÜTest']); + $expected = ['=?UTF-8?B?w4TDlsOcVGVzdA==?= ']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => '日本語Test')); - $expected = array('=?UTF-8?B?5pel5pys6KqeVGVzdA==?= '); + $result = $this->CakeEmail->formatAddress(['cake@cakephp.org' => '日本語Test']); + $expected = ['=?UTF-8?B?5pel5pys6KqeVGVzdA==?= ']; $this->assertSame($expected, $result); } @@ -488,22 +488,22 @@ public function testFormatAddress() { * @return void */ public function testFormatAddressEncodeAndEscape() { - $result = $this->CakeEmail->formatAddress(array( + $result = $this->CakeEmail->formatAddress([ 'test@example.com' => 'Website, ascii' - )); - $expected = array('"Website, ascii" '); + ]); + $expected = ['"Website, ascii" ']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array( + $result = $this->CakeEmail->formatAddress([ 'test@example.com' => 'Wébsite, unicode' - )); - $expected = array('=?UTF-8?B?V8OpYnNpdGUsIHVuaWNvZGU=?= '); + ]); + $expected = ['=?UTF-8?B?V8OpYnNpdGUsIHVuaWNvZGU=?= ']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array( + $result = $this->CakeEmail->formatAddress([ 'test@example.com' => 'Website, électric' - )); - $expected = array('"Website, =?UTF-8?B?w6lsZWN0cmlj?=" '); + ]); + $expected = ['"Website, =?UTF-8?B?w6lsZWN0cmlj?=" ']; $this->assertSame($expected, $result); } @@ -516,17 +516,17 @@ public function testFormatAddressJapanese() { $this->skipIf(!function_exists('mb_convert_encoding')); $this->CakeEmail->headerCharset = 'ISO-2022-JP'; - $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => '日本語Test')); - $expected = array('=?ISO-2022-JP?B?GyRCRnxLXDhsGyhCVGVzdA==?= '); + $result = $this->CakeEmail->formatAddress(['cake@cakephp.org' => '日本語Test']); + $expected = ['=?ISO-2022-JP?B?GyRCRnxLXDhsGyhCVGVzdA==?= ']; $this->assertSame($expected, $result); - $result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => '寿限無寿限無五劫の擦り切れ海砂利水魚の水行末雲来末風来末食う寝る処に住む処やぶら小路の藪柑子パイポパイポパイポのシューリンガンシューリンガンのグーリンダイグーリンダイのポンポコピーのポンポコナーの長久命の長助')); - $expected = array("=?ISO-2022-JP?B?GyRCPHc4Qkw1PHc4Qkw1OF45ZSROOyQkakBaJGwzJDo9TXg/ZTV7GyhC?=\r\n" . + $result = $this->CakeEmail->formatAddress(['cake@cakephp.org' => '寿限無寿限無五劫の擦り切れ海砂利水魚の水行末雲来末風来末食う寝る処に住む処やぶら小路の藪柑子パイポパイポパイポのシューリンガンシューリンガンのグーリンダイグーリンダイのポンポコピーのポンポコナーの長久命の長助']); + $expected = ["=?ISO-2022-JP?B?GyRCPHc4Qkw1PHc4Qkw1OF45ZSROOyQkakBaJGwzJDo9TXg/ZTV7GyhC?=\r\n" . " =?ISO-2022-JP?B?GyRCJE4/ZTlUS3YxQE1oS3ZJd01oS3Y/KSQmPzIkaz1oJEs9OyRgGyhC?=\r\n" . " =?ISO-2022-JP?B?GyRCPWgkZCRWJGk+Lk8pJE5pLjQ7O1IlUSUkJV0lUSUkJV0lUSUkGyhC?=\r\n" . " =?ISO-2022-JP?B?GyRCJV0kTiU3JWUhPCVqJXMlLCVzJTclZSE8JWolcyUsJXMkTiUwGyhC?=\r\n" . " =?ISO-2022-JP?B?GyRCITwlaiVzJUAlJCUwITwlaiVzJUAlJCROJV0lcyVdJTMlVCE8GyhC?=\r\n" . - " =?ISO-2022-JP?B?GyRCJE4lXSVzJV0lMyVKITwkTkQ5NVdMPyRORDk9dRsoQg==?= "); + " =?ISO-2022-JP?B?GyRCJE4lXSVzJV0lMyVKITwkTkQ5NVdMPyRORDk9dRsoQg==?= "]; $this->assertSame($expected, $result); } @@ -548,15 +548,15 @@ public function testAddresses() { $this->CakeEmail->addCc('cc2@cakephp.org', 'Cc2 CakePHP'); $this->CakeEmail->addBcc('bcc2@cakephp.org', 'Bcc2 CakePHP'); - $this->assertSame($this->CakeEmail->from(), array('cake@cakephp.org' => 'CakePHP')); - $this->assertSame($this->CakeEmail->replyTo(), array('replyto@cakephp.org' => 'ReplyTo CakePHP')); - $this->assertSame($this->CakeEmail->readReceipt(), array('readreceipt@cakephp.org' => 'ReadReceipt CakePHP')); - $this->assertSame($this->CakeEmail->returnPath(), array('returnpath@cakephp.org' => 'ReturnPath CakePHP')); - $this->assertSame($this->CakeEmail->to(), array('to@cakephp.org' => 'To, CakePHP', 'to2@cakephp.org' => 'To2 CakePHP')); - $this->assertSame($this->CakeEmail->cc(), array('cc@cakephp.org' => 'Cc CakePHP', 'cc2@cakephp.org' => 'Cc2 CakePHP')); - $this->assertSame($this->CakeEmail->bcc(), array('bcc@cakephp.org' => 'Bcc CakePHP', 'bcc2@cakephp.org' => 'Bcc2 CakePHP')); + $this->assertSame($this->CakeEmail->from(), ['cake@cakephp.org' => 'CakePHP']); + $this->assertSame($this->CakeEmail->replyTo(), ['replyto@cakephp.org' => 'ReplyTo CakePHP']); + $this->assertSame($this->CakeEmail->readReceipt(), ['readreceipt@cakephp.org' => 'ReadReceipt CakePHP']); + $this->assertSame($this->CakeEmail->returnPath(), ['returnpath@cakephp.org' => 'ReturnPath CakePHP']); + $this->assertSame($this->CakeEmail->to(), ['to@cakephp.org' => 'To, CakePHP', 'to2@cakephp.org' => 'To2 CakePHP']); + $this->assertSame($this->CakeEmail->cc(), ['cc@cakephp.org' => 'Cc CakePHP', 'cc2@cakephp.org' => 'Cc2 CakePHP']); + $this->assertSame($this->CakeEmail->bcc(), ['bcc@cakephp.org' => 'Bcc CakePHP', 'bcc2@cakephp.org' => 'Bcc2 CakePHP']); - $headers = $this->CakeEmail->getHeaders(array_fill_keys(array('from', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc'), true)); + $headers = $this->CakeEmail->getHeaders(array_fill_keys(['from', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc'], true)); $this->assertSame($headers['From'], 'CakePHP '); $this->assertSame($headers['Reply-To'], 'ReplyTo CakePHP '); $this->assertSame($headers['Disposition-Notification-To'], 'ReadReceipt CakePHP '); @@ -606,7 +606,7 @@ public function testMessageIdInvalid() { */ public function testDomain() { $result = $this->CakeEmail->domain(); - $expected = env('HTTP_HOST') ? env('HTTP_HOST') : php_uname('n'); + $expected = env('HTTP_HOST') ?: php_uname('n'); $this->assertSame($expected, $result); $this->CakeEmail->domain('example.org'); @@ -682,19 +682,19 @@ public function testSubjectJapanese() { */ public function testHeaders() { $this->CakeEmail->messageId(false); - $this->CakeEmail->setHeaders(array('X-Something' => 'nice')); - $expected = array( + $this->CakeEmail->setHeaders(['X-Something' => 'nice']); + $expected = [ 'X-Something' => 'nice', 'X-Mailer' => 'CakePHP Email', 'Date' => date(DATE_RFC2822), 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding' => '8bit' - ); + ]; $this->assertSame($expected, $this->CakeEmail->getHeaders()); - $this->CakeEmail->addHeaders(array('X-Something' => 'very nice', 'X-Other' => 'cool')); - $expected = array( + $this->CakeEmail->addHeaders(['X-Something' => 'very nice', 'X-Other' => 'cool']); + $expected = [ 'X-Something' => 'very nice', 'X-Other' => 'cool', 'X-Mailer' => 'CakePHP Email', @@ -702,13 +702,13 @@ public function testHeaders() { 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding' => '8bit' - ); + ]; $this->assertSame($expected, $this->CakeEmail->getHeaders()); $this->CakeEmail->from('cake@cakephp.org'); $this->assertSame($expected, $this->CakeEmail->getHeaders()); - $expected = array( + $expected = [ 'From' => 'cake@cakephp.org', 'X-Something' => 'very nice', 'X-Other' => 'cool', @@ -717,15 +717,15 @@ public function testHeaders() { 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding' => '8bit' - ); - $this->assertSame($expected, $this->CakeEmail->getHeaders(array('from' => true))); + ]; + $this->assertSame($expected, $this->CakeEmail->getHeaders(['from' => true])); $this->CakeEmail->from('cake@cakephp.org', 'CakePHP'); $expected['From'] = 'CakePHP '; - $this->assertSame($expected, $this->CakeEmail->getHeaders(array('from' => true))); + $this->assertSame($expected, $this->CakeEmail->getHeaders(['from' => true])); - $this->CakeEmail->to(array('cake@cakephp.org', 'php@cakephp.org' => 'CakePHP')); - $expected = array( + $this->CakeEmail->to(['cake@cakephp.org', 'php@cakephp.org' => 'CakePHP']); + $expected = [ 'From' => 'CakePHP ', 'To' => 'cake@cakephp.org, CakePHP ', 'X-Something' => 'very nice', @@ -735,11 +735,11 @@ public function testHeaders() { 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=UTF-8', 'Content-Transfer-Encoding' => '8bit' - ); - $this->assertSame($expected, $this->CakeEmail->getHeaders(array('from' => true, 'to' => true))); + ]; + $this->assertSame($expected, $this->CakeEmail->getHeaders(['from' => true, 'to' => true])); $this->CakeEmail->charset = 'ISO-2022-JP'; - $expected = array( + $expected = [ 'From' => 'CakePHP ', 'To' => 'cake@cakephp.org, CakePHP ', 'X-Something' => 'very nice', @@ -749,10 +749,10 @@ public function testHeaders() { 'MIME-Version' => '1.0', 'Content-Type' => 'text/plain; charset=ISO-2022-JP', 'Content-Transfer-Encoding' => '7bit' - ); - $this->assertSame($expected, $this->CakeEmail->getHeaders(array('from' => true, 'to' => true))); + ]; + $this->assertSame($expected, $this->CakeEmail->getHeaders(['from' => true, 'to' => true])); - $result = $this->CakeEmail->setHeaders(array()); + $result = $this->CakeEmail->setHeaders([]); $this->assertInstanceOf('CakeEmail', $result); } @@ -762,13 +762,13 @@ public function testHeaders() { * @return array */ public static function invalidHeaders() { - return array( - array(10), - array(''), - array('string'), - array(false), - array(null) - ); + return [ + [10], + [''], + ['string'], + [false], + [null] + ]; } /** @@ -800,19 +800,19 @@ public function testInvalidAddHeaders($value) { */ public function testTemplate() { $this->CakeEmail->template('template', 'layout'); - $expected = array('template' => 'template', 'layout' => 'layout'); + $expected = ['template' => 'template', 'layout' => 'layout']; $this->assertSame($expected, $this->CakeEmail->template()); $this->CakeEmail->template('new_template'); - $expected = array('template' => 'new_template', 'layout' => 'layout'); + $expected = ['template' => 'new_template', 'layout' => 'layout']; $this->assertSame($expected, $this->CakeEmail->template()); $this->CakeEmail->template('template', null); - $expected = array('template' => 'template', 'layout' => null); + $expected = ['template' => 'template', 'layout' => null]; $this->assertSame($expected, $this->CakeEmail->template()); $this->CakeEmail->template(null, null); - $expected = array('template' => null, 'layout' => null); + $expected = ['template' => null, 'layout' => null]; $this->assertSame($expected, $this->CakeEmail->template()); } @@ -835,16 +835,16 @@ public function testTheme() { * @return void */ public function testViewVars() { - $this->assertSame(array(), $this->CakeEmail->viewVars()); + $this->assertSame([], $this->CakeEmail->viewVars()); - $this->CakeEmail->viewVars(array('value' => 12345)); - $this->assertSame(array('value' => 12345), $this->CakeEmail->viewVars()); + $this->CakeEmail->viewVars(['value' => 12345]); + $this->assertSame(['value' => 12345], $this->CakeEmail->viewVars()); - $this->CakeEmail->viewVars(array('name' => 'CakePHP')); - $this->assertSame(array('value' => 12345, 'name' => 'CakePHP'), $this->CakeEmail->viewVars()); + $this->CakeEmail->viewVars(['name' => 'CakePHP']); + $this->assertSame(['value' => 12345, 'name' => 'CakePHP'], $this->CakeEmail->viewVars()); - $this->CakeEmail->viewVars(array('value' => 4567)); - $this->assertSame(array('value' => 4567, 'name' => 'CakePHP'), $this->CakeEmail->viewVars()); + $this->CakeEmail->viewVars(['value' => 4567]); + $this->assertSame(['value' => 4567, 'name' => 'CakePHP'], $this->CakeEmail->viewVars()); } /** @@ -854,33 +854,33 @@ public function testViewVars() { */ public function testAttachments() { $this->CakeEmail->attachments(CAKE . 'basics.php'); - $expected = array( - 'basics.php' => array( + $expected = [ + 'basics.php' => [ 'file' => CAKE . 'basics.php', 'mimetype' => 'text/x-php' - ) - ); + ] + ]; $this->assertSame($expected, $this->CakeEmail->attachments()); - $this->CakeEmail->attachments(array()); - $this->assertSame(array(), $this->CakeEmail->attachments()); + $this->CakeEmail->attachments([]); + $this->assertSame([], $this->CakeEmail->attachments()); - $this->CakeEmail->attachments(array( - array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain') - )); + $this->CakeEmail->attachments([ + ['file' => CAKE . 'basics.php', 'mimetype' => 'text/plain'] + ]); $this->CakeEmail->addAttachments(CAKE . 'bootstrap.php'); - $this->CakeEmail->addAttachments(array(CAKE . 'bootstrap.php')); - $this->CakeEmail->addAttachments(array('other.txt' => CAKE . 'bootstrap.php', 'license' => CAKE . 'LICENSE.txt')); - $expected = array( - 'basics.php' => array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain'), - 'bootstrap.php' => array('file' => CAKE . 'bootstrap.php', 'mimetype' => 'text/x-php'), - 'other.txt' => array('file' => CAKE . 'bootstrap.php', 'mimetype' => 'text/x-php'), - 'license' => array('file' => CAKE . 'LICENSE.txt', 'mimetype' => 'text/plain') - ); + $this->CakeEmail->addAttachments([CAKE . 'bootstrap.php']); + $this->CakeEmail->addAttachments(['other.txt' => CAKE . 'bootstrap.php', 'license' => CAKE . 'LICENSE.txt']); + $expected = [ + 'basics.php' => ['file' => CAKE . 'basics.php', 'mimetype' => 'text/plain'], + 'bootstrap.php' => ['file' => CAKE . 'bootstrap.php', 'mimetype' => 'text/x-php'], + 'other.txt' => ['file' => CAKE . 'bootstrap.php', 'mimetype' => 'text/x-php'], + 'license' => ['file' => CAKE . 'LICENSE.txt', 'mimetype' => 'text/plain'] + ]; $this->assertSame($expected, $this->CakeEmail->attachments()); $this->expectException('SocketException'); - $this->CakeEmail->attachments(array(array('nofile' => CAKE . 'basics.php', 'mimetype' => 'text/plain'))); + $this->CakeEmail->attachments([['nofile' => CAKE . 'basics.php', 'mimetype' => 'text/plain']]); } /** @@ -920,20 +920,20 @@ public function testExtendTransport() { public function testConfig() { $transportClass = $this->CakeEmail->transport('debug')->transportClass(); - $config = array('test' => 'ok', 'test2' => true); + $config = ['test' => 'ok', 'test2' => true]; $this->CakeEmail->config($config); $this->assertSame($config, $transportClass->config()); - $expected = $config + array('subject' => 'Default Subject'); + $expected = $config + ['subject' => 'Default Subject']; $this->assertSame($expected, $this->CakeEmail->config()); - $this->CakeEmail->config(array()); + $this->CakeEmail->config([]); $this->assertSame($config, $transportClass->config()); - $config = array('test' => 'test@example.com', 'subject' => 'my test subject'); + $config = ['test' => 'test@example.com', 'subject' => 'my test subject']; $this->CakeEmail->config($config); - $expected = array('test' => 'test@example.com', 'subject' => 'my test subject', 'test2' => true); + $expected = ['test' => 'test@example.com', 'subject' => 'my test subject', 'test2' => true]; $this->assertSame($expected, $this->CakeEmail->config()); - $this->assertSame(array('test' => 'test@example.com', 'test2' => true), $transportClass->config()); + $this->assertSame(['test' => 'test@example.com', 'test2' => true], $transportClass->config()); } /** @@ -975,7 +975,7 @@ public function testConfigString() { public function testConfigMerge() { $this->CakeEmail->config('test2'); - $expected = array( + $expected = [ 'host' => 'cakephp.org', 'port' => 25, 'timeout' => 60, @@ -984,15 +984,15 @@ public function testConfigMerge() { 'client' => null, 'tls' => false, 'ssl_allow_self_signed' => false - ); + ]; $this->assertEquals($expected, $this->CakeEmail->transportClass()->config()); - $this->CakeEmail->config(array('log' => true)); + $this->CakeEmail->config(['log' => true]); $this->CakeEmail->transportClass()->config(); - $expected += array('log' => true); + $expected += ['log' => true]; $this->assertEquals($expected, $this->CakeEmail->transportClass()->config()); - $this->CakeEmail->config(array('timeout' => 45)); + $this->CakeEmail->config(['timeout' => 45]); $result = $this->CakeEmail->transportClass()->config(); $this->assertEquals(45, $result['timeout']); } @@ -1010,9 +1010,9 @@ public function testSendWithNoContentDoesNotOverwriteViewVar() { $this->CakeEmail->subject('My title'); $this->CakeEmail->emailFormat('text'); $this->CakeEmail->template('default'); - $this->CakeEmail->viewVars(array( + $this->CakeEmail->viewVars([ 'content' => 'A message to you', - )); + ]); $result = $this->CakeEmail->send(); $this->assertStringContainsString('A message to you', $result['message']); @@ -1027,12 +1027,12 @@ public function testSendWithContent() { $this->CakeEmail->reset(); $this->CakeEmail->transport('Debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $result = $this->CakeEmail->send("Here is my body, with multi lines.\nThis is the second line.\r\n\r\nAnd the last."); - $expected = array('headers', 'message'); + $expected = ['headers', 'message']; $this->assertEquals($expected, array_keys($result)); $expected = "Here is my body, with multi lines.\r\nThis is the second line.\r\n\r\nAnd the last.\r\n\r\n"; @@ -1050,10 +1050,10 @@ public function testSendWithContent() { $this->CakeEmail->reset(); $this->CakeEmail->transport('Debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); - $result = $this->CakeEmail->send(array('Sending content', 'As array')); + $this->CakeEmail->config(['empty']); + $result = $this->CakeEmail->send(['Sending content', 'As array']); $expected = "Sending content\r\nAs array\r\n\r\n\r\n"; $this->assertSame($expected, $result['message']); } @@ -1067,7 +1067,7 @@ public function testSendWithoutFrom() { $this->CakeEmail->transport('Debug'); $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->expectException('SocketException'); $this->CakeEmail->send("Forgot to set From"); } @@ -1081,7 +1081,7 @@ public function testSendWithoutTo() { $this->CakeEmail->transport('Debug'); $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->expectException('SocketException'); $this->CakeEmail->send("Forgot to set To"); } @@ -1097,7 +1097,7 @@ public function testSendNoTemplateWithAttachments() { $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('My title'); $this->CakeEmail->emailFormat('text'); - $this->CakeEmail->attachments(array(CAKE . 'basics.php')); + $this->CakeEmail->attachments([CAKE . 'basics.php']); $result = $this->CakeEmail->send('Hello'); $boundary = $this->CakeEmail->getBoundary(); @@ -1130,10 +1130,10 @@ public function testSendNoTemplateWithDataStringAttachment() { $this->CakeEmail->subject('My title'); $this->CakeEmail->emailFormat('text'); $data = file_get_contents(CAKE . 'Console/Templates/skel/webroot/img/cake.icon.png'); - $this->CakeEmail->attachments(array('cake.icon.png' => array( + $this->CakeEmail->attachments(['cake.icon.png' => [ 'data' => $data, 'mimetype' => 'image/png' - ))); + ]]); $result = $this->CakeEmail->send('Hello'); $boundary = $this->CakeEmail->getBoundary(); @@ -1166,9 +1166,9 @@ public function testSendNoTemplateWithDataStringAttachmentNoMime() { $this->CakeEmail->subject('My title'); $this->CakeEmail->emailFormat('text'); $data = file_get_contents(CAKE . 'Console/Templates/skel/webroot/img/cake.icon.png'); - $this->CakeEmail->attachments(array('cake.icon.png' => array( + $this->CakeEmail->attachments(['cake.icon.png' => [ 'data' => $data - ))); + ]]); $result = $this->CakeEmail->send('Hello'); $boundary = $this->CakeEmail->getBoundary(); @@ -1200,7 +1200,7 @@ public function testSendNoTemplateWithAttachmentsAsBoth() { $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('My title'); $this->CakeEmail->emailFormat('both'); - $this->CakeEmail->attachments(array(CAKE . 'VERSION.txt')); + $this->CakeEmail->attachments([CAKE . 'VERSION.txt']); $result = $this->CakeEmail->send('Hello'); $boundary = $this->CakeEmail->getBoundary(); @@ -1244,12 +1244,12 @@ public function testSendWithInlineAttachments() { $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('My title'); $this->CakeEmail->emailFormat('both'); - $this->CakeEmail->attachments(array( - 'cake.png' => array( + $this->CakeEmail->attachments([ + 'cake.png' => [ 'file' => CAKE . 'VERSION.txt', 'contentId' => 'abc123' - ) - )); + ] + ]); $result = $this->CakeEmail->send('Hello'); $boundary = $this->CakeEmail->getBoundary(); @@ -1299,12 +1299,12 @@ public function testSendWithInlineAttachmentsHtmlOnly() { $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('My title'); $this->CakeEmail->emailFormat('html'); - $this->CakeEmail->attachments(array( - 'cake.png' => array( + $this->CakeEmail->attachments([ + 'cake.png' => [ 'file' => CAKE . 'VERSION.txt', 'contentId' => 'abc123' - ) - )); + ] + ]); $result = $this->CakeEmail->send('Hello'); $boundary = $this->CakeEmail->getBoundary(); @@ -1341,12 +1341,12 @@ public function testSendWithNoContentDispositionAttachments() { $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('My title'); $this->CakeEmail->emailFormat('text'); - $this->CakeEmail->attachments(array( - 'cake.png' => array( + $this->CakeEmail->attachments([ + 'cake.png' => [ 'file' => CAKE . 'VERSION.txt', 'contentDisposition' => false - ) - )); + ] + ]); $result = $this->CakeEmail->send('Hello'); $boundary = $this->CakeEmail->getBoundary(); @@ -1373,23 +1373,23 @@ public function testSendWithNoContentDispositionAttachments() { * @return void */ public function testSendWithLog() { - CakeLog::config('email', array( + CakeLog::config('email', [ 'engine' => 'File', 'path' => TMP - )); + ]); CakeLog::drop('default'); $this->CakeEmail->transport('Debug'); $this->CakeEmail->to('me@cakephp.org'); $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('log' => 'cake_test_emails')); + $this->CakeEmail->config(['log' => 'cake_test_emails']); $result = $this->CakeEmail->send("Logging This"); App::uses('File', 'Utility'); $File = new File(TMP . 'cake_test_emails.log'); $log = $File->read(); - $this->assertTrue(strpos($log, $result['headers']) !== false); - $this->assertTrue(strpos($log, $result['message']) !== false); + $this->assertTrue(str_contains($log, $result['headers'])); + $this->assertTrue(str_contains($log, $result['message'])); $File->delete(); CakeLog::drop('email'); } @@ -1400,25 +1400,25 @@ public function testSendWithLog() { * @return void */ public function testSendWithLogAndScope() { - CakeLog::config('email', array( + CakeLog::config('email', [ 'engine' => 'File', 'path' => TMP, - 'types' => array('cake_test_emails'), - 'scopes' => array('email') - )); + 'types' => ['cake_test_emails'], + 'scopes' => ['email'] + ]); CakeLog::drop('default'); $this->CakeEmail->transport('Debug'); $this->CakeEmail->to('me@cakephp.org'); $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('log' => array('level' => 'cake_test_emails', 'scope' => 'email'))); + $this->CakeEmail->config(['log' => ['level' => 'cake_test_emails', 'scope' => 'email']]); $result = $this->CakeEmail->send("Logging This"); App::uses('File', 'Utility'); $File = new File(TMP . 'cake_test_emails.log'); $log = $File->read(); - $this->assertTrue(strpos($log, $result['headers']) !== false); - $this->assertTrue(strpos($log, $result['message']) !== false); + $this->assertTrue(str_contains($log, $result['headers'])); + $this->assertTrue(str_contains($log, $result['message'])); $File->delete(); CakeLog::drop('email'); } @@ -1433,9 +1433,9 @@ public function testSendRender() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('default', 'default'); $result = $this->CakeEmail->send(); @@ -1454,9 +1454,9 @@ public function testSendRenderNoLayout() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('default', null); $result = $this->CakeEmail->send('message body.'); @@ -1474,9 +1474,9 @@ public function testSendRenderBoth() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('default', 'default'); $this->CakeEmail->emailFormat('both'); $result = $this->CakeEmail->send(); @@ -1522,9 +1522,9 @@ public function testSendRenderJapanese() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('default', 'japanese'); $this->CakeEmail->charset = 'ISO-2022-JP'; $result = $this->CakeEmail->send(); @@ -1545,9 +1545,9 @@ public function testSendRenderThemed() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->theme('TestTheme'); $this->CakeEmail->template('themed', 'default'); $result = $this->CakeEmail->send(); @@ -1568,9 +1568,9 @@ public function testSendRenderWithHTML() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->emailFormat('html'); $this->CakeEmail->template('html', 'default'); $result = $this->CakeEmail->send(); @@ -1589,11 +1589,11 @@ public function testSendRenderWithVars() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('custom', 'default'); - $this->CakeEmail->viewVars(array('value' => 12345)); + $this->CakeEmail->viewVars(['value' => 12345]); $result = $this->CakeEmail->send(); $this->assertStringContainsString('Here is your value: 12345', $result['message']); @@ -1610,11 +1610,11 @@ public function testSendRenderWithVarsJapanese() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('japanese', 'default'); - $this->CakeEmail->viewVars(array('value' => '日本語の差し込み123')); + $this->CakeEmail->viewVars(['value' => '日本語の差し込み123']); $this->CakeEmail->charset = 'ISO-2022-JP'; $result = $this->CakeEmail->send(); @@ -1633,20 +1633,20 @@ public function testSendRenderWithHelpers() { $timestamp = time(); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('custom_helper', 'default'); - $this->CakeEmail->viewVars(array('time' => $timestamp)); + $this->CakeEmail->viewVars(['time' => $timestamp]); - $result = $this->CakeEmail->helpers(array('Time')); + $result = $this->CakeEmail->helpers(['Time']); $this->assertInstanceOf('CakeEmail', $result); $result = $this->CakeEmail->send(); $this->assertTrue((bool)strpos($result['message'], 'Right now: ' . date('Y-m-d\TH:i:s\Z', $timestamp))); $result = $this->CakeEmail->helpers(); - $this->assertEquals(array('Time'), $result); + $this->assertEquals(['Time'], $result); } /** @@ -1659,12 +1659,12 @@ public function testSendRenderWithImage() { $this->CakeEmail->transport('Debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('image'); $this->CakeEmail->emailFormat('html'); - $server = env('SERVER_NAME') ? env('SERVER_NAME') : 'localhost'; + $server = env('SERVER_NAME') ?: 'localhost'; if (env('SERVER_PORT') && env('SERVER_PORT') != 80) { $server .= ':' . env('SERVER_PORT'); @@ -1681,17 +1681,17 @@ public function testSendRenderWithImage() { * @return void */ public function testSendRenderPlugin() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $this->CakeEmail->reset(); $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $result = $this->CakeEmail->template('TestPlugin.test_plugin_tpl', 'default')->send(); $this->assertStringContainsString('Into TestPlugin.', $result['message']); @@ -1719,7 +1719,7 @@ public function testSendRenderPlugin() { $this->assertStringContainsString('Into TestPlugin. (themed)', $result['message']); - $this->CakeEmail->viewVars(array('value' => 12345)); + $this->CakeEmail->viewVars(['value' => 12345]); $result = $this->CakeEmail->template('custom', 'TestPlugin.plug_default')->send(); $this->assertStringContainsString('Here is your value: 12345', $result['message']); $this->assertStringContainsString('This email was sent using the TestPlugin.', $result['message']); @@ -1738,11 +1738,11 @@ public function testSendMultipleMIME() { $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); $this->CakeEmail->template('custom', 'default'); - $this->CakeEmail->config(array()); - $this->CakeEmail->viewVars(array('value' => 12345)); + $this->CakeEmail->config([]); + $this->CakeEmail->viewVars(['value' => 12345]); $this->CakeEmail->emailFormat('both'); $this->CakeEmail->send(); @@ -1752,7 +1752,7 @@ public function testSendMultipleMIME() { $this->assertContains('--' . $boundary, $message); $this->assertContains('--' . $boundary . '--', $message); - $this->CakeEmail->attachments(array('fake.php' => __FILE__)); + $this->CakeEmail->attachments(['fake.php' => __FILE__]); $this->CakeEmail->send(); $message = $this->CakeEmail->message(); @@ -1773,22 +1773,22 @@ public function testSendAttachment() { $this->CakeEmail->reset(); $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array()); - $this->CakeEmail->attachments(array(CAKE . 'basics.php')); + $this->CakeEmail->config([]); + $this->CakeEmail->attachments([CAKE . 'basics.php']); $result = $this->CakeEmail->send('body'); $this->assertStringContainsString("Content-Type: text/x-php\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename=\"basics.php\"", $result['message']); - $this->CakeEmail->attachments(array('my.file.txt' => CAKE . 'basics.php')); + $this->CakeEmail->attachments(['my.file.txt' => CAKE . 'basics.php']); $result = $this->CakeEmail->send('body'); $this->assertStringContainsString("Content-Type: text/x-php\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename=\"my.file.txt\"", $result['message']); - $this->CakeEmail->attachments(array('file.txt' => array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain'))); + $this->CakeEmail->attachments(['file.txt' => ['file' => CAKE . 'basics.php', 'mimetype' => 'text/plain']]); $result = $this->CakeEmail->send('body'); $this->assertStringContainsString("Content-Type: text/plain\r\nContent-Transfer-Encoding: base64\r\nContent-Disposition: attachment; filename=\"file.txt\"", $result['message']); - $this->CakeEmail->attachments(array('file2.txt' => array('file' => CAKE . 'basics.php', 'mimetype' => 'text/plain', 'contentId' => 'a1b1c1'))); + $this->CakeEmail->attachments(['file2.txt' => ['file' => CAKE . 'basics.php', 'mimetype' => 'text/plain', 'contentId' => 'a1b1c1']]); $result = $this->CakeEmail->send('body'); $this->assertStringContainsString("Content-Type: text/plain\r\nContent-Transfer-Encoding: base64\r\nContent-ID: \r\nContent-Disposition: inline; filename=\"file2.txt\"", $result['message']); } @@ -1799,30 +1799,30 @@ public function testSendAttachment() { * @return void */ public function testDeliver() { - $instance = CakeEmail::deliver('all@cakephp.org', 'About', 'Everything ok', array('from' => 'root@cakephp.org'), false); + $instance = CakeEmail::deliver('all@cakephp.org', 'About', 'Everything ok', ['from' => 'root@cakephp.org'], false); $this->assertInstanceOf('CakeEmail', $instance); - $this->assertSame($instance->to(), array('all@cakephp.org' => 'all@cakephp.org')); + $this->assertSame($instance->to(), ['all@cakephp.org' => 'all@cakephp.org']); $this->assertSame($instance->subject(), 'About'); - $this->assertSame($instance->from(), array('root@cakephp.org' => 'root@cakephp.org')); + $this->assertSame($instance->from(), ['root@cakephp.org' => 'root@cakephp.org']); - $config = array( + $config = [ 'from' => 'cake@cakephp.org', 'to' => 'debug@cakephp.org', 'subject' => 'Update ok', 'template' => 'custom', 'layout' => 'custom_layout', - 'viewVars' => array('value' => 123), - 'cc' => array('cake@cakephp.org' => 'Myself') - ); - $instance = CakeEmail::deliver(null, null, array('name' => 'CakePHP'), $config, false); - $this->assertSame($instance->from(), array('cake@cakephp.org' => 'cake@cakephp.org')); - $this->assertSame($instance->to(), array('debug@cakephp.org' => 'debug@cakephp.org')); + 'viewVars' => ['value' => 123], + 'cc' => ['cake@cakephp.org' => 'Myself'] + ]; + $instance = CakeEmail::deliver(null, null, ['name' => 'CakePHP'], $config, false); + $this->assertSame($instance->from(), ['cake@cakephp.org' => 'cake@cakephp.org']); + $this->assertSame($instance->to(), ['debug@cakephp.org' => 'debug@cakephp.org']); $this->assertSame($instance->subject(), 'Update ok'); - $this->assertSame($instance->template(), array('template' => 'custom', 'layout' => 'custom_layout')); - $this->assertSame($instance->viewVars(), array('value' => 123, 'name' => 'CakePHP')); - $this->assertSame($instance->cc(), array('cake@cakephp.org' => 'Myself')); + $this->assertSame($instance->template(), ['template' => 'custom', 'layout' => 'custom_layout']); + $this->assertSame($instance->viewVars(), ['value' => 123, 'name' => 'CakePHP']); + $this->assertSame($instance->cc(), ['cake@cakephp.org' => 'Myself']); - $configs = array('from' => 'root@cakephp.org', 'message' => 'Message from configs', 'transport' => 'Debug'); + $configs = ['from' => 'root@cakephp.org', 'message' => 'Message from configs', 'transport' => 'Debug']; $instance = CakeEmail::deliver('all@cakephp.org', 'About', null, $configs, true); $message = $instance->message(); $this->assertEquals($configs['message'], $message[0]); @@ -1837,9 +1837,9 @@ public function testMessage() { $this->CakeEmail->reset(); $this->CakeEmail->transport('debug'); $this->CakeEmail->from('cake@cakephp.org'); - $this->CakeEmail->to(array('you@cakephp.org' => 'You')); + $this->CakeEmail->to(['you@cakephp.org' => 'You']); $this->CakeEmail->subject('My title'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->template('default', 'default'); $this->CakeEmail->emailFormat('both'); $this->CakeEmail->send(); @@ -1876,10 +1876,10 @@ public function testReset() { $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->theme('TestTheme'); $this->CakeEmail->emailPattern('/.+@.+\..+/i'); - $this->assertSame(array('cake@cakephp.org' => 'cake@cakephp.org'), $this->CakeEmail->to()); + $this->assertSame(['cake@cakephp.org' => 'cake@cakephp.org'], $this->CakeEmail->to()); $this->CakeEmail->reset(); - $this->assertSame(array(), $this->CakeEmail->to()); + $this->assertSame([], $this->CakeEmail->to()); $this->assertNull($this->CakeEmail->theme()); $this->assertSame(CakeEmail::EMAIL_PATTERN, $this->CakeEmail->emailPattern()); } @@ -1905,61 +1905,61 @@ public function testResetWithCharset() { public function testWrap() { $text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac turpis orci, non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.'; $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD); - $expected = array( + $expected = [ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac turpis orci,', 'non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.', '' - ); + ]; $this->assertSame($expected, $result); $text = 'Lorem ipsum dolor sit amet, consectetur < adipiscing elit. Donec ac turpis orci, non commodo odio. Morbi nibh nisi, vehicula > pellentesque accumsan amet.'; $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD); - $expected = array( + $expected = [ 'Lorem ipsum dolor sit amet, consectetur < adipiscing elit. Donec ac turpis', 'orci, non commodo odio. Morbi nibh nisi, vehicula > pellentesque accumsan', 'amet.', '' - ); + ]; $this->assertSame($expected, $result); $text = '

Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Donec ac turpis orci, non commodo odio.
Morbi nibh nisi, vehicula pellentesque accumsan amet.


'; $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD); - $expected = array( + $expected = [ '

Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Donec ac', 'turpis orci, non commodo odio.
Morbi nibh nisi, vehicula', 'pellentesque accumsan amet.


', '' - ); + ]; $this->assertSame($expected, $result); $text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac turpis orci, non commodo odio. Morbi nibh nisi, vehicula pellentesque accumsan amet.'; $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD); - $expected = array( + $expected = [ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac', 'turpis orci, non commodo odio. Morbi nibh', 'nisi, vehicula pellentesque accumsan amet.', '' - ); + ]; $this->assertSame($expected, $result); $text = 'Lorem ipsum ok'; $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD); - $expected = array( + $expected = [ 'Lorem ipsum', '', 'ok', '' - ); + ]; $this->assertSame($expected, $result); $text = 'Lorem ipsum withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite ok.'; $result = $this->CakeEmail->wrap($text, CakeEmail::LINE_LENGTH_SHOULD); - $expected = array( + $expected = [ 'Lorem ipsum', 'withonewordverybigMorethanthelineshouldsizeofrfcspecificationbyieeeavailableonieeesite', 'ok.', '' - ); + ]; $this->assertSame($expected, $result); } @@ -1971,8 +1971,8 @@ public function testWrap() { public function testRenderWithLayoutAndAttachment() { $this->CakeEmail->emailFormat('html'); $this->CakeEmail->template('html', 'default'); - $this->CakeEmail->attachments(array(CAKE . 'basics.php')); - $result = $this->CakeEmail->render(array()); + $this->CakeEmail->attachments([CAKE . 'basics.php']); + $result = $this->CakeEmail->render([]); $this->assertNotEmpty($result); $result = $this->CakeEmail->getBoundary(); @@ -1985,16 +1985,16 @@ public function testRenderWithLayoutAndAttachment() { * @return void */ public function testConstructWithConfigArray() { - $configs = array( - 'from' => array('some@example.com' => 'My website'), + $configs = [ + 'from' => ['some@example.com' => 'My website'], 'to' => 'test@example.com', 'subject' => 'Test mail subject', 'transport' => 'Debug', - ); + ]; $this->CakeEmail = new CakeEmail($configs); $result = $this->CakeEmail->to(); - $this->assertEquals(array($configs['to'] => $configs['to']), $result); + $this->assertEquals([$configs['to'] => $configs['to']], $result); $result = $this->CakeEmail->from(); $this->assertEquals($configs['from'], $result); @@ -2020,13 +2020,13 @@ public function testConstructWithConfigArray() { * @return void */ public function testConfigArrayWithLayoutWithoutTemplate() { - $configs = array( - 'from' => array('some@example.com' => 'My website'), + $configs = [ + 'from' => ['some@example.com' => 'My website'], 'to' => 'test@example.com', 'subject' => 'Test mail subject', 'transport' => 'Debug', 'layout' => 'custom' - ); + ]; $this->CakeEmail = new CakeEmail($configs); $result = $this->CakeEmail->template(); @@ -2109,15 +2109,15 @@ public function testConfigCharset() { $this->assertEquals(Configure::read('App.encoding'), $email->charset); $this->assertEquals(Configure::read('App.encoding'), $email->headerCharset); - $email = new CakeEmail(array('charset' => 'iso-2022-jp', 'headerCharset' => 'iso-2022-jp-ms')); + $email = new CakeEmail(['charset' => 'iso-2022-jp', 'headerCharset' => 'iso-2022-jp-ms']); $this->assertEquals('iso-2022-jp', $email->charset); $this->assertEquals('iso-2022-jp-ms', $email->headerCharset); - $email = new CakeEmail(array('charset' => 'iso-2022-jp')); + $email = new CakeEmail(['charset' => 'iso-2022-jp']); $this->assertEquals('iso-2022-jp', $email->charset); $this->assertEquals('iso-2022-jp', $email->headerCharset); - $email = new CakeEmail(array('headerCharset' => 'iso-2022-jp-ms')); + $email = new CakeEmail(['headerCharset' => 'iso-2022-jp-ms']); $this->assertEquals(Configure::read('App.encoding'), $email->charset); $this->assertEquals('iso-2022-jp-ms', $email->headerCharset); } @@ -2129,9 +2129,9 @@ public function testConfigCharset() { */ public function testHeaderEncoding() { $this->skipIf(!function_exists('mb_convert_encoding')); - $email = new CakeEmail(array('headerCharset' => 'iso-2022-jp-ms', 'transport' => 'Debug')); + $email = new CakeEmail(['headerCharset' => 'iso-2022-jp-ms', 'transport' => 'Debug']); $email->subject('あれ?もしかしての前と'); - $headers = $email->getHeaders(array('subject')); + $headers = $email->getHeaders(['subject']); $expected = "?ISO-2022-JP?B?GyRCJCIkbCEpJGIkNyQrJDckRiROQTAkSBsoQg==?="; $this->assertStringContainsString($expected, $headers['Subject']); @@ -2147,13 +2147,13 @@ public function testHeaderEncoding() { */ public function testBodyEncoding() { $this->skipIf(!function_exists('mb_convert_encoding')); - $email = new CakeEmail(array( + $email = new CakeEmail([ 'charset' => 'iso-2022-jp', 'headerCharset' => 'iso-2022-jp-ms', 'transport' => 'Debug' - )); + ]); $email->subject('あれ?もしかしての前と'); - $headers = $email->getHeaders(array('subject')); + $headers = $email->getHeaders(['subject']); $expected = "?ISO-2022-JP?B?GyRCJCIkbCEpJGIkNyQrJDckRiROQTAkSBsoQg==?="; $this->assertStringContainsString($expected, $headers['Subject']); @@ -2170,13 +2170,13 @@ public function testBodyEncoding() { */ public function testBodyEncodingIso2022Jp() { $this->skipIf(!function_exists('mb_convert_encoding')); - $email = new CakeEmail(array( + $email = new CakeEmail([ 'charset' => 'iso-2022-jp', 'headerCharset' => 'iso-2022-jp', 'transport' => 'Debug' - )); + ]); $email->subject('あれ?もしかしての前と'); - $headers = $email->getHeaders(array('subject')); + $headers = $email->getHeaders(['subject']); $expected = "?ISO-2022-JP?B?GyRCJCIkbCEpJGIkNyQrJDckRiROQTAkSBsoQg==?="; $this->assertStringContainsString($expected, $headers['Subject']); @@ -2194,13 +2194,13 @@ public function testBodyEncodingIso2022Jp() { */ public function testBodyEncodingIso2022JpMs() { $this->skipIf(!function_exists('mb_convert_encoding')); - $email = new CakeEmail(array( + $email = new CakeEmail([ 'charset' => 'iso-2022-jp-ms', 'headerCharset' => 'iso-2022-jp-ms', 'transport' => 'Debug' - )); + ]); $email->subject('あれ?もしかしての前と'); - $headers = $email->getHeaders(array('subject')); + $headers = $email->getHeaders(['subject']); $expected = "?ISO-2022-JP?B?GyRCJCIkbCEpJGIkNyQrJDckRiROQTAkSBsoQg==?="; $this->assertStringContainsString($expected, $headers['Subject']); @@ -2301,12 +2301,12 @@ public function testHeaderCharset() { public function testCharsetsCompatible() { $this->skipIf(!function_exists('mb_convert_encoding')); - $checkHeaders = array( + $checkHeaders = [ 'from' => true, 'to' => true, 'cc' => true, 'subject' => true, - ); + ]; // Header Charset : null (used by default UTF-8) // Body Charset : ISO-2022-JP @@ -2354,7 +2354,7 @@ public function testCharsetsCompatible() { * @return CakeEmail */ protected function _getEmailByOldStyleCharset($charset, $headerCharset) { - $email = new CakeEmail(array('transport' => 'Debug')); + $email = new CakeEmail(['transport' => 'Debug']); if (!empty($charset)) { $email->charset = $charset; @@ -2378,7 +2378,7 @@ protected function _getEmailByOldStyleCharset($charset, $headerCharset) { * @return CakeEmail */ protected function _getEmailByNewStyleCharset($charset, $headerCharset) { - $email = new CakeEmail(array('transport' => 'Debug')); + $email = new CakeEmail(['transport' => 'Debug']); if (!empty($charset)) { $email->charset($charset); @@ -2409,7 +2409,7 @@ public function testWrapLongLine() { $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('Wordwrap Test'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $result = $this->CakeEmail->send($message); $expected = "' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - 26) . "\r\n" . str_repeat('x', 26) . "\r\n\r\n\r\n"; @@ -2460,7 +2460,7 @@ public function testWrapWithTagsAcrossLines() { $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('Wordwrap Test'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $result = $this->CakeEmail->send($message); $message = str_replace("\r\n", "\n", substr($message, 0, -9)); $message = str_replace("\n", "\r\n", $message); @@ -2484,7 +2484,7 @@ public function testWrapIncludeLessThanSign() { $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('Wordwrap Test'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $result = $this->CakeEmail->send($message); $message = substr($message, 0, -1); $expected = "{$message}\r\nx\r\n\r\n"; @@ -2507,7 +2507,7 @@ public function testWrapForJapaneseEncoding() { $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('Wordwrap Test'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->charset('iso-2022-jp'); $this->CakeEmail->headerCharset('iso-2022-jp'); $result = $this->CakeEmail->send($message); @@ -2528,7 +2528,7 @@ public function testZeroOnlyLinesNotBeingEmptied() { $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->to('cake@cakephp.org'); $this->CakeEmail->subject('Wordwrap Test'); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $result = $this->CakeEmail->send($message); $expected = "{$message}\r\n\r\n"; $this->assertEquals($expected, $result['message']); @@ -2541,7 +2541,7 @@ public function testZeroOnlyLinesNotBeingEmptied() { */ public function testReallyLongLine() { $this->CakeEmail->reset(); - $this->CakeEmail->config(array('empty')); + $this->CakeEmail->config(['empty']); $this->CakeEmail->transport('Debug'); $this->CakeEmail->from('cake@cakephp.org'); $this->CakeEmail->to('cake@cakephp.org'); diff --git a/lib/Cake/Test/Case/Network/Email/DebugTransportTest.php b/lib/Cake/Test/Case/Network/Email/DebugTransportTest.php index 4f53868832..ee53535c4a 100644 --- a/lib/Cake/Test/Case/Network/Email/DebugTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/DebugTransportTest.php @@ -41,16 +41,16 @@ public function setUp() : void { * @return void */ public function testSend() { - $email = $this->getMock('CakeEmail', array('message'), array(), 'DebugCakeEmail'); + $email = $this->getMock('CakeEmail', ['message'], [], 'DebugCakeEmail'); $email->from('noreply@cakephp.org', 'CakePHP Test'); $email->to('cake@cakephp.org', 'CakePHP'); - $email->cc(array('mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso')); + $email->cc(['mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso']); $email->bcc('phpnut@cakephp.org'); $email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>'); $email->subject('Testing Message'); $date = date(DATE_RFC2822); - $email->setHeaders(array('X-Mailer' => DebugCakeEmail::EMAIL_CLIENT, 'Date' => $date)); - $email->expects($this->once())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', ''))); + $email->setHeaders(['X-Mailer' => DebugCakeEmail::EMAIL_CLIENT, 'Date' => $date]); + $email->expects($this->once())->method('message')->will($this->returnValue(['First Line', 'Second Line', '.Third Line', ''])); $headers = "From: CakePHP Test \r\n"; $headers .= "To: CakePHP \r\n"; diff --git a/lib/Cake/Test/Case/Network/Email/MailTransportTest.php b/lib/Cake/Test/Case/Network/Email/MailTransportTest.php index 60f218c1f5..f406cfee0c 100644 --- a/lib/Cake/Test/Case/Network/Email/MailTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/MailTransportTest.php @@ -32,8 +32,8 @@ class MailTransportTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->MailTransport = $this->getMock('MailTransport', array('_mail')); - $this->MailTransport->config(array('additionalParameters' => '-f')); + $this->MailTransport = $this->getMock('MailTransport', ['_mail']); + $this->MailTransport->config(['additionalParameters' => '-f']); } /** @@ -42,23 +42,23 @@ public function setUp() : void { * @return void */ public function testSendData() { - $email = $this->getMock('CakeEmail', array('message'), array()); + $email = $this->getMock('CakeEmail', ['message'], []); $email->from('noreply@cakephp.org', 'CakePHP Test'); $email->returnPath('pleasereply@cakephp.org', 'CakePHP Return'); $email->to('cake@cakephp.org', 'CakePHP'); - $email->cc(array('mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso')); + $email->cc(['mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso']); $email->bcc('phpnut@cakephp.org'); $email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>'); $longNonAscii = 'Foø Bår Béz Foø Bår Béz Foø Bår Béz Foø Bår Béz'; $email->subject($longNonAscii); $date = date(DATE_RFC2822); - $email->setHeaders(array( + $email->setHeaders([ 'X-Mailer' => 'CakePHP Email', 'Date' => $date, 'X-add' => mb_encode_mimeheader($longNonAscii, 'utf8', 'B'), - )); + ]); $email->expects($this->any())->method('message') - ->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', ''))); + ->will($this->returnValue(['First Line', 'Second Line', '.Third Line', ''])); $encoded = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?='; $encoded .= ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?='; @@ -79,7 +79,7 @@ public function testSendData() { ->with( 'CakePHP ', $encoded, - implode("\r\n", array('First Line', 'Second Line', '.Third Line', '')), + implode("\r\n", ['First Line', 'Second Line', '.Third Line', '']), $data, '-f' ); diff --git a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php index 7377e88ec5..d57b7475a9 100644 --- a/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php +++ b/lib/Cake/Test/Case/Network/Email/SmtpTransportTest.php @@ -52,7 +52,7 @@ protected function _generateSocket() { */ public function __call($method, $args) { $method = '_' . $method; - return call_user_func_array(array($this, $method), $args); + return call_user_func_array([$this, $method], $args); } } @@ -69,11 +69,11 @@ class SmtpTransportTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->socket = $this->getMock('CakeSocket', array('read', 'write', 'connect', 'enableCrypto')); + $this->socket = $this->getMock('CakeSocket', ['read', 'write', 'connect', 'enableCrypto']); $this->SmtpTransport = new SmtpTestTransport(); $this->SmtpTransport->setSocket($this->socket); - $this->SmtpTransport->config(array('client' => 'localhost')); + $this->SmtpTransport->config(['client' => 'localhost']); } /** @@ -99,7 +99,7 @@ public function testConnectEhlo() { * @return void */ public function testConnectEhloTls() { - $this->SmtpTransport->config(array('tls' => true)); + $this->SmtpTransport->config(['tls' => true]); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); @@ -120,7 +120,7 @@ public function testConnectEhloTls() { public function testConnectEhloTlsOnNonTlsServer() { $this->expectException(SocketException::class); $this->expectExceptionMessage("SMTP server did not accept the connection or trying to connect to non TLS SMTP server using TLS."); - $this->SmtpTransport->config(array('tls' => true)); + $this->SmtpTransport->config(['tls' => true]); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); @@ -138,7 +138,7 @@ public function testConnectEhloTlsOnNonTlsServer() { public function testConnectEhloNoTlsOnRequiredTlsServer() { $this->expectException(SocketException::class); $this->expectExceptionMessage("SMTP authentication method not allowed, check if SMTP server requires TLS."); - $this->SmtpTransport->config(array('tls' => false, 'username' => 'user', 'password' => 'pass')); + $this->SmtpTransport->config(['tls' => false, 'username' => 'user', 'password' => 'pass']); $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n")); $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n"); @@ -193,7 +193,7 @@ public function testAuth() { $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("334 Pass\r\n")); $this->socket->expects($this->at(4))->method('write')->with("c3Rvcnk=\r\n"); $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("235 OK\r\n")); - $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); + $this->SmtpTransport->config(['username' => 'mark', 'password' => 'story']); $this->SmtpTransport->auth(); } @@ -207,7 +207,7 @@ public function testAuthNotRecognized() { $this->expectExceptionMessage("AUTH command not recognized or not implemented, SMTP server may not require authentication."); $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("500 5.3.3 Unrecognized command\r\n")); - $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); + $this->SmtpTransport->config(['username' => 'mark', 'password' => 'story']); $this->SmtpTransport->auth(); } @@ -222,7 +222,7 @@ public function testAuthNotImplemented() { $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); $this->socket->expects($this->at(1))->method('read') ->will($this->returnValue("502 5.3.3 Command not implemented\r\n")); - $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); + $this->SmtpTransport->config(['username' => 'mark', 'password' => 'story']); $this->SmtpTransport->auth(); } @@ -237,7 +237,7 @@ public function testAuthBadSequence() { $this->socket->expects($this->at(0))->method('write')->with("AUTH LOGIN\r\n"); $this->socket->expects($this->at(1))->method('read') ->will($this->returnValue("503 5.5.1 Already authenticated\r\n")); - $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); + $this->SmtpTransport->config(['username' => 'mark', 'password' => 'story']); $this->SmtpTransport->auth(); } @@ -253,7 +253,7 @@ public function testAuthBadUsername() { $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("334 Login\r\n")); $this->socket->expects($this->at(2))->method('write')->with("bWFyaw==\r\n"); $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n")); - $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); + $this->SmtpTransport->config(['username' => 'mark', 'password' => 'story']); $this->SmtpTransport->auth(); } @@ -271,7 +271,7 @@ public function testAuthBadPassword() { $this->socket->expects($this->at(3))->method('read')->will($this->returnValue("334 Pass\r\n")); $this->socket->expects($this->at(4))->method('write')->with("c3Rvcnk=\r\n"); $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("535 5.7.8 Authentication failed\r\n")); - $this->SmtpTransport->config(array('username' => 'mark', 'password' => 'story')); + $this->SmtpTransport->config(['username' => 'mark', 'password' => 'story']); $this->SmtpTransport->auth(); } @@ -283,7 +283,7 @@ public function testAuthBadPassword() { public function testAuthNoAuth() { $this->socket->expects($this->any())->method('write')->with($this->logicalNot($this->stringContains('AUTH LOGIN'))); - $this->SmtpTransport->config(array('username' => null, 'password' => null)); + $this->SmtpTransport->config(['username' => null, 'password' => null]); $this->SmtpTransport->auth(); } @@ -297,7 +297,7 @@ public function testRcpt() { $email->from('noreply@cakephp.org', 'CakePHP Test'); $email->to('cake@cakephp.org', 'CakePHP'); $email->bcc('phpnut@cakephp.org'); - $email->cc(array('mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso')); + $email->cc(['mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso']); $this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:\r\n"); $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("250 OK\r\n")); @@ -338,17 +338,17 @@ public function testRcptWithReturnPath() { * @return void */ public function testSendData() { - $email = $this->getMock('CakeEmail', array('message'), array(), 'SmtpCakeEmail'); + $email = $this->getMock('CakeEmail', ['message'], [], 'SmtpCakeEmail'); $email->from('noreply@cakephp.org', 'CakePHP Test'); $email->returnPath('pleasereply@cakephp.org', 'CakePHP Return'); $email->to('cake@cakephp.org', 'CakePHP'); - $email->cc(array('mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso')); + $email->cc(['mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso']); $email->bcc('phpnut@cakephp.org'); $email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>'); $email->subject('Testing SMTP'); $date = date(DATE_RFC2822); - $email->setHeaders(array('X-Mailer' => SmtpCakeEmail::EMAIL_CLIENT, 'Date' => $date)); - $email->expects($this->once())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', ''))); + $email->setHeaders(['X-Mailer' => SmtpCakeEmail::EMAIL_CLIENT, 'Date' => $date]); + $email->expects($this->once())->method('message')->will($this->returnValue(['First Line', 'Second Line', '.Third Line', ''])); $data = "From: CakePHP Test \r\n"; $data .= "To: CakePHP \r\n"; @@ -391,14 +391,14 @@ public function testQuit() { * @return void */ public function testEmptyConfigArray() { - $expected = $this->SmtpTransport->config(array( + $expected = $this->SmtpTransport->config([ 'client' => 'myhost.com', 'port' => 666 - )); + ]); $this->assertEquals(666, $expected['port']); - $result = $this->SmtpTransport->config(array()); + $result = $this->SmtpTransport->config([]); $this->assertEquals($expected, $result); } @@ -425,18 +425,18 @@ public function testGetLastResponse() { $this->socket->expects($this->at(12))->method('read')->will($this->returnValue("250 DSN\r\n")); $this->SmtpTransport->connect(); - $expected = array( - array('code' => '250', 'message' => 'PIPELINING'), - array('code' => '250', 'message' => 'SIZE 102400000'), - array('code' => '250', 'message' => 'VRFY'), - array('code' => '250', 'message' => 'ETRN'), - array('code' => '250', 'message' => 'STARTTLS'), - array('code' => '250', 'message' => 'AUTH PLAIN LOGIN'), - array('code' => '250', 'message' => 'AUTH=PLAIN LOGIN'), - array('code' => '250', 'message' => 'ENHANCEDSTATUSCODES'), - array('code' => '250', 'message' => '8BITMIME'), - array('code' => '250', 'message' => 'DSN') - ); + $expected = [ + ['code' => '250', 'message' => 'PIPELINING'], + ['code' => '250', 'message' => 'SIZE 102400000'], + ['code' => '250', 'message' => 'VRFY'], + ['code' => '250', 'message' => 'ETRN'], + ['code' => '250', 'message' => 'STARTTLS'], + ['code' => '250', 'message' => 'AUTH PLAIN LOGIN'], + ['code' => '250', 'message' => 'AUTH=PLAIN LOGIN'], + ['code' => '250', 'message' => 'ENHANCEDSTATUSCODES'], + ['code' => '250', 'message' => '8BITMIME'], + ['code' => '250', 'message' => 'DSN'] + ]; $result = $this->SmtpTransport->getLastResponse(); $this->assertEquals($expected, $result); @@ -451,9 +451,9 @@ public function testGetLastResponse() { $this->SmtpTransport->sendRcpt($email); - $expected = array( - array('code' => '250', 'message' => 'OK'), - ); + $expected = [ + ['code' => '250', 'message' => 'OK'], + ]; $result = $this->SmtpTransport->getLastResponse(); $this->assertEquals($expected, $result); } @@ -464,7 +464,7 @@ public function testGetLastResponse() { * @return void */ public function testBufferResponseLines() { - $reponseLines = array( + $reponseLines = [ '123', "456\tFOO", 'FOOBAR', @@ -472,16 +472,16 @@ public function testBufferResponseLines() { '250-ENHANCEDSTATUSCODES', '250-8BITMIME', '250 DSN', - ); + ]; $this->SmtpTransport->bufferResponseLines($reponseLines); - $expected = array( - array('code' => '123', 'message' => null), - array('code' => '250', 'message' => 'PIPELINING'), - array('code' => '250', 'message' => 'ENHANCEDSTATUSCODES'), - array('code' => '250', 'message' => '8BITMIME'), - array('code' => '250', 'message' => 'DSN') - ); + $expected = [ + ['code' => '123', 'message' => null], + ['code' => '250', 'message' => 'PIPELINING'], + ['code' => '250', 'message' => 'ENHANCEDSTATUSCODES'], + ['code' => '250', 'message' => '8BITMIME'], + ['code' => '250', 'message' => 'DSN'] + ]; $result = $this->SmtpTransport->getLastResponse(); $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php b/lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php index c2501cc645..1bb92404ac 100644 --- a/lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php +++ b/lib/Cake/Test/Case/Network/Http/BasicAuthenticationTest.php @@ -52,11 +52,11 @@ class BasicAuthenticationTest extends CakeTestCase { */ public function testAuthentication() { $http = new HttpSocket(); - $auth = array( + $auth = [ 'method' => 'Basic', 'user' => 'mark', 'pass' => 'secret' - ); + ]; BasicAuthentication::authentication($http, $auth); $this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Authorization']); @@ -69,11 +69,11 @@ public function testAuthentication() { */ public function testProxyAuthentication() { $http = new HttpSocket(); - $proxy = array( + $proxy = [ 'method' => 'Basic', 'user' => 'mark', 'pass' => 'secret' - ); + ]; BasicAuthentication::proxyAuthentication($http, $proxy); $this->assertEquals('Basic bWFyazpzZWNyZXQ=', $http->request['header']['Proxy-Authorization']); @@ -87,13 +87,13 @@ public function testProxyAuthentication() { public function testProxyAuthenticationSsl() { $http = new TestSslHttpSocket(); $http->request['uri']['scheme'] = 'https'; - $proxy = array( + $proxy = [ 'host' => 'localhost', 'port' => 3128, 'method' => 'Basic', 'user' => 'mark', 'pass' => 'secret' - ); + ]; $http->testSetProxy($proxy); diff --git a/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php b/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php index 37deca1103..c4071babf1 100644 --- a/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php +++ b/lib/Cake/Test/Case/Network/Http/DigestAuthenticationTest.php @@ -39,7 +39,7 @@ class DigestHttpSocket extends HttpSocket { * @param mixed $request * @return void */ - public function request($request = array()) { + public function request($request = []) { if ($request === false) { if (isset($this->response['header']['WWW-Authenticate'])) { unset($this->response['header']['WWW-Authenticate']); @@ -96,7 +96,7 @@ public function testBasic() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; $this->assertFalse(isset($this->HttpSocket->request['header']['Authorization'])); - $auth = array('user' => 'admin', 'pass' => '1234'); + $auth = ['user' => 'admin', 'pass' => '1234']; DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertTrue(isset($this->HttpSocket->request['header']['Authorization'])); $this->assertEquals('The batcave', $auth['realm']); @@ -110,7 +110,7 @@ public function testBasic() { */ public function testQop() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; - $auth = array('user' => 'admin', 'pass' => '1234'); + $auth = ['user' => 'admin', 'pass' => '1234']; DigestAuthentication::authentication($this->HttpSocket, $auth); $expected = 'Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="da7e2a46b471d77f70a9bb3698c8902b"'; $this->assertEquals($expected, $this->HttpSocket->request['header']['Authorization']); @@ -118,7 +118,7 @@ public function testQop() { $this->assertFalse(isset($auth['nc'])); $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'; - $auth = array('user' => 'admin', 'pass' => '1234'); + $auth = ['user' => 'admin', 'pass' => '1234']; DigestAuthentication::authentication($this->HttpSocket, $auth); $expected = '@Digest username="admin", realm="The batcave", nonce="4cded326c6c51", uri="/", response="[a-z0-9]{32}", qop="auth", nc=00000001, cnonce="[a-z0-9]+"@'; $this->assertMatchesRegularExpression($expected, $this->HttpSocket->request['header']['Authorization']); @@ -133,12 +133,12 @@ public function testQop() { */ public function testOpaque() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; - $auth = array('user' => 'admin', 'pass' => '1234'); + $auth = ['user' => 'admin', 'pass' => '1234']; DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertFalse(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"')); $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",opaque="d8ea7aa61a1693024c4cc3a516f49b3c"'; - $auth = array('user' => 'admin', 'pass' => '1234'); + $auth = ['user' => 'admin', 'pass' => '1234']; DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'opaque="d8ea7aa61a1693024c4cc3a516f49b3c"') > 0); } @@ -150,7 +150,7 @@ public function testOpaque() { */ public function testMultipleRequest() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51",qop="auth"'; - $auth = array('user' => 'admin', 'pass' => '1234'); + $auth = ['user' => 'admin', 'pass' => '1234']; DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertTrue(strpos($this->HttpSocket->request['header']['Authorization'], 'nc=00000001') > 0); $this->assertEquals(2, $auth['nc']); @@ -178,7 +178,7 @@ public function testMultipleRequest() { public function testPathChanged() { $this->HttpSocket->nextHeader = 'Digest realm="The batcave",nonce="4cded326c6c51"'; $this->HttpSocket->request['uri']['path'] = '/admin'; - $auth = array('user' => 'admin', 'pass' => '1234'); + $auth = ['user' => 'admin', 'pass' => '1234']; DigestAuthentication::authentication($this->HttpSocket, $auth); $responsePos = strpos($this->HttpSocket->request['header']['Authorization'], 'response='); $response = substr($this->HttpSocket->request['header']['Authorization'], $responsePos + 10, 32); @@ -193,7 +193,7 @@ public function testPathChanged() { public function testNoDigestResponse() { $this->HttpSocket->nextHeader = false; $this->HttpSocket->request['uri']['path'] = '/admin'; - $auth = array('user' => 'admin', 'pass' => '1234'); + $auth = ['user' => 'admin', 'pass' => '1234']; DigestAuthentication::authentication($this->HttpSocket, $auth); $this->assertFalse(isset($this->HttpSocket->request['header']['Authorization'])); } diff --git a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php index 928fb0dbd8..50eabff7e0 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpResponseTest.php @@ -128,12 +128,12 @@ public function testToString() { * @return void */ public function testGetHeader() { - $this->HttpResponse->headers = array( + $this->HttpResponse->headers = [ 'foo' => 'Bar', 'Some' => 'ok', 'HeAdEr' => 'value', 'content-Type' => 'text/plain' - ); + ]; $this->assertEquals('Bar', $this->HttpResponse->getHeader('foo')); $this->assertEquals('Bar', $this->HttpResponse->getHeader('Foo')); @@ -143,7 +143,7 @@ public function testGetHeader() { $this->assertNull($this->HttpResponse->getHeader(0)); $this->assertEquals('Bar', $this->HttpResponse->getHeader('foo', false)); - $this->assertEquals('not from class', $this->HttpResponse->getHeader('foo', array('foo' => 'not from class'))); + $this->assertEquals('not from class', $this->HttpResponse->getHeader('foo', ['foo' => 'not from class'])); } /** @@ -230,65 +230,65 @@ public function testIsRedirect() { * @return void */ public function testParseHeader() { - $r = $this->HttpResponse->parseHeader(array('foo' => 'Bar', 'fOO-bAr' => 'quux')); - $this->assertEquals(array('foo' => 'Bar', 'fOO-bAr' => 'quux'), $r); + $r = $this->HttpResponse->parseHeader(['foo' => 'Bar', 'fOO-bAr' => 'quux']); + $this->assertEquals(['foo' => 'Bar', 'fOO-bAr' => 'quux'], $r); $r = $this->HttpResponse->parseHeader(true); $this->assertEquals(false, $r); $header = "Host: cakephp.org\t\r\n"; $r = $this->HttpResponse->parseHeader($header); - $expected = array( + $expected = [ 'Host' => 'cakephp.org' - ); + ]; $this->assertEquals($expected, $r); $header = "Date:Sat, 07 Apr 2007 10:10:25 GMT\r\nX-Powered-By: PHP/5.1.2\r\n"; $r = $this->HttpResponse->parseHeader($header); - $expected = array( + $expected = [ 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT', 'X-Powered-By' => 'PHP/5.1.2' - ); + ]; $this->assertEquals($expected, $r); $header = "people: Jim,John\r\nfoo-LAND: Bar\r\ncAKe-PHP: rocks\r\n"; $r = $this->HttpResponse->parseHeader($header); - $expected = array( + $expected = [ 'people' => 'Jim,John', 'foo-LAND' => 'Bar', 'cAKe-PHP' => 'rocks' - ); + ]; $this->assertEquals($expected, $r); $header = "People: Jim,John,Tim\r\nPeople: Lisa,Tina,Chelsea\r\n"; $r = $this->HttpResponse->parseHeader($header); - $expected = array( - 'People' => array('Jim,John,Tim', 'Lisa,Tina,Chelsea') - ); + $expected = [ + 'People' => ['Jim,John,Tim', 'Lisa,Tina,Chelsea'] + ]; $this->assertEquals($expected, $r); $header = "Date:Sat, 07 Apr 2007 10:10:25 GMT\r\nLink: \r\nX-Total-Count: 19\r\n"; $r = $this->HttpResponse->parseHeader($header); - $expected = array( + $expected = [ 'Date' => 'Sat, 07 Apr 2007 10:10:25 GMT', 'Link' => '', 'X-Total-Count' => '19', - ); + ]; $this->assertEquals($expected, $r); $header = "Multi-Line: I am a\r\n multi line \r\n\tfield value.\r\nSingle-Line: I am not\r\n"; $r = $this->HttpResponse->parseHeader($header); - $expected = array( + $expected = [ 'Multi-Line' => "I am a multi line field value.", 'Single-Line' => 'I am not' - ); + ]; $this->assertEquals($expected, $r); $header = "Esc\"@\"ped: value\r\n"; $r = $this->HttpResponse->parseHeader($header); - $expected = array( + $expected = [ 'Esc@ped' => 'value' - ); + ]; $this->assertEquals($expected, $r); } @@ -298,35 +298,35 @@ public function testParseHeader() { * @return void */ public function testParseResponse() { - $tests = array( - 'simple-request' => array( - 'response' => array( + $tests = [ + 'simple-request' => [ + 'response' => [ 'status-line' => "HTTP/1.x 200 OK\r\n", 'header' => "Date: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\n", 'body' => "

Hello World

\r\n

It's good to be html

" - ), - 'expectations' => array( + ], + 'expectations' => [ 'httpVersion' => 'HTTP/1.x', 'code' => 200, 'reasonPhrase' => 'OK', - 'headers' => array('Date' => 'Mon, 16 Apr 2007 04:14:16 GMT', 'Server' => 'CakeHttp Server'), + 'headers' => ['Date' => 'Mon, 16 Apr 2007 04:14:16 GMT', 'Server' => 'CakeHttp Server'], 'body' => "

Hello World

\r\n

It's good to be html

" - ) - ), - 'no-header' => array( - 'response' => array( + ] + ], + 'no-header' => [ + 'response' => [ 'status-line' => "HTTP/1.x 404 OK\r\n", 'header' => null - ), - 'expectations' => array( + ], + 'expectations' => [ 'code' => 404, - 'headers' => array() - ) - ) - ); + 'headers' => [] + ] + ] + ]; - $testResponse = array(); - $expectations = array(); + $testResponse = []; + $expectations = []; foreach ($tests as $name => $test) { $testResponse = array_merge($testResponse, $test['response']); @@ -338,7 +338,7 @@ public function testParseResponse() { $this->assertEquals($expectedVal, $this->HttpResponse->{$property}, 'Test "' . $name . '": response.' . $property . ' - %s'); } - foreach (array('status-line', 'header', 'body', 'response') as $field) { + foreach (['status-line', 'header', 'body', 'response'] as $field) { $this->assertEquals($this->HttpResponse['raw'][$field], $testResponse[$field], 'Test response.raw.' . $field . ': %s'); } } @@ -350,12 +350,12 @@ public function testParseResponse() { * @return array */ public static function invalidParseResponseDataProvider() { - return array( - array(array('foo' => 'bar')), - array(true), - array("HTTP Foo\r\nBar: La"), - array('HTTP/1.1 TEST ERROR') - ); + return [ + [['foo' => 'bar']], + [true], + ["HTTP Foo\r\nBar: La"], + ['HTTP/1.1 TEST ERROR'] + ]; } /** @@ -379,22 +379,22 @@ public function testDecodeBody() { $this->assertEquals(false, $r); $r = $this->HttpResponse->decodeBody('Foobar', false); - $this->assertEquals(array('body' => 'Foobar', 'header' => false), $r); + $this->assertEquals(['body' => 'Foobar', 'header' => false], $r); $encoding = 'chunked'; - $sample = array( + $sample = [ 'encoded' => "19\r\nThis is a chunked message\r\n0\r\n", - 'decoded' => array('body' => "This is a chunked message", 'header' => false) - ); + 'decoded' => ['body' => "This is a chunked message", 'header' => false] + ]; $r = $this->HttpResponse->decodeBody($sample['encoded'], $encoding); $this->assertEquals($r, $sample['decoded']); $encoding = 'chunked'; - $sample = array( + $sample = [ 'encoded' => "19\nThis is a chunked message\r\n0\n", - 'decoded' => array('body' => "This is a chunked message", 'header' => false) - ); + 'decoded' => ['body' => "This is a chunked message", 'header' => false] + ]; $r = $this->HttpResponse->decodeBody($sample['encoded'], $encoding); $this->assertEquals($r, $sample['decoded'], 'Inconsistent line terminators should be tolerated.'); @@ -410,13 +410,13 @@ public function testDecodeFooCoded() { $this->assertEquals(false, $r); $r = $this->HttpResponse->decodeBody('Foobar', false); - $this->assertEquals(array('body' => 'Foobar', 'header' => false), $r); + $this->assertEquals(['body' => 'Foobar', 'header' => false], $r); $encoding = 'foo-bar'; - $sample = array( + $sample = [ 'encoded' => '!Foobar!', - 'decoded' => array('body' => '!Foobar!', 'header' => false), - ); + 'decoded' => ['body' => '!Foobar!', 'header' => false], + ]; $r = $this->HttpResponse->decodeBody($sample['encoded'], $encoding); $this->assertEquals($r, $sample['decoded']); @@ -455,7 +455,7 @@ public function testDecodeChunkedBody() { $encoded = "19\r\nThis is a chunked message\r\nE\r\n\nThat is cool\n\r\n0\r\nfoo-header: bar\r\ncake: PHP\r\n\r\n"; $r = $this->HttpResponse->decodeChunkedBody($encoded); $this->assertEquals($r['body'], $decoded); - $this->assertEquals(array('foo-header' => 'bar', 'cake' => 'PHP'), $r['header']); + $this->assertEquals(['foo-header' => 'bar', 'cake' => 'PHP'], $r['header']); } /** @@ -476,46 +476,46 @@ public function testDecodeChunkedBodyError() { * @return void */ public function testParseCookies() { - $header = array( - 'Set-Cookie' => array( + $header = [ + 'Set-Cookie' => [ 'foo=bar', 'people=jim,jack,johnny";";Path=/accounts', 'google=not=nice', '1271; domain=.example.com; expires=Fri, 04-Nov-2016 12:50:26 GMT; path=/', 'cakephp=great; Secure' - ), + ], 'Transfer-Encoding' => 'chunked', 'Date' => 'Sun, 18 Nov 2007 18:57:42 GMT', - ); + ]; $cookies = $this->HttpResponse->parseCookies($header); - $expected = array( - 'foo' => array( + $expected = [ + 'foo' => [ 'value' => 'bar' - ), - 'people' => array( + ], + 'people' => [ 'value' => 'jim,jack,johnny";"', 'path' => '/accounts', - ), - 'google' => array( + ], + 'google' => [ 'value' => 'not=nice', - ), - '' => array( + ], + '' => [ 'value' => '1271', 'domain' => '.example.com', 'expires' => 'Fri, 04-Nov-2016 12:50:26 GMT', 'path' => '/' - ), - 'cakephp' => array( + ], + 'cakephp' => [ 'value' => 'great', 'secure' => true, - ) - ); + ] + ]; $this->assertEquals($expected, $cookies); $header['Set-Cookie'] = 'foo=bar'; - $expected = array( - 'foo' => array('value' => 'bar') - ); + $expected = [ + 'foo' => ['value' => 'bar'] + ]; $cookies = $this->HttpResponse->parseCookies($header); $this->assertEquals($expected, $cookies); } @@ -552,14 +552,14 @@ public function testArrayAccess() { $this->HttpResponse->httpVersion = 'HTTP/1.1'; $this->HttpResponse->code = 200; $this->HttpResponse->reasonPhrase = 'OK'; - $this->HttpResponse->headers = array( + $this->HttpResponse->headers = [ 'Server' => 'CakePHP', 'ContEnt-Type' => 'text/plain' - ); - $this->HttpResponse->cookies = array( - 'foo' => array('value' => 'bar'), - 'bar' => array('value' => 'foo') - ); + ]; + $this->HttpResponse->cookies = [ + 'foo' => ['value' => 'bar'], + 'bar' => ['value' => 'foo'] + ]; $this->HttpResponse->body = 'This is a test!'; $this->HttpResponse->raw = "HTTP/1.1 200 OK\r\nServer: CakePHP\r\nContEnt-Type: text/plain\r\n\r\nThis is a test!"; $expectedOne = "HTTP/1.1 200 OK\r\n"; @@ -578,19 +578,19 @@ public function testArrayAccess() { $expected = 'OK'; $this->assertEquals($expected, $this->HttpResponse['status']['reason-phrase']); - $expected = array( + $expected = [ 'Server' => 'CakePHP', 'ContEnt-Type' => 'text/plain' - ); + ]; $this->assertEquals($expected, $this->HttpResponse['header']); $expected = 'This is a test!'; $this->assertEquals($expected, $this->HttpResponse['body']); - $expected = array( - 'foo' => array('value' => 'bar'), - 'bar' => array('value' => 'foo') - ); + $expected = [ + 'foo' => ['value' => 'bar'], + 'bar' => ['value' => 'foo'] + ]; $this->assertEquals($expected, $this->HttpResponse['cookies']); $this->HttpResponse->raw = "HTTP/1.1 200 OK\r\n\r\nThis is a test!"; diff --git a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php index 07dfb6c87a..62fa3616b2 100644 --- a/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php +++ b/lib/Cake/Test/Case/Network/Http/HttpSocketTest.php @@ -95,7 +95,7 @@ public function configUri($uri = null) { * @param bool|array $base If true use default URI config, otherwise indexed array to set 'scheme', 'host', 'port', etc. * @return array Parsed URI */ - public function parseUri($uri = null, $base = array()) { + public function parseUri($uri = null, $base = []) { return parent::_parseUri($uri, $base); } @@ -106,7 +106,7 @@ public function parseUri($uri = null, $base = array()) { * @param string $uriTemplate The Uri template/format to use * @return string A fully qualified URL formatted according to $uriTemplate */ - public function buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { + public function buildUri($uri = [], $uriTemplate = '%scheme://%user:%pass@%host:%port/%path?%query#%fragment') { return parent::_buildUri($uri, $uriTemplate); } @@ -136,7 +136,7 @@ public function parseQuery($query) { * @param array $request Needs to contain a 'uri' key. Should also contain a 'method' key, otherwise defaults to GET. * @return string Request line */ - public function buildRequestLine($request = array()) { + public function buildRequestLine($request = []) { return parent::_buildRequestLine($request); } @@ -190,8 +190,8 @@ class HttpSocketTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $this->Socket = $this->getMock('TestHttpSocket', array('read', 'write', 'connect')); - $this->RequestSocket = $this->getMock('TestHttpSocket', array('read', 'write', 'connect', 'request')); + $this->Socket = $this->getMock('TestHttpSocket', ['read', 'write', 'connect']); + $this->RequestSocket = $this->getMock('TestHttpSocket', ['read', 'write', 'connect', 'request']); } /** @@ -213,7 +213,7 @@ public function testConstruct() { $this->Socket->reset(); $baseConfig = $this->Socket->config; $this->Socket->expects($this->never())->method('connect'); - $this->Socket->__construct(array('host' => 'foo-bar')); + $this->Socket->__construct(['host' => 'foo-bar']); $baseConfig['host'] = 'foo-bar'; $baseConfig['cryptoType'] = 'tls'; $this->assertEquals($this->Socket->config, $baseConfig); @@ -228,7 +228,7 @@ public function testConstruct() { $this->assertEquals($this->Socket->config, $baseConfig); $this->Socket->reset(); - $this->Socket->__construct(array('request' => array('uri' => 'http://www.cakephp.org:23/'))); + $this->Socket->__construct(['request' => ['uri' => 'http://www.cakephp.org:23/']]); $this->assertEquals($this->Socket->config, $baseConfig); } @@ -240,7 +240,7 @@ public function testConstruct() { public function testConfigUri() { $this->Socket->reset(); $r = $this->Socket->configUri('https://bob:secret@www.cakephp.org:23/?query=foo'); - $expected = array( + $expected = [ 'persistent' => false, 'host' => 'www.cakephp.org', 'protocol' => 'tcp', @@ -250,26 +250,26 @@ public function testConfigUri() { 'ssl_allow_self_signed' => false, 'ssl_verify_depth' => 5, 'ssl_verify_host' => true, - 'request' => array( - 'uri' => array( + 'request' => [ + 'uri' => [ 'scheme' => 'https', 'host' => 'www.cakephp.org', 'port' => 23 - ), + ], 'redirect' => false, - 'cookies' => array(), - ) - ); + 'cookies' => [], + ] + ]; $this->assertEquals($expected, $this->Socket->config); $this->assertTrue($r); - $r = $this->Socket->configUri(array('host' => 'www.foo-bar.org')); + $r = $this->Socket->configUri(['host' => 'www.foo-bar.org']); $expected['host'] = 'www.foo-bar.org'; $expected['request']['uri']['host'] = 'www.foo-bar.org'; $this->assertEquals($expected, $this->Socket->config); $this->assertTrue($r); $r = $this->Socket->configUri('http://www.foo.com'); - $expected = array( + $expected = [ 'persistent' => false, 'host' => 'www.foo.com', 'protocol' => 'tcp', @@ -279,16 +279,16 @@ public function testConfigUri() { 'ssl_allow_self_signed' => false, 'ssl_verify_depth' => 5, 'ssl_verify_host' => true, - 'request' => array( - 'uri' => array( + 'request' => [ + 'uri' => [ 'scheme' => 'http', 'host' => 'www.foo.com', 'port' => 80 - ), + ], 'redirect' => false, - 'cookies' => array(), - ) - ); + 'cookies' => [], + ] + ]; $this->assertEquals($expected, $this->Socket->config); $this->assertTrue($r); @@ -316,11 +316,11 @@ public function testRequest() { $response = $this->Socket->request(true); $this->assertFalse($response); - $tests = array( - array( + $tests = [ + [ 'request' => 'http://www.cakephp.org/?foo=bar', - 'expectation' => array( - 'config' => array( + 'expectation' => [ + 'config' => [ 'persistent' => false, 'host' => 'www.cakephp.org', 'protocol' => 'tcp', @@ -330,224 +330,224 @@ public function testRequest() { 'ssl_allow_self_signed' => false, 'ssl_verify_depth' => 5, 'ssl_verify_host' => true, - 'request' => array( - 'uri' => array( + 'request' => [ + 'uri' => [ 'scheme' => 'http', 'host' => 'www.cakephp.org', 'port' => 80 - ), + ], 'redirect' => false, - 'cookies' => array() - ) - ), - 'request' => array( + 'cookies' => [] + ] + ], + 'request' => [ 'method' => 'GET', - 'uri' => array( + 'uri' => [ 'scheme' => 'http', 'host' => 'www.cakephp.org', 'port' => 80, 'user' => null, 'pass' => null, 'path' => '/', - 'query' => array('foo' => 'bar'), + 'query' => ['foo' => 'bar'], 'fragment' => null - ), + ], 'version' => '1.1', 'body' => '', 'line' => "GET /?foo=bar HTTP/1.1\r\n", 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n", 'raw' => "", 'redirect' => false, - 'cookies' => array(), - 'proxy' => array(), - 'auth' => array() - ) - ) - ), - array( - 'request' => array( - 'uri' => array( + 'cookies' => [], + 'proxy' => [], + 'auth' => [] + ] + ] + ], + [ + 'request' => [ + 'uri' => [ 'host' => 'www.cakephp.org', 'query' => '?foo=bar' - ) - ) - ), - array( + ] + ] + ], + [ 'request' => 'www.cakephp.org/?foo=bar' - ), - array( - 'request' => array( + ], + [ + 'request' => [ 'host' => '192.168.0.1', 'uri' => 'http://www.cakephp.org/?foo=bar' - ), - 'expectation' => array( - 'request' => array( - 'uri' => array('host' => 'www.cakephp.org') - ), - 'config' => array( - 'request' => array( - 'uri' => array('host' => 'www.cakephp.org') - ), + ], + 'expectation' => [ + 'request' => [ + 'uri' => ['host' => 'www.cakephp.org'] + ], + 'config' => [ + 'request' => [ + 'uri' => ['host' => 'www.cakephp.org'] + ], 'host' => '192.168.0.1' - ) - ) - ), - 'reset4' => array( - 'request.uri.query' => array() - ), - array( - 'request' => array( - 'header' => array('Foo@woo' => 'bar-value') - ), - 'expectation' => array( - 'request' => array( + ] + ] + ], + 'reset4' => [ + 'request.uri.query' => [] + ], + [ + 'request' => [ + 'header' => ['Foo@woo' => 'bar-value'] + ], + 'expectation' => [ + 'request' => [ 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nFoo\"@\"woo: bar-value\r\n", 'line' => "GET / HTTP/1.1\r\n" - ) - ) - ), - array( - 'request' => array('header' => array('Foo@woo' => 'bar-value', 'host' => 'foo.com'), 'uri' => 'http://www.cakephp.org/'), - 'expectation' => array( - 'request' => array( + ] + ] + ], + [ + 'request' => ['header' => ['Foo@woo' => 'bar-value', 'host' => 'foo.com'], 'uri' => 'http://www.cakephp.org/'], + 'expectation' => [ + 'request' => [ 'header' => "Host: foo.com\r\nConnection: close\r\nUser-Agent: CakePHP\r\nFoo\"@\"woo: bar-value\r\n" - ), - 'config' => array( + ], + 'config' => [ 'host' => 'www.cakephp.org' - ) - ) - ), - array( - 'request' => array('header' => "Foo: bar\r\n"), - 'expectation' => array( - 'request' => array( + ] + ] + ], + [ + 'request' => ['header' => "Foo: bar\r\n"], + 'expectation' => [ + 'request' => [ 'header' => "Foo: bar\r\n" - ) - ) - ), - array( - 'request' => array('header' => "Foo: bar\r\n", 'uri' => 'http://www.cakephp.org/search?q=http_socket#ignore-me'), - 'expectation' => array( - 'request' => array( - 'uri' => array( + ] + ] + ], + [ + 'request' => ['header' => "Foo: bar\r\n", 'uri' => 'http://www.cakephp.org/search?q=http_socket#ignore-me'], + 'expectation' => [ + 'request' => [ + 'uri' => [ 'path' => '/search', - 'query' => array('q' => 'http_socket'), + 'query' => ['q' => 'http_socket'], 'fragment' => 'ignore-me' - ), + ], 'line' => "GET /search?q=http_socket HTTP/1.1\r\n" - ) - ) - ), - 'reset8' => array( - 'request.uri.query' => array() - ), - array( - 'request' => array( + ] + ] + ], + 'reset8' => [ + 'request.uri.query' => [] + ], + [ + 'request' => [ 'method' => 'POST', 'uri' => 'http://www.cakephp.org/posts/add', - 'body' => array( + 'body' => [ 'name' => 'HttpSocket-is-released', 'date' => 'today' - ) - ), - 'expectation' => array( - 'request' => array( + ] + ], + 'expectation' => [ + 'request' => [ 'method' => 'POST', - 'uri' => array( + 'uri' => [ 'path' => '/posts/add', 'fragment' => null - ), + ], 'body' => "name=HttpSocket-is-released&date=today", 'line' => "POST /posts/add HTTP/1.1\r\n", 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n", 'raw' => "name=HttpSocket-is-released&date=today" - ) - ) - ), - array( - 'request' => array( + ] + ] + ], + [ + 'request' => [ 'method' => 'POST', 'uri' => 'http://www.cakephp.org:8080/posts/add', - 'body' => array( + 'body' => [ 'name' => 'HttpSocket-is-released', 'date' => 'today' - ) - ), - 'expectation' => array( - 'config' => array( + ] + ], + 'expectation' => [ + 'config' => [ 'port' => 8080, - 'request' => array( - 'uri' => array( + 'request' => [ + 'uri' => [ 'port' => 8080 - ) - ) - ), - 'request' => array( - 'uri' => array( + ] + ] + ], + 'request' => [ + 'uri' => [ 'port' => 8080 - ), + ], 'header' => "Host: www.cakephp.org:8080\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" - ) - ) - ), - 'reset10' => array( + ] + ] + ], + 'reset10' => [ 'config.protocol' => 'ssl' - ), - array( - 'request' => array( + ], + [ + 'request' => [ 'method' => 'POST', 'uri' => 'https://www.cakephp.org/posts/add', - 'body' => array( + 'body' => [ 'name' => 'HttpSocket-is-released', 'date' => 'today' - ) - ), - 'expectation' => array( - 'config' => array( + ] + ], + 'expectation' => [ + 'config' => [ 'port' => 443, - 'request' => array( - 'uri' => array( + 'request' => [ + 'uri' => [ 'scheme' => 'https', 'port' => 443 - ) - ) - ), - 'request' => array( - 'uri' => array( + ] + ] + ], + 'request' => [ + 'uri' => [ 'scheme' => 'https', 'port' => 443 - ), + ], 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\n" - ) - ) - ), - 'reset11' => array( + ] + ] + ], + 'reset11' => [ 'config.protocol' => 'ssl' - ), - array( - 'request' => array( + ], + [ + 'request' => [ 'version' => '1.0', 'method' => 'POST', 'uri' => 'https://www.cakephp.org/posts/add', - 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today'), - 'cookies' => array('foo' => array('value' => 'bar')) - ), - 'expectation' => array( - 'request' => array( + 'body' => ['name' => 'HttpSocket-is-released', 'date' => 'today'], + 'cookies' => ['foo' => ['value' => 'bar']] + ], + 'expectation' => [ + 'request' => [ 'version' => '1.0', 'line' => "POST /posts/add HTTP/1.0\r\n", 'header' => "Host: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nContent-Type: application/x-www-form-urlencoded\r\nContent-Length: 38\r\nCookie: foo=bar\r\n", - 'cookies' => array( - 'foo' => array('value' => 'bar'), - ) - ) - ) - ) - ); - - $expectation = array(); + 'cookies' => [ + 'foo' => ['value' => 'bar'], + ] + ] + ] + ] + ]; + + $expectation = []; foreach ($tests as $i => $test) { - if (strpos($i, 'reset') === 0) { + if (str_starts_with($i, 'reset')) { foreach ($test as $path => $val) { $expectation = Hash::insert($expectation, $path, $val); } @@ -562,13 +562,13 @@ public function testRequest() { $raw = $expectation['request']['raw']; $expectation['request']['raw'] = $expectation['request']['line'] . $expectation['request']['header'] . "\r\n" . $raw; - $r = array('config' => $this->Socket->config, 'request' => $this->Socket->request); + $r = ['config' => $this->Socket->config, 'request' => $this->Socket->request]; $this->assertEquals($r, $expectation, 'Failed test #' . $i . ' '); $expectation['request']['raw'] = $raw; } $this->Socket->reset(); - $request = array('method' => 'POST', 'uri' => 'http://www.cakephp.org/posts/add', 'body' => array('name' => 'HttpSocket-is-released', 'date' => 'today')); + $request = ['method' => 'POST', 'uri' => 'http://www.cakephp.org/posts/add', 'body' => ['name' => 'HttpSocket-is-released', 'date' => 'today']]; $this->Socket->request($request); $this->assertEquals("name=HttpSocket-is-released&date=today", $this->Socket->request['body']); } @@ -584,15 +584,15 @@ public function testGetWithSchemeAndPort() { ->will($this->returnValue(false)); $this->Socket->reset(); - $request = array( - 'uri' => array( + $request = [ + 'uri' => [ 'scheme' => 'http', 'host' => 'cakephp.org', 'port' => 8080, 'path' => '/', - ), + ], 'method' => 'GET' - ); + ]; $this->Socket->request($request); $this->assertStringContainsString('Host: cakephp.org:8080', $this->Socket->request['header']); } @@ -608,15 +608,15 @@ public function testRequestWithStringQuery() { ->will($this->returnValue(false)); $this->Socket->reset(); - $request = array( - 'uri' => array( + $request = [ + 'uri' => [ 'scheme' => 'http', 'host' => 'cakephp.org', 'path' => 'index.php', 'query' => 'somestring' - ), + ], 'method' => 'GET' - ); + ]; $this->Socket->request($request); $this->assertStringContainsString("GET /index.php?somestring HTTP/1.1", $this->Socket->request['line']); } @@ -629,7 +629,7 @@ public function testRequestWithStringQuery() { public function testRequestNotAllowedUri() { $this->expectException(SocketException::class); $this->Socket->reset(); - $request = array('uri' => '*', 'method' => 'GET'); + $request = ['uri' => '*', 'method' => 'GET']; $this->Socket->request($request); } @@ -641,7 +641,7 @@ public function testRequestNotAllowedUri() { public function testRequest2() { $this->Socket->reset(); - $request = array('uri' => 'htpp://www.cakephp.org/'); + $request = ['uri' => 'htpp://www.cakephp.org/']; $number = mt_rand(0, 9999999); $this->Socket->expects($this->any())->method('connect')->will($this->returnValue(true)); $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

Hello, your lucky number is " . $number . "

"; @@ -662,7 +662,7 @@ public function testRequest2() { * @return void */ public function testRequest3() { - $request = array('uri' => 'htpp://www.cakephp.org/'); + $request = ['uri' => 'htpp://www.cakephp.org/']; $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a cookie test!

"; $this->Socket->expects($this->any()) @@ -672,11 +672,11 @@ public function testRequest3() { $this->Socket->connected = true; $this->Socket->request($request); $result = $this->Socket->response['cookies']; - $expected = array( - 'foo' => array( + $expected = [ + 'foo' => [ 'value' => 'bar' - ) - ); + ] + ]; $this->assertEquals($expected, $result); $this->assertEquals($expected, $this->Socket->config['request']['cookies']['www.cakephp.org']); $this->assertFalse($this->Socket->connected); @@ -688,26 +688,26 @@ public function testRequest3() { * @return void */ public function testRequestWithConstructor() { - $request = array( - 'request' => array( - 'uri' => array( + $request = [ + 'request' => [ + 'uri' => [ 'scheme' => 'http', 'host' => 'localhost', 'port' => '5984', 'user' => null, 'pass' => null - ) - ) - ); - $http = $this->getMock('TestHttpSocket', array('read', 'write', 'connect', 'request'), array($request)); + ] + ] + ]; + $http = $this->getMock('TestHttpSocket', ['read', 'write', 'connect', 'request'], [$request]); - $expected = array('method' => 'GET', 'uri' => 'http://localhost:5984/_test'); + $expected = ['method' => 'GET', 'uri' => 'http://localhost:5984/_test']; $http->expects($this->at(0))->method('request')->with($expected); $http->get('/_test'); - $expected = array('method' => 'GET', 'uri' => 'http://localhost:5984/_test?count=4'); + $expected = ['method' => 'GET', 'uri' => 'http://localhost:5984/_test?count=4']; $http->expects($this->at(0))->method('request')->with($expected); - $http->get('/_test', array('count' => 4)); + $http->get('/_test', ['count' => 4]); } /** @@ -748,14 +748,14 @@ public function testRequestWithResource() { */ public function testRequestWithCrossCookie() { $this->Socket->connected = true; - $this->Socket->config['request']['cookies'] = array(); + $this->Socket->config['request']['cookies'] = []; $serverResponse = "HTTP/1.x 200 OK\r\nSet-Cookie: foo=bar\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); - $expected = array('www.cakephp.org' => array('foo' => array('value' => 'bar'))); + $expected = ['www.cakephp.org' => ['foo' => ['value' => 'bar']]]; $this->Socket->request('http://www.cakephp.org/'); $this->assertEquals($expected, $this->Socket->config['request']['cookies']); @@ -763,8 +763,8 @@ public function testRequestWithCrossCookie() { $this->Socket->expects($this->at(1))->method('read')->will($this->returnValue($serverResponse)); $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); $this->Socket->request('http://www.cakephp.org/other'); - $this->assertEquals(array('foo' => array('value' => 'bar')), $this->Socket->request['cookies']); - $expected['www.cakephp.org'] += array('bar' => array('value' => 'foo')); + $this->assertEquals(['foo' => ['value' => 'bar']], $this->Socket->request['cookies']); + $expected['www.cakephp.org'] += ['bar' => ['value' => 'foo']]; $this->assertEquals($expected, $this->Socket->config['request']['cookies']); $serverResponse = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

This is a test!

"; @@ -778,7 +778,7 @@ public function testRequestWithCrossCookie() { $this->Socket->expects($this->at(2))->method('read')->will($this->returnValue(false)); $this->Socket->request('http://www.cake.com'); $this->assertTrue(empty($this->Socket->request['cookies'])); - $expected['www.cake.com'] = array('foobar' => array('value' => 'ok')); + $expected['www.cake.com'] = ['foobar' => ['value' => 'ok']]; $this->assertEquals($expected, $this->Socket->config['request']['cookies']); } @@ -806,10 +806,10 @@ public function testRequestCustomResponse() { * @return void */ public function testRequestWithRedirectUrlEncoded() { - $request = array( + $request = [ 'uri' => 'http://localhost/oneuri', 'redirect' => 1 - ); + ]; $serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://i.cmpnet.com%2Ftechonline%2Fpdf%2Fa+b.pdf=\r\n\r\n"; $serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

You have been redirected

"; @@ -840,10 +840,10 @@ public function testRequestWithRedirectUrlEncoded() { * @return void */ public function testRequestWithRedirectAsTrue() { - $request = array( + $request = [ 'uri' => 'http://localhost/oneuri', 'redirect' => true - ); + ]; $serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n"; $serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

You have been redirected

"; @@ -861,10 +861,10 @@ public function testRequestWithRedirectAsTrue() { * @return void */ public function testRequestWithRedirectAsInt() { - $request = array( + $request = [ 'uri' => 'http://localhost/oneuri', 'redirect' => 2 - ); + ]; $serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n"; $serverResponse2 = "HTTP/1.x 200 OK\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\n\r\n

You have been redirected

"; @@ -882,10 +882,10 @@ public function testRequestWithRedirectAsInt() { * @return void */ public function testRequestWithRedirectAsIntReachingZero() { - $request = array( + $request = [ 'uri' => 'http://localhost/oneuri', 'redirect' => 1 - ); + ]; $serverResponse1 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/oneruri\r\n\r\n"; $serverResponse2 = "HTTP/1.x 302 Found\r\nDate: Mon, 16 Apr 2007 04:14:16 GMT\r\nServer: CakeHttp Server\r\nContent-Type: text/html\r\nLocation: http://localhost/anotheruri\r\n\r\n"; @@ -915,13 +915,13 @@ public function testProxy() { $this->assertEquals($expected, $this->Socket->request['raw']); $this->assertEquals('proxy.server', $this->Socket->config['host']); $this->assertEquals(123, $this->Socket->config['port']); - $expected = array( + $expected = [ 'host' => 'proxy.server', 'port' => 123, 'method' => null, 'user' => null, 'pass' => null - ); + ]; $this->assertEquals($expected, $this->Socket->request['proxy']); $expected = "GET http://www.cakephp.org/bakery HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\n\r\n"; @@ -929,13 +929,13 @@ public function testProxy() { $this->assertEquals($expected, $this->Socket->request['raw']); $this->assertEquals('proxy.server', $this->Socket->config['host']); $this->assertEquals(123, $this->Socket->config['port']); - $expected = array( + $expected = [ 'host' => 'proxy.server', 'port' => 123, 'method' => null, 'user' => null, 'pass' => null - ); + ]; $this->assertEquals($expected, $this->Socket->request['proxy']); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\n\r\n"; @@ -944,33 +944,33 @@ public function testProxy() { $this->assertEquals($expected, $this->Socket->request['raw']); $this->assertEquals('proxy.server', $this->Socket->config['host']); $this->assertEquals(123, $this->Socket->config['port']); - $expected = array( + $expected = [ 'host' => 'proxy.server', 'port' => 123, 'method' => 'Test', 'user' => 'mark', 'pass' => 'secret' - ); + ]; $this->assertEquals($expected, $this->Socket->request['proxy']); $this->Socket->configAuth('Test', 'login', 'passwd'); $expected = "GET http://www.cakephp.org/ HTTP/1.1\r\nHost: www.cakephp.org\r\nConnection: close\r\nUser-Agent: CakePHP\r\nProxy-Authorization: Test mark.secret\r\nAuthorization: Test login.passwd\r\n\r\n"; $this->Socket->request('http://www.cakephp.org/'); $this->assertEquals($expected, $this->Socket->request['raw']); - $expected = array( + $expected = [ 'host' => 'proxy.server', 'port' => 123, 'method' => 'Test', 'user' => 'mark', 'pass' => 'secret' - ); + ]; $this->assertEquals($expected, $this->Socket->request['proxy']); - $expected = array( - 'Test' => array( + $expected = [ + 'Test' => [ 'user' => 'login', 'pass' => 'passwd' - ) - ); + ] + ]; $this->assertEquals($expected, $this->Socket->request['auth']); } @@ -1000,10 +1000,10 @@ public function testUrl() { $url = $this->Socket->url('/search?q=bar'); $this->assertEquals('http://www.cakephp.org/search?q=bar', $url); - $url = $this->Socket->url(array('host' => 'www.foobar.org', 'query' => array('q' => 'bar'))); + $url = $this->Socket->url(['host' => 'www.foobar.org', 'query' => ['q' => 'bar']]); $this->assertEquals('http://www.foobar.org/?q=bar', $url); - $url = $this->Socket->url(array('path' => '/supersearch', 'query' => array('q' => 'bar'))); + $url = $this->Socket->url(['path' => '/supersearch', 'query' => ['q' => 'bar']]); $this->assertEquals('http://www.cakephp.org/supersearch?q=bar', $url); $this->Socket->configUri('http://www.google.com'); @@ -1038,43 +1038,43 @@ public function testGet() { $this->RequestSocket->expects($this->at(0)) ->method('request') - ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/')); + ->with(['method' => 'GET', 'uri' => 'http://www.google.com/']); $this->RequestSocket->expects($this->at(1)) ->method('request') - ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/?foo=bar')); + ->with(['method' => 'GET', 'uri' => 'http://www.google.com/?foo=bar']); $this->RequestSocket->expects($this->at(2)) ->method('request') - ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/?foo=bar')); + ->with(['method' => 'GET', 'uri' => 'http://www.google.com/?foo=bar']); $this->RequestSocket->expects($this->at(3)) ->method('request') - ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/?foo=23&foobar=42')); + ->with(['method' => 'GET', 'uri' => 'http://www.google.com/?foo=23&foobar=42']); $this->RequestSocket->expects($this->at(4)) ->method('request') - ->with(array('method' => 'GET', 'uri' => 'http://www.google.com/', 'version' => '1.0')); + ->with(['method' => 'GET', 'uri' => 'http://www.google.com/', 'version' => '1.0']); $this->RequestSocket->expects($this->at(5)) ->method('request') - ->with(array('method' => 'GET', 'uri' => 'https://secure.example.com/test.php?one=two')); + ->with(['method' => 'GET', 'uri' => 'https://secure.example.com/test.php?one=two']); $this->RequestSocket->expects($this->at(6)) ->method('request') - ->with(array('method' => 'GET', 'uri' => 'https://example.com/oauth/access?clientid=123&redirect_uri=http%3A%2F%2Fexample.com&code=456')); + ->with(['method' => 'GET', 'uri' => 'https://example.com/oauth/access?clientid=123&redirect_uri=http%3A%2F%2Fexample.com&code=456']); $this->RequestSocket->get('http://www.google.com/'); - $this->RequestSocket->get('http://www.google.com/', array('foo' => 'bar')); + $this->RequestSocket->get('http://www.google.com/', ['foo' => 'bar']); $this->RequestSocket->get('http://www.google.com/', 'foo=bar'); - $this->RequestSocket->get('http://www.google.com/?foo=bar', array('foobar' => '42', 'foo' => '23')); - $this->RequestSocket->get('http://www.google.com/', null, array('version' => '1.0')); - $this->RequestSocket->get('https://secure.example.com/test.php', array('one' => 'two')); - $this->RequestSocket->get('https://example.com/oauth/access', array( + $this->RequestSocket->get('http://www.google.com/?foo=bar', ['foobar' => '42', 'foo' => '23']); + $this->RequestSocket->get('http://www.google.com/', null, ['version' => '1.0']); + $this->RequestSocket->get('https://secure.example.com/test.php', ['one' => 'two']); + $this->RequestSocket->get('https://example.com/oauth/access', [ 'clientid' => '123', 'redirect_uri' => 'http://example.com', 'code' => 456 - )); + ]); } /** @@ -1086,43 +1086,43 @@ public function testHead() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') - ->with(array('method' => 'HEAD', 'uri' => 'http://www.google.com/')); + ->with(['method' => 'HEAD', 'uri' => 'http://www.google.com/']); $this->RequestSocket->expects($this->at(1)) ->method('request') - ->with(array('method' => 'HEAD', 'uri' => 'http://www.google.com/?foo=bar')); + ->with(['method' => 'HEAD', 'uri' => 'http://www.google.com/?foo=bar']); $this->RequestSocket->expects($this->at(2)) ->method('request') - ->with(array('method' => 'HEAD', 'uri' => 'http://www.google.com/?foo=bar')); + ->with(['method' => 'HEAD', 'uri' => 'http://www.google.com/?foo=bar']); $this->RequestSocket->expects($this->at(3)) ->method('request') - ->with(array('method' => 'HEAD', 'uri' => 'http://www.google.com/?foo=23&foobar=42')); + ->with(['method' => 'HEAD', 'uri' => 'http://www.google.com/?foo=23&foobar=42']); $this->RequestSocket->expects($this->at(4)) ->method('request') - ->with(array('method' => 'HEAD', 'uri' => 'http://www.google.com/', 'version' => '1.0')); + ->with(['method' => 'HEAD', 'uri' => 'http://www.google.com/', 'version' => '1.0']); $this->RequestSocket->expects($this->at(5)) ->method('request') - ->with(array('method' => 'HEAD', 'uri' => 'https://secure.example.com/test.php?one=two')); + ->with(['method' => 'HEAD', 'uri' => 'https://secure.example.com/test.php?one=two']); $this->RequestSocket->expects($this->at(6)) ->method('request') - ->with(array('method' => 'HEAD', 'uri' => 'https://example.com/oauth/access?clientid=123&redirect_uri=http%3A%2F%2Fexample.com&code=456')); + ->with(['method' => 'HEAD', 'uri' => 'https://example.com/oauth/access?clientid=123&redirect_uri=http%3A%2F%2Fexample.com&code=456']); $this->RequestSocket->head('http://www.google.com/'); - $this->RequestSocket->head('http://www.google.com/', array('foo' => 'bar')); + $this->RequestSocket->head('http://www.google.com/', ['foo' => 'bar']); $this->RequestSocket->head('http://www.google.com/', 'foo=bar'); - $this->RequestSocket->head('http://www.google.com/?foo=bar', array('foobar' => '42', 'foo' => '23')); - $this->RequestSocket->head('http://www.google.com/', null, array('version' => '1.0')); - $this->RequestSocket->head('https://secure.example.com/test.php', array('one' => 'two')); - $this->RequestSocket->head('https://example.com/oauth/access', array( + $this->RequestSocket->head('http://www.google.com/?foo=bar', ['foobar' => '42', 'foo' => '23']); + $this->RequestSocket->head('http://www.google.com/', null, ['version' => '1.0']); + $this->RequestSocket->head('https://secure.example.com/test.php', ['one' => 'two']); + $this->RequestSocket->head('https://example.com/oauth/access', [ 'clientid' => '123', 'redirect_uri' => 'http://example.com', 'code' => 456 - )); + ]); } /** @@ -1135,7 +1135,7 @@ public function testAuth() { ->method('read')->will($this->returnValue(false)); $this->Socket->get('http://mark:secret@example.com/test'); - $this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); + $this->assertTrue(str_contains($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=')); $this->Socket->configAuth(false); $this->Socket->get('http://example.com/test'); @@ -1143,29 +1143,29 @@ public function testAuth() { $this->Socket->configAuth('Test', 'mark', 'passwd'); $this->Socket->get('http://example.com/test'); - $this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Test mark.passwd') !== false); + $this->assertTrue(str_contains($this->Socket->request['header'], 'Authorization: Test mark.passwd')); $this->Socket->configAuth(false); - $this->Socket->request(array( + $this->Socket->request([ 'method' => 'GET', 'uri' => 'http://example.com/test', - 'auth' => array( + 'auth' => [ 'method' => 'Basic', 'user' => 'joel', 'pass' => 'hunter2' - ) - )); - $this->assertEquals($this->Socket->request['auth'], array('Basic' => array('user' => 'joel', 'pass' => 'hunter2'))); - $this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic am9lbDpodW50ZXIy') !== false); + ] + ]); + $this->assertEquals($this->Socket->request['auth'], ['Basic' => ['user' => 'joel', 'pass' => 'hunter2']]); + $this->assertTrue(str_contains($this->Socket->request['header'], 'Authorization: Basic am9lbDpodW50ZXIy')); $this->Socket->configAuth('Basic', 'mark', 'password'); - $this->Socket->request(array( + $this->Socket->request([ 'method' => 'GET', 'uri' => 'http://example.com/test', - 'header' => array( + 'header' => [ 'Authorization' => 'OtherAuth Hi.There' - ) - )); + ] + ]); $this->assertPattern('/Authorization: OtherAuth Hi\.There/m', $this->Socket->request['header']); } @@ -1181,22 +1181,22 @@ public function testConsecutiveGetResetsAuthCredentials() { $this->Socket->get('http://mark:secret@example.com/test'); $this->assertEquals('mark', $this->Socket->request['uri']['user']); $this->assertEquals('secret', $this->Socket->request['uri']['pass']); - $this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); + $this->assertTrue(str_contains($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=')); $this->Socket->get('/test2'); - $this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); + $this->assertTrue(str_contains($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=')); - $this->Socket->request(array( + $this->Socket->request([ 'method' => 'GET', 'uri' => 'http://example.com/test', - 'header' => array( + 'header' => [ 'Authorization' => 'OtherAuth Hi.There' - ) - )); + ] + ]); $this->assertPattern('/Authorization: OtherAuth Hi\.There/m', $this->Socket->request['header']); $this->Socket->get('/test3'); - $this->assertTrue(strpos($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=') !== false); + $this->assertTrue(str_contains($this->Socket->request['header'], 'Authorization: Basic bWFyazpzZWNyZXQ=')); } /** @@ -1208,19 +1208,19 @@ public function testPost() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') - ->with(array('method' => 'POST', 'uri' => 'http://www.google.com/', 'body' => array())); + ->with(['method' => 'POST', 'uri' => 'http://www.google.com/', 'body' => []]); $this->RequestSocket->expects($this->at(1)) ->method('request') - ->with(array('method' => 'POST', 'uri' => 'http://www.google.com/', 'body' => array('Foo' => 'bar'))); + ->with(['method' => 'POST', 'uri' => 'http://www.google.com/', 'body' => ['Foo' => 'bar']]); $this->RequestSocket->expects($this->at(2)) ->method('request') - ->with(array('method' => 'POST', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server')); + ->with(['method' => 'POST', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server']); $this->RequestSocket->post('http://www.google.com/'); - $this->RequestSocket->post('http://www.google.com/', array('Foo' => 'bar')); - $this->RequestSocket->post('http://www.google.com/', null, array('line' => 'Hey Server')); + $this->RequestSocket->post('http://www.google.com/', ['Foo' => 'bar']); + $this->RequestSocket->post('http://www.google.com/', null, ['line' => 'Hey Server']); } /** @@ -1232,19 +1232,19 @@ public function testPut() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') - ->with(array('method' => 'PUT', 'uri' => 'http://www.google.com/', 'body' => array())); + ->with(['method' => 'PUT', 'uri' => 'http://www.google.com/', 'body' => []]); $this->RequestSocket->expects($this->at(1)) ->method('request') - ->with(array('method' => 'PUT', 'uri' => 'http://www.google.com/', 'body' => array('Foo' => 'bar'))); + ->with(['method' => 'PUT', 'uri' => 'http://www.google.com/', 'body' => ['Foo' => 'bar']]); $this->RequestSocket->expects($this->at(2)) ->method('request') - ->with(array('method' => 'PUT', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server')); + ->with(['method' => 'PUT', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server']); $this->RequestSocket->put('http://www.google.com/'); - $this->RequestSocket->put('http://www.google.com/', array('Foo' => 'bar')); - $this->RequestSocket->put('http://www.google.com/', null, array('line' => 'Hey Server')); + $this->RequestSocket->put('http://www.google.com/', ['Foo' => 'bar']); + $this->RequestSocket->put('http://www.google.com/', null, ['line' => 'Hey Server']); } /** @@ -1256,19 +1256,19 @@ public function testPatch() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') - ->with(array('method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => array())); + ->with(['method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => []]); $this->RequestSocket->expects($this->at(1)) ->method('request') - ->with(array('method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => array('Foo' => 'bar'))); + ->with(['method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => ['Foo' => 'bar']]); $this->RequestSocket->expects($this->at(2)) ->method('request') - ->with(array('method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server')); + ->with(['method' => 'PATCH', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server']); $this->RequestSocket->patch('http://www.google.com/'); - $this->RequestSocket->patch('http://www.google.com/', array('Foo' => 'bar')); - $this->RequestSocket->patch('http://www.google.com/', null, array('line' => 'Hey Server')); + $this->RequestSocket->patch('http://www.google.com/', ['Foo' => 'bar']); + $this->RequestSocket->patch('http://www.google.com/', null, ['line' => 'Hey Server']); } /** @@ -1280,19 +1280,19 @@ public function testDelete() { $this->RequestSocket->reset(); $this->RequestSocket->expects($this->at(0)) ->method('request') - ->with(array('method' => 'DELETE', 'uri' => 'http://www.google.com/', 'body' => array())); + ->with(['method' => 'DELETE', 'uri' => 'http://www.google.com/', 'body' => []]); $this->RequestSocket->expects($this->at(1)) ->method('request') - ->with(array('method' => 'DELETE', 'uri' => 'http://www.google.com/', 'body' => array('Foo' => 'bar'))); + ->with(['method' => 'DELETE', 'uri' => 'http://www.google.com/', 'body' => ['Foo' => 'bar']]); $this->RequestSocket->expects($this->at(2)) ->method('request') - ->with(array('method' => 'DELETE', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server')); + ->with(['method' => 'DELETE', 'uri' => 'http://www.google.com/', 'body' => null, 'line' => 'Hey Server']); $this->RequestSocket->delete('http://www.google.com/'); - $this->RequestSocket->delete('http://www.google.com/', array('Foo' => 'bar')); - $this->RequestSocket->delete('http://www.google.com/', null, array('line' => 'Hey Server')); + $this->RequestSocket->delete('http://www.google.com/', ['Foo' => 'bar']); + $this->RequestSocket->delete('http://www.google.com/', null, ['line' => 'Hey Server']); } /** @@ -1311,19 +1311,19 @@ public function testBuildRequestLine() { $r = $this->Socket->buildRequestLine(true); $this->assertEquals(false, $r); - $r = $this->Socket->buildRequestLine(array('foo' => 'bar', 'method' => 'foo')); + $r = $this->Socket->buildRequestLine(['foo' => 'bar', 'method' => 'foo']); $this->assertEquals(false, $r); - $r = $this->Socket->buildRequestLine(array('method' => 'GET', 'uri' => 'http://www.cakephp.org/search?q=socket')); + $r = $this->Socket->buildRequestLine(['method' => 'GET', 'uri' => 'http://www.cakephp.org/search?q=socket']); $this->assertEquals("GET /search?q=socket HTTP/1.1\r\n", $r); - $request = array( + $request = [ 'method' => 'GET', - 'uri' => array( + 'uri' => [ 'path' => '/search', - 'query' => array('q' => 'socket') - ) - ); + 'query' => ['q' => 'socket'] + ] + ]; $r = $this->Socket->buildRequestLine($request); $this->assertEquals("GET /search?q=socket HTTP/1.1\r\n", $r); @@ -1331,7 +1331,7 @@ public function testBuildRequestLine() { $r = $this->Socket->buildRequestLine($request); $this->assertEquals("GET /search?q=socket HTTP/1.1\r\n", $r); - $request = array('method' => 'OPTIONS', 'uri' => '*'); + $request = ['method' => 'OPTIONS', 'uri' => '*']; $r = $this->Socket->buildRequestLine($request); $this->assertEquals("OPTIONS * HTTP/1.1\r\n", $r); @@ -1343,14 +1343,14 @@ public function testBuildRequestLine() { $r = $this->Socket->buildRequestLine("GET * HTTP/1.1\r\n"); $this->assertEquals("GET * HTTP/1.1\r\n", $r); - $request = array( + $request = [ 'version' => '1.0', 'method' => 'GET', - 'uri' => array( + 'uri' => [ 'path' => '/search', - 'query' => array('q' => 'socket') - ) - ); + 'query' => ['q' => 'socket'] + ] + ]; $r = $this->Socket->buildRequestLine($request); $this->assertEquals("GET /search?q=socket HTTP/1.0\r\n", $r); } @@ -1383,123 +1383,123 @@ public function testBadBuildRequestLine2() { public function testParseUri() { $this->Socket->reset(); - $uri = $this->Socket->parseUri(array('invalid' => 'uri-string')); + $uri = $this->Socket->parseUri(['invalid' => 'uri-string']); $this->assertEquals(false, $uri); - $uri = $this->Socket->parseUri(array('invalid' => 'uri-string'), array('host' => 'somehost')); - $this->assertEquals(array('host' => 'somehost', 'invalid' => 'uri-string'), $uri); + $uri = $this->Socket->parseUri(['invalid' => 'uri-string'], ['host' => 'somehost']); + $this->assertEquals(['host' => 'somehost', 'invalid' => 'uri-string'], $uri); $uri = $this->Socket->parseUri(false); $this->assertEquals(false, $uri); $uri = $this->Socket->parseUri('/my-cool-path'); - $this->assertEquals(array('path' => '/my-cool-path'), $uri); + $this->assertEquals(['path' => '/my-cool-path'], $uri); $uri = $this->Socket->parseUri('http://bob:foo123@www.cakephp.org:40/search?q=dessert#results'); - $this->assertEquals($uri, array( + $this->assertEquals($uri, [ 'scheme' => 'http', 'host' => 'www.cakephp.org', 'port' => 40, 'user' => 'bob', 'pass' => 'foo123', 'path' => '/search', - 'query' => array('q' => 'dessert'), + 'query' => ['q' => 'dessert'], 'fragment' => 'results' - )); + ]); $uri = $this->Socket->parseUri('http://www.cakephp.org/'); - $this->assertEquals($uri, array( + $this->assertEquals($uri, [ 'scheme' => 'http', 'host' => 'www.cakephp.org', 'path' => '/' - )); + ]); $uri = $this->Socket->parseUri('http://www.cakephp.org', true); - $this->assertEquals($uri, array( + $this->assertEquals($uri, [ 'scheme' => 'http', 'host' => 'www.cakephp.org', 'port' => 80, 'user' => null, 'pass' => null, 'path' => '/', - 'query' => array(), + 'query' => [], 'fragment' => null - )); + ]); $uri = $this->Socket->parseUri('https://www.cakephp.org', true); - $this->assertEquals($uri, array( + $this->assertEquals($uri, [ 'scheme' => 'https', 'host' => 'www.cakephp.org', 'port' => 443, 'user' => null, 'pass' => null, 'path' => '/', - 'query' => array(), + 'query' => [], 'fragment' => null - )); + ]); $uri = $this->Socket->parseUri('www.cakephp.org:443/query?foo', true); - $this->assertEquals($uri, array( + $this->assertEquals($uri, [ 'scheme' => 'https', 'host' => 'www.cakephp.org', 'port' => 443, 'user' => null, 'pass' => null, 'path' => '/query', - 'query' => array('foo' => ""), + 'query' => ['foo' => ""], 'fragment' => null - )); + ]); - $uri = $this->Socket->parseUri('http://www.cakephp.org', array('host' => 'piephp.org', 'user' => 'bob', 'fragment' => 'results')); - $this->assertEquals($uri, array( + $uri = $this->Socket->parseUri('http://www.cakephp.org', ['host' => 'piephp.org', 'user' => 'bob', 'fragment' => 'results']); + $this->assertEquals($uri, [ 'host' => 'www.cakephp.org', 'user' => 'bob', 'fragment' => 'results', 'scheme' => 'http' - )); + ]); - $uri = $this->Socket->parseUri('https://www.cakephp.org', array('scheme' => 'http', 'port' => 23)); - $this->assertEquals($uri, array( + $uri = $this->Socket->parseUri('https://www.cakephp.org', ['scheme' => 'http', 'port' => 23]); + $this->assertEquals($uri, [ 'scheme' => 'https', 'port' => 23, 'host' => 'www.cakephp.org' - )); + ]); - $uri = $this->Socket->parseUri('www.cakephp.org:59', array('scheme' => array('http', 'https'), 'port' => 80)); - $this->assertEquals($uri, array( + $uri = $this->Socket->parseUri('www.cakephp.org:59', ['scheme' => ['http', 'https'], 'port' => 80]); + $this->assertEquals($uri, [ 'scheme' => 'http', 'port' => 59, 'host' => 'www.cakephp.org' - )); + ]); - $uri = $this->Socket->parseUri(array('scheme' => 'http', 'host' => 'www.google.com', 'port' => 8080), array('scheme' => array('http', 'https'), 'host' => 'www.google.com', 'port' => array(80, 443))); - $this->assertEquals($uri, array( + $uri = $this->Socket->parseUri(['scheme' => 'http', 'host' => 'www.google.com', 'port' => 8080], ['scheme' => ['http', 'https'], 'host' => 'www.google.com', 'port' => [80, 443]]); + $this->assertEquals($uri, [ 'scheme' => 'http', 'host' => 'www.google.com', 'port' => 8080 - )); + ]); $uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2%3Dvalue3'); - $this->assertEquals($uri, array( + $this->assertEquals($uri, [ 'scheme' => 'http', 'host' => 'www.cakephp.org', 'path' => '/', - 'query' => array( + 'query' => [ 'param1' => 'value1', 'param2' => 'value2=value3' - ) - )); + ] + ]); $uri = $this->Socket->parseUri('http://www.cakephp.org/?param1=value1¶m2=value2=value3'); - $this->assertEquals($uri, array( + $this->assertEquals($uri, [ 'scheme' => 'http', 'host' => 'www.cakephp.org', 'path' => '/', - 'query' => array( + 'query' => [ 'param1' => 'value1', 'param2' => 'value2=value3' - ) - )); + ] + ]); } /** @@ -1516,55 +1516,55 @@ public function testBuildUri() { $r = $this->Socket->buildUri('foo.com'); $this->assertEquals('http://foo.com/', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org')); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org']); $this->assertEquals('http://www.cakephp.org/', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'scheme' => 'https')); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org', 'scheme' => 'https']); $this->assertEquals('https://www.cakephp.org/', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'port' => 23)); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org', 'port' => 23]); $this->assertEquals('http://www.cakephp.org:23/', $r); - $r = $this->Socket->buildUri(array('path' => 'www.google.com/search', 'query' => 'q=cakephp')); + $r = $this->Socket->buildUri(['path' => 'www.google.com/search', 'query' => 'q=cakephp']); $this->assertEquals('http://www.google.com/search?q=cakephp', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'scheme' => 'https', 'port' => 79)); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org', 'scheme' => 'https', 'port' => 79]); $this->assertEquals('https://www.cakephp.org:79/', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'path' => 'foo')); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org', 'path' => 'foo']); $this->assertEquals('http://www.cakephp.org/foo', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'path' => '/foo')); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org', 'path' => '/foo']); $this->assertEquals('http://www.cakephp.org/foo', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'path' => '/search', 'query' => array('q' => 'HttpSocket'))); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org', 'path' => '/search', 'query' => ['q' => 'HttpSocket']]); $this->assertEquals('http://www.cakephp.org/search?q=HttpSocket', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'fragment' => 'bar')); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org', 'fragment' => 'bar']); $this->assertEquals('http://www.cakephp.org/#bar', $r); - $r = $this->Socket->buildUri(array( + $r = $this->Socket->buildUri([ 'scheme' => 'https', 'host' => 'www.cakephp.org', 'port' => 25, 'user' => 'bob', 'pass' => 'secret', 'path' => '/cool', - 'query' => array('foo' => 'bar'), + 'query' => ['foo' => 'bar'], 'fragment' => 'comment' - )); + ]); $this->assertEquals('https://bob:secret@www.cakephp.org:25/cool?foo=bar#comment', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'fragment' => 'bar'), '%fragment?%host'); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org', 'fragment' => 'bar'], '%fragment?%host'); $this->assertEquals('bar?www.cakephp.org', $r); - $r = $this->Socket->buildUri(array('host' => 'www.cakephp.org'), '%fragment???%host'); + $r = $this->Socket->buildUri(['host' => 'www.cakephp.org'], '%fragment???%host'); $this->assertEquals('???www.cakephp.org', $r); - $r = $this->Socket->buildUri(array('path' => '*'), '/%path?%query'); + $r = $this->Socket->buildUri(['path' => '*'], '/%path?%query'); $this->assertEquals('*', $r); - $r = $this->Socket->buildUri(array('scheme' => 'foo', 'host' => 'www.cakephp.org')); + $r = $this->Socket->buildUri(['scheme' => 'foo', 'host' => 'www.cakephp.org']); $this->assertEquals('foo://www.cakephp.org:80/', $r); } @@ -1576,99 +1576,99 @@ public function testBuildUri() { public function testParseQuery() { $this->Socket->reset(); - $query = $this->Socket->parseQuery(array('framework' => 'cakephp')); - $this->assertEquals(array('framework' => 'cakephp'), $query); + $query = $this->Socket->parseQuery(['framework' => 'cakephp']); + $this->assertEquals(['framework' => 'cakephp'], $query); $query = $this->Socket->parseQuery(''); - $this->assertEquals(array(), $query); + $this->assertEquals([], $query); $query = $this->Socket->parseQuery('framework=cakephp'); - $this->assertEquals(array('framework' => 'cakephp'), $query); + $this->assertEquals(['framework' => 'cakephp'], $query); $query = $this->Socket->parseQuery('?framework=cakephp'); - $this->assertEquals(array('framework' => 'cakephp'), $query); + $this->assertEquals(['framework' => 'cakephp'], $query); $query = $this->Socket->parseQuery('a&b&c'); - $this->assertEquals(array('a' => '', 'b' => '', 'c' => ''), $query); + $this->assertEquals(['a' => '', 'b' => '', 'c' => ''], $query); $query = $this->Socket->parseQuery('value=12345'); - $this->assertEquals(array('value' => '12345'), $query); + $this->assertEquals(['value' => '12345'], $query); $query = $this->Socket->parseQuery('a[0]=foo&a[1]=bar&a[2]=cake'); - $this->assertEquals(array('a' => array(0 => 'foo', 1 => 'bar', 2 => 'cake')), $query); + $this->assertEquals(['a' => [0 => 'foo', 1 => 'bar', 2 => 'cake']], $query); $query = $this->Socket->parseQuery('a[]=foo&a[]=bar&a[]=cake'); - $this->assertEquals(array('a' => array(0 => 'foo', 1 => 'bar', 2 => 'cake')), $query); + $this->assertEquals(['a' => [0 => 'foo', 1 => 'bar', 2 => 'cake']], $query); $query = $this->Socket->parseQuery('a[][]=foo&a[][]=bar&a[][]=cake'); - $expectedQuery = array( - 'a' => array( - 0 => array( + $expectedQuery = [ + 'a' => [ + 0 => [ 0 => 'foo' - ), - 1 => array( + ], + 1 => [ 0 => 'bar' - ), - array( + ], + [ 0 => 'cake' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expectedQuery, $query); $query = $this->Socket->parseQuery('a[][]=foo&a[bar]=php&a[][]=bar&a[][]=cake'); - $expectedQuery = array( - 'a' => array( - array('foo'), + $expectedQuery = [ + 'a' => [ + ['foo'], 'bar' => 'php', - array('bar'), - array('cake') - ) - ); + ['bar'], + ['cake'] + ] + ]; $this->assertEquals($expectedQuery, $query); $query = $this->Socket->parseQuery('user[]=jim&user[3]=tom&user[]=bob'); - $expectedQuery = array( - 'user' => array( + $expectedQuery = [ + 'user' => [ 0 => 'jim', 3 => 'tom', 4 => 'bob' - ) - ); + ] + ]; $this->assertEquals($expectedQuery, $query); $queryStr = 'user[0]=foo&user[0][items][]=foo&user[0][items][]=bar&user[][name]=jim&user[1][items][personal][]=book&user[1][items][personal][]=pen&user[1][items][]=ball&user[count]=2&empty'; $query = $this->Socket->parseQuery($queryStr); - $expectedQuery = array( - 'user' => array( - 0 => array( - 'items' => array( + $expectedQuery = [ + 'user' => [ + 0 => [ + 'items' => [ 'foo', 'bar' - ) - ), - 1 => array( + ] + ], + 1 => [ 'name' => 'jim', - 'items' => array( - 'personal' => array( + 'items' => [ + 'personal' => [ 'book', 'pen' - ), + ], 'ball' - ) - ), + ] + ], 'count' => '2' - ), + ], 'empty' => '' - ); + ]; $this->assertEquals($expectedQuery, $query); $query = 'openid.ns=example.com&foo=bar&foo=baz'; $result = $this->Socket->parseQuery($query); - $expected = array( + $expected = [ 'openid.ns' => 'example.com', - 'foo' => array('bar', 'baz') - ); + 'foo' => ['bar', 'baz'] + ]; $this->assertEquals($expected, $result); } @@ -1687,25 +1687,25 @@ public function testBuildHeader() { $r = $this->Socket->buildHeader('My raw header'); $this->assertEquals('My raw header', $r); - $r = $this->Socket->buildHeader(array('Host' => 'www.cakephp.org')); + $r = $this->Socket->buildHeader(['Host' => 'www.cakephp.org']); $this->assertEquals("Host: www.cakephp.org\r\n", $r); - $r = $this->Socket->buildHeader(array('Host' => 'www.cakephp.org', 'Connection' => 'Close')); + $r = $this->Socket->buildHeader(['Host' => 'www.cakephp.org', 'Connection' => 'Close']); $this->assertEquals("Host: www.cakephp.org\r\nConnection: Close\r\n", $r); - $r = $this->Socket->buildHeader(array('People' => array('Bob', 'Jim', 'John'))); + $r = $this->Socket->buildHeader(['People' => ['Bob', 'Jim', 'John']]); $this->assertEquals("People: Bob,Jim,John\r\n", $r); - $r = $this->Socket->buildHeader(array('Multi-Line-Field' => "This is my\r\nMulti Line field")); + $r = $this->Socket->buildHeader(['Multi-Line-Field' => "This is my\r\nMulti Line field"]); $this->assertEquals("Multi-Line-Field: This is my\r\n Multi Line field\r\n", $r); - $r = $this->Socket->buildHeader(array('Multi-Line-Field' => "This is my\r\n Multi Line field")); + $r = $this->Socket->buildHeader(['Multi-Line-Field' => "This is my\r\n Multi Line field"]); $this->assertEquals("Multi-Line-Field: This is my\r\n Multi Line field\r\n", $r); - $r = $this->Socket->buildHeader(array('Multi-Line-Field' => "This is my\r\n\tMulti Line field")); + $r = $this->Socket->buildHeader(['Multi-Line-Field' => "This is my\r\n\tMulti Line field"]); $this->assertEquals("Multi-Line-Field: This is my\r\n\tMulti Line field\r\n", $r); - $r = $this->Socket->buildHeader(array('Test@Field' => "My value")); + $r = $this->Socket->buildHeader(['Test@Field' => "My value"]); $this->assertEquals("Test\"@\"Field: My value\r\n", $r); } @@ -1715,16 +1715,16 @@ public function testBuildHeader() { * @return void */ public function testBuildCookies() { - $cookies = array( - 'foo' => array( + $cookies = [ + 'foo' => [ 'value' => 'bar' - ), - 'people' => array( + ], + 'people' => [ 'value' => 'jim,jack,johnny;', 'path' => '/accounts' - ), + ], 'key' => 'value' - ); + ]; $expect = "Cookie: foo=bar; people=jim,jack,johnny\";\"; key=value\r\n"; $result = $this->Socket->buildCookies($cookies); $this->assertEquals($expect, $result); @@ -1738,12 +1738,12 @@ public function testBuildCookies() { public function testTokenEscapeChars() { $this->Socket->reset(); - $expected = array( + $expected = [ '\x22', '\x28', '\x29', '\x3c', '\x3e', '\x40', '\x2c', '\x3b', '\x3a', '\x5c', '\x2f', '\x5b', '\x5d', '\x3f', '\x3d', '\x7b', '\x7d', '\x20', '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07', '\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f', '\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17', '\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f', '\x7f' - ); + ]; $r = $this->Socket->tokenEscapeChars(); $this->assertEquals($expected, $r); @@ -1812,7 +1812,7 @@ public function testReset() { public function testPartialReset() { $this->Socket->reset(); - $partialResetProperties = array('request', 'response'); + $partialResetProperties = ['request', 'response']; $initialState = get_class_vars('HttpSocket'); foreach ($initialState as $property => $value) { @@ -1844,7 +1844,7 @@ public function testVerifyPeer() { $this->markTestSkipped('Found valid certificate, was expecting invalid certificate.'); } catch (SocketException $e) { $message = $e->getMessage(); - $this->skipIf(strpos($message, 'Invalid HTTP') !== false, 'Invalid HTTP Response received, skipping.'); + $this->skipIf(str_contains($message, 'Invalid HTTP'), 'Invalid HTTP Response received, skipping.'); $this->assertStringContainsString('Failed to enable crypto', $message); } } @@ -1855,14 +1855,14 @@ public function testVerifyPeer() { * @return array */ public function statusProvider() { - return array( - array('HTTP/1.1 200 ', '200'), - array('HTTP/1.1 200 ', '200'), - array('HTTP/1.1 200', '200'), - array('HTTP/1.1 200 OK', '200', 'OK'), - array('HTTP/1.1 404 Not Found', '404', 'Not Found'), - array('HTTP/1.1 404 Not Found', '404', 'Not Found'), - ); + return [ + ['HTTP/1.1 200 ', '200'], + ['HTTP/1.1 200 ', '200'], + ['HTTP/1.1 200', '200'], + ['HTTP/1.1 200 OK', '200', 'OK'], + ['HTTP/1.1 404 Not Found', '404', 'Not Found'], + ['HTTP/1.1 404 Not Found', '404', 'Not Found'], + ]; } /** @@ -1881,11 +1881,11 @@ public function testResponseStatusParsing($status, $code, $msg = '') { $response = $this->Socket->request('http://www.cakephp.org/'); $this->assertInstanceOf('HttpSocketResponse', $response); - $expected = array( + $expected = [ 'http-version' => 'HTTP/1.1', 'code' => $code, 'reason-phrase' => $msg - ); + ]; $this->assertEquals($expected, $response['status']); } diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php index 08d45e46f8..af1687c84d 100644 --- a/lib/Cake/Test/Case/Routing/DispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php @@ -125,7 +125,7 @@ class MyPluginController extends MyPluginAppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * index method @@ -169,7 +169,7 @@ class SomePagesController extends AppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * display method @@ -196,7 +196,7 @@ public function index() { * @return CakeResponse */ public function responseGenerator() { - return new CakeResponse(array('body' => 'new response')); + return new CakeResponse(['body' => 'new response']); } /** @@ -223,7 +223,7 @@ class OtherPagesController extends MyPluginAppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * display method @@ -258,7 +258,7 @@ class TestDispatchPagesController extends AppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * admin_index method @@ -300,7 +300,7 @@ class ArticlesTestController extends ArticlesTestAppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * admin_index method @@ -334,7 +334,7 @@ class SomePostsController extends AppController { * * @var array */ - public $uses = array(); + public $uses = []; /** * autoRender property @@ -354,7 +354,7 @@ public function beforeFilter() { } else { $this->params['action'] = 'change'; } - $this->params['pass'] = array('changed'); + $this->params['pass'] = ['changed']; } /** @@ -389,25 +389,25 @@ class TestCachedPagesController extends Controller { * * @var array */ - public $uses = array(); + public $uses = []; /** * helpers property * * @var array */ - public $helpers = array('Cache', 'Html'); + public $helpers = ['Cache', 'Html']; /** * cacheAction property * * @var array */ - public $cacheAction = array( + public $cacheAction = [ 'index' => '+2 sec', 'test_nocache_tags' => '+2 sec', 'view' => '+2 sec' - ); + ]; /** * Mock out the response object so it doesn't send headers. @@ -485,7 +485,7 @@ class TimesheetsController extends Controller { * * @var array */ - public $uses = array(); + public $uses = []; /** * index method @@ -516,7 +516,7 @@ class TestFilterDispatcher extends DispatcherFilter { public function beforeDispatch(CakeEvent $event) { $event->stopPropagation(); $response = $event->data['request']; - $response->addParams(array('settings' => $this->settings)); + $response->addParams(['settings' => $this->settings]); return null; } @@ -546,7 +546,7 @@ class DispatcherTest extends CakeTestCase { public function setUp() : void { parent::setUp(); $this->_get = $_GET; - $_GET = array(); + $_GET = []; $this->_post = $_POST; $this->_files = $_FILES; $this->_server = $_SERVER; @@ -582,7 +582,7 @@ public function tearDown() : void { Configure::write('App', $this->_app); Configure::write('Cache', $this->_cache); Configure::write('debug', $this->_debug); - Configure::write('Dispatcher.filters', array()); + Configure::write('Dispatcher.filters', []); } /** @@ -594,7 +594,7 @@ public function tearDown() : void { public function testParseParamsWithoutZerosAndEmptyPost() { $Dispatcher = new Dispatcher(); $request = new CakeRequest("/testcontroller/testaction/params1/params2/params3"); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $request]); $Dispatcher->parseParams($event); $this->assertSame($request['controller'], 'testcontroller'); $this->assertSame($request['action'], 'testaction'); @@ -614,7 +614,7 @@ public function testParseParamsReturnsPostedData() { $_POST['testdata'] = "My Posted Content"; $Dispatcher = new Dispatcher(); $request = new CakeRequest("/"); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $request]); $Dispatcher->parseParams($event); $Dispatcher->parseParams($event); $this->assertEquals("My Posted Content", $request['data']['testdata']); @@ -629,7 +629,7 @@ public function testParseParamsReturnsPostedData() { public function testParseParamsWithSingleZero() { $Dispatcher = new Dispatcher(); $test = new CakeRequest("/testcontroller/testaction/1/0/23"); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $test)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $test]); $Dispatcher->parseParams($event); $this->assertSame($test['controller'], 'testcontroller'); @@ -648,7 +648,7 @@ public function testParseParamsWithSingleZero() { public function testParseParamsWithManySingleZeros() { $Dispatcher = new Dispatcher(); $test = new CakeRequest("/testcontroller/testaction/0/0/0/0/0/0"); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $test)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $test]); $Dispatcher->parseParams($event); $this->assertMatchesRegularExpression('/\\A(?:0)\\z/', $test['pass'][0]); @@ -668,7 +668,7 @@ public function testParseParamsWithManySingleZeros() { public function testParseParamsWithManyZerosInEachSectionOfUrl() { $Dispatcher = new Dispatcher(); $test = new CakeRequest("/testcontroller/testaction/000/0000/00000/000000/000000/0000000"); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $test)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $test]); $Dispatcher->parseParams($event); $this->assertMatchesRegularExpression('/\\A(?:000)\\z/', $test['pass'][0]); @@ -688,7 +688,7 @@ public function testParseParamsWithManyZerosInEachSectionOfUrl() { public function testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl() { $Dispatcher = new Dispatcher(); $test = new CakeRequest("/testcontroller/testaction/01/0403/04010/000002/000030/0000400"); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $test)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $test]); $Dispatcher->parseParams($event); $this->assertMatchesRegularExpression('/\\A(?:01)\\z/', $test['pass'][0]); @@ -708,14 +708,14 @@ public function testParseParamsWithMixedOneToManyZerosInEachSectionOfUrl() { */ public function testQueryStringOnRoot() { Router::reload(); - Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); - Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); + Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']); + Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']); Router::connect('/:controller/:action/*'); - $_GET = array('coffee' => 'life', 'sleep' => 'sissies'); + $_GET = ['coffee' => 'life', 'sleep' => 'sissies']; $Dispatcher = new Dispatcher(); $request = new CakeRequest('posts/home/?coffee=life&sleep=sissies'); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $request]); $Dispatcher->parseParams($event); $this->assertMatchesRegularExpression('/posts/', $request['controller']); @@ -726,7 +726,7 @@ public function testQueryStringOnRoot() { $Dispatcher = new Dispatcher(); $request = new CakeRequest('/?coffee=life&sleep=sissy'); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $request]); $Dispatcher->parseParams($event); $this->assertMatchesRegularExpression('/pages/', $request['controller']); $this->assertMatchesRegularExpression('/display/', $request['action']); @@ -750,7 +750,7 @@ public function testMissingController() { $url = new CakeRequest('some_controller/home/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); } /** @@ -768,7 +768,7 @@ public function testMissingControllerInterface() { $url = new CakeRequest('dispatcher_test_interface/index'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); } /** @@ -786,7 +786,7 @@ public function testMissingControllerAbstract() { $url = new CakeRequest('dispatcher_test_abstract/index'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); } /** @@ -795,31 +795,31 @@ public function testMissingControllerAbstract() { * @return void */ public function testDispatchBasic() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $Dispatcher = new TestDispatcher(); Configure::write('App.baseUrl', '/index.php'); $url = new CakeRequest('pages/home/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $expected = 'Pages'; $this->assertEquals($expected, $Dispatcher->controller->name); - $expected = array('0' => 'home', 'param' => 'value', 'param2' => 'value2'); + $expected = ['0' => 'home', 'param' => 'value', 'param2' => 'value2']; $this->assertSame($expected, $Dispatcher->controller->passedArgs); Configure::write('App.baseUrl', '/pages/index.php'); $url = new CakeRequest('pages/home'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $expected = 'Pages'; $this->assertEquals($expected, $Dispatcher->controller->name); $url = new CakeRequest('pages/home/'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertNull($Dispatcher->controller->plugin); $expected = 'Pages'; @@ -832,23 +832,23 @@ public function testDispatchBasic() { Configure::write('App.baseUrl', '/timesheets/index.php'); $url = new CakeRequest('timesheets'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $expected = 'Timesheets'; $this->assertEquals($expected, $Dispatcher->controller->name); $url = new CakeRequest('timesheets/'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('Timesheets', $Dispatcher->controller->name); $this->assertEquals('/timesheets/index.php', $url->base); $url = new CakeRequest('test_dispatch_pages/camelCased'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('TestDispatchPages', $Dispatcher->controller->name); $url = new CakeRequest('test_dispatch_pages/camelCased/something. .'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('something. .', $Dispatcher->controller->params['pass'][0], 'Period was chopped off. %s'); } @@ -861,7 +861,7 @@ public function testDispatchActionReturnsResponse() { Router::connect('/:controller/:action'); $Dispatcher = new Dispatcher(); $request = new CakeRequest('some_pages/responseGenerator'); - $response = $this->getMock('CakeResponse', array('_sendHeader')); + $response = $this->getMock('CakeResponse', ['_sendHeader']); ob_start(); $Dispatcher->dispatch($request, $response); @@ -879,7 +879,7 @@ public function testDispatchActionSendsFile() { Router::connect('/:controller/:action'); $Dispatcher = new Dispatcher(); $request = new CakeRequest('some_pages/sendfile'); - $response = $this->getMock('CakeResponse', array( + $response = $this->getMock('CakeResponse', [ 'header', 'type', 'download', @@ -888,7 +888,7 @@ public function testDispatchActionSendsFile() { '_isActive', '_clearBuffer', '_flushBuffer' - )); + ]); $response->expects($this->exactly(1)) ->method('_isActive') ->will($this->returnValue(true)); @@ -904,19 +904,19 @@ public function testDispatchActionSendsFile() { * @return void */ public function testAdminDispatch() { - $_POST = array(); + $_POST = []; $Dispatcher = new TestDispatcher(); - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Configure::write('App.baseUrl', '/cake/repo/branches/1.2.x.x/index.php'); $url = new CakeRequest('admin/test_dispatch_pages/index/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); Router::reload(); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('TestDispatchPages', $Dispatcher->controller->name); - $this->assertSame($Dispatcher->controller->passedArgs, array('param' => 'value', 'param2' => 'value2')); + $this->assertSame($Dispatcher->controller->passedArgs, ['param' => 'value', 'param2' => 'value2']); $this->assertTrue($Dispatcher->controller->params['admin']); $expected = '/cake/repo/branches/1.2.x.x/index.php/admin/test_dispatch_pages/index/param:value/param2:value2'; @@ -933,26 +933,26 @@ public function testAdminDispatch() { * @triggers DispatcherTest $Dispatcher, array('request' => $url) */ public function testPluginDispatch() { - $_POST = array(); + $_POST = []; Router::reload(); $Dispatcher = new TestDispatcher(); Router::connect( '/my_plugin/:controller/*', - array('plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'display') + ['plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'display'] ); $url = new CakeRequest('my_plugin/some_pages/home/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); - $event = new CakeEvent('DispatcherTest', $Dispatcher, array('request' => $url)); + $event = new CakeEvent('DispatcherTest', $Dispatcher, ['request' => $url]); $Dispatcher->parseParams($event); - $expected = array( - 'pass' => array('home'), - 'named' => array('param' => 'value', 'param2' => 'value2'), 'plugin' => 'my_plugin', + $expected = [ + 'pass' => ['home'], + 'named' => ['param' => 'value', 'param2' => 'value2'], 'plugin' => 'my_plugin', 'controller' => 'some_pages', 'action' => 'display' - ); + ]; foreach ($expected as $key => $value) { $this->assertEquals($value, $url[$key], 'Value mismatch ' . $key . ' %'); } @@ -960,7 +960,7 @@ public function testPluginDispatch() { $this->assertSame($Dispatcher->controller->plugin, 'MyPlugin'); $this->assertSame($Dispatcher->controller->name, 'SomePages'); $this->assertSame($Dispatcher->controller->params['controller'], 'some_pages'); - $this->assertSame($Dispatcher->controller->passedArgs, array('0' => 'home', 'param' => 'value', 'param2' => 'value2')); + $this->assertSame($Dispatcher->controller->passedArgs, ['0' => 'home', 'param' => 'value', 'param2' => 'value2']); } /** @@ -969,26 +969,26 @@ public function testPluginDispatch() { * @return void */ public function testAutomaticPluginDispatch() { - $_POST = array(); + $_POST = []; $_SERVER['PHP_SELF'] = '/cake/repo/branches/1.2.x.x/index.php'; Router::reload(); $Dispatcher = new TestDispatcher(); Router::connect( '/my_plugin/:controller/:action/*', - array('plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'display') + ['plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'display'] ); $Dispatcher->base = false; $url = new CakeRequest('my_plugin/other_pages/index/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertSame($Dispatcher->controller->plugin, 'MyPlugin'); $this->assertSame($Dispatcher->controller->name, 'OtherPages'); $this->assertSame($Dispatcher->controller->action, 'index'); - $this->assertSame($Dispatcher->controller->passedArgs, array('param' => 'value', 'param2' => 'value2')); + $this->assertSame($Dispatcher->controller->passedArgs, ['param' => 'value', 'param2' => 'value2']); $expected = '/cake/repo/branches/1.2.x.x/my_plugin/other_pages/index/param:value/param2:value2'; $this->assertSame($expected, $url->here); @@ -1007,7 +1007,7 @@ public function testAutomaticPluginControllerDispatch() { $plugins[] = 'MyPlugin'; $plugins[] = 'ArticlesTest'; - CakePlugin::load('MyPlugin', array('path' => '/fake/path')); + CakePlugin::load('MyPlugin', ['path' => '/fake/path']); Router::reload(); $Dispatcher = new TestDispatcher(); @@ -1016,12 +1016,12 @@ public function testAutomaticPluginControllerDispatch() { $url = new CakeRequest('my_plugin/my_plugin/add/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertSame($Dispatcher->controller->plugin, 'MyPlugin'); $this->assertSame($Dispatcher->controller->name, 'MyPlugin'); $this->assertSame($Dispatcher->controller->action, 'add'); - $this->assertEquals(array('param' => 'value', 'param2' => 'value2'), $Dispatcher->controller->params['named']); + $this->assertEquals(['param' => 'value', 'param2' => 'value2'], $Dispatcher->controller->params['named']); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; @@ -1029,13 +1029,13 @@ public function testAutomaticPluginControllerDispatch() { $Dispatcher->base = false; // Simulates the Route for a real plugin, installed in APP/plugins - Router::connect('/my_plugin/:controller/:action/*', array('plugin' => 'my_plugin')); + Router::connect('/my_plugin/:controller/:action/*', ['plugin' => 'my_plugin']); $plugin = 'MyPlugin'; $pluginUrl = Inflector::underscore($plugin); $url = new CakeRequest($pluginUrl); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertSame($Dispatcher->controller->plugin, 'MyPlugin'); $this->assertSame($Dispatcher->controller->name, 'MyPlugin'); $this->assertSame($Dispatcher->controller->action, 'index'); @@ -1043,7 +1043,7 @@ public function testAutomaticPluginControllerDispatch() { $expected = $pluginUrl; $this->assertEquals($expected, $Dispatcher->controller->params['controller']); - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; @@ -1052,42 +1052,42 @@ public function testAutomaticPluginControllerDispatch() { $url = new CakeRequest('admin/my_plugin/my_plugin/add/5/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('my_plugin', $Dispatcher->controller->params['plugin']); $this->assertEquals('my_plugin', $Dispatcher->controller->params['controller']); $this->assertEquals('admin_add', $Dispatcher->controller->params['action']); - $this->assertEquals(array(5), $Dispatcher->controller->params['pass']); - $this->assertEquals(array('param' => 'value', 'param2' => 'value2'), $Dispatcher->controller->params['named']); + $this->assertEquals([5], $Dispatcher->controller->params['pass']); + $this->assertEquals(['param' => 'value', 'param2' => 'value2'], $Dispatcher->controller->params['named']); $this->assertSame($Dispatcher->controller->plugin, 'MyPlugin'); $this->assertSame($Dispatcher->controller->name, 'MyPlugin'); $this->assertSame($Dispatcher->controller->action, 'admin_add'); - $expected = array(0 => 5, 'param' => 'value', 'param2' => 'value2'); + $expected = [0 => 5, 'param' => 'value', 'param2' => 'value2']; $this->assertEquals($expected, $Dispatcher->controller->passedArgs); - Configure::write('Routing.prefixes', array('admin')); - CakePlugin::load('ArticlesTest', array('path' => '/fake/path')); + Configure::write('Routing.prefixes', ['admin']); + CakePlugin::load('ArticlesTest', ['path' => '/fake/path']); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; $Dispatcher = new TestDispatcher(); - $Dispatcher->dispatch(new CakeRequest('admin/articles_test'), $response, array('return' => 1)); + $Dispatcher->dispatch(new CakeRequest('admin/articles_test'), $response, ['return' => 1]); $this->assertSame($Dispatcher->controller->plugin, 'ArticlesTest'); $this->assertSame($Dispatcher->controller->name, 'ArticlesTest'); $this->assertSame($Dispatcher->controller->action, 'admin_index'); - $expected = array( - 'pass' => array(), - 'named' => array(), + $expected = [ + 'pass' => [], + 'named' => [], 'controller' => 'articles_test', 'plugin' => 'articles_test', 'action' => 'admin_index', 'prefix' => 'admin', 'admin' => true, 'return' => 1 - ); + ]; foreach ($expected as $key => $value) { $this->assertEquals($expected[$key], $Dispatcher->controller->request[$key], 'Value mismatch ' . $key); } @@ -1100,7 +1100,7 @@ public function testAutomaticPluginControllerDispatch() { * @return void */ public function testAutomaticPluginDispatchWithShortAccess() { - CakePlugin::load('MyPlugin', array('path' => '/fake/path')); + CakePlugin::load('MyPlugin', ['path' => '/fake/path']); Router::reload(); $Dispatcher = new TestDispatcher(); @@ -1109,7 +1109,7 @@ public function testAutomaticPluginDispatchWithShortAccess() { $url = new CakeRequest('my_plugin/'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('my_plugin', $Dispatcher->controller->params['controller']); $this->assertEquals('my_plugin', $Dispatcher->controller->params['plugin']); $this->assertEquals('index', $Dispatcher->controller->params['action']); @@ -1127,10 +1127,10 @@ public function testPluginShortCutUrlsWithControllerThatNeedsToBeLoaded() { $this->skipIf($loaded, 'TestPluginController already loaded.'); Router::reload(); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $Dispatcher = new TestDispatcher(); $Dispatcher->base = false; @@ -1138,21 +1138,21 @@ public function testPluginShortCutUrlsWithControllerThatNeedsToBeLoaded() { $url = new CakeRequest('test_plugin/'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('test_plugin', $Dispatcher->controller->params['controller']); $this->assertEquals('test_plugin', $Dispatcher->controller->params['plugin']); $this->assertEquals('index', $Dispatcher->controller->params['action']); $this->assertFalse(isset($Dispatcher->controller->params['pass'][0])); $url = new CakeRequest('/test_plugin/tests/index'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('tests', $Dispatcher->controller->params['controller']); $this->assertEquals('test_plugin', $Dispatcher->controller->params['plugin']); $this->assertEquals('index', $Dispatcher->controller->params['action']); $this->assertFalse(isset($Dispatcher->controller->params['pass'][0])); $url = new CakeRequest('/test_plugin/tests/index/some_param'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertEquals('tests', $Dispatcher->controller->params['controller']); $this->assertEquals('test_plugin', $Dispatcher->controller->params['plugin']); $this->assertEquals('index', $Dispatcher->controller->params['action']); @@ -1175,7 +1175,7 @@ public function testAutomaticPluginControllerMissingActionDispatch() { $url = new CakeRequest('my_plugin/not_here/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); } /** @@ -1193,7 +1193,7 @@ public function testAutomaticPluginControllerIndexMissingAction() { $url = new CakeRequest('my_plugin/param:value/param2:value2'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); } /** @@ -1203,16 +1203,16 @@ public function testAutomaticPluginControllerIndexMissingAction() { */ public function testTestPluginDispatch() { $Dispatcher = new TestDispatcher(); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); Router::reload(); Router::parse('/'); $url = new CakeRequest('/test_plugin/tests/index'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->assertTrue(class_exists('TestsController')); $this->assertTrue(class_exists('TestPluginAppController')); $this->assertTrue(class_exists('PluginsComponent')); @@ -1230,32 +1230,32 @@ public function testTestPluginDispatch() { * @return void */ public function testDispatcherFilterSubscriber() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS], + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); - Configure::write('Dispatcher.filters', array( - array('callable' => 'TestPlugin.TestDispatcherFilter') - )); + Configure::write('Dispatcher.filters', [ + ['callable' => 'TestPlugin.TestDispatcherFilter'] + ]); $dispatcher = new TestDispatcher(); $request = new CakeRequest('/'); $request->params['altered'] = false; - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher->dispatch($request, $response); $this->assertTrue($request->params['altered']); $this->assertEquals(304, $response->statusCode()); - Configure::write('Dispatcher.filters', array( + Configure::write('Dispatcher.filters', [ 'TestPlugin.Test2DispatcherFilter', 'TestPlugin.TestDispatcherFilter' - )); + ]); $dispatcher = new TestDispatcher(); $request = new CakeRequest('/'); $request->params['altered'] = false; - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher->dispatch($request, $response); $this->assertFalse($request->params['altered']); @@ -1269,15 +1269,15 @@ public function testDispatcherFilterSubscriber() { * @return void */ public function testDispatcherFilterSettings() { - Configure::write('Dispatcher.filters', array( - 'TestFilterDispatcher' => array('service' => 'google.com') - )); + Configure::write('Dispatcher.filters', [ + 'TestFilterDispatcher' => ['service' => 'google.com'] + ]); $Dispatcher = new Dispatcher(); $url = new CakeRequest('some_pages/index'); $response = $this->getMock('CakeResponse'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $settings = $url->param('settings'); - $this->assertEquals($settings, array('service' => 'google.com')); + $this->assertEquals($settings, ['service' => 'google.com']); } /** @@ -1287,17 +1287,17 @@ public function testDispatcherFilterSettings() { */ public function testDispatcherFilterSuscriberMissing() { $this->expectException(MissingDispatcherFilterException::class); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); CakePlugin::load('TestPlugin'); - Configure::write('Dispatcher.filters', array( - array('callable' => 'TestPlugin.NotAFilter') - )); + Configure::write('Dispatcher.filters', [ + ['callable' => 'TestPlugin.NotAFilter'] + ]); $dispatcher = new TestDispatcher(); $request = new CakeRequest('/'); - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher->dispatch($request, $response); } @@ -1307,67 +1307,67 @@ public function testDispatcherFilterSuscriberMissing() { * @return void */ public function testDispatcherFilterCallable() { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); $dispatcher = new TestDispatcher(); - Configure::write('Dispatcher.filters', array( - array('callable' => array($dispatcher, 'filterTest'), 'on' => 'before') - )); + Configure::write('Dispatcher.filters', [ + ['callable' => [$dispatcher, 'filterTest'], 'on' => 'before'] + ]); $request = new CakeRequest('/'); - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher->dispatch($request, $response); $this->assertEquals('Dispatcher.beforeDispatch', $request->params['eventName']); $dispatcher = new TestDispatcher(); - Configure::write('Dispatcher.filters', array( - array('callable' => array($dispatcher, 'filterTest'), 'on' => 'after') - )); + Configure::write('Dispatcher.filters', [ + ['callable' => [$dispatcher, 'filterTest'], 'on' => 'after'] + ]); $request = new CakeRequest('/'); - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher->dispatch($request, $response); $this->assertEquals('Dispatcher.afterDispatch', $request->params['eventName']); $dispatcher = new TestDispatcher(); - Configure::write('Dispatcher.filters', array( - 'filterTest' => array('callable' => array($dispatcher, 'filterTest'), 'on' => 'before') - )); + Configure::write('Dispatcher.filters', [ + 'filterTest' => ['callable' => [$dispatcher, 'filterTest'], 'on' => 'before'] + ]); $request = new CakeRequest('/'); - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher->dispatch($request, $response); $this->assertEquals('Dispatcher.beforeDispatch', $request->params['eventName']); // Test that it is possible to skip the route connection process $dispatcher = new TestDispatcher(); - Configure::write('Dispatcher.filters', array( - array('callable' => array($dispatcher, 'filterTest2'), 'on' => 'before', 'priority' => 1) - )); + Configure::write('Dispatcher.filters', [ + ['callable' => [$dispatcher, 'filterTest2'], 'on' => 'before', 'priority' => 1] + ]); $request = new CakeRequest('/'); - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher->dispatch($request, $response); $this->assertEmpty($dispatcher->controller); - $expected = array('controller' => null, 'action' => null, 'plugin' => null, 'named' => array(), 'pass' => array()); + $expected = ['controller' => null, 'action' => null, 'plugin' => null, 'named' => [], 'pass' => []]; $this->assertEquals($expected, $request->params); $dispatcher = new TestDispatcher(); - Configure::write('Dispatcher.filters', array( - array('callable' => array($dispatcher, 'filterTest2'), 'on' => 'before', 'priority' => 1) - )); + Configure::write('Dispatcher.filters', [ + ['callable' => [$dispatcher, 'filterTest2'], 'on' => 'before', 'priority' => 1] + ]); $request = new CakeRequest('/'); $request->params['return'] = true; - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $response->body('this is a body'); $result = $dispatcher->dispatch($request, $response); $this->assertEquals('this is a body', $result); $request = new CakeRequest('/'); - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $response->expects($this->once())->method('send'); $response->body('this is a body'); $result = $dispatcher->dispatch($request, $response); @@ -1385,14 +1385,14 @@ public function testChangingParamsFromBeforeFilter() { $url = new CakeRequest('some_posts/index/param:value/param2:value2'); try { - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $this->fail('No exception.'); } catch (MissingActionException $e) { $this->assertEquals('Action SomePostsController::view() could not be found.', $e->getMessage()); } $url = new CakeRequest('some_posts/something_else/param:value/param2:value2'); - $Dispatcher->dispatch($url, $response, array('return' => 1)); + $Dispatcher->dispatch($url, $response, ['return' => 1]); $expected = 'SomePosts'; $this->assertEquals($expected, $Dispatcher->controller->name); @@ -1400,7 +1400,7 @@ public function testChangingParamsFromBeforeFilter() { $expected = 'change'; $this->assertEquals($expected, $Dispatcher->controller->action); - $expected = array('changed'); + $expected = ['changed']; $this->assertSame($expected, $Dispatcher->controller->params['pass']); } @@ -1412,16 +1412,16 @@ public function testChangingParamsFromBeforeFilter() { public function testAssets() { Router::reload(); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Vendor' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); - Configure::write('Dispatcher.filters', array('AssetDispatcher')); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Vendor' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); + Configure::write('Dispatcher.filters', ['AssetDispatcher']); $Dispatcher = new TestDispatcher(); - $response = $this->getMock('CakeResponse', array('_sendHeader')); + $response = $this->getMock('CakeResponse', ['_sendHeader']); try { $Dispatcher->dispatch(new CakeRequest('theme/test_theme/../webroot/css/test_asset.css'), $response); @@ -1449,76 +1449,76 @@ public function testAssets() { * @return array */ public static function assetProvider() { - return array( - array( + return [ + [ 'theme/test_theme/flash/theme_test.swf', 'View/Themed/TestTheme/webroot/flash/theme_test.swf' - ), - array( + ], + [ 'theme/test_theme/pdfs/theme_test.pdf', 'View/Themed/TestTheme/webroot/pdfs/theme_test.pdf' - ), - array( + ], + [ 'theme/test_theme/img/test.jpg', 'View/Themed/TestTheme/webroot/img/test.jpg' - ), - array( + ], + [ 'theme/test_theme/css/test_asset.css', 'View/Themed/TestTheme/webroot/css/test_asset.css' - ), - array( + ], + [ 'theme/test_theme/js/theme.js', 'View/Themed/TestTheme/webroot/js/theme.js' - ), - array( + ], + [ 'theme/test_theme/js/one/theme_one.js', 'View/Themed/TestTheme/webroot/js/one/theme_one.js' - ), - array( + ], + [ 'theme/test_theme/space%20image.text', 'View/Themed/TestTheme/webroot/space image.text' - ), - array( + ], + [ 'test_plugin/root.js', 'Plugin/TestPlugin/webroot/root.js' - ), - array( + ], + [ 'test_plugin/flash/plugin_test.swf', 'Plugin/TestPlugin/webroot/flash/plugin_test.swf' - ), - array( + ], + [ 'test_plugin/pdfs/plugin_test.pdf', 'Plugin/TestPlugin/webroot/pdfs/plugin_test.pdf' - ), - array( + ], + [ 'test_plugin/js/test_plugin/test.js', 'Plugin/TestPlugin/webroot/js/test_plugin/test.js' - ), - array( + ], + [ 'test_plugin/css/test_plugin_asset.css', 'Plugin/TestPlugin/webroot/css/test_plugin_asset.css' - ), - array( + ], + [ 'test_plugin/img/cake.icon.gif', 'Plugin/TestPlugin/webroot/img/cake.icon.gif' - ), - array( + ], + [ 'plugin_js/js/plugin_js.js', 'Plugin/PluginJs/webroot/js/plugin_js.js' - ), - array( + ], + [ 'plugin_js/js/one/plugin_one.js', 'Plugin/PluginJs/webroot/js/one/plugin_one.js' - ), - array( + ], + [ 'test_plugin/css/unknown.extension', 'Plugin/TestPlugin/webroot/css/unknown.extension' - ), - array( + ], + [ 'test_plugin/css/theme_one.htc', 'Plugin/TestPlugin/webroot/css/theme_one.htc' - ), - ); + ], + ]; } /** @@ -1531,16 +1531,16 @@ public static function assetProvider() { public function testAsset($url, $file) { Router::reload(); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Vendor' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); - CakePlugin::load(array('TestPlugin', 'PluginJs')); - Configure::write('Dispatcher.filters', array('AssetDispatcher')); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Vendor' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Vendor' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); + CakePlugin::load(['TestPlugin', 'PluginJs']); + Configure::write('Dispatcher.filters', ['AssetDispatcher']); $Dispatcher = new TestDispatcher(); - $response = $this->getMock('CakeResponse', array('_sendHeader')); + $response = $this->getMock('CakeResponse', ['_sendHeader']); $Dispatcher->dispatch(new CakeRequest($url), $response); $result = ob_get_clean(); @@ -1560,13 +1560,13 @@ public function testAsset($url, $file) { * @return void */ public function testMissingAssetProcessor404() { - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $Dispatcher = new TestDispatcher(); - Configure::write('Asset.filter', array( + Configure::write('Asset.filter', [ 'js' => '', 'css' => null - )); - Configure::write('Dispatcher.filters', array('AssetDispatcher')); + ]); + Configure::write('Dispatcher.filters', ['AssetDispatcher']); $request = new CakeRequest('ccss/cake.generic.css'); $Dispatcher->dispatch($request, $response); @@ -1585,17 +1585,17 @@ public function testMissingAssetProcessor404() { * @return array */ public static function cacheActionProvider() { - return array( - array('/'), - array('test_cached_pages/index'), - array('TestCachedPages/index'), - array('test_cached_pages/test_nocache_tags'), - array('TestCachedPages/test_nocache_tags'), - array('test_cached_pages/view/param/param'), - array('test_cached_pages/view/foo:bar/value:goo'), - array('test_cached_pages/view?q=cakephp'), - array('test_cached_pages/themed'), - ); + return [ + ['/'], + ['test_cached_pages/index'], + ['TestCachedPages/index'], + ['test_cached_pages/test_nocache_tags'], + ['TestCachedPages/test_nocache_tags'], + ['test_cached_pages/view/param/param'], + ['test_cached_pages/view/foo:bar/value:goo'], + ['test_cached_pages/view?q=cakephp'], + ['test_cached_pages/themed'], + ]; } /** @@ -1610,23 +1610,23 @@ public function testFullPageCachingDispatch($url) { Configure::write('debug', 2); Router::reload(); - Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index')); + Router::connect('/', ['controller' => 'test_cached_pages', 'action' => 'index']); Router::connect('/:controller/:action/*'); - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS), - ), App::RESET); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS], + ], App::RESET); $dispatcher = new TestDispatcher(); $request = new CakeRequest($url); - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher->dispatch($request, $response); $out = $response->body(); - Configure::write('Dispatcher.filters', array('CacheDispatcher')); + Configure::write('Dispatcher.filters', ['CacheDispatcher']); $request = new CakeRequest($url); - $response = $this->getMock('CakeResponse', array('send')); + $response = $this->getMock('CakeResponse', ['send']); $dispatcher = new TestDispatcher(); $dispatcher->dispatch($request, $response); $cached = $response->body(); @@ -1657,9 +1657,9 @@ public function testHttpMethodOverrides() { $dispatcher = new Dispatcher(); $request = new CakeRequest('/posts'); - $event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $dispatcher, ['request' => $request]); $dispatcher->parseParams($event); - $expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST'); + $expected = ['pass' => [], 'named' => [], 'plugin' => null, 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST']; foreach ($expected as $key => $value) { $this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s'); } @@ -1668,17 +1668,17 @@ public function testHttpMethodOverrides() { $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT'; $request = new CakeRequest('/posts/5'); - $event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $dispatcher, ['request' => $request]); $dispatcher->parseParams($event); - $expected = array( - 'pass' => array('5'), - 'named' => array(), + $expected = [ + 'pass' => ['5'], + 'named' => [], 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT' - ); + ]; foreach ($expected as $key => $value) { $this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s'); } @@ -1687,9 +1687,9 @@ public function testHttpMethodOverrides() { $_SERVER['REQUEST_METHOD'] = 'GET'; $request = new CakeRequest('/posts/5'); - $event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $dispatcher, ['request' => $request]); $dispatcher->parseParams($event); - $expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '[method]' => 'GET'); + $expected = ['pass' => ['5'], 'named' => [], 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '[method]' => 'GET']; foreach ($expected as $key => $value) { $this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s'); } @@ -1697,25 +1697,25 @@ public function testHttpMethodOverrides() { $_POST['_method'] = 'PUT'; $request = new CakeRequest('/posts/5'); - $event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $dispatcher, ['request' => $request]); $dispatcher->parseParams($event); - $expected = array('pass' => array('5'), 'named' => array(), 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT'); + $expected = ['pass' => ['5'], 'named' => [], 'id' => '5', 'plugin' => null, 'controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT']; foreach ($expected as $key => $value) { $this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s'); } $_POST['_method'] = 'POST'; - $_POST['data'] = array('Post' => array('title' => 'New Post')); + $_POST['data'] = ['Post' => ['title' => 'New Post']]; $_POST['extra'] = 'data'; - $_SERVER = array(); + $_SERVER = []; $request = new CakeRequest('/posts'); - $event = new CakeEvent('DispatcherTest', $dispatcher, array('request' => $request)); + $event = new CakeEvent('DispatcherTest', $dispatcher, ['request' => $request]); $dispatcher->parseParams($event); - $expected = array( - 'pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'add', - '[method]' => 'POST', 'data' => array('extra' => 'data', 'Post' => array('title' => 'New Post')), - ); + $expected = [ + 'pass' => [], 'named' => [], 'plugin' => null, 'controller' => 'posts', 'action' => 'add', + '[method]' => 'POST', 'data' => ['extra' => 'data', 'Post' => ['title' => 'New Post']], + ]; foreach ($expected as $key => $value) { $this->assertEquals($value, $request[$key], 'Value mismatch for ' . $key . ' %s'); } diff --git a/lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php b/lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php index 5d1c408134..f3888ec27b 100644 --- a/lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/Filter/AssetDispatcherTest.php @@ -32,7 +32,7 @@ class AssetDispatcherTest extends CakeTestCase { */ public function tearDown() : void { parent::tearDown(); - Configure::write('Dispatcher.filters', array()); + Configure::write('Dispatcher.filters', []); } /** @@ -48,15 +48,15 @@ public function tearDown() : void { */ public function testAssetFilterForThemeAndPlugins() { $filter = new AssetDispatcher(); - $response = $this->getMock('CakeResponse', array('_sendHeader')); - Configure::write('Asset.filter', array( + $response = $this->getMock('CakeResponse', ['_sendHeader']); + Configure::write('Asset.filter', [ 'js' => '', 'css' => '' - )); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); + ]); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); $request = new CakeRequest('theme/test_theme/ccss/cake.generic.css'); $event = new CakeEvent('DispatcherTest', $this, compact('request', 'response')); @@ -98,17 +98,17 @@ public function testAssetFilterForThemeAndPlugins() { */ public function testNoHandleRoutedExtension() { $filter = new AssetDispatcher(); - $response = $this->getMock('CakeResponse', array('_sendHeader')); - Configure::write('Asset.filter', array( + $response = $this->getMock('CakeResponse', ['_sendHeader']); + Configure::write('Asset.filter', [ 'js' => '', 'css' => '' - )); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); + ]); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); Router::parseExtensions('json'); - Router::connect('/test_plugin/api/v1/:action', array('controller' => 'api')); + Router::connect('/test_plugin/api/v1/:action', ['controller' => 'api']); CakePlugin::load('TestPlugin'); $request = new CakeRequest('test_plugin/api/v1/forwarding.json'); @@ -127,18 +127,18 @@ public function testNoHandleRoutedExtension() { */ public function testNotModified() { $filter = new AssetDispatcher(); - Configure::write('Asset.filter', array( + Configure::write('Asset.filter', [ 'js' => '', 'css' => '' - )); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + ]); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $time = filemtime(App::themePath('TestTheme') . 'webroot' . DS . 'img' . DS . 'cake.power.gif'); $time = new DateTime('@' . $time); - $response = $this->getMock('CakeResponse', array('send', 'checkNotModified')); + $response = $this->getMock('CakeResponse', ['send', 'checkNotModified']); $request = new CakeRequest('theme/test_theme/img/cake.power.gif'); $response->expects($this->once())->method('checkNotModified') @@ -152,7 +152,7 @@ public function testNotModified() { $this->assertEquals(200, $response->statusCode()); $this->assertEquals($time->format('D, j M Y H:i:s') . ' GMT', $response->modified()); - $response = $this->getMock('CakeResponse', array('_sendHeader', 'checkNotModified')); + $response = $this->getMock('CakeResponse', ['_sendHeader', 'checkNotModified']); $request = new CakeRequest('theme/test_theme/img/cake.power.gif'); $response->expects($this->once())->method('checkNotModified') ->with($request) @@ -171,7 +171,7 @@ public function testNotModified() { public function test404OnDoubleSlash() { $filter = new AssetDispatcher(); - $response = $this->getMock('CakeResponse', array('_sendHeader')); + $response = $this->getMock('CakeResponse', ['_sendHeader']); $request = new CakeRequest('//index.php'); $event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response')); @@ -186,11 +186,11 @@ public function test404OnDoubleSlash() { * @triggers Dispatcher.beforeRequest $this, compact('request', 'response') */ public function test404OnDoubleDot() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); - $response = $this->getMock('CakeResponse', array('_sendHeader')); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); + $response = $this->getMock('CakeResponse', ['_sendHeader']); $request = new CakeRequest('theme/test_theme/../../../../../../VERSION.txt'); $event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response')); $filter = new AssetDispatcher(); @@ -205,12 +205,12 @@ public function test404OnDoubleDot() { * @triggers Dispatcher.beforeRequest $this, compact('request', 'response') */ public function test404OnDoubleDotEncoded() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); - $response = $this->getMock('CakeResponse', array('_sendHeader', 'send')); + $response = $this->getMock('CakeResponse', ['_sendHeader', 'send']); $request = new CakeRequest('theme/test_theme/%2e./%2e./%2e./%2e./%2e./%2e./VERSION.txt'); $event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response')); @@ -231,16 +231,16 @@ public function test404OnDoubleDotEncoded() { */ public function testAssetContentLength() { Router::reload(); - Configure::write('Dispatcher.filters', array('AssetDispatcher')); - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + Configure::write('Dispatcher.filters', ['AssetDispatcher']); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); $url = 'theme/test_theme/css/test_asset.css'; $file = 'View/Themed/TestTheme/webroot/css/test_asset.css'; $request = new CakeRequest($url); - $response = $this->getMock('CakeResponse', array('_sendHeader', 'send')); + $response = $this->getMock('CakeResponse', ['_sendHeader', 'send']); $event = new CakeEvent('Dispatcher.beforeRequest', $this, compact('request', 'response')); $filter = new AssetDispatcher(); diff --git a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php index e4e841ac18..50b9f40c9f 100644 --- a/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/CakeRouteTest.php @@ -33,7 +33,7 @@ class CakeRouteTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - Configure::write('Routing', array('admin' => null, 'prefixes' => array())); + Configure::write('Routing', ['admin' => null, 'prefixes' => []]); } /** @@ -42,11 +42,11 @@ public function setUp() : void { * @return void */ public function testConstruction() { - $route = new CakeRoute('/:controller/:action/:id', array(), array('id' => '[0-9]+')); + $route = new CakeRoute('/:controller/:action/:id', [], ['id' => '[0-9]+']); $this->assertEquals('/:controller/:action/:id', $route->template); - $this->assertEquals(array(), $route->defaults); - $this->assertEquals(array('id' => '[0-9]+'), $route->options); + $this->assertEquals([], $route->defaults); + $this->assertEquals(['id' => '[0-9]+'], $route->options); $this->assertFalse($route->compiled()); } @@ -56,13 +56,13 @@ public function testConstruction() { * @return void */ public function testBasicRouteCompiling() { - $route = new CakeRoute('/', array('controller' => 'pages', 'action' => 'display', 'home')); + $route = new CakeRoute('/', ['controller' => 'pages', 'action' => 'display', 'home']); $result = $route->compile(); $expected = '#^/*$#'; $this->assertEquals($expected, $result); - $this->assertEquals(array(), $route->keys); + $this->assertEquals([], $route->keys); - $route = new CakeRoute('/:controller/:action', array('controller' => 'posts')); + $route = new CakeRoute('/:controller/:action', ['controller' => 'posts']); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/posts/edit'); @@ -70,7 +70,7 @@ public function testBasicRouteCompiling() { $this->assertDoesNotMatchRegularExpression($result, '/posts'); $this->assertDoesNotMatchRegularExpression($result, '/posts/super_delete/1'); - $route = new CakeRoute('/posts/foo:id', array('controller' => 'posts', 'action' => 'view')); + $route = new CakeRoute('/posts/foo:id', ['controller' => 'posts', 'action' => 'view']); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/posts/foo:1'); @@ -78,9 +78,9 @@ public function testBasicRouteCompiling() { $this->assertDoesNotMatchRegularExpression($result, '/posts'); $this->assertDoesNotMatchRegularExpression($result, '/posts/'); - $this->assertEquals(array('id'), $route->keys); + $this->assertEquals(['id'], $route->keys); - $route = new CakeRoute('/:plugin/:controller/:action/*', array('plugin' => 'test_plugin', 'action' => 'index')); + $route = new CakeRoute('/:plugin/:controller/:action/*', ['plugin' => 'test_plugin', 'action' => 'index']); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/test_plugin/posts/index'); $this->assertMatchesRegularExpression($result, '/test_plugin/posts/edit/5'); @@ -93,11 +93,11 @@ public function testBasicRouteCompiling() { * @return void */ public function testRouteParameterOverlap() { - $route = new CakeRoute('/invoices/add/:idd/:id', array('controller' => 'invoices', 'action' => 'add')); + $route = new CakeRoute('/invoices/add/:idd/:id', ['controller' => 'invoices', 'action' => 'add']); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/invoices/add/1/3'); - $route = new CakeRoute('/invoices/add/:id/:idd', array('controller' => 'invoices', 'action' => 'add')); + $route = new CakeRoute('/invoices/add/:id/:idd', ['controller' => 'invoices', 'action' => 'add']); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/invoices/add/1/3'); } @@ -110,29 +110,29 @@ public function testRouteParameterOverlap() { public function testRouteCompilingWithParamPatterns() { $route = new CakeRoute( '/:controller/:action/:id', - array(), - array('id' => Router::ID) + [], + ['id' => Router::ID] ); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/posts/edit/1'); $this->assertMatchesRegularExpression($result, '/posts/view/518098'); $this->assertDoesNotMatchRegularExpression($result, '/posts/edit/name-of-post'); $this->assertDoesNotMatchRegularExpression($result, '/posts/edit/4/other:param'); - $this->assertEquals(array('id', 'controller', 'action'), $route->keys); + $this->assertEquals(['id', 'controller', 'action'], $route->keys); $route = new CakeRoute( '/:lang/:controller/:action/:id', - array('controller' => 'testing4'), - array('id' => Router::ID, 'lang' => '[a-z]{3}') + ['controller' => 'testing4'], + ['id' => Router::ID, 'lang' => '[a-z]{3}'] ); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/eng/posts/edit/1'); $this->assertMatchesRegularExpression($result, '/cze/articles/view/1'); $this->assertDoesNotMatchRegularExpression($result, '/language/articles/view/2'); $this->assertDoesNotMatchRegularExpression($result, '/eng/articles/view/name-of-article'); - $this->assertEquals(array('lang', 'id', 'controller', 'action'), $route->keys); + $this->assertEquals(['lang', 'id', 'controller', 'action'], $route->keys); - foreach (array(':', '@', ';', '$', '-') as $delim) { + foreach ([':', '@', ';', '$', '-'] as $delim) { $route = new CakeRoute('/posts/:id' . $delim . ':title'); $result = $route->compile(); @@ -141,13 +141,13 @@ public function testRouteCompilingWithParamPatterns() { $this->assertDoesNotMatchRegularExpression($result, '/posts/11!nameofarticle'); $this->assertDoesNotMatchRegularExpression($result, '/posts/11'); - $this->assertEquals(array('title', 'id'), $route->keys); + $this->assertEquals(['title', 'id'], $route->keys); } $route = new CakeRoute( '/posts/:id::title/:year', - array('controller' => 'posts', 'action' => 'view'), - array('id' => Router::ID, 'year' => Router::YEAR, 'title' => '[a-z-_]+') + ['controller' => 'posts', 'action' => 'view'], + ['id' => Router::ID, 'year' => Router::YEAR, 'title' => '[a-z-_]+'] ); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/posts/1:name-of-article/2009/'); @@ -155,12 +155,12 @@ public function testRouteCompilingWithParamPatterns() { $this->assertDoesNotMatchRegularExpression($result, '/posts/hey_now:nameofarticle'); $this->assertDoesNotMatchRegularExpression($result, '/posts/:nameofarticle/2009'); $this->assertDoesNotMatchRegularExpression($result, '/posts/:nameofarticle/01'); - $this->assertEquals(array('year', 'title', 'id'), $route->keys); + $this->assertEquals(['year', 'title', 'id'], $route->keys); $route = new CakeRoute( '/posts/:url_title-(uuid::id)', - array('controller' => 'posts', 'action' => 'view'), - array('pass' => array('id', 'url_title'), 'id' => Router::ID) + ['controller' => 'posts', 'action' => 'view'], + ['pass' => ['id', 'url_title'], 'id' => Router::ID] ); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/posts/some_title_for_article-(uuid:12534)/'); @@ -168,7 +168,7 @@ public function testRouteCompilingWithParamPatterns() { $this->assertDoesNotMatchRegularExpression($result, '/posts/'); $this->assertDoesNotMatchRegularExpression($result, '/posts/nameofarticle'); $this->assertDoesNotMatchRegularExpression($result, '/posts/nameofarticle-12347'); - $this->assertEquals(array('url_title', 'id'), $route->keys); + $this->assertEquals(['url_title', 'id'], $route->keys); } /** @@ -180,8 +180,8 @@ public function testRouteCompilingWithParamPatterns() { public function testComplexRouteCompilingAndParsing() { $route = new CakeRoute( '/posts/:month/:day/:year/*', - array('controller' => 'posts', 'action' => 'view'), - array('year' => Router::YEAR, 'month' => Router::MONTH, 'day' => Router::DAY) + ['controller' => 'posts', 'action' => 'view'], + ['year' => Router::YEAR, 'month' => Router::MONTH, 'day' => Router::DAY] ); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/posts/08/01/2007/title-of-post'); @@ -197,28 +197,28 @@ public function testComplexRouteCompilingAndParsing() { $route = new CakeRoute( "/:extra/page/:slug/*", - array('controller' => 'pages', 'action' => 'view', 'extra' => null), - array("extra" => '[a-z1-9_]*', "slug" => '[a-z1-9_]+', "action" => 'view') + ['controller' => 'pages', 'action' => 'view', 'extra' => null], + ["extra" => '[a-z1-9_]*', "slug" => '[a-z1-9_]+', "action" => 'view'] ); $result = $route->compile(); $this->assertMatchesRegularExpression($result, '/some_extra/page/this_is_the_slug'); $this->assertMatchesRegularExpression($result, '/page/this_is_the_slug'); - $this->assertEquals(array('slug', 'extra'), $route->keys); - $this->assertEquals(array('extra' => '[a-z1-9_]*', 'slug' => '[a-z1-9_]+', 'action' => 'view'), $route->options); - $expected = array( + $this->assertEquals(['slug', 'extra'], $route->keys); + $this->assertEquals(['extra' => '[a-z1-9_]*', 'slug' => '[a-z1-9_]+', 'action' => 'view'], $route->options); + $expected = [ 'controller' => 'pages', 'action' => 'view' - ); + ]; $this->assertEquals($expected, $route->defaults); $route = new CakeRoute( '/:controller/:action/*', - array('project' => false), - array( + ['project' => false], + [ 'controller' => 'source|wiki|commits|tickets|comments|view', 'action' => 'branches|history|branch|logs|view|start|add|edit|modify' - ) + ] ); $this->assertFalse($route->parse('/chaw_test/wiki')); @@ -236,80 +236,80 @@ public function testComplexRouteCompilingAndParsing() { * @return void */ public function testMatchBasic() { - $route = new CakeRoute('/:controller/:action/:id', array('plugin' => null)); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null)); + $route = new CakeRoute('/:controller/:action/:id', ['plugin' => null]); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'plugin' => null]); $this->assertFalse($result); - $result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 0)); + $result = $route->match(['plugin' => null, 'controller' => 'posts', 'action' => 'view', 0]); $this->assertFalse($result); - $result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => 1)); + $result = $route->match(['plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => 1]); $this->assertEquals('/posts/view/1', $result); - $route = new CakeRoute('/', array('controller' => 'pages', 'action' => 'display', 'home')); - $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'home')); + $route = new CakeRoute('/', ['controller' => 'pages', 'action' => 'display', 'home']); + $result = $route->match(['controller' => 'pages', 'action' => 'display', 'home']); $this->assertEquals('/', $result); - $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'about')); + $result = $route->match(['controller' => 'pages', 'action' => 'display', 'about']); $this->assertFalse($result); - $route = new CakeRoute('/pages/*', array('controller' => 'pages', 'action' => 'display')); - $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'home')); + $route = new CakeRoute('/pages/*', ['controller' => 'pages', 'action' => 'display']); + $result = $route->match(['controller' => 'pages', 'action' => 'display', 'home']); $this->assertEquals('/pages/home', $result); - $result = $route->match(array('controller' => 'pages', 'action' => 'display', 'about')); + $result = $route->match(['controller' => 'pages', 'action' => 'display', 'about']); $this->assertEquals('/pages/about', $result); - $route = new CakeRoute('/blog/:action', array('controller' => 'posts')); - $result = $route->match(array('controller' => 'posts', 'action' => 'view')); + $route = new CakeRoute('/blog/:action', ['controller' => 'posts']); + $result = $route->match(['controller' => 'posts', 'action' => 'view']); $this->assertEquals('/blog/view', $result); - $result = $route->match(array('controller' => 'nodes', 'action' => 'view')); + $result = $route->match(['controller' => 'nodes', 'action' => 'view']); $this->assertFalse($result); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 1)); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 1]); $this->assertFalse($result); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => 2)); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'id' => 2]); $this->assertFalse($result); - $route = new CakeRoute('/foo/:controller/:action', array('action' => 'index')); - $result = $route->match(array('controller' => 'posts', 'action' => 'view')); + $route = new CakeRoute('/foo/:controller/:action', ['action' => 'index']); + $result = $route->match(['controller' => 'posts', 'action' => 'view']); $this->assertEquals('/foo/posts/view', $result); - $route = new CakeRoute('/:plugin/:id/*', array('controller' => 'posts', 'action' => 'view')); - $result = $route->match(array('plugin' => 'test', 'controller' => 'posts', 'action' => 'view', 'id' => '1')); + $route = new CakeRoute('/:plugin/:id/*', ['controller' => 'posts', 'action' => 'view']); + $result = $route->match(['plugin' => 'test', 'controller' => 'posts', 'action' => 'view', 'id' => '1']); $this->assertEquals('/test/1/', $result); - $result = $route->match(array('plugin' => 'fo', 'controller' => 'posts', 'action' => 'view', 'id' => '1', '0')); + $result = $route->match(['plugin' => 'fo', 'controller' => 'posts', 'action' => 'view', 'id' => '1', '0']); $this->assertEquals('/fo/1/0', $result); - $result = $route->match(array('plugin' => 'fo', 'controller' => 'nodes', 'action' => 'view', 'id' => 1)); + $result = $route->match(['plugin' => 'fo', 'controller' => 'nodes', 'action' => 'view', 'id' => 1]); $this->assertFalse($result); - $result = $route->match(array('plugin' => 'fo', 'controller' => 'posts', 'action' => 'edit', 'id' => 1)); + $result = $route->match(['plugin' => 'fo', 'controller' => 'posts', 'action' => 'edit', 'id' => 1]); $this->assertFalse($result); - $route = new CakeRoute('/admin/subscriptions/:action/*', array( + $route = new CakeRoute('/admin/subscriptions/:action/*', [ 'controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin' - )); + ]); - $url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1); + $url = ['controller' => 'subscribe', 'admin' => true, 'action' => 'edit', 1]; $result = $route->match($url); $expected = '/admin/subscriptions/edit/1'; $this->assertEquals($expected, $result); - $url = array( + $url = [ 'controller' => 'subscribe', 'admin' => true, 'action' => 'edit_admin_e', 1 - ); + ]; $result = $route->match($url); $expected = '/admin/subscriptions/edit_admin_e/1'; $this->assertEquals($expected, $result); - $url = array('controller' => 'subscribe', 'admin' => true, 'action' => 'admin_edit', 1); + $url = ['controller' => 'subscribe', 'admin' => true, 'action' => 'admin_edit', 1]; $result = $route->match($url); $expected = '/admin/subscriptions/edit/1'; $this->assertEquals($expected, $result); @@ -321,12 +321,12 @@ public function testMatchBasic() { * @return void */ public function testGreedyRouteFailurePassedArg() { - $route = new CakeRoute('/:controller/:action', array('plugin' => null)); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', '0')); + $route = new CakeRoute('/:controller/:action', ['plugin' => null]); + $result = $route->match(['controller' => 'posts', 'action' => 'view', '0']); $this->assertFalse($result); - $route = new CakeRoute('/:controller/:action', array('plugin' => null)); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'test')); + $route = new CakeRoute('/:controller/:action', ['plugin' => null]); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'test']); $this->assertFalse($result); } @@ -336,8 +336,8 @@ public function testGreedyRouteFailurePassedArg() { * @return void */ public function testGreedyRouteFailureNamedParam() { - $route = new CakeRoute('/:controller/:action', array('plugin' => null)); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'page' => 1)); + $route = new CakeRoute('/:controller/:action', ['plugin' => null]); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'page' => 1]); $this->assertFalse($result); } @@ -347,10 +347,10 @@ public function testGreedyRouteFailureNamedParam() { * @return void */ public function testMatchWithFalseyValues() { - $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); - $result = $route->match(array( + $route = new CakeRoute('/:controller/:action/*', ['plugin' => null]); + $result = $route->match([ 'controller' => 'posts', 'action' => 'index', 'plugin' => null, 'admin' => false - )); + ]); $this->assertEquals('/posts/index/', $result); } @@ -362,33 +362,33 @@ public function testMatchWithFalseyValues() { public function testMatchWithNamedParametersAndPassedArgs() { Router::connectNamed(true); - $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); - $result = $route->match(array('controller' => 'posts', 'action' => 'index', 'plugin' => null, 'page' => 1)); + $route = new CakeRoute('/:controller/:action/*', ['plugin' => null]); + $result = $route->match(['controller' => 'posts', 'action' => 'index', 'plugin' => null, 'page' => 1]); $this->assertEquals('/posts/index/page:1', $result); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5)); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'plugin' => null, 5]); $this->assertEquals('/posts/view/5', $result); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 0)); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'plugin' => null, 0]); $this->assertEquals('/posts/view/0', $result); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, '0')); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'plugin' => null, '0']); $this->assertEquals('/posts/view/0', $result); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, 'page' => 1, 'limit' => 20, 'order' => 'title')); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'plugin' => null, 5, 'page' => 1, 'limit' => 20, 'order' => 'title']); $this->assertEquals('/posts/view/5/page:1/limit:20/order:title', $result); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'plugin' => null, 'word space', 'order' => 'Θ')); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'plugin' => null, 'word space', 'order' => 'Θ']); $this->assertEquals('/posts/view/word%20space/order:%CE%98', $result); - $route = new CakeRoute('/test2/*', array('controller' => 'pages', 'action' => 'display', 2)); - $result = $route->match(array('controller' => 'pages', 'action' => 'display', 1)); + $route = new CakeRoute('/test2/*', ['controller' => 'pages', 'action' => 'display', 2]); + $result = $route->match(['controller' => 'pages', 'action' => 'display', 1]); $this->assertFalse($result); - $result = $route->match(array('controller' => 'pages', 'action' => 'display', 2, 'something')); + $result = $route->match(['controller' => 'pages', 'action' => 'display', 2, 'something']); $this->assertEquals('/test2/something', $result); - $result = $route->match(array('controller' => 'pages', 'action' => 'display', 5, 'something')); + $result = $route->match(['controller' => 'pages', 'action' => 'display', 5, 'something']); $this->assertFalse($result); } @@ -399,7 +399,7 @@ public function testMatchWithNamedParametersAndPassedArgs() { */ public function testParseNamedParametersUrlDecode() { Router::connectNamed(true); - $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); + $route = new CakeRoute('/:controller/:action/*', ['plugin' => null]); $result = $route->parse('/posts/index/page:%CE%98'); $this->assertEquals('Θ', $result['named']['page']); @@ -419,17 +419,17 @@ public function testParseNamedParametersUrlDecode() { */ public function testParseNamedKeyUrlDecode() { Router::connectNamed(true); - $route = new CakeRoute('/:controller/:action/*', array('plugin' => null)); + $route = new CakeRoute('/:controller/:action/*', ['plugin' => null]); // checking /post/index/user[0]:a/user[1]:b $result = $route->parse('/posts/index/user%5B0%5D:a/user%5B1%5D:b'); $this->assertArrayHasKey('user', $result['named']); - $this->assertEquals(array('a', 'b'), $result['named']['user']); + $this->assertEquals(['a', 'b'], $result['named']['user']); // checking /post/index/user[]:a/user[]:b $result = $route->parse('/posts/index/user%5B%5D:a/user%5B%5D:b'); $this->assertArrayHasKey('user', $result['named']); - $this->assertEquals(array('a', 'b'), $result['named']['user']); + $this->assertEquals(['a', 'b'], $result['named']['user']); } /** @@ -439,7 +439,7 @@ public function testParseNamedKeyUrlDecode() { */ public function testNamedParamsWithNullFalse() { $route = new CakeRoute('/:controller/:action/*'); - $result = $route->match(array('controller' => 'posts', 'action' => 'index', 'page' => null, 'sort' => false)); + $result = $route->match(['controller' => 'posts', 'action' => 'index', 'page' => null, 'sort' => false]); $this->assertEquals('/posts/index/', $result); } @@ -449,17 +449,17 @@ public function testNamedParamsWithNullFalse() { * @return void */ public function testMatchWithPatterns() { - $route = new CakeRoute('/:controller/:action/:id', array('plugin' => null), array('id' => '[0-9]+')); - $result = $route->match(array('controller' => 'posts', 'action' => 'view', 'id' => 'foo')); + $route = new CakeRoute('/:controller/:action/:id', ['plugin' => null], ['id' => '[0-9]+']); + $result = $route->match(['controller' => 'posts', 'action' => 'view', 'id' => 'foo']); $this->assertFalse($result); - $result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '9')); + $result = $route->match(['plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '9']); $this->assertEquals('/posts/view/9', $result); - $result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '922')); + $result = $route->match(['plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => '922']); $this->assertEquals('/posts/view/922', $result); - $result = $route->match(array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => 'a99')); + $result = $route->match(['plugin' => null, 'controller' => 'posts', 'action' => 'view', 'id' => 'a99']); $this->assertFalse($result); } @@ -471,17 +471,17 @@ public function testMatchWithPatterns() { public function testPersistParams() { $route = new CakeRoute( '/:lang/:color/blog/:action', - array('controller' => 'posts'), - array('persist' => array('lang', 'color')) + ['controller' => 'posts'], + ['persist' => ['lang', 'color']] ); - $url = array('controller' => 'posts', 'action' => 'index'); - $params = array('lang' => 'en', 'color' => 'blue'); + $url = ['controller' => 'posts', 'action' => 'index']; + $params = ['lang' => 'en', 'color' => 'blue']; $result = $route->persistParams($url, $params); $this->assertEquals('en', $result['lang']); $this->assertEquals('blue', $result['color']); - $url = array('controller' => 'posts', 'action' => 'index', 'color' => 'red'); - $params = array('lang' => 'en', 'color' => 'blue'); + $url = ['controller' => 'posts', 'action' => 'index', 'color' => 'red']; + $params = ['lang' => 'en', 'color' => 'blue']; $result = $route->persistParams($url, $params); $this->assertEquals('en', $result['lang']); $this->assertEquals('red', $result['color']); @@ -493,12 +493,12 @@ public function testPersistParams() { * @return void */ public function testPersistParamsNonArray() { - $url = array('controller' => 'posts', 'action' => 'index'); - $params = array('lang' => 'en', 'color' => 'blue'); + $url = ['controller' => 'posts', 'action' => 'index']; + $params = ['lang' => 'en', 'color' => 'blue']; $route = new CakeRoute( '/:lang/:color/blog/:action', - array('controller' => 'posts') + ['controller' => 'posts'] // No persist options ); $result = $route->persistParams($url, $params); @@ -506,16 +506,16 @@ public function testPersistParamsNonArray() { $route = new CakeRoute( '/:lang/:color/blog/:action', - array('controller' => 'posts'), - array('persist' => false) + ['controller' => 'posts'], + ['persist' => false] ); $result = $route->persistParams($url, $params); $this->assertEquals($url, $result); $route = new CakeRoute( '/:lang/:color/blog/:action', - array('controller' => 'posts'), - array('persist' => 'derp') + ['controller' => 'posts'], + ['persist' => 'derp'] ); $result = $route->persistParams($url, $params); $this->assertEquals($url, $result); @@ -529,8 +529,8 @@ public function testPersistParamsNonArray() { public function testParse() { $route = new CakeRoute( '/:controller/:action/:id', - array('controller' => 'testing4', 'id' => null), - array('id' => Router::ID) + ['controller' => 'testing4', 'id' => null], + ['id' => Router::ID] ); $route->compile(); $result = $route->parse('/posts/view/1'); @@ -540,7 +540,7 @@ public function testParse() { $route = new Cakeroute( '/admin/:controller', - array('prefix' => 'admin', 'admin' => 1, 'action' => 'index') + ['prefix' => 'admin', 'admin' => 1, 'action' => 'index'] ); $route->compile(); $result = $route->parse('/admin/'); @@ -559,7 +559,7 @@ public function testParse() { public function testParseUrlDecodeElements() { $route = new Cakeroute( '/:controller/:slug', - array('action' => 'view') + ['action' => 'view'] ); $route->compile(); $result = $route->parse('/posts/%E2%88%82%E2%88%82'); @@ -579,14 +579,14 @@ public function testParseUrlDecodeElements() { * @return void */ public function testParseWithPassDefaults() { - $route = new Cakeroute('/:controller', array('action' => 'display', 'home')); + $route = new Cakeroute('/:controller', ['action' => 'display', 'home']); $result = $route->parse('/posts'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'display', - 'pass' => array('home'), - 'named' => array() - ); + 'pass' => ['home'], + 'named' => [] + ]; $this->assertEquals($expected, $result); } @@ -597,7 +597,7 @@ public function testParseWithPassDefaults() { */ public function testParseWithHttpHeaderConditions() { $_SERVER['REQUEST_METHOD'] = 'GET'; - $route = new CakeRoute('/sample', array('controller' => 'posts', 'action' => 'index', '[method]' => 'POST')); + $route = new CakeRoute('/sample', ['controller' => 'posts', 'action' => 'index', '[method]' => 'POST']); $this->assertFalse($route->parse('/sample')); } @@ -610,17 +610,17 @@ public function testParseWithHttpHeaderConditions() { public function testPatternOnAction() { $route = new CakeRoute( '/blog/:action/*', - array('controller' => 'blog_posts'), - array('action' => 'other|actions') + ['controller' => 'blog_posts'], + ['action' => 'other|actions'] ); - $result = $route->match(array('controller' => 'blog_posts', 'action' => 'foo')); + $result = $route->match(['controller' => 'blog_posts', 'action' => 'foo']); $this->assertFalse($result); - $result = $route->match(array('controller' => 'blog_posts', 'action' => 'actions')); + $result = $route->match(['controller' => 'blog_posts', 'action' => 'actions']); $this->assertNotEmpty($result); $result = $route->parse('/blog/other'); - $expected = array('controller' => 'blog_posts', 'action' => 'other', 'pass' => array(), 'named' => array()); + $expected = ['controller' => 'blog_posts', 'action' => 'other', 'pass' => [], 'named' => []]; $this->assertEquals($expected, $result); $result = $route->parse('/blog/foobar'); @@ -635,24 +635,24 @@ public function testPatternOnAction() { public function testParsePassedArgument() { $route = new CakeRoute('/:controller/:action/*'); $result = $route->parse('/posts/edit/1/2/0'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'edit', - 'pass' => array('1', '2', '0'), - 'named' => array() - ); + 'pass' => ['1', '2', '0'], + 'named' => [] + ]; $this->assertEquals($expected, $result); $result = $route->parse('/posts/edit/a-string/page:1/sort:value'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'edit', - 'pass' => array('a-string'), - 'named' => array( + 'pass' => ['a-string'], + 'named' => [ 'page' => 1, 'sort' => 'value' - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -662,66 +662,66 @@ public function testParsePassedArgument() { * @return void */ public function testParseNamedParametersWithRules() { - $route = new CakeRoute('/:controller/:action/*', array(), array( - 'named' => array( + $route = new CakeRoute('/:controller/:action/*', [], [ + 'named' => [ 'wibble', - 'fish' => array('action' => 'index'), - 'fizz' => array('controller' => array('comments', 'other')), + 'fish' => ['action' => 'index'], + 'fizz' => ['controller' => ['comments', 'other']], 'pattern' => 'val-[\d]+' - ) - )); + ] + ]); $result = $route->parse('/posts/display/wibble:spin/fish:trout/fizz:buzz/unknown:value'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'display', - 'pass' => array('fish:trout', 'fizz:buzz', 'unknown:value'), - 'named' => array( + 'pass' => ['fish:trout', 'fizz:buzz', 'unknown:value'], + 'named' => [ 'wibble' => 'spin' - ) - ); + ] + ]; $this->assertEquals($expected, $result, 'Fish should not be parsed, as action != index'); $result = $route->parse('/posts/index/wibble:spin/fish:trout/fizz:buzz'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'index', - 'pass' => array('fizz:buzz'), - 'named' => array( + 'pass' => ['fizz:buzz'], + 'named' => [ 'wibble' => 'spin', 'fish' => 'trout' - ) - ); + ] + ]; $this->assertEquals($expected, $result, 'Fizz should be parsed, as controller == comments|other'); $result = $route->parse('/comments/index/wibble:spin/fish:trout/fizz:buzz'); - $expected = array( + $expected = [ 'controller' => 'comments', 'action' => 'index', - 'pass' => array(), - 'named' => array( + 'pass' => [], + 'named' => [ 'wibble' => 'spin', 'fish' => 'trout', 'fizz' => 'buzz' - ) - ); + ] + ]; $this->assertEquals($expected, $result, 'All params should be parsed as conditions were met.'); $result = $route->parse('/comments/index/pattern:val--'); - $expected = array( + $expected = [ 'controller' => 'comments', 'action' => 'index', - 'pass' => array('pattern:val--'), - 'named' => array() - ); + 'pass' => ['pattern:val--'], + 'named' => [] + ]; $this->assertEquals($expected, $result, 'Named parameter pattern unmet.'); $result = $route->parse('/comments/index/pattern:val-2'); - $expected = array( + $expected = [ 'controller' => 'comments', 'action' => 'index', - 'pass' => array(), - 'named' => array('pattern' => 'val-2') - ); + 'pass' => [], + 'named' => ['pattern' => 'val-2'] + ]; $this->assertEquals($expected, $result, 'Named parameter pattern met.'); } @@ -731,22 +731,22 @@ public function testParseNamedParametersWithRules() { * @return void */ public function testParseGreedyNamed() { - $route = new CakeRoute('/:controller/:action/*', array(), array( - 'named' => array( - 'fizz' => array('controller' => 'comments'), + $route = new CakeRoute('/:controller/:action/*', [], [ + 'named' => [ + 'fizz' => ['controller' => 'comments'], 'pattern' => 'val-[\d]+', - ), + ], 'greedyNamed' => true - )); + ]); $result = $route->parse('/posts/display/wibble:spin/fizz:buzz/pattern:ignored'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'display', - 'pass' => array('fizz:buzz', 'pattern:ignored'), - 'named' => array( + 'pass' => ['fizz:buzz', 'pattern:ignored'], + 'named' => [ 'wibble' => 'spin', - ) - ); + ] + ]; $this->assertEquals($expected, $result, 'Greedy named grabs everything, rules are followed'); } @@ -756,11 +756,11 @@ public function testParseGreedyNamed() { * @return void */ public function testMatchGreedyNamedExcludesPrefixes() { - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Router::reload(); - $route = new CakeRoute('/sales/*', array('controller' => 'sales', 'action' => 'index')); - $this->assertFalse($route->match(array('controller' => 'sales', 'action' => 'index', 'admin' => 1)), 'Greedy named consume routing prefixes.'); + $route = new CakeRoute('/sales/*', ['controller' => 'sales', 'action' => 'index']); + $this->assertFalse($route->match(['controller' => 'sales', 'action' => 'index', 'admin' => 1]), 'Greedy named consume routing prefixes.'); } /** @@ -771,51 +771,51 @@ public function testMatchGreedyNamedExcludesPrefixes() { public function testParseArrayNamedParameters() { $route = new CakeRoute('/:controller/:action/*'); $result = $route->parse('/tests/action/var[]:val1/var[]:val2'); - $expected = array( + $expected = [ 'controller' => 'tests', 'action' => 'action', - 'named' => array( - 'var' => array( + 'named' => [ + 'var' => [ 'val1', 'val2' - ) - ), - 'pass' => array(), - ); + ] + ], + 'pass' => [], + ]; $this->assertEquals($expected, $result); $result = $route->parse('/tests/action/theanswer[is]:42/var[]:val2/var[]:val3'); - $expected = array( + $expected = [ 'controller' => 'tests', 'action' => 'action', - 'named' => array( - 'theanswer' => array( + 'named' => [ + 'theanswer' => [ 'is' => 42 - ), - 'var' => array( + ], + 'var' => [ 'val2', 'val3' - ) - ), - 'pass' => array(), - ); + ] + ], + 'pass' => [], + ]; $this->assertEquals($expected, $result); $result = $route->parse('/tests/action/theanswer[is][not]:42/theanswer[]:5/theanswer[is]:6'); - $expected = array( + $expected = [ 'controller' => 'tests', 'action' => 'action', - 'named' => array( - 'theanswer' => array( + 'named' => [ + 'theanswer' => [ 5, - 'is' => array( + 'is' => [ 6, 'not' => 42 - ) - ), - ), - 'pass' => array(), - ); + ] + ], + ], + 'pass' => [], + ]; $this->assertEquals($expected, $result); } @@ -827,29 +827,29 @@ public function testParseArrayNamedParameters() { public function testMatchNamedParametersArray() { $route = new CakeRoute('/:controller/:action/*'); - $url = array( + $url = [ 'controller' => 'posts', 'action' => 'index', - 'filter' => array( + 'filter' => [ 'one', 'model' => 'value' - ) - ); + ] + ]; $result = $route->match($url); $expected = '/posts/index/filter%5B0%5D:one/filter%5Bmodel%5D:value'; $this->assertEquals($expected, $result); - $url = array( + $url = [ 'controller' => 'posts', 'action' => 'index', - 'filter' => array( + 'filter' => [ 'one', - 'model' => array( + 'model' => [ 'two', 'order' => 'field' - ) - ) - ); + ] + ] + ]; $result = $route->match($url); $expected = '/posts/index/filter%5B0%5D:one/filter%5Bmodel%5D%5B0%5D:two/filter%5Bmodel%5D%5Border%5D:field'; $this->assertEquals($expected, $result); @@ -863,10 +863,10 @@ public function testMatchNamedParametersArray() { public function testMatchSimilarParameters() { $route = new CakeRoute('/:thisParam/:thisParamIsLonger'); - $url = array( + $url = [ 'thisParamIsLonger' => 'bar', 'thisParam' => 'foo', - ); + ]; $result = $route->match($url); $expected = '/foo/bar'; @@ -879,13 +879,13 @@ public function testMatchSimilarParameters() { * @return void */ public function testMatchTrailing() { - $route = new CakeRoute('/pages/**', array('controller' => 'pages', 'action' => 'display')); + $route = new CakeRoute('/pages/**', ['controller' => 'pages', 'action' => 'display']); $id = 'test/ spaces/漢字/la†în'; - $result = $route->match(array( + $result = $route->match([ 'controller' => 'pages', 'action' => 'display', $id - )); + ]); $expected = '/pages/test/%20spaces/%E6%BC%A2%E5%AD%97/la%E2%80%A0%C3%AEn'; $this->assertEquals($expected, $result); } @@ -896,17 +896,17 @@ public function testMatchTrailing() { * @return void */ public function testPassArgRestructure() { - $route = new CakeRoute('/:controller/:action/:slug', array(), array( - 'pass' => array('slug') - )); + $route = new CakeRoute('/:controller/:action/:slug', [], [ + 'pass' => ['slug'] + ]); $result = $route->parse('/posts/view/my-title'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'view', 'slug' => 'my-title', - 'pass' => array('my-title'), - 'named' => array() - ); + 'pass' => ['my-title'], + 'named' => [] + ]; $this->assertEquals($expected, $result, 'Slug should have moved'); } @@ -918,21 +918,21 @@ public function testPassArgRestructure() { public function testParseTrailing() { $route = new CakeRoute('/:controller/:action/**'); $result = $route->parse('/posts/index/1/2/3/foo:bar'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'index', - 'pass' => array('1/2/3/foo:bar'), - 'named' => array() - ); + 'pass' => ['1/2/3/foo:bar'], + 'named' => [] + ]; $this->assertEquals($expected, $result); $result = $route->parse('/posts/index/http://example.com'); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'index', - 'pass' => array('http://example.com'), - 'named' => array() - ); + 'pass' => ['http://example.com'], + 'named' => [] + ]; $this->assertEquals($expected, $result); } @@ -942,14 +942,14 @@ public function testParseTrailing() { * @return void */ public function testParseTrailingUTF8() { - $route = new CakeRoute('/category/**', array('controller' => 'categories', 'action' => 'index')); + $route = new CakeRoute('/category/**', ['controller' => 'categories', 'action' => 'index']); $result = $route->parse('/category/%D9%85%D9%88%D8%A8%D8%A7%DB%8C%D9%84'); - $expected = array( + $expected = [ 'controller' => 'categories', 'action' => 'index', - 'pass' => array('موبایل'), - 'named' => array() - ); + 'pass' => ['موبایل'], + 'named' => [] + ]; $this->assertEquals($expected, $result); } @@ -961,19 +961,19 @@ public function testParseTrailingUTF8() { public function testUTF8PatternOnSection() { $route = new CakeRoute( '/:section', - array('plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index'), - array( - 'persist' => array('section'), + ['plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index'], + [ + 'persist' => ['section'], 'section' => 'آموزش|weblog' - ) + ] ); $result = $route->parse('/%D8%A2%D9%85%D9%88%D8%B2%D8%B4'); - $expected = array('section' => 'آموزش', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => array(), 'named' => array()); + $expected = ['section' => 'آموزش', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => [], 'named' => []]; $this->assertEquals($expected, $result); $result = $route->parse('/weblog'); - $expected = array('section' => 'weblog', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => array(), 'named' => array()); + $expected = ['section' => 'weblog', 'plugin' => 'blogs', 'controller' => 'posts', 'action' => 'index', 'pass' => [], 'named' => []]; $this->assertEquals($expected, $result); } @@ -983,27 +983,27 @@ public function testUTF8PatternOnSection() { * @return void */ public function testSetState() { - $route = CakeRoute::__set_state(array( - 'keys' => array(), - 'options' => array(), - 'defaults' => array( + $route = CakeRoute::__set_state([ + 'keys' => [], + 'options' => [], + 'defaults' => [ 'controller' => 'pages', 'action' => 'display', 'home', - ), + ], 'template' => '/', '_greedy' => false, '_compiledRoute' => null, - '_headerMap' => array ( + '_headerMap' => [ 'type' => 'content_type', 'method' => 'request_method', 'server' => 'server_name', - ), - )); + ], + ]); $this->assertInstanceOf('CakeRoute', $route); - $this->assertSame('/', $route->match(array('controller' => 'pages', 'action' => 'display', 'home'))); - $this->assertFalse($route->match(array('controller' => 'pages', 'action' => 'display', 'about'))); - $expected = array('controller' => 'pages', 'action' => 'display', 'pass' => array('home'), 'named' => array()); + $this->assertSame('/', $route->match(['controller' => 'pages', 'action' => 'display', 'home'])); + $this->assertFalse($route->match(['controller' => 'pages', 'action' => 'display', 'about'])); + $expected = ['controller' => 'pages', 'action' => 'display', 'pass' => ['home'], 'named' => []]; $this->assertEquals($expected, $route->parse('/')); } diff --git a/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php b/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php index 61728cc6d7..a4e02150ac 100644 --- a/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php @@ -33,7 +33,7 @@ class PluginShortRouteTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - Configure::write('Routing', array('admin' => null, 'prefixes' => array())); + Configure::write('Routing', ['admin' => null, 'prefixes' => []]); Router::reload(); } @@ -43,7 +43,7 @@ public function setUp() : void { * @return void */ public function testParsing() { - $route = new PluginShortRoute('/:plugin', array('action' => 'index'), array('plugin' => 'foo|bar')); + $route = new PluginShortRoute('/:plugin', ['action' => 'index'], ['plugin' => 'foo|bar']); $result = $route->parse('/foo'); $this->assertEquals('foo', $result['plugin']); @@ -60,12 +60,12 @@ public function testParsing() { * @return void */ public function testMatch() { - $route = new PluginShortRoute('/:plugin', array('action' => 'index'), array('plugin' => 'foo|bar')); + $route = new PluginShortRoute('/:plugin', ['action' => 'index'], ['plugin' => 'foo|bar']); - $result = $route->match(array('plugin' => 'foo', 'controller' => 'posts', 'action' => 'index')); + $result = $route->match(['plugin' => 'foo', 'controller' => 'posts', 'action' => 'index']); $this->assertFalse($result, 'plugin controller mismatch was converted. %s'); - $result = $route->match(array('plugin' => 'foo', 'controller' => 'foo', 'action' => 'index')); + $result = $route->match(['plugin' => 'foo', 'controller' => 'foo', 'action' => 'index']); $this->assertEquals('/foo', $result); } } diff --git a/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php b/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php index 3ba37a562e..801e45653c 100644 --- a/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php @@ -34,7 +34,7 @@ class RedirectRouteTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - Configure::write('Routing', array('admin' => null, 'prefixes' => array())); + Configure::write('Routing', ['admin' => null, 'prefixes' => []]); Router::reload(); } @@ -44,16 +44,16 @@ public function setUp() : void { * @return void */ public function testParsing() { - $route = new RedirectRoute('/home', array('controller' => 'posts')); + $route = new RedirectRoute('/home', ['controller' => 'posts']); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/home'); $header = $route->response->header(); $this->assertEquals(Router::url('/posts', true), $header['Location']); - $route = new RedirectRoute('/home', array('controller' => 'posts', 'action' => 'index')); + $route = new RedirectRoute('/home', ['controller' => 'posts', 'action' => 'index']); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/home'); $header = $route->response->header(); $this->assertEquals(Router::url('/posts', true), $header['Location']); @@ -61,59 +61,59 @@ public function testParsing() { $route = new RedirectRoute('/google', 'http://google.com'); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/google'); $header = $route->response->header(); $this->assertEquals('http://google.com', $header['Location']); - $route = new RedirectRoute('/posts/*', array('controller' => 'posts', 'action' => 'view'), array('status' => 302)); + $route = new RedirectRoute('/posts/*', ['controller' => 'posts', 'action' => 'view'], ['status' => 302]); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/posts/2'); $header = $route->response->header(); $this->assertEquals(Router::url('/posts/view', true), $header['Location']); $this->assertEquals(302, $route->response->statusCode()); - $route = new RedirectRoute('/posts/*', array('controller' => 'posts', 'action' => 'view'), array('persist' => true)); + $route = new RedirectRoute('/posts/*', ['controller' => 'posts', 'action' => 'view'], ['persist' => true]); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/posts/2'); $header = $route->response->header(); $this->assertEquals(Router::url('/posts/view/2', true), $header['Location']); - $route = new RedirectRoute('/posts/*', '/test', array('persist' => true)); + $route = new RedirectRoute('/posts/*', '/test', ['persist' => true]); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/posts/2'); $header = $route->response->header(); $this->assertEquals(Router::url('/test', true), $header['Location']); - $route = new RedirectRoute('/my_controllers/:action/*', array('controller' => 'tags', 'action' => 'add'), array('persist' => true)); + $route = new RedirectRoute('/my_controllers/:action/*', ['controller' => 'tags', 'action' => 'add'], ['persist' => true]); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/my_controllers/do_something/passme/named:param'); $header = $route->response->header(); $this->assertEquals(Router::url('/tags/add/passme/named:param', true), $header['Location']); - $route = new RedirectRoute('/my_controllers/:action/*', array('controller' => 'tags', 'action' => 'add')); + $route = new RedirectRoute('/my_controllers/:action/*', ['controller' => 'tags', 'action' => 'add']); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/my_controllers/do_something/passme/named:param'); $header = $route->response->header(); $this->assertEquals(Router::url('/tags/add', true), $header['Location']); - $route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang'))); + $route = new RedirectRoute('/:lang/my_controllers', ['controller' => 'tags', 'action' => 'add'], ['lang' => '(nl|en)', 'persist' => ['lang']]); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/nl/my_controllers/'); $header = $route->response->header(); $this->assertEquals(Router::url('/tags/add/lang:nl', true), $header['Location']); - Router::$routes = array(); // reset default routes - Router::connect('/:lang/preferred_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang'))); - $route = new RedirectRoute('/:lang/my_controllers', array('controller' => 'tags', 'action' => 'add'), array('lang' => '(nl|en)', 'persist' => array('lang'))); + Router::$routes = []; // reset default routes + Router::connect('/:lang/preferred_controllers', ['controller' => 'tags', 'action' => 'add'], ['lang' => '(nl|en)', 'persist' => ['lang']]); + $route = new RedirectRoute('/:lang/my_controllers', ['controller' => 'tags', 'action' => 'add'], ['lang' => '(nl|en)', 'persist' => ['lang']]); $route->stop = false; - $route->response = $this->getMock('CakeResponse', array('_sendHeader')); + $route->response = $this->getMock('CakeResponse', ['_sendHeader']); $route->parse('/nl/my_controllers/'); $header = $route->response->header(); $this->assertEquals(Router::url('/nl/preferred_controllers', true), $header['Location']); diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 46eea437ff..59f53d3063 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -37,7 +37,7 @@ class RouterTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - Configure::write('Routing', array('admin' => null, 'prefixes' => array())); + Configure::write('Routing', ['admin' => null, 'prefixes' => []]); } /** @@ -60,8 +60,8 @@ public function tearDown() : void { public function testFullBaseUrl() { $this->assertMatchesRegularExpression('/^http(s)?:\/\//', Router::url('/', true)); $this->assertMatchesRegularExpression('/^http(s)?:\/\//', Router::url(null, true)); - $this->assertMatchesRegularExpression('/^http(s)?:\/\//', Router::url(array('full_base' => true))); - $this->assertSame(FULL_BASE_URL . '/', Router::url(array('full_base' => true))); + $this->assertMatchesRegularExpression('/^http(s)?:\/\//', Router::url(['full_base' => true])); + $this->assertSame(FULL_BASE_URL . '/', Router::url(['full_base' => true])); } /** @@ -97,8 +97,8 @@ public function testBaseUrlWithBasePath() { * @return void */ public function testRouteDefaultParams() { - Router::connect('/:controller', array('controller' => 'posts')); - $this->assertEquals(Router::url(array('action' => 'index')), '/'); + Router::connect('/:controller', ['controller' => 'posts']); + $this->assertEquals(Router::url(['action' => 'index']), '/'); } /** @@ -111,43 +111,43 @@ public function testMapResources() { $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/posts'); - $this->assertEquals(array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => 'GET'), $result); - $this->assertEquals(array('posts'), $resources); + $this->assertEquals(['pass' => [], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => 'GET'], $result); + $this->assertEquals(['posts'], $resources); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/posts/13'); - $this->assertEquals(array('pass' => array('13'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'view', 'id' => '13', '[method]' => 'GET'), $result); + $this->assertEquals(['pass' => ['13'], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'view', 'id' => '13', '[method]' => 'GET'], $result); $_SERVER['REQUEST_METHOD'] = 'POST'; $result = Router::parse('/posts'); - $this->assertEquals(array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST'), $result); + $this->assertEquals(['pass' => [], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'add', '[method]' => 'POST'], $result); $_SERVER['REQUEST_METHOD'] = 'PUT'; $result = Router::parse('/posts/13'); - $this->assertEquals(array('pass' => array('13'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => '13', '[method]' => 'PUT'), $result); + $this->assertEquals(['pass' => ['13'], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => '13', '[method]' => 'PUT'], $result); $result = Router::parse('/posts/475acc39-a328-44d3-95fb-015000000000'); - $this->assertEquals(array('pass' => array('475acc39-a328-44d3-95fb-015000000000'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => '475acc39-a328-44d3-95fb-015000000000', '[method]' => 'PUT'), $result); + $this->assertEquals(['pass' => ['475acc39-a328-44d3-95fb-015000000000'], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => '475acc39-a328-44d3-95fb-015000000000', '[method]' => 'PUT'], $result); $_SERVER['REQUEST_METHOD'] = 'DELETE'; $result = Router::parse('/posts/13'); - $this->assertEquals(array('pass' => array('13'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'delete', 'id' => '13', '[method]' => 'DELETE'), $result); + $this->assertEquals(['pass' => ['13'], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'delete', 'id' => '13', '[method]' => 'DELETE'], $result); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/posts/add'); - $this->assertSame(array(), $result); + $this->assertSame([], $result); Router::reload(); - $resources = Router::mapResources('Posts', array('id' => '[a-z0-9_]+')); - $this->assertEquals(array('posts'), $resources); + $resources = Router::mapResources('Posts', ['id' => '[a-z0-9_]+']); + $this->assertEquals(['posts'], $resources); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/posts/add'); - $this->assertEquals(array('pass' => array('add'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'view', 'id' => 'add', '[method]' => 'GET'), $result); + $this->assertEquals(['pass' => ['add'], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'view', 'id' => 'add', '[method]' => 'GET'], $result); $_SERVER['REQUEST_METHOD'] = 'PUT'; $result = Router::parse('/posts/name'); - $this->assertEquals(array('pass' => array('name'), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => 'name', '[method]' => 'PUT'), $result); + $this->assertEquals(['pass' => ['name'], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'edit', 'id' => 'name', '[method]' => 'PUT'], $result); } /** @@ -156,37 +156,37 @@ public function testMapResources() { * @return void */ public function testPluginMapResources() { - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ) - )); + ] + ]); $resources = Router::mapResources('TestPlugin.TestPlugin'); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/test_plugin/test_plugin'); - $expected = array( - 'pass' => array(), - 'named' => array(), + $expected = [ + 'pass' => [], + 'named' => [], 'plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index', '[method]' => 'GET' - ); + ]; $this->assertEquals($expected, $result); - $this->assertEquals(array('test_plugin'), $resources); + $this->assertEquals(['test_plugin'], $resources); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/test_plugin/test_plugin/13'); - $expected = array( - 'pass' => array('13'), - 'named' => array(), + $expected = [ + 'pass' => ['13'], + 'named' => [], 'plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'view', 'id' => '13', '[method]' => 'GET' - ); + ]; $this->assertEquals($expected, $result); } @@ -194,19 +194,19 @@ public function testPluginMapResources() { * testMapResources with custom connectOptions */ public function testMapResourcesConnectOptions() { - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ) - )); + ] + ]); CakePlugin::load('TestPlugin'); App::uses('TestRoute', 'TestPlugin.Routing/Route'); - Router::mapResources('Posts', array( - 'connectOptions' => array( + Router::mapResources('Posts', [ + 'connectOptions' => [ 'routeClass' => 'TestPlugin.TestRoute', 'foo' => '^(bar)$', - ), - )); + ], + ]); $route = end(Router::$routes); $this->assertInstanceOf('TestRoute', $route); $this->assertEquals('^(bar)$', $route->options['foo']); @@ -218,38 +218,38 @@ public function testMapResourcesConnectOptions() { * @return void */ public function testPluginMapResourcesWithPrefix() { - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ) - )); - $resources = Router::mapResources('TestPlugin.TestPlugin', array('prefix' => '/api/')); + ] + ]); + $resources = Router::mapResources('TestPlugin.TestPlugin', ['prefix' => '/api/']); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/api/test_plugin'); - $expected = array( - 'pass' => array(), - 'named' => array(), + $expected = [ + 'pass' => [], + 'named' => [], 'plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index', '[method]' => 'GET' - ); + ]; $this->assertEquals($expected, $result); - $this->assertEquals(array('test_plugin'), $resources); + $this->assertEquals(['test_plugin'], $resources); - Router::mapResources('Posts', array('prefix' => 'api')); + Router::mapResources('Posts', ['prefix' => 'api']); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/api/posts'); - $expected = array( - 'pass' => array(), - 'named' => array(), + $expected = [ + 'pass' => [], + 'named' => [], 'plugin' => null, 'controller' => 'posts', 'action' => 'index', '[method]' => 'GET' - ); + ]; $this->assertEquals($expected, $result); } @@ -259,15 +259,15 @@ public function testPluginMapResourcesWithPrefix() { * @return void */ public function testMultipleResourceRoute() { - Router::connect('/:controller', array('action' => 'index', '[method]' => array('GET', 'POST'))); + Router::connect('/:controller', ['action' => 'index', '[method]' => ['GET', 'POST']]); $_SERVER['REQUEST_METHOD'] = 'GET'; $result = Router::parse('/posts'); - $this->assertEquals(array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => array('GET', 'POST')), $result); + $this->assertEquals(['pass' => [], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => ['GET', 'POST']], $result); $_SERVER['REQUEST_METHOD'] = 'POST'; $result = Router::parse('/posts'); - $this->assertEquals(array('pass' => array(), 'named' => array(), 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => array('GET', 'POST')), $result); + $this->assertEquals(['pass' => [], 'named' => [], 'plugin' => '', 'controller' => 'posts', 'action' => 'index', '[method]' => ['GET', 'POST']], $result); } /** @@ -278,27 +278,27 @@ public function testMultipleResourceRoute() { public function testGenerateUrlResourceRoute() { Router::mapResources('Posts'); - $result = Router::url(array('controller' => 'posts', 'action' => 'index', '[method]' => 'GET')); + $result = Router::url(['controller' => 'posts', 'action' => 'index', '[method]' => 'GET']); $expected = '/posts'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'view', '[method]' => 'GET', 'id' => 10)); + $result = Router::url(['controller' => 'posts', 'action' => 'view', '[method]' => 'GET', 'id' => 10]); $expected = '/posts/10'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'add', '[method]' => 'POST')); + $result = Router::url(['controller' => 'posts', 'action' => 'add', '[method]' => 'POST']); $expected = '/posts'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'id' => 10)); + $result = Router::url(['controller' => 'posts', 'action' => 'edit', '[method]' => 'PUT', 'id' => 10]); $expected = '/posts/10'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'delete', '[method]' => 'DELETE', 'id' => 10)); + $result = Router::url(['controller' => 'posts', 'action' => 'delete', '[method]' => 'DELETE', 'id' => 10]); $expected = '/posts/10'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'edit', '[method]' => 'POST', 'id' => 10)); + $result = Router::url(['controller' => 'posts', 'action' => 'edit', '[method]' => 'POST', 'id' => 10]); $expected = '/posts/10'; $this->assertEquals($expected, $result); } @@ -320,7 +320,7 @@ public function testUrlNormalization() { $result = Router::normalize('users/logout'); $this->assertEquals($expected, $result); - $result = Router::normalize(array('controller' => 'users', 'action' => 'logout')); + $result = Router::normalize(['controller' => 'users', 'action' => 'logout']); $this->assertEquals($expected, $result); $result = Router::normalize('/'); @@ -383,9 +383,9 @@ public function testUrlGenerationBasic() { extract(Router::getNamedExpressions()); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'action' => 'index', 'plugin' => null, 'controller' => 'subscribe', 'admin' => true - )); + ]); $request->base = '/magazine'; $request->here = '/magazine'; $request->webroot = '/magazine/'; @@ -396,117 +396,117 @@ public function testUrlGenerationBasic() { Router::reload(); - Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); - $out = Router::url(array('controller' => 'pages', 'action' => 'display', 'home')); + Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']); + $out = Router::url(['controller' => 'pages', 'action' => 'display', 'home']); $this->assertEquals('/', $out); - Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); - $result = Router::url(array('controller' => 'pages', 'action' => 'display', 'about')); + Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']); + $result = Router::url(['controller' => 'pages', 'action' => 'display', 'about']); $expected = '/pages/about'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/:plugin/:id/*', array('controller' => 'posts', 'action' => 'view'), array('id' => $ID)); + Router::connect('/:plugin/:id/*', ['controller' => 'posts', 'action' => 'view'], ['id' => $ID]); Router::parse('/'); - $result = Router::url(array('plugin' => 'cake_plugin', 'controller' => 'posts', 'action' => 'view', 'id' => '1')); + $result = Router::url(['plugin' => 'cake_plugin', 'controller' => 'posts', 'action' => 'view', 'id' => '1']); $expected = '/cake_plugin/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('plugin' => 'cake_plugin', 'controller' => 'posts', 'action' => 'view', 'id' => '1', '0')); + $result = Router::url(['plugin' => 'cake_plugin', 'controller' => 'posts', 'action' => 'view', 'id' => '1', '0']); $expected = '/cake_plugin/1/0'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/:controller/:action/:id', array(), array('id' => $ID)); + Router::connect('/:controller/:action/:id', [], ['id' => $ID]); Router::parse('/'); - $result = Router::url(array('controller' => 'posts', 'action' => 'view', 'id' => '1')); + $result = Router::url(['controller' => 'posts', 'action' => 'view', 'id' => '1']); $expected = '/posts/view/1'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/:controller/:id', array('action' => 'view')); + Router::connect('/:controller/:id', ['action' => 'view']); Router::parse('/'); - $result = Router::url(array('controller' => 'posts', 'action' => 'view', 'id' => '1')); + $result = Router::url(['controller' => 'posts', 'action' => 'view', 'id' => '1']); $expected = '/posts/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0')); + $result = Router::url(['controller' => 'posts', 'action' => 'index', '0']); $expected = '/posts/index/0'; $this->assertEquals($expected, $result); - Router::connect('/view/*', array('controller' => 'posts', 'action' => 'view')); + Router::connect('/view/*', ['controller' => 'posts', 'action' => 'view']); Router::promote(); - $result = Router::url(array('controller' => 'posts', 'action' => 'view', '1')); + $result = Router::url(['controller' => 'posts', 'action' => 'view', '1']); $expected = '/view/1'; $this->assertEquals($expected, $result); Router::reload(); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'action' => 'index', 'plugin' => null, 'controller' => 'real_controller_name' - )); + ]); $request->base = '/'; $request->here = '/'; $request->webroot = '/'; Router::setRequestInfo($request); - Router::connect('short_controller_name/:action/*', array('controller' => 'real_controller_name')); + Router::connect('short_controller_name/:action/*', ['controller' => 'real_controller_name']); Router::parse('/'); - $result = Router::url(array('controller' => 'real_controller_name', 'page' => '1')); + $result = Router::url(['controller' => 'real_controller_name', 'page' => '1']); $expected = '/short_controller_name/index/page:1'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'add')); + $result = Router::url(['action' => 'add']); $expected = '/short_controller_name/add'; $this->assertEquals($expected, $result); Router::reload(); Router::parse('/'); $request = new CakeRequest(); - $request->addParams(array( - 'action' => 'index', 'plugin' => null, 'controller' => 'users', 'url' => array('url' => 'users') - )); + $request->addParams([ + 'action' => 'index', 'plugin' => null, 'controller' => 'users', 'url' => ['url' => 'users'] + ]); $request->base = '/'; $request->here = '/'; $request->webroot = '/'; Router::setRequestInfo($request); - $result = Router::url(array('action' => 'login')); + $result = Router::url(['action' => 'login']); $expected = '/users/login'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/page/*', array('plugin' => null, 'controller' => 'pages', 'action' => 'view')); + Router::connect('/page/*', ['plugin' => null, 'controller' => 'pages', 'action' => 'view']); Router::parse('/'); - $result = Router::url(array('plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'view', 'my-page')); + $result = Router::url(['plugin' => 'my_plugin', 'controller' => 'pages', 'action' => 'view', 'my-page']); $expected = '/my_plugin/pages/view/my-page'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/contact/:action', array('plugin' => 'contact', 'controller' => 'contact')); + Router::connect('/contact/:action', ['plugin' => 'contact', 'controller' => 'contact']); Router::parse('/'); - $result = Router::url(array('plugin' => 'contact', 'controller' => 'contact', 'action' => 'me')); + $result = Router::url(['plugin' => 'contact', 'controller' => 'contact', 'action' => 'me']); $expected = '/contact/me'; $this->assertEquals($expected, $result); Router::reload(); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'action' => 'index', 'plugin' => 'myplugin', 'controller' => 'mycontroller', 'admin' => false - )); + ]); $request->base = '/'; $request->here = '/'; $request->webroot = '/'; Router::setRequestInfo($request); - $result = Router::url(array('plugin' => null, 'controller' => 'myothercontroller')); + $result = Router::url(['plugin' => null, 'controller' => 'myothercontroller']); $expected = '/myothercontroller'; $this->assertEquals($expected, $result); } @@ -517,17 +517,17 @@ public function testUrlGenerationBasic() { * @return void */ public function testUrlCatchAllRoute() { - Router::connect('/*', array('controller' => 'categories', 'action' => 'index')); - $result = Router::url(array('controller' => 'categories', 'action' => 'index', '0')); + Router::connect('/*', ['controller' => 'categories', 'action' => 'index']); + $result = Router::url(['controller' => 'categories', 'action' => 'index', '0']); $this->assertEquals('/0', $result); - $expected = array( + $expected = [ 'plugin' => null, 'controller' => 'categories', 'action' => 'index', - 'pass' => array('0'), - 'named' => array() - ); + 'pass' => ['0'], + 'named' => [] + ]; $result = Router::parse('/0'); $this->assertEquals($expected, $result); @@ -541,52 +541,52 @@ public function testUrlCatchAllRoute() { * @return void */ public function testArrayNamedParameters() { - $result = Router::url(array('controller' => 'tests', 'pages' => array( + $result = Router::url(['controller' => 'tests', 'pages' => [ 1, 2, 3 - ))); + ]]); $expected = '/tests/index/pages%5B0%5D:1/pages%5B1%5D:2/pages%5B2%5D:3'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'tests', - 'pages' => array( - 'param1' => array( + $result = Router::url(['controller' => 'tests', + 'pages' => [ + 'param1' => [ 'one', 'two' - ), + ], 'three' - ) - )); + ] + ]); $expected = '/tests/index/pages%5Bparam1%5D%5B0%5D:one/pages%5Bparam1%5D%5B1%5D:two/pages%5B0%5D:three'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'tests', - 'pages' => array( - 'param1' => array( + $result = Router::url(['controller' => 'tests', + 'pages' => [ + 'param1' => [ 'one' => 1, 'two' => 2 - ), + ], 'three' - ) - )); + ] + ]); $expected = '/tests/index/pages%5Bparam1%5D%5Bone%5D:1/pages%5Bparam1%5D%5Btwo%5D:2/pages%5B0%5D:three'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'tests', - 'super' => array( - 'nested' => array( + $result = Router::url(['controller' => 'tests', + 'super' => [ + 'nested' => [ 'array' => 'awesome', 'something' => 'else' - ), + ], 'cool' - ) - )); + ] + ]); $expected = '/tests/index/super%5Bnested%5D%5Barray%5D:awesome/super%5Bnested%5D%5Bsomething%5D:else/super%5B0%5D:cool'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'tests', 'namedParam' => array( + $result = Router::url(['controller' => 'tests', 'namedParam' => [ 'keyed' => 'is an array', 'test' - ))); + ]]); $expected = '/tests/index/namedParam%5Bkeyed%5D:is%20an%20array/namedParam%5B0%5D:test'; $this->assertEquals($expected, $result); } @@ -597,20 +597,20 @@ public function testArrayNamedParameters() { * @return void */ public function testUrlGenerationWithQueryStrings() { - $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2')); + $result = Router::url(['controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2']); $expected = '/posts/index/0?var=test&var2=test2'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', '0', '?' => 'var=test&var2=test2')); + $result = Router::url(['controller' => 'posts', '0', '?' => 'var=test&var2=test2']); $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', '0', '?' => array('var' => 'test', 'var2' => 'test2'))); + $result = Router::url(['controller' => 'posts', '0', '?' => ['var' => 'test', 'var2' => 'test2']]); $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', '0', '?' => array('var' => null))); + $result = Router::url(['controller' => 'posts', '0', '?' => ['var' => null]]); $this->assertEquals('/posts/index/0', $result); - $result = Router::url(array('controller' => 'posts', '0', '?' => 'var=test&var2=test2', '#' => 'unencoded string %')); + $result = Router::url(['controller' => 'posts', '0', '?' => 'var=test&var2=test2', '#' => 'unencoded string %']); $expected = '/posts/index/0?var=test&var2=test2#unencoded string %'; $this->assertEquals($expected, $result); } @@ -623,79 +623,79 @@ public function testUrlGenerationWithQueryStrings() { public function testUrlGenerationWithRegexQualifiedParams() { Router::connect( ':language/galleries', - array('controller' => 'galleries', 'action' => 'index'), - array('language' => '[a-z]{3}') + ['controller' => 'galleries', 'action' => 'index'], + ['language' => '[a-z]{3}'] ); Router::connect( '/:language/:admin/:controller/:action/*', - array('admin' => 'admin'), - array('language' => '[a-z]{3}', 'admin' => 'admin') + ['admin' => 'admin'], + ['language' => '[a-z]{3}', 'admin' => 'admin'] ); Router::connect('/:language/:controller/:action/*', - array(), - array('language' => '[a-z]{3}') + [], + ['language' => '[a-z]{3}'] ); - $result = Router::url(array('admin' => false, 'language' => 'dan', 'action' => 'index', 'controller' => 'galleries')); + $result = Router::url(['admin' => false, 'language' => 'dan', 'action' => 'index', 'controller' => 'galleries']); $expected = '/dan/galleries'; $this->assertEquals($expected, $result); - $result = Router::url(array('admin' => false, 'language' => 'eng', 'action' => 'index', 'controller' => 'galleries')); + $result = Router::url(['admin' => false, 'language' => 'eng', 'action' => 'index', 'controller' => 'galleries']); $expected = '/eng/galleries'; $this->assertEquals($expected, $result); Router::reload(); Router::connect('/:language/pages', - array('controller' => 'pages', 'action' => 'index'), - array('language' => '[a-z]{3}') + ['controller' => 'pages', 'action' => 'index'], + ['language' => '[a-z]{3}'] ); - Router::connect('/:language/:controller/:action/*', array(), array('language' => '[a-z]{3}')); + Router::connect('/:language/:controller/:action/*', [], ['language' => '[a-z]{3}']); - $result = Router::url(array('language' => 'eng', 'action' => 'index', 'controller' => 'pages')); + $result = Router::url(['language' => 'eng', 'action' => 'index', 'controller' => 'pages']); $expected = '/eng/pages'; $this->assertEquals($expected, $result); - $result = Router::url(array('language' => 'eng', 'controller' => 'pages')); + $result = Router::url(['language' => 'eng', 'controller' => 'pages']); $this->assertEquals($expected, $result); - $result = Router::url(array('language' => 'eng', 'controller' => 'pages', 'action' => 'add')); + $result = Router::url(['language' => 'eng', 'controller' => 'pages', 'action' => 'add']); $expected = '/eng/pages/add'; $this->assertEquals($expected, $result); Router::reload(); Router::connect('/forestillinger/:month/:year/*', - array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar'), - array('month' => '0[1-9]|1[012]', 'year' => '[12][0-9]{3}') + ['plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar'], + ['month' => '0[1-9]|1[012]', 'year' => '[12][0-9]{3}'] ); Router::parse('/'); - $result = Router::url(array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'month' => 10, 'year' => 2007, 'min-forestilling')); + $result = Router::url(['plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'month' => 10, 'year' => 2007, 'min-forestilling']); $expected = '/forestillinger/10/2007/min-forestilling'; $this->assertEquals($expected, $result); Router::reload(); Router::connect('/kalender/:month/:year/*', - array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar'), - array('month' => '0[1-9]|1[012]', 'year' => '[12][0-9]{3}') + ['plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar'], + ['month' => '0[1-9]|1[012]', 'year' => '[12][0-9]{3}'] ); - Router::connect('/kalender/*', array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar')); + Router::connect('/kalender/*', ['plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar']); Router::parse('/'); - $result = Router::url(array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'min-forestilling')); + $result = Router::url(['plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'min-forestilling']); $expected = '/kalender/min-forestilling'; $this->assertEquals($expected, $result); - $result = Router::url(array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'year' => 2007, 'month' => 10, 'min-forestilling')); + $result = Router::url(['plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'year' => 2007, 'month' => 10, 'min-forestilling']); $expected = '/kalender/10/2007/min-forestilling'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/:controller/:action/*', array(), array( + Router::connect('/:controller/:action/*', [], [ 'controller' => 'source|wiki|commits|tickets|comments|view', 'action' => 'branches|history|branch|logs|view|start|add|edit|modify' - )); + ]); } /** @@ -704,39 +704,39 @@ public function testUrlGenerationWithRegexQualifiedParams() { * @return void */ public function testUrlGenerationWithAdminPrefix() { - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Router::reload(); - Router::connectNamed(array('event', 'lang')); - Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); - Router::connect('/pages/contact_us', array('controller' => 'pages', 'action' => 'contact_us')); - Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); - Router::connect('/reset/*', array('admin' => true, 'controller' => 'users', 'action' => 'reset')); - Router::connect('/tests', array('controller' => 'tests', 'action' => 'index')); + Router::connectNamed(['event', 'lang']); + Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']); + Router::connect('/pages/contact_us', ['controller' => 'pages', 'action' => 'contact_us']); + Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']); + Router::connect('/reset/*', ['admin' => true, 'controller' => 'users', 'action' => 'reset']); + Router::connect('/tests', ['controller' => 'tests', 'action' => 'index']); Router::parseExtensions('rss'); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'controller' => 'registrations', 'action' => 'admin_index', 'plugin' => null, 'prefix' => 'admin', 'admin' => true, 'ext' => 'html' - )); + ]); $request->base = ''; $request->here = '/admin/registrations/index'; $request->webroot = '/'; Router::setRequestInfo($request); - $result = Router::url(array('page' => 2)); + $result = Router::url(['page' => 2]); $expected = '/admin/registrations/index/page:2'; $this->assertEquals($expected, $result); Router::reload(); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'controller' => 'subscriptions', 'action' => 'admin_index', 'plugin' => null, 'admin' => true, - 'url' => array('url' => 'admin/subscriptions/index/page:2') - )); + 'url' => ['url' => 'admin/subscriptions/index/page:2'] + ]); $request->base = '/magazine'; $request->here = '/magazine/admin/subscriptions/index/page:2'; $request->webroot = '/magazine/'; @@ -744,98 +744,98 @@ public function testUrlGenerationWithAdminPrefix() { Router::parse('/'); - $result = Router::url(array('page' => 3)); + $result = Router::url(['page' => 3]); $expected = '/magazine/admin/subscriptions/index/page:3'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/admin/subscriptions/:action/*', array('controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin')); + Router::connect('/admin/subscriptions/:action/*', ['controller' => 'subscribe', 'admin' => true, 'prefix' => 'admin']); Router::parse('/'); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'action' => 'admin_index', 'plugin' => null, 'controller' => 'subscribe', - 'admin' => true, 'url' => array('url' => 'admin/subscriptions/edit/1') - )); + 'admin' => true, 'url' => ['url' => 'admin/subscriptions/edit/1'] + ]); $request->base = '/magazine'; $request->here = '/magazine/admin/subscriptions/edit/1'; $request->webroot = '/magazine/'; Router::setRequestInfo($request); - $result = Router::url(array('action' => 'edit', 1)); + $result = Router::url(['action' => 'edit', 1]); $expected = '/magazine/admin/subscriptions/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('admin' => true, 'controller' => 'users', 'action' => 'login')); + $result = Router::url(['admin' => true, 'controller' => 'users', 'action' => 'login']); $expected = '/magazine/admin/users/login'; $this->assertEquals($expected, $result); Router::reload(); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'admin' => true, 'action' => 'index', 'plugin' => null, 'controller' => 'users', - 'url' => array('url' => 'users') - )); + 'url' => ['url' => 'users'] + ]); $request->base = '/'; $request->here = '/'; $request->webroot = '/'; Router::setRequestInfo($request); - Router::connect('/page/*', array('controller' => 'pages', 'action' => 'view', 'admin' => true, 'prefix' => 'admin')); + Router::connect('/page/*', ['controller' => 'pages', 'action' => 'view', 'admin' => true, 'prefix' => 'admin']); Router::parse('/'); - $result = Router::url(array('admin' => true, 'controller' => 'pages', 'action' => 'view', 'my-page')); + $result = Router::url(['admin' => true, 'controller' => 'pages', 'action' => 'view', 'my-page']); $expected = '/page/my-page'; $this->assertEquals($expected, $result); Router::reload(); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'pages', 'action' => 'admin_add', 'prefix' => 'admin', 'admin' => true, - 'url' => array('url' => 'admin/pages/add') - )); + 'url' => ['url' => 'admin/pages/add'] + ]); $request->base = ''; $request->here = '/admin/pages/add'; $request->webroot = '/'; Router::setRequestInfo($request); Router::parse('/'); - $result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'add', 'id' => false)); + $result = Router::url(['plugin' => null, 'controller' => 'pages', 'action' => 'add', 'id' => false]); $expected = '/admin/pages/add'; $this->assertEquals($expected, $result); Router::reload(); Router::parse('/'); $request = new CakeRequest(); - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'pages', 'action' => 'admin_add', 'prefix' => 'admin', 'admin' => true, - 'url' => array('url' => 'admin/pages/add') - )); + 'url' => ['url' => 'admin/pages/add'] + ]); $request->base = ''; $request->here = '/admin/pages/add'; $request->webroot = '/'; Router::setRequestInfo($request); - $result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'add', 'id' => false)); + $result = Router::url(['plugin' => null, 'controller' => 'pages', 'action' => 'add', 'id' => false]); $expected = '/admin/pages/add'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/admin/:controller/:action/:id', array('admin' => true), array('id' => '[0-9]+')); + Router::connect('/admin/:controller/:action/:id', ['admin' => true], ['id' => '[0-9]+']); Router::parse('/'); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( - 'plugin' => null, 'controller' => 'pages', 'action' => 'admin_edit', 'pass' => array('284'), + $request->addParams([ + 'plugin' => null, 'controller' => 'pages', 'action' => 'admin_edit', 'pass' => ['284'], 'prefix' => 'admin', 'admin' => true, - 'url' => array('url' => 'admin/pages/edit/284') - ))->addPaths(array( + 'url' => ['url' => 'admin/pages/edit/284'] + ])->addPaths([ 'base' => '', 'here' => '/admin/pages/edit/284', 'webroot' => '/' - )) + ]) ); - $result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'edit', 'id' => '284')); + $result = Router::url(['plugin' => null, 'controller' => 'pages', 'action' => 'edit', 'id' => '284']); $expected = '/admin/pages/edit/284'; $this->assertEquals($expected, $result); @@ -844,15 +844,15 @@ public function testUrlGenerationWithAdminPrefix() { $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'pages', 'action' => 'admin_add', 'prefix' => 'admin', - 'admin' => true, 'url' => array('url' => 'admin/pages/add') - ))->addPaths(array( + 'admin' => true, 'url' => ['url' => 'admin/pages/add'] + ])->addPaths([ 'base' => '', 'here' => '/admin/pages/add', 'webroot' => '/' - )) + ]) ); - $result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'add', 'id' => false)); + $result = Router::url(['plugin' => null, 'controller' => 'pages', 'action' => 'add', 'id' => false]); $expected = '/admin/pages/add'; $this->assertEquals($expected, $result); @@ -861,31 +861,31 @@ public function testUrlGenerationWithAdminPrefix() { $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'pages', 'action' => 'admin_edit', 'prefix' => 'admin', - 'admin' => true, 'pass' => array('284'), 'url' => array('url' => 'admin/pages/edit/284') - ))->addPaths(array( + 'admin' => true, 'pass' => ['284'], 'url' => ['url' => 'admin/pages/edit/284'] + ])->addPaths([ 'base' => '', 'here' => '/admin/pages/edit/284', 'webroot' => '/' - )) + ]) ); - $result = Router::url(array('plugin' => null, 'controller' => 'pages', 'action' => 'edit', 284)); + $result = Router::url(['plugin' => null, 'controller' => 'pages', 'action' => 'edit', 284]); $expected = '/admin/pages/edit/284'; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/admin/posts/*', array('controller' => 'posts', 'action' => 'index', 'admin' => true)); + Router::connect('/admin/posts/*', ['controller' => 'posts', 'action' => 'index', 'admin' => true]); Router::parse('/'); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'posts', 'action' => 'admin_index', 'prefix' => 'admin', - 'admin' => true, 'pass' => array('284'), 'url' => array('url' => 'admin/posts') - ))->addPaths(array( + 'admin' => true, 'pass' => ['284'], 'url' => ['url' => 'admin/posts'] + ])->addPaths([ 'base' => '', 'here' => '/admin/posts', 'webroot' => '/' - )) + ]) ); - $result = Router::url(array('all')); + $result = Router::url(['all']); $expected = '/admin/posts/all'; $this->assertEquals($expected, $result); } @@ -897,19 +897,19 @@ public function testUrlGenerationWithAdminPrefix() { */ public function testUrlGenerationWithExtensions() { Router::parse('/'); - $result = Router::url(array('plugin' => null, 'controller' => 'articles', 'action' => 'add', 'id' => null, 'ext' => 'json')); + $result = Router::url(['plugin' => null, 'controller' => 'articles', 'action' => 'add', 'id' => null, 'ext' => 'json']); $expected = '/articles/add.json'; $this->assertEquals($expected, $result); - $result = Router::url(array('plugin' => null, 'controller' => 'articles', 'action' => 'add', 'ext' => 'json')); + $result = Router::url(['plugin' => null, 'controller' => 'articles', 'action' => 'add', 'ext' => 'json']); $expected = '/articles/add.json'; $this->assertEquals($expected, $result); - $result = Router::url(array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'id' => null, 'ext' => 'json')); + $result = Router::url(['plugin' => null, 'controller' => 'articles', 'action' => 'index', 'id' => null, 'ext' => 'json']); $expected = '/articles.json'; $this->assertEquals($expected, $result); - $result = Router::url(array('plugin' => null, 'controller' => 'articles', 'action' => 'index', 'ext' => 'json')); + $result = Router::url(['plugin' => null, 'controller' => 'articles', 'action' => 'index', 'ext' => 'json']); $expected = '/articles.json'; $this->assertEquals($expected, $result); } @@ -922,35 +922,35 @@ public function testUrlGenerationWithExtensions() { public function testUrlGenerationPlugins() { $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => 'test', 'controller' => 'controller', 'action' => 'index' - ))->addPaths(array( + ])->addPaths([ 'base' => '/base', 'here' => '/clients/sage/portal/donations', 'webroot' => '/base/' - )) + ]) ); $this->assertEquals(Router::url('read/1'), '/base/test/controller/read/1'); Router::reload(); - Router::connect('/:lang/:plugin/:controller/*', array('action' => 'index')); + Router::connect('/:lang/:plugin/:controller/*', ['action' => 'index']); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'lang' => 'en', 'plugin' => 'shows', 'controller' => 'shows', 'action' => 'index', - 'url' => array('url' => 'en/shows/'), - ))->addPaths(array( + 'url' => ['url' => 'en/shows/'], + ])->addPaths([ 'base' => '', 'here' => '/en/shows', 'webroot' => '/' - )) + ]) ); Router::parse('/en/shows/'); - $result = Router::url(array( + $result = Router::url([ 'lang' => 'en', 'controller' => 'shows', 'action' => 'index', 'page' => '1', - )); + ]); $expected = '/en/shows/shows/page:1'; $this->assertEquals($expected, $result); } @@ -964,35 +964,35 @@ public function testCanLeavePlugin() { Router::reload(); Router::connect( '/admin/other/:controller/:action/*', - array( + [ 'admin' => 1, 'plugin' => 'aliased', 'prefix' => 'admin' - ) + ] ); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( - 'pass' => array(), + $request->addParams([ + 'pass' => [], 'admin' => true, 'prefix' => 'admin', 'plugin' => 'this', 'action' => 'admin_index', 'controller' => 'interesting', - 'url' => array('url' => 'admin/this/interesting/index'), - ))->addPaths(array( + 'url' => ['url' => 'admin/this/interesting/index'], + ])->addPaths([ 'base' => '', 'here' => '/admin/this/interesting/index', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array('plugin' => null, 'controller' => 'posts', 'action' => 'index')); + $result = Router::url(['plugin' => null, 'controller' => 'posts', 'action' => 'index']); $this->assertEquals('/admin/posts', $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'index')); + $result = Router::url(['controller' => 'posts', 'action' => 'index']); $this->assertEquals('/admin/this/posts', $result); - $result = Router::url(array('plugin' => 'aliased', 'controller' => 'posts', 'action' => 'index')); + $result = Router::url(['plugin' => 'aliased', 'controller' => 'posts', 'action' => 'index']); $this->assertEquals('/admin/other/posts/index', $result); } @@ -1002,15 +1002,15 @@ public function testCanLeavePlugin() { * @return void */ public function testUrlParseFailureDoubleSlash() { - Router::connect('/posts', array('controller' => 'posts', 'action' => 'index')); + Router::connect('/posts', ['controller' => 'posts', 'action' => 'index']); $result = Router::parse('/posts'); $this->assertEquals( - array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'index'), + ['pass' => [], 'named' => [], 'plugin' => null, 'controller' => 'posts', 'action' => 'index'], $result ); $result = Router::parse('//posts'); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); } /** @@ -1021,39 +1021,39 @@ public function testUrlParseFailureDoubleSlash() { public function testUrlParsing() { extract(Router::getNamedExpressions()); - Router::connect('/posts/:value/:somevalue/:othervalue/*', array('controller' => 'posts', 'action' => 'view'), array('value', 'somevalue', 'othervalue')); + Router::connect('/posts/:value/:somevalue/:othervalue/*', ['controller' => 'posts', 'action' => 'view'], ['value', 'somevalue', 'othervalue']); $result = Router::parse('/posts/2007/08/01/title-of-post-here'); - $expected = array('value' => '2007', 'somevalue' => '08', 'othervalue' => '01', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => array('0' => 'title-of-post-here'), 'named' => array()); + $expected = ['value' => '2007', 'somevalue' => '08', 'othervalue' => '01', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => ['0' => 'title-of-post-here'], 'named' => []]; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/:year/:month/:day/*', array('controller' => 'posts', 'action' => 'view'), array('year' => $Year, 'month' => $Month, 'day' => $Day)); + Router::connect('/posts/:year/:month/:day/*', ['controller' => 'posts', 'action' => 'view'], ['year' => $Year, 'month' => $Month, 'day' => $Day]); $result = Router::parse('/posts/2007/08/01/title-of-post-here'); - $expected = array('year' => '2007', 'month' => '08', 'day' => '01', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => array('0' => 'title-of-post-here'), 'named' => array()); + $expected = ['year' => '2007', 'month' => '08', 'day' => '01', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => ['0' => 'title-of-post-here'], 'named' => []]; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/:day/:year/:month/*', array('controller' => 'posts', 'action' => 'view'), array('year' => $Year, 'month' => $Month, 'day' => $Day)); + Router::connect('/posts/:day/:year/:month/*', ['controller' => 'posts', 'action' => 'view'], ['year' => $Year, 'month' => $Month, 'day' => $Day]); $result = Router::parse('/posts/01/2007/08/title-of-post-here'); - $expected = array('day' => '01', 'year' => '2007', 'month' => '08', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => array('0' => 'title-of-post-here'), 'named' => array()); + $expected = ['day' => '01', 'year' => '2007', 'month' => '08', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => ['0' => 'title-of-post-here'], 'named' => []]; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/:month/:day/:year/*', array('controller' => 'posts', 'action' => 'view'), array('year' => $Year, 'month' => $Month, 'day' => $Day)); + Router::connect('/posts/:month/:day/:year/*', ['controller' => 'posts', 'action' => 'view'], ['year' => $Year, 'month' => $Month, 'day' => $Day]); $result = Router::parse('/posts/08/01/2007/title-of-post-here'); - $expected = array('month' => '08', 'day' => '01', 'year' => '2007', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => array('0' => 'title-of-post-here'), 'named' => array()); + $expected = ['month' => '08', 'day' => '01', 'year' => '2007', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => ['0' => 'title-of-post-here'], 'named' => []]; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/:year/:month/:day/*', array('controller' => 'posts', 'action' => 'view')); + Router::connect('/posts/:year/:month/:day/*', ['controller' => 'posts', 'action' => 'view']); $result = Router::parse('/posts/2007/08/01/title-of-post-here'); - $expected = array('year' => '2007', 'month' => '08', 'day' => '01', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => array('0' => 'title-of-post-here'), 'named' => array()); + $expected = ['year' => '2007', 'month' => '08', 'day' => '01', 'controller' => 'posts', 'action' => 'view', 'plugin' => '', 'pass' => ['0' => 'title-of-post-here'], 'named' => []]; $this->assertEquals($expected, $result); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; $result = Router::parse('/pages/display/home'); - $expected = array('plugin' => null, 'pass' => array('home'), 'controller' => 'pages', 'action' => 'display', 'named' => array()); + $expected = ['plugin' => null, 'pass' => ['home'], 'controller' => 'pages', 'action' => 'display', 'named' => []]; $this->assertEquals($expected, $result); $result = Router::parse('pages/display/home/'); @@ -1063,78 +1063,78 @@ public function testUrlParsing() { $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/page/*', array('controller' => 'test')); + Router::connect('/page/*', ['controller' => 'test']); $result = Router::parse('/page/my-page'); - $expected = array('pass' => array('my-page'), 'plugin' => null, 'controller' => 'test', 'action' => 'index', 'named' => array()); + $expected = ['pass' => ['my-page'], 'plugin' => null, 'controller' => 'test', 'action' => 'index', 'named' => []]; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/:language/contact', array('language' => 'eng', 'plugin' => 'contact', 'controller' => 'contact', 'action' => 'index'), array('language' => '[a-z]{3}')); + Router::connect('/:language/contact', ['language' => 'eng', 'plugin' => 'contact', 'controller' => 'contact', 'action' => 'index'], ['language' => '[a-z]{3}']); $result = Router::parse('/eng/contact'); - $expected = array('pass' => array(), 'named' => array(), 'language' => 'eng', 'plugin' => 'contact', 'controller' => 'contact', 'action' => 'index'); + $expected = ['pass' => [], 'named' => [], 'language' => 'eng', 'plugin' => 'contact', 'controller' => 'contact', 'action' => 'index']; $this->assertEquals($expected, $result); Router::reload(); Router::connect('/forestillinger/:month/:year/*', - array('plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar'), - array('month' => '0[1-9]|1[012]', 'year' => '[12][0-9]{3}') + ['plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar'], + ['month' => '0[1-9]|1[012]', 'year' => '[12][0-9]{3}'] ); $result = Router::parse('/forestillinger/10/2007/min-forestilling'); - $expected = array('pass' => array('min-forestilling'), 'plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'year' => 2007, 'month' => 10, 'named' => array()); + $expected = ['pass' => ['min-forestilling'], 'plugin' => 'shows', 'controller' => 'shows', 'action' => 'calendar', 'year' => 2007, 'month' => 10, 'named' => []]; $this->assertEquals($expected, $result); Router::reload(); Router::connect('/:controller/:action/*'); - Router::connect('/', array('plugin' => 'pages', 'controller' => 'pages', 'action' => 'display')); + Router::connect('/', ['plugin' => 'pages', 'controller' => 'pages', 'action' => 'display']); $result = Router::parse('/'); - $expected = array('pass' => array(), 'named' => array(), 'controller' => 'pages', 'action' => 'display', 'plugin' => 'pages'); + $expected = ['pass' => [], 'named' => [], 'controller' => 'pages', 'action' => 'display', 'plugin' => 'pages']; $this->assertEquals($expected, $result); $result = Router::parse('/posts/edit/0'); - $expected = array('pass' => array(0), 'named' => array(), 'controller' => 'posts', 'action' => 'edit', 'plugin' => null); + $expected = ['pass' => [0], 'named' => [], 'controller' => 'posts', 'action' => 'edit', 'plugin' => null]; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/:id::url_title', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('id', 'url_title'), 'id' => '[\d]+')); + Router::connect('/posts/:id::url_title', ['controller' => 'posts', 'action' => 'view'], ['pass' => ['id', 'url_title'], 'id' => '[\d]+']); $result = Router::parse('/posts/5:sample-post-title'); - $expected = array('pass' => array('5', 'sample-post-title'), 'named' => array(), 'id' => 5, 'url_title' => 'sample-post-title', 'plugin' => null, 'controller' => 'posts', 'action' => 'view'); + $expected = ['pass' => ['5', 'sample-post-title'], 'named' => [], 'id' => 5, 'url_title' => 'sample-post-title', 'plugin' => null, 'controller' => 'posts', 'action' => 'view']; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/:id::url_title/*', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('id', 'url_title'), 'id' => '[\d]+')); + Router::connect('/posts/:id::url_title/*', ['controller' => 'posts', 'action' => 'view'], ['pass' => ['id', 'url_title'], 'id' => '[\d]+']); $result = Router::parse('/posts/5:sample-post-title/other/params/4'); - $expected = array('pass' => array('5', 'sample-post-title', 'other', 'params', '4'), 'named' => array(), 'id' => 5, 'url_title' => 'sample-post-title', 'plugin' => null, 'controller' => 'posts', 'action' => 'view'); + $expected = ['pass' => ['5', 'sample-post-title', 'other', 'params', '4'], 'named' => [], 'id' => 5, 'url_title' => 'sample-post-title', 'plugin' => null, 'controller' => 'posts', 'action' => 'view']; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/:url_title-(uuid::id)', array('controller' => 'posts', 'action' => 'view'), array('pass' => array('id', 'url_title'), 'id' => $UUID)); + Router::connect('/posts/:url_title-(uuid::id)', ['controller' => 'posts', 'action' => 'view'], ['pass' => ['id', 'url_title'], 'id' => $UUID]); $result = Router::parse('/posts/sample-post-title-(uuid:47fc97a9-019c-41d1-a058-1fa3cbdd56cb)'); - $expected = array('pass' => array('47fc97a9-019c-41d1-a058-1fa3cbdd56cb', 'sample-post-title'), 'named' => array(), 'id' => '47fc97a9-019c-41d1-a058-1fa3cbdd56cb', 'url_title' => 'sample-post-title', 'plugin' => null, 'controller' => 'posts', 'action' => 'view'); + $expected = ['pass' => ['47fc97a9-019c-41d1-a058-1fa3cbdd56cb', 'sample-post-title'], 'named' => [], 'id' => '47fc97a9-019c-41d1-a058-1fa3cbdd56cb', 'url_title' => 'sample-post-title', 'plugin' => null, 'controller' => 'posts', 'action' => 'view']; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/view/*', array('controller' => 'posts', 'action' => 'view'), array('named' => false)); + Router::connect('/posts/view/*', ['controller' => 'posts', 'action' => 'view'], ['named' => false]); $result = Router::parse('/posts/view/foo:bar/routing:fun'); - $expected = array('pass' => array('foo:bar', 'routing:fun'), 'named' => array(), 'plugin' => null, 'controller' => 'posts', 'action' => 'view'); + $expected = ['pass' => ['foo:bar', 'routing:fun'], 'named' => [], 'plugin' => null, 'controller' => 'posts', 'action' => 'view']; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/view/*', array('controller' => 'posts', 'action' => 'view'), array('named' => array('foo', 'answer'))); + Router::connect('/posts/view/*', ['controller' => 'posts', 'action' => 'view'], ['named' => ['foo', 'answer']]); $result = Router::parse('/posts/view/foo:bar/routing:fun/answer:42'); - $expected = array('pass' => array('routing:fun'), 'named' => array('foo' => 'bar', 'answer' => '42'), 'plugin' => null, 'controller' => 'posts', 'action' => 'view'); + $expected = ['pass' => ['routing:fun'], 'named' => ['foo' => 'bar', 'answer' => '42'], 'plugin' => null, 'controller' => 'posts', 'action' => 'view']; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/view/*', array('controller' => 'posts', 'action' => 'view'), array('named' => array('foo', 'answer'), 'greedyNamed' => true)); + Router::connect('/posts/view/*', ['controller' => 'posts', 'action' => 'view'], ['named' => ['foo', 'answer'], 'greedyNamed' => true]); $result = Router::parse('/posts/view/foo:bar/routing:fun/answer:42'); - $expected = array('pass' => array(), 'named' => array('foo' => 'bar', 'routing' => 'fun', 'answer' => '42'), 'plugin' => null, 'controller' => 'posts', 'action' => 'view'); + $expected = ['pass' => [], 'named' => ['foo' => 'bar', 'routing' => 'fun', 'answer' => '42'], 'plugin' => null, 'controller' => 'posts', 'action' => 'view']; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/posts/view/*', array('controller' => 'posts', 'action' => 'view'), array('named' => array('foo', 'answer'), 'greedyNamed' => true)); + Router::connect('/posts/view/*', ['controller' => 'posts', 'action' => 'view'], ['named' => ['foo', 'answer'], 'greedyNamed' => true]); $result = Router::parse('/posts/view/foo:bar/routing:fun/answer:42?id=123&tab=abc'); - $expected = array('pass' => array(), 'named' => array('foo' => 'bar', 'routing' => 'fun', 'answer' => '42'), 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '?' => array('id' => '123', 'tab' => 'abc')); + $expected = ['pass' => [], 'named' => ['foo' => 'bar', 'routing' => 'fun', 'answer' => '42'], 'plugin' => null, 'controller' => 'posts', 'action' => 'view', '?' => ['id' => '123', 'tab' => 'abc']]; $this->assertEquals($expected, $result); } @@ -1147,55 +1147,55 @@ public function testPersistentParameters() { Router::reload(); Router::connect( '/:lang/:color/posts/view/*', - array('controller' => 'posts', 'action' => 'view'), - array('persist' => array('lang', 'color')) + ['controller' => 'posts', 'action' => 'view'], + ['persist' => ['lang', 'color']] ); Router::connect( '/:lang/:color/posts/index', - array('controller' => 'posts', 'action' => 'index'), - array('persist' => array('lang')) + ['controller' => 'posts', 'action' => 'index'], + ['persist' => ['lang']] ); - Router::connect('/:lang/:color/posts/edit/*', array('controller' => 'posts', 'action' => 'edit')); - Router::connect('/about', array('controller' => 'pages', 'action' => 'view', 'about')); + Router::connect('/:lang/:color/posts/edit/*', ['controller' => 'posts', 'action' => 'edit']); + Router::connect('/about', ['controller' => 'pages', 'action' => 'view', 'about']); Router::parse('/en/red/posts/view/5'); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'lang' => 'en', 'color' => 'red', 'prefix' => 'admin', 'plugin' => null, 'action' => 'view', 'controller' => 'posts', - ))->addPaths(array( + ])->addPaths([ 'base' => '/', 'here' => '/en/red/posts/view/5', 'webroot' => '/', - )) + ]) ); $expected = '/en/red/posts/view/6'; - $result = Router::url(array('controller' => 'posts', 'action' => 'view', 6)); + $result = Router::url(['controller' => 'posts', 'action' => 'view', 6]); $this->assertEquals($expected, $result); $expected = '/en/blue/posts/index'; - $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'color' => 'blue')); + $result = Router::url(['controller' => 'posts', 'action' => 'index', 'color' => 'blue']); $this->assertEquals($expected, $result); $expected = '/posts/edit/6'; - $result = Router::url(array('controller' => 'posts', 'action' => 'edit', 6, 'color' => null, 'lang' => null)); + $result = Router::url(['controller' => 'posts', 'action' => 'edit', 6, 'color' => null, 'lang' => null]); $this->assertEquals($expected, $result); $expected = '/posts'; - $result = Router::url(array('controller' => 'posts', 'action' => 'index')); + $result = Router::url(['controller' => 'posts', 'action' => 'index']); $this->assertEquals($expected, $result); $expected = '/posts/edit/7'; - $result = Router::url(array('controller' => 'posts', 'action' => 'edit', 7)); + $result = Router::url(['controller' => 'posts', 'action' => 'edit', 7]); $this->assertEquals($expected, $result); $expected = '/about'; - $result = Router::url(array('controller' => 'pages', 'action' => 'view', 'about')); + $result = Router::url(['controller' => 'pages', 'action' => 'view', 'about']); $this->assertEquals($expected, $result); } @@ -1207,11 +1207,11 @@ public function testPersistentParameters() { public function testUuidRoutes() { Router::connect( '/subjects/add/:category_id', - array('controller' => 'subjects', 'action' => 'add'), - array('category_id' => '\w{8}-\w{4}-\w{4}-\w{4}-\w{12}') + ['controller' => 'subjects', 'action' => 'add'], + ['category_id' => '\w{8}-\w{4}-\w{4}-\w{4}-\w{12}'] ); $result = Router::parse('/subjects/add/4795d601-19c8-49a6-930e-06a8b01d17b7'); - $expected = array('pass' => array(), 'named' => array(), 'category_id' => '4795d601-19c8-49a6-930e-06a8b01d17b7', 'plugin' => null, 'controller' => 'subjects', 'action' => 'add'); + $expected = ['pass' => [], 'named' => [], 'category_id' => '4795d601-19c8-49a6-930e-06a8b01d17b7', 'plugin' => null, 'controller' => 'subjects', 'action' => 'add']; $this->assertEquals($expected, $result); } @@ -1223,31 +1223,31 @@ public function testUuidRoutes() { public function testRouteSymmetry() { Router::connect( "/:extra/page/:slug/*", - array('controller' => 'pages', 'action' => 'view', 'extra' => null), - array("extra" => '[a-z1-9_]*', "slug" => '[a-z1-9_]+', "action" => 'view') + ['controller' => 'pages', 'action' => 'view', 'extra' => null], + ["extra" => '[a-z1-9_]*', "slug" => '[a-z1-9_]+', "action" => 'view'] ); $result = Router::parse('/some_extra/page/this_is_the_slug'); - $expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'pages', 'action' => 'view', 'slug' => 'this_is_the_slug', 'extra' => 'some_extra'); + $expected = ['pass' => [], 'named' => [], 'plugin' => null, 'controller' => 'pages', 'action' => 'view', 'slug' => 'this_is_the_slug', 'extra' => 'some_extra']; $this->assertEquals($expected, $result); $result = Router::parse('/page/this_is_the_slug'); - $expected = array('pass' => array(), 'named' => array(), 'plugin' => null, 'controller' => 'pages', 'action' => 'view', 'slug' => 'this_is_the_slug', 'extra' => null); + $expected = ['pass' => [], 'named' => [], 'plugin' => null, 'controller' => 'pages', 'action' => 'view', 'slug' => 'this_is_the_slug', 'extra' => null]; $this->assertEquals($expected, $result); Router::reload(); Router::connect( "/:extra/page/:slug/*", - array('controller' => 'pages', 'action' => 'view', 'extra' => null), - array("extra" => '[a-z1-9_]*', "slug" => '[a-z1-9_]+') + ['controller' => 'pages', 'action' => 'view', 'extra' => null], + ["extra" => '[a-z1-9_]*', "slug" => '[a-z1-9_]+'] ); Router::parse('/'); - $result = Router::url(array('admin' => null, 'plugin' => null, 'controller' => 'pages', 'action' => 'view', 'slug' => 'this_is_the_slug', 'extra' => null)); + $result = Router::url(['admin' => null, 'plugin' => null, 'controller' => 'pages', 'action' => 'view', 'slug' => 'this_is_the_slug', 'extra' => null]); $expected = '/page/this_is_the_slug'; $this->assertEquals($expected, $result); - $result = Router::url(array('admin' => null, 'plugin' => null, 'controller' => 'pages', 'action' => 'view', 'slug' => 'this_is_the_slug', 'extra' => 'some_extra')); + $result = Router::url(['admin' => null, 'plugin' => null, 'controller' => 'pages', 'action' => 'view', 'slug' => 'this_is_the_slug', 'extra' => 'some_extra']); $expected = '/some_extra/page/this_is_the_slug'; $this->assertEquals($expected, $result); } @@ -1259,7 +1259,7 @@ public function testRouteSymmetry() { * @dataProvider parseReverseSymmetryData */ public function testParseReverseSymmetry($url) { - $this->assertSame($url, Router::reverse(Router::parse($url) + array('url' => array()))); + $this->assertSame($url, Router::reverse(Router::parse($url) + ['url' => []])); } /** @@ -1268,15 +1268,15 @@ public function testParseReverseSymmetry($url) { * @return array */ public function parseReverseSymmetryData() { - return array( - array('/'), - array('/controller/action'), - array('/controller/action/param'), - array('/controller/action?param1=value1¶m2=value2'), - array('/controller/action/param?param1=value1'), - array('/controller/action/named1:nv1'), - array('/controller/action/named1:nv1?param1=value1') - ); + return [ + ['/'], + ['/controller/action'], + ['/controller/action/param'], + ['/controller/action?param1=value1¶m2=value2'], + ['/controller/action/param?param1=value1'], + ['/controller/action/named1:nv1'], + ['/controller/action/named1:nv1?param1=value1'] + ]; } /** @@ -1288,16 +1288,16 @@ public function parseReverseSymmetryData() { public function testRoutingPrefixesSetting() { $restore = Configure::read('Routing'); - Configure::write('Routing.prefixes', array('admin', 'member', 'super_user')); + Configure::write('Routing.prefixes', ['admin', 'member', 'super_user']); Router::reload(); $result = Router::prefixes(); - $expected = array('admin', 'member', 'super_user'); + $expected = ['admin', 'member', 'super_user']; $this->assertEquals($expected, $result); - Configure::write('Routing.prefixes', array('admin', 'member')); + Configure::write('Routing.prefixes', ['admin', 'member']); Router::reload(); $result = Router::prefixes(); - $expected = array('admin', 'member'); + $expected = ['admin', 'member']; $this->assertEquals($expected, $result); Configure::write('Routing', $restore); @@ -1309,31 +1309,31 @@ public function testRoutingPrefixesSetting() { * @return void */ public function testPrefixRoutingAndPlugins() { - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); $paths = App::path('plugins'); - App::build(array( - 'plugins' => array( + App::build([ + 'plugins' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ) - ), App::RESET); - CakePlugin::load(array('TestPlugin')); + ] + ], App::RESET); + CakePlugin::load(['TestPlugin']); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'admin' => true, 'controller' => 'controller', 'action' => 'action', 'plugin' => null, 'prefix' => 'admin' - ))->addPaths(array( + ])->addPaths([ 'base' => '/', 'here' => '/', 'webroot' => '/base/', - )) + ]) ); Router::parse('/'); - $result = Router::url(array('plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index')); + $result = Router::url(['plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index']); $expected = '/admin/test_plugin'; $this->assertEquals($expected, $result); @@ -1341,31 +1341,31 @@ public function testPrefixRoutingAndPlugins() { require CAKE . 'Config' . DS . 'routes.php'; $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => 'test_plugin', 'controller' => 'show_tickets', 'action' => 'admin_edit', - 'pass' => array('6'), 'prefix' => 'admin', 'admin' => true, 'form' => array(), - 'url' => array('url' => 'admin/shows/show_tickets/edit/6') - ))->addPaths(array( + 'pass' => ['6'], 'prefix' => 'admin', 'admin' => true, 'form' => [], + 'url' => ['url' => 'admin/shows/show_tickets/edit/6'] + ])->addPaths([ 'base' => '/', 'here' => '/admin/shows/show_tickets/edit/6', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array( + $result = Router::url([ 'plugin' => 'test_plugin', 'controller' => 'show_tickets', 'action' => 'edit', 6, 'admin' => true, 'prefix' => 'admin' - )); + ]); $expected = '/admin/test_plugin/show_tickets/edit/6'; $this->assertEquals($expected, $result); - $result = Router::url(array( + $result = Router::url([ 'plugin' => 'test_plugin', 'controller' => 'show_tickets', 'action' => 'index', 'admin' => true - )); + ]); $expected = '/admin/test_plugin/show_tickets'; $this->assertEquals($expected, $result); - App::build(array('plugins' => $paths)); + App::build(['plugins' => $paths]); } /** @@ -1374,10 +1374,10 @@ public function testPrefixRoutingAndPlugins() { * @return void */ public function testParseExtensions() { - $this->assertEquals(array(), Router::extensions()); + $this->assertEquals([], Router::extensions()); Router::parseExtensions('rss'); - $this->assertEquals(array('rss'), Router::extensions()); + $this->assertEquals(['rss'], Router::extensions()); } /** @@ -1386,8 +1386,8 @@ public function testParseExtensions() { * @return void */ public function testSetExtensions() { - Router::setExtensions(array('rss')); - $this->assertEquals(array('rss'), Router::extensions()); + Router::setExtensions(['rss']); + $this->assertEquals(['rss'], Router::extensions()); require CAKE . 'Config' . DS . 'routes.php'; $result = Router::parse('/posts.rss'); @@ -1400,15 +1400,15 @@ public function testSetExtensions() { $result = Router::parse('/posts.xml'); $this->assertFalse(isset($result['ext'])); - Router::setExtensions(array('xml')); + Router::setExtensions(['xml']); $result = Router::extensions(); - $this->assertEquals(array('rss', 'xml'), $result); + $this->assertEquals(['rss', 'xml'], $result); $result = Router::parse('/posts.xml'); $this->assertEquals('xml', $result['ext']); - $result = Router::setExtensions(array('pdf'), false); - $this->assertEquals(array('pdf'), $result); + $result = Router::setExtensions(['pdf'], false); + $this->assertEquals(['pdf'], $result); } /** @@ -1421,15 +1421,15 @@ public function testExtensionParsing() { require CAKE . 'Config' . DS . 'routes.php'; $result = Router::parse('/posts.rss'); - $expected = array('plugin' => null, 'controller' => 'posts', 'action' => 'index', 'ext' => 'rss', 'pass' => array(), 'named' => array()); + $expected = ['plugin' => null, 'controller' => 'posts', 'action' => 'index', 'ext' => 'rss', 'pass' => [], 'named' => []]; $this->assertEquals($expected, $result); $result = Router::parse('/posts/view/1.rss'); - $expected = array('plugin' => null, 'controller' => 'posts', 'action' => 'view', 'pass' => array('1'), 'named' => array(), 'ext' => 'rss'); + $expected = ['plugin' => null, 'controller' => 'posts', 'action' => 'view', 'pass' => ['1'], 'named' => [], 'ext' => 'rss']; $this->assertEquals($expected, $result); $result = Router::parse('/posts/view/1.rss?query=test'); - $expected['?'] = array('query' => 'test'); + $expected['?'] = ['query' => 'test']; $this->assertEquals($expected, $result); $result = Router::parse('/posts/view/1.atom'); @@ -1443,24 +1443,24 @@ public function testExtensionParsing() { Router::parseExtensions('rss', 'xml'); $result = Router::parse('/posts.xml'); - $expected = array('plugin' => null, 'controller' => 'posts', 'action' => 'index', 'ext' => 'xml', 'pass' => array(), 'named' => array()); + $expected = ['plugin' => null, 'controller' => 'posts', 'action' => 'index', 'ext' => 'xml', 'pass' => [], 'named' => []]; $this->assertEquals($expected, $result); $result = Router::parse('/posts.atom?hello=goodbye'); - $expected = array('plugin' => null, 'controller' => 'posts.atom', 'action' => 'index', 'pass' => array(), 'named' => array(), '?' => array('hello' => 'goodbye')); + $expected = ['plugin' => null, 'controller' => 'posts.atom', 'action' => 'index', 'pass' => [], 'named' => [], '?' => ['hello' => 'goodbye']]; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/controller/action', array('controller' => 'controller', 'action' => 'action', 'ext' => 'rss')); + Router::connect('/controller/action', ['controller' => 'controller', 'action' => 'action', 'ext' => 'rss']); $result = Router::parse('/controller/action'); - $expected = array('controller' => 'controller', 'action' => 'action', 'plugin' => null, 'ext' => 'rss', 'named' => array(), 'pass' => array()); + $expected = ['controller' => 'controller', 'action' => 'action', 'plugin' => null, 'ext' => 'rss', 'named' => [], 'pass' => []]; $this->assertEquals($expected, $result); Router::reload(); Router::parseExtensions('rss'); - Router::connect('/controller/action', array('controller' => 'controller', 'action' => 'action', 'ext' => 'rss')); + Router::connect('/controller/action', ['controller' => 'controller', 'action' => 'action', 'ext' => 'rss']); $result = Router::parse('/controller/action'); - $expected = array('controller' => 'controller', 'action' => 'action', 'plugin' => null, 'ext' => 'rss', 'named' => array(), 'pass' => array()); + $expected = ['controller' => 'controller', 'action' => 'action', 'plugin' => null, 'ext' => 'rss', 'named' => [], 'pass' => []]; $this->assertEquals($expected, $result); } @@ -1470,25 +1470,25 @@ public function testExtensionParsing() { * @return void */ public function testQuerystringGeneration() { - $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2')); + $result = Router::url(['controller' => 'posts', 'action' => 'index', '0', '?' => 'var=test&var2=test2']); $expected = '/posts/index/0?var=test&var2=test2'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => array('var' => 'test', 'var2' => 'test2'))); + $result = Router::url(['controller' => 'posts', 'action' => 'index', '0', '?' => ['var' => 'test', 'var2' => 'test2']]); $this->assertEquals($expected, $result); $expected .= '&more=test+data'; - $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => array('var' => 'test', 'var2' => 'test2', 'more' => 'test data'))); + $result = Router::url(['controller' => 'posts', 'action' => 'index', '0', '?' => ['var' => 'test', 'var2' => 'test2', 'more' => 'test data']]); $this->assertEquals($expected, $result); // Test bug #4614 $restore = ini_get('arg_separator.output'); ini_set('arg_separator.output', '&'); - $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => array('var' => 'test', 'var2' => 'test2', 'more' => 'test data'))); + $result = Router::url(['controller' => 'posts', 'action' => 'index', '0', '?' => ['var' => 'test', 'var2' => 'test2', 'more' => 'test data']]); $this->assertEquals($expected, $result); ini_set('arg_separator.output', $restore); - $result = Router::url(array('controller' => 'posts', 'action' => 'index', '0', '?' => array('var' => 'test', 'var2' => 'test2')), array('escape' => true)); + $result = Router::url(['controller' => 'posts', 'action' => 'index', '0', '?' => ['var' => 'test', 'var2' => 'test2']], ['escape' => true]); $expected = '/posts/index/0?var=test&var2=test2'; $this->assertEquals($expected, $result); } @@ -1499,27 +1499,27 @@ public function testQuerystringGeneration() { * @return void */ public function testConnectNamed() { - $named = Router::connectNamed(false, array('default' => true)); + $named = Router::connectNamed(false, ['default' => true]); $this->assertFalse($named['greedyNamed']); $this->assertEquals(array_keys($named['rules']), $named['default']); Router::reload(); - Router::connect('/foo/*', array('controller' => 'bar', 'action' => 'fubar')); - Router::connectNamed(array(), array('separator' => '=')); + Router::connect('/foo/*', ['controller' => 'bar', 'action' => 'fubar']); + Router::connectNamed([], ['separator' => '=']); $result = Router::parse('/foo/param1=value1/param2=value2'); - $expected = array('pass' => array(), 'named' => array('param1' => 'value1', 'param2' => 'value2'), 'controller' => 'bar', 'action' => 'fubar', 'plugin' => null); + $expected = ['pass' => [], 'named' => ['param1' => 'value1', 'param2' => 'value2'], 'controller' => 'bar', 'action' => 'fubar', 'plugin' => null]; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/controller/action/*', array('controller' => 'controller', 'action' => 'action'), array('named' => array('param1' => 'value[\d]'))); - Router::connectNamed(array(), array('greedy' => false, 'separator' => '=')); + Router::connect('/controller/action/*', ['controller' => 'controller', 'action' => 'action'], ['named' => ['param1' => 'value[\d]']]); + Router::connectNamed([], ['greedy' => false, 'separator' => '=']); $result = Router::parse('/controller/action/param1=value1/param2=value2'); - $expected = array('pass' => array('param2=value2'), 'named' => array('param1' => 'value1'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $expected = ['pass' => ['param2=value2'], 'named' => ['param1' => 'value1'], 'controller' => 'controller', 'action' => 'action', 'plugin' => null]; $this->assertEquals($expected, $result); Router::reload(); Router::connect('/:controller/:action/*'); - Router::connectNamed(array('page'), array('default' => false, 'greedy' => false)); + Router::connectNamed(['page'], ['default' => false, 'greedy' => false]); $result = Router::parse('/categories/index/limit=5'); $this->assertTrue(empty($result['named'])); } @@ -1530,57 +1530,57 @@ public function testConnectNamed() { * @return void */ public function testNamedArgsUrlGeneration() { - $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 1, 'deleted' => 1)); + $result = Router::url(['controller' => 'posts', 'action' => 'index', 'published' => 1, 'deleted' => 1]); $expected = '/posts/index/published:1/deleted:1'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'posts', 'action' => 'index', 'published' => 0, 'deleted' => 0)); + $result = Router::url(['controller' => 'posts', 'action' => 'index', 'published' => 0, 'deleted' => 0]); $expected = '/posts/index/published:0/deleted:0'; $this->assertEquals($expected, $result); Router::reload(); extract(Router::getNamedExpressions()); - Router::connectNamed(array('file' => '[\w\.\-]+\.(html|png)')); - Router::connect('/', array('controller' => 'graphs', 'action' => 'index')); - Router::connect('/:id/*', array('controller' => 'graphs', 'action' => 'view'), array('id' => $ID)); + Router::connectNamed(['file' => '[\w\.\-]+\.(html|png)']); + Router::connect('/', ['controller' => 'graphs', 'action' => 'index']); + Router::connect('/:id/*', ['controller' => 'graphs', 'action' => 'view'], ['id' => $ID]); - $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.png')); + $result = Router::url(['controller' => 'graphs', 'action' => 'view', 'id' => 12, 'file' => 'asdf.png']); $expected = '/12/file:asdf.png'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'graphs', 'action' => 'view', 12, 'file' => 'asdf.foo')); + $result = Router::url(['controller' => 'graphs', 'action' => 'view', 12, 'file' => 'asdf.foo']); $expected = '/graphs/view/12/file:asdf.foo'; $this->assertEquals($expected, $result); - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Router::reload(); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'admin' => true, 'controller' => 'controller', 'action' => 'index', 'plugin' => null - ))->addPaths(array( + ])->addPaths([ 'base' => '/', 'here' => '/', 'webroot' => '/base/', - )) + ]) ); Router::parse('/'); - $result = Router::url(array('page' => 1, 0 => null, 'sort' => 'controller', 'direction' => 'asc', 'order' => null)); + $result = Router::url(['page' => 1, 0 => null, 'sort' => 'controller', 'direction' => 'asc', 'order' => null]); $expected = "/admin/controller/index/page:1/sort:controller/direction:asc"; $this->assertEquals($expected, $result); Router::reload(); $request = new CakeRequest('admin/controller/index'); - $request->addParams(array( + $request->addParams([ 'admin' => true, 'controller' => 'controller', 'action' => 'index', 'plugin' => null - )); + ]); $request->base = '/'; Router::setRequestInfo($request); Router::parse('/admin/controller/index/type:whatever'); - $result = Router::url(array('type' => 'new')); + $result = Router::url(['type' => 'new']); $expected = "/admin/controller/index/type:new"; $this->assertEquals($expected, $result); } @@ -1594,16 +1594,16 @@ public function testNamedArgsUrlParsing() { Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value'); - $expected = array('pass' => array(), 'named' => array('param1' => 'value1:1', 'param2' => 'value2:3', 'param' => 'value'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $expected = ['pass' => [], 'named' => ['param1' => 'value1:1', 'param2' => 'value2:3', 'param' => 'value'], 'controller' => 'controller', 'action' => 'action', 'plugin' => null]; $this->assertEquals($expected, $result); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; $result = Router::connectNamed(false); - $this->assertEquals(array(), array_keys($result['rules'])); + $this->assertEquals([], array_keys($result['rules'])); $this->assertFalse($result['greedyNamed']); $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value'); - $expected = array('pass' => array('param1:value1:1', 'param2:value2:3', 'param:value'), 'named' => array(), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $expected = ['pass' => ['param1:value1:1', 'param2:value2:3', 'param:value'], 'named' => [], 'controller' => 'controller', 'action' => 'action', 'plugin' => null]; $this->assertEquals($expected, $result); Router::reload(); @@ -1615,34 +1615,34 @@ public function testNamedArgsUrlParsing() { Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; - Router::connectNamed(array('param1' => 'not-matching')); + Router::connectNamed(['param1' => 'not-matching']); $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param:value'); - $expected = array('pass' => array('param1:value1:1'), 'named' => array('param2' => 'value2:3', 'param' => 'value'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $expected = ['pass' => ['param1:value1:1'], 'named' => ['param2' => 'value2:3', 'param' => 'value'], 'controller' => 'controller', 'action' => 'action', 'plugin' => null]; $this->assertEquals($expected, $result); $result = Router::parse('/foo/view/param1:value1:1/param2:value2:3/param:value'); - $expected = array('pass' => array('param1:value1:1'), 'named' => array('param2' => 'value2:3', 'param' => 'value'), 'controller' => 'foo', 'action' => 'view', 'plugin' => null); + $expected = ['pass' => ['param1:value1:1'], 'named' => ['param2' => 'value2:3', 'param' => 'value'], 'controller' => 'foo', 'action' => 'view', 'plugin' => null]; $this->assertEquals($expected, $result); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; - Router::connectNamed(array('param1' => '[\d]', 'param2' => '[a-z]', 'param3' => '[\d]')); + Router::connectNamed(['param1' => '[\d]', 'param2' => '[a-z]', 'param3' => '[\d]']); $result = Router::parse('/controller/action/param1:1/param2:2/param3:3'); - $expected = array('pass' => array('param2:2'), 'named' => array('param1' => '1', 'param3' => '3'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $expected = ['pass' => ['param2:2'], 'named' => ['param1' => '1', 'param3' => '3'], 'controller' => 'controller', 'action' => 'action', 'plugin' => null]; $this->assertEquals($expected, $result); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; - Router::connectNamed(array('param1' => '[\d]', 'param2' => true, 'param3' => '[\d]')); + Router::connectNamed(['param1' => '[\d]', 'param2' => true, 'param3' => '[\d]']); $result = Router::parse('/controller/action/param1:1/param2:2/param3:3'); - $expected = array('pass' => array(), 'named' => array('param1' => '1', 'param2' => '2', 'param3' => '3'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $expected = ['pass' => [], 'named' => ['param1' => '1', 'param2' => '2', 'param3' => '3'], 'controller' => 'controller', 'action' => 'action', 'plugin' => null]; $this->assertEquals($expected, $result); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; - Router::connectNamed(array('param1' => 'value[\d]+:[\d]+'), array('greedy' => false)); + Router::connectNamed(['param1' => 'value[\d]+:[\d]+'], ['greedy' => false]); $result = Router::parse('/controller/action/param1:value1:1/param2:value2:3/param3:value'); - $expected = array('pass' => array('param2:value2:3', 'param3:value'), 'named' => array('param1' => 'value1:1'), 'controller' => 'controller', 'action' => 'action', 'plugin' => null); + $expected = ['pass' => ['param2:value2:3', 'param3:value'], 'named' => ['param1' => 'value1:1'], 'controller' => 'controller', 'action' => 'action', 'plugin' => null]; $this->assertEquals($expected, $result); } @@ -1654,66 +1654,66 @@ public function testNamedArgsUrlParsing() { */ public function testUrlGenerationWithLegacyPrefixes() { Router::reload(); - Router::connect('/protected/:controller/:action/*', array( + Router::connect('/protected/:controller/:action/*', [ 'prefix' => 'protected', 'protected' => true - )); + ]); Router::parse('/'); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'images', 'action' => 'index', - 'prefix' => null, 'admin' => false, 'url' => array('url' => 'images/index') - ))->addPaths(array( + 'prefix' => null, 'admin' => false, 'url' => ['url' => 'images/index'] + ])->addPaths([ 'base' => '', 'here' => '/images/index', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array('protected' => true)); + $result = Router::url(['protected' => true]); $expected = '/protected/images/index'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'images', 'action' => 'add')); + $result = Router::url(['controller' => 'images', 'action' => 'add']); $expected = '/images/add'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'images', 'action' => 'add', 'protected' => true)); + $result = Router::url(['controller' => 'images', 'action' => 'add', 'protected' => true]); $expected = '/protected/images/add'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'edit', 1)); + $result = Router::url(['action' => 'edit', 1]); $expected = '/images/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'edit', 1, 'protected' => true)); + $result = Router::url(['action' => 'edit', 1, 'protected' => true]); $expected = '/protected/images/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true)); + $result = Router::url(['action' => 'protected_edit', 1, 'protected' => true]); $expected = '/protected/images/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'edit', 1, 'protected' => true)); + $result = Router::url(['action' => 'edit', 1, 'protected' => true]); $expected = '/protected/images/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1)); + $result = Router::url(['controller' => 'others', 'action' => 'edit', 1]); $expected = '/others/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true)); + $result = Router::url(['controller' => 'others', 'action' => 'edit', 1, 'protected' => true]); $expected = '/protected/others/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1)); + $result = Router::url(['controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1]); $expected = '/protected/others/edit/1/page:1'; $this->assertEquals($expected, $result); - Router::connectNamed(array('random')); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value')); + Router::connectNamed(['random']); + $result = Router::url(['controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value']); $expected = '/protected/others/edit/1/random:my-value'; $this->assertEquals($expected, $result); } @@ -1724,68 +1724,68 @@ public function testUrlGenerationWithLegacyPrefixes() { * @return void */ public function testUrlGenerationWithAutoPrefixes() { - Configure::write('Routing.prefixes', array('protected')); + Configure::write('Routing.prefixes', ['protected']); Router::reload(); Router::parse('/'); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'images', 'action' => 'index', - 'prefix' => null, 'protected' => false, 'url' => array('url' => 'images/index') - ))->addPaths(array( + 'prefix' => null, 'protected' => false, 'url' => ['url' => 'images/index'] + ])->addPaths([ 'base' => '', 'here' => '/images/index', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array('controller' => 'images', 'action' => 'add')); + $result = Router::url(['controller' => 'images', 'action' => 'add']); $expected = '/images/add'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'images', 'action' => 'add', 'protected' => true)); + $result = Router::url(['controller' => 'images', 'action' => 'add', 'protected' => true]); $expected = '/protected/images/add'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'images', 'action' => 'add_protected_test', 'protected' => true)); + $result = Router::url(['controller' => 'images', 'action' => 'add_protected_test', 'protected' => true]); $expected = '/protected/images/add_protected_test'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'edit', 1)); + $result = Router::url(['action' => 'edit', 1]); $expected = '/images/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'edit', 1, 'protected' => true)); + $result = Router::url(['action' => 'edit', 1, 'protected' => true]); $expected = '/protected/images/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'protected_edit', 1, 'protected' => true)); + $result = Router::url(['action' => 'protected_edit', 1, 'protected' => true]); $expected = '/protected/images/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'protectededit', 1, 'protected' => true)); + $result = Router::url(['action' => 'protectededit', 1, 'protected' => true]); $expected = '/protected/images/protectededit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'edit', 1, 'protected' => true)); + $result = Router::url(['action' => 'edit', 1, 'protected' => true]); $expected = '/protected/images/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1)); + $result = Router::url(['controller' => 'others', 'action' => 'edit', 1]); $expected = '/others/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true)); + $result = Router::url(['controller' => 'others', 'action' => 'edit', 1, 'protected' => true]); $expected = '/protected/others/edit/1'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1)); + $result = Router::url(['controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'page' => 1]); $expected = '/protected/others/edit/1/page:1'; $this->assertEquals($expected, $result); - Router::connectNamed(array('random')); - $result = Router::url(array('controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value')); + Router::connectNamed(['random']); + $result = Router::url(['controller' => 'others', 'action' => 'edit', 1, 'protected' => true, 'random' => 'my-value']); $expected = '/protected/others/edit/1/random:my-value'; $this->assertEquals($expected, $result); } @@ -1796,27 +1796,27 @@ public function testUrlGenerationWithAutoPrefixes() { * @return void */ public function testAutoPrefixRoutePersistence() { - Configure::write('Routing.prefixes', array('protected')); + Configure::write('Routing.prefixes', ['protected']); Router::reload(); Router::parse('/'); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'images', 'action' => 'index', 'prefix' => 'protected', - 'protected' => true, 'url' => array('url' => 'protected/images/index') - ))->addPaths(array( + 'protected' => true, 'url' => ['url' => 'protected/images/index'] + ])->addPaths([ 'base' => '', 'here' => '/protected/images/index', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array('controller' => 'images', 'action' => 'add')); + $result = Router::url(['controller' => 'images', 'action' => 'add']); $expected = '/protected/images/add'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'images', 'action' => 'add', 'protected' => false)); + $result = Router::url(['controller' => 'images', 'action' => 'add', 'protected' => false]); $expected = '/images/add'; $this->assertEquals($expected, $result); } @@ -1827,38 +1827,38 @@ public function testAutoPrefixRoutePersistence() { * @return void */ public function testPrefixOverride() { - Configure::write('Routing.prefixes', array('protected', 'admin')); + Configure::write('Routing.prefixes', ['protected', 'admin']); Router::reload(); Router::parse('/'); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'images', 'action' => 'index', 'prefix' => 'protected', - 'protected' => true, 'url' => array('url' => 'protected/images/index') - ))->addPaths(array( + 'protected' => true, 'url' => ['url' => 'protected/images/index'] + ])->addPaths([ 'base' => '', 'here' => '/protected/images/index', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array('controller' => 'images', 'action' => 'add', 'admin' => true)); + $result = Router::url(['controller' => 'images', 'action' => 'add', 'admin' => true]); $expected = '/admin/images/add'; $this->assertEquals($expected, $result); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'images', 'action' => 'index', 'prefix' => 'admin', - 'admin' => true, 'url' => array('url' => 'admin/images/index') - ))->addPaths(array( + 'admin' => true, 'url' => ['url' => 'admin/images/index'] + ])->addPaths([ 'base' => '', 'here' => '/admin/images/index', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array('controller' => 'images', 'action' => 'add', 'protected' => true)); + $result = Router::url(['controller' => 'images', 'action' => 'add', 'protected' => true]); $expected = '/protected/images/add'; $this->assertEquals($expected, $result); } @@ -1869,20 +1869,20 @@ public function testPrefixOverride() { * @return void */ public function testPrefixFalseIgnored() { - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Router::reload(); - Router::connect('/cache_css/*', array('admin' => false, 'controller' => 'asset_compress', 'action' => 'get')); + Router::connect('/cache_css/*', ['admin' => false, 'controller' => 'asset_compress', 'action' => 'get']); - $url = Router::url(array('controller' => 'asset_compress', 'action' => 'get', 'test')); + $url = Router::url(['controller' => 'asset_compress', 'action' => 'get', 'test']); $expected = '/cache_css/test'; $this->assertEquals($expected, $url); - $url = Router::url(array('admin' => false, 'controller' => 'asset_compress', 'action' => 'get', 'test')); + $url = Router::url(['admin' => false, 'controller' => 'asset_compress', 'action' => 'get', 'test']); $expected = '/cache_css/test'; $this->assertEquals($expected, $url); - $url = Router::url(array('admin' => true, 'controller' => 'asset_compress', 'action' => 'get', 'test')); + $url = Router::url(['admin' => true, 'controller' => 'asset_compress', 'action' => 'get', 'test']); $this->assertEquals('/admin/asset_compress/get/test', $url); } @@ -1894,25 +1894,25 @@ public function testPrefixFalseIgnored() { public function testRemoveBase() { $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'controller', 'action' => 'index', - 'bare' => 0, 'url' => array('url' => 'protected/images/index') - ))->addPaths(array( + 'bare' => 0, 'url' => ['url' => 'protected/images/index'] + ])->addPaths([ 'base' => '/base', 'here' => '/', 'webroot' => '/base/', - )) + ]) ); - $result = Router::url(array('controller' => 'my_controller', 'action' => 'my_action')); + $result = Router::url(['controller' => 'my_controller', 'action' => 'my_action']); $expected = '/base/my_controller/my_action'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'my_controller', 'action' => 'my_action', 'base' => false)); + $result = Router::url(['controller' => 'my_controller', 'action' => 'my_action', 'base' => false]); $expected = '/my_controller/my_action'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'my_controller', 'action' => 'my_action', 'base' => true)); + $result = Router::url(['controller' => 'my_controller', 'action' => 'my_action', 'base' => true]); $expected = '/base/my_controller/my_action/base:1'; $this->assertEquals($expected, $result); } @@ -1923,43 +1923,43 @@ public function testRemoveBase() { * @return void */ public function testPagesUrlParsing() { - Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); - Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); + Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']); + Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']); $result = Router::parse('/'); - $expected = array('pass' => array('home'), 'named' => array(), 'plugin' => null, 'controller' => 'pages', 'action' => 'display'); + $expected = ['pass' => ['home'], 'named' => [], 'plugin' => null, 'controller' => 'pages', 'action' => 'display']; $this->assertEquals($expected, $result); $result = Router::parse('/pages/home/'); - $expected = array('pass' => array('home'), 'named' => array(), 'plugin' => null, 'controller' => 'pages', 'action' => 'display'); + $expected = ['pass' => ['home'], 'named' => [], 'plugin' => null, 'controller' => 'pages', 'action' => 'display']; $this->assertEquals($expected, $result); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; - Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); + Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']); $result = Router::parse('/'); - $expected = array('pass' => array('home'), 'named' => array(), 'plugin' => null, 'controller' => 'pages', 'action' => 'display'); + $expected = ['pass' => ['home'], 'named' => [], 'plugin' => null, 'controller' => 'pages', 'action' => 'display']; $this->assertEquals($expected, $result); $result = Router::parse('/pages/display/home/event:value'); - $expected = array('pass' => array('home'), 'named' => array('event' => 'value'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display'); + $expected = ['pass' => ['home'], 'named' => ['event' => 'value'], 'plugin' => null, 'controller' => 'pages', 'action' => 'display']; $this->assertEquals($expected, $result); $result = Router::parse('/pages/display/home/event:Val_u2'); - $expected = array('pass' => array('home'), 'named' => array('event' => 'Val_u2'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display'); + $expected = ['pass' => ['home'], 'named' => ['event' => 'Val_u2'], 'plugin' => null, 'controller' => 'pages', 'action' => 'display']; $this->assertEquals($expected, $result); $result = Router::parse('/pages/display/home/event:val-ue'); - $expected = array('pass' => array('home'), 'named' => array('event' => 'val-ue'), 'plugin' => null, 'controller' => 'pages', 'action' => 'display'); + $expected = ['pass' => ['home'], 'named' => ['event' => 'val-ue'], 'plugin' => null, 'controller' => 'pages', 'action' => 'display']; $this->assertEquals($expected, $result); Router::reload(); - Router::connect('/', array('controller' => 'posts', 'action' => 'index')); - Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display')); + Router::connect('/', ['controller' => 'posts', 'action' => 'index']); + Router::connect('/pages/*', ['controller' => 'pages', 'action' => 'display']); $result = Router::parse('/pages/contact/'); - $expected = array('pass' => array('contact'), 'named' => array(), 'plugin' => null, 'controller' => 'pages', 'action' => 'display'); + $expected = ['pass' => ['contact'], 'named' => [], 'plugin' => null, 'controller' => 'pages', 'action' => 'display']; $this->assertEquals($expected, $result); } @@ -2004,26 +2004,26 @@ public function testParsingWithPatternOnAction() { Router::reload(); Router::connect( '/blog/:action/*', - array('controller' => 'blog_posts'), - array('action' => 'other|actions') + ['controller' => 'blog_posts'], + ['action' => 'other|actions'] ); $result = Router::parse('/blog/other'); - $expected = array( + $expected = [ 'plugin' => null, 'controller' => 'blog_posts', 'action' => 'other', - 'pass' => array(), - 'named' => array() - ); + 'pass' => [], + 'named' => [] + ]; $this->assertEquals($expected, $result); $result = Router::parse('/blog/foobar'); - $this->assertSame(array(), $result); + $this->assertSame([], $result); - $result = Router::url(array('controller' => 'blog_posts', 'action' => 'foo')); + $result = Router::url(['controller' => 'blog_posts', 'action' => 'foo']); $this->assertEquals('/blog_posts/foo', $result); - $result = Router::url(array('controller' => 'blog_posts', 'action' => 'actions')); + $result = Router::url(['controller' => 'blog_posts', 'action' => 'actions']); $this->assertEquals('/blog/actions', $result); } @@ -2033,65 +2033,65 @@ public function testParsingWithPatternOnAction() { * @return void */ public function testParsingWithPrefixes() { - $adminParams = array('prefix' => 'admin', 'admin' => true); + $adminParams = ['prefix' => 'admin', 'admin' => true]; Router::connect('/admin/:controller', $adminParams); Router::connect('/admin/:controller/:action', $adminParams); Router::connect('/admin/:controller/:action/*', $adminParams); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'controller', 'action' => 'index' - ))->addPaths(array( + ])->addPaths([ 'base' => '/base', 'here' => '/', 'webroot' => '/base/', - )) + ]) ); $result = Router::parse('/admin/posts/'); - $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'admin', 'plugin' => null, 'controller' => 'posts', 'action' => 'admin_index', 'admin' => true); + $expected = ['pass' => [], 'named' => [], 'prefix' => 'admin', 'plugin' => null, 'controller' => 'posts', 'action' => 'admin_index', 'admin' => true]; $this->assertEquals($expected, $result); $result = Router::parse('/admin/posts'); $this->assertEquals($expected, $result); - $result = Router::url(array('admin' => true, 'controller' => 'posts')); + $result = Router::url(['admin' => true, 'controller' => 'posts']); $expected = '/base/admin/posts'; $this->assertEquals($expected, $result); $result = Router::prefixes(); - $expected = array('admin'); + $expected = ['admin']; $this->assertEquals($expected, $result); Router::reload(); - $prefixParams = array('prefix' => 'members', 'members' => true); + $prefixParams = ['prefix' => 'members', 'members' => true]; Router::connect('/members/:controller', $prefixParams); Router::connect('/members/:controller/:action', $prefixParams); Router::connect('/members/:controller/:action/*', $prefixParams); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'controller', 'action' => 'index', 'bare' => 0 - ))->addPaths(array( + ])->addPaths([ 'base' => '/base', 'here' => '/', 'webroot' => '/', - )) + ]) ); $result = Router::parse('/members/posts/index'); - $expected = array('pass' => array(), 'named' => array(), 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'members_index', 'members' => true); + $expected = ['pass' => [], 'named' => [], 'prefix' => 'members', 'plugin' => null, 'controller' => 'posts', 'action' => 'members_index', 'members' => true]; $this->assertEquals($expected, $result); - $result = Router::url(array('members' => true, 'controller' => 'posts', 'action' => 'index', 'page' => 2)); + $result = Router::url(['members' => true, 'controller' => 'posts', 'action' => 'index', 'page' => 2]); $expected = '/base/members/posts/index/page:2'; $this->assertEquals($expected, $result); - $result = Router::url(array('members' => true, 'controller' => 'users', 'action' => 'add')); + $result = Router::url(['members' => true, 'controller' => 'users', 'action' => 'add']); $expected = '/base/members/users/add'; $this->assertEquals($expected, $result); } @@ -2102,30 +2102,30 @@ public function testParsingWithPrefixes() { * @return void */ public function testUrlWritingWithPrefixes() { - Router::connect('/company/:controller/:action/*', array('prefix' => 'company', 'company' => true)); - Router::connect('/login', array('controller' => 'users', 'action' => 'login')); + Router::connect('/company/:controller/:action/*', ['prefix' => 'company', 'company' => true]); + Router::connect('/login', ['controller' => 'users', 'action' => 'login']); - $result = Router::url(array('controller' => 'users', 'action' => 'login', 'company' => true)); + $result = Router::url(['controller' => 'users', 'action' => 'login', 'company' => true]); $expected = '/company/users/login'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'users', 'action' => 'company_login', 'company' => true)); + $result = Router::url(['controller' => 'users', 'action' => 'company_login', 'company' => true]); $expected = '/company/users/login'; $this->assertEquals($expected, $result); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'users', 'action' => 'login', 'company' => true - ))->addPaths(array( + ])->addPaths([ 'base' => '/', 'here' => '/', 'webroot' => '/base/', - )) + ]) ); - $result = Router::url(array('controller' => 'users', 'action' => 'login', 'company' => false)); + $result = Router::url(['controller' => 'users', 'action' => 'login', 'company' => false]); $expected = '/login'; $this->assertEquals($expected, $result); } @@ -2138,26 +2138,26 @@ public function testUrlWritingWithPrefixes() { public function testUrlWritingWithPrefixesAndCustomRoutes() { Router::connect( '/admin/login', - array('controller' => 'users', 'action' => 'login', 'prefix' => 'admin', 'admin' => true) + ['controller' => 'users', 'action' => 'login', 'prefix' => 'admin', 'admin' => true] ); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'posts', 'action' => 'index', 'admin' => true, 'prefix' => 'admin' - ))->addPaths(array( + ])->addPaths([ 'base' => '/', 'here' => '/', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array('controller' => 'users', 'action' => 'login', 'admin' => true)); + $result = Router::url(['controller' => 'users', 'action' => 'login', 'admin' => true]); $this->assertEquals('/admin/login', $result); - $result = Router::url(array('controller' => 'users', 'action' => 'login')); + $result = Router::url(['controller' => 'users', 'action' => 'login']); $this->assertEquals('/admin/login', $result); - $result = Router::url(array('controller' => 'users', 'action' => 'admin_login')); + $result = Router::url(['controller' => 'users', 'action' => 'admin_login']); $this->assertEquals('/admin/login', $result); } @@ -2167,51 +2167,51 @@ public function testUrlWritingWithPrefixesAndCustomRoutes() { * @return void */ public function testPassedArgsOrder() { - Router::connect('/test-passed/*', array('controller' => 'pages', 'action' => 'display', 'home')); - Router::connect('/test2/*', array('controller' => 'pages', 'action' => 'display', 2)); - Router::connect('/test/*', array('controller' => 'pages', 'action' => 'display', 1)); + Router::connect('/test-passed/*', ['controller' => 'pages', 'action' => 'display', 'home']); + Router::connect('/test2/*', ['controller' => 'pages', 'action' => 'display', 2]); + Router::connect('/test/*', ['controller' => 'pages', 'action' => 'display', 1]); Router::parse('/'); - $result = Router::url(array('controller' => 'pages', 'action' => 'display', 1, 'whatever')); + $result = Router::url(['controller' => 'pages', 'action' => 'display', 1, 'whatever']); $expected = '/test/whatever'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'pages', 'action' => 'display', 2, 'whatever')); + $result = Router::url(['controller' => 'pages', 'action' => 'display', 2, 'whatever']); $expected = '/test2/whatever'; $this->assertEquals($expected, $result); - $result = Router::url(array('controller' => 'pages', 'action' => 'display', 'home', 'whatever')); + $result = Router::url(['controller' => 'pages', 'action' => 'display', 'home', 'whatever']); $expected = '/test-passed/whatever'; $this->assertEquals($expected, $result); - Configure::write('Routing.prefixes', array('admin')); + Configure::write('Routing.prefixes', ['admin']); Router::reload(); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'images', 'action' => 'index', - 'url' => array('url' => 'protected/images/index') - ))->addPaths(array( + 'url' => ['url' => 'protected/images/index'] + ])->addPaths([ 'base' => '', 'here' => '/protected/images/index', 'webroot' => '/', - )) + ]) ); - Router::connect('/protected/:controller/:action/*', array( + Router::connect('/protected/:controller/:action/*', [ 'controller' => 'users', 'action' => 'index', 'prefix' => 'protected' - )); + ]); Router::parse('/'); - $result = Router::url(array('controller' => 'images', 'action' => 'add')); + $result = Router::url(['controller' => 'images', 'action' => 'add']); $expected = '/protected/images/add'; $this->assertEquals($expected, $result); $result = Router::prefixes(); - $expected = array('admin', 'protected'); + $expected = ['admin', 'protected']; $this->assertEquals($expected, $result); } @@ -2221,39 +2221,39 @@ public function testPassedArgsOrder() { * @return void */ public function testRegexRouteMatching() { - Router::connect('/:locale/:controller/:action/*', array(), array('locale' => 'dan|eng')); + Router::connect('/:locale/:controller/:action/*', [], ['locale' => 'dan|eng']); $result = Router::parse('/eng/test/test_action'); - $expected = array('pass' => array(), 'named' => array(), 'locale' => 'eng', 'controller' => 'test', 'action' => 'test_action', 'plugin' => null); + $expected = ['pass' => [], 'named' => [], 'locale' => 'eng', 'controller' => 'test', 'action' => 'test_action', 'plugin' => null]; $this->assertEquals($expected, $result); $result = Router::parse('/badness/test/test_action'); - $this->assertSame(array(), $result); + $this->assertSame([], $result); Router::reload(); - Router::connect('/:locale/:controller/:action/*', array(), array('locale' => 'dan|eng')); + Router::connect('/:locale/:controller/:action/*', [], ['locale' => 'dan|eng']); $request = new CakeRequest(); Router::setRequestInfo( - $request->addParams(array( + $request->addParams([ 'plugin' => null, 'controller' => 'test', 'action' => 'index', - 'url' => array('url' => 'test/test_action') - ))->addPaths(array( + 'url' => ['url' => 'test/test_action'] + ])->addPaths([ 'base' => '', 'here' => '/test/test_action', 'webroot' => '/', - )) + ]) ); - $result = Router::url(array('action' => 'test_another_action')); + $result = Router::url(['action' => 'test_another_action']); $expected = '/test/test_another_action'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'test_another_action', 'locale' => 'eng')); + $result = Router::url(['action' => 'test_another_action', 'locale' => 'eng']); $expected = '/eng/test/test_another_action'; $this->assertEquals($expected, $result); - $result = Router::url(array('action' => 'test_another_action', 'locale' => 'badness')); + $result = Router::url(['action' => 'test_another_action', 'locale' => 'badness']); $expected = '/test/test_another_action/locale:badness'; $this->assertEquals($expected, $result); } @@ -2291,11 +2291,11 @@ public function testCurrentRouteWhenNonExistentRoute() { * @return void */ public function testCurrentRoute() { - $url = array('controller' => 'pages', 'action' => 'display', 'government'); + $url = ['controller' => 'pages', 'action' => 'display', 'government']; Router::connect('/government', $url); Router::parse('/government'); $route = Router::currentRoute(); - $this->assertEquals(array_merge($url, array('plugin' => null)), $route->defaults); + $this->assertEquals(array_merge($url, ['plugin' => null]), $route->defaults); } /** @@ -2304,23 +2304,23 @@ public function testCurrentRoute() { * @return void */ public function testRequestRoute() { - $url = array('controller' => 'products', 'action' => 'display', 5); + $url = ['controller' => 'products', 'action' => 'display', 5]; Router::connect('/government', $url); Router::parse('/government'); $route = Router::requestRoute(); - $this->assertEquals(array_merge($url, array('plugin' => null)), $route->defaults); + $this->assertEquals(array_merge($url, ['plugin' => null]), $route->defaults); // test that the first route is matched Router::connect('/government', $url); Router::parse('/government'); $route = Router::requestRoute(); - $this->assertEquals(array_merge($url, array('plugin' => null)), $route->defaults); + $this->assertEquals(array_merge($url, ['plugin' => null]), $route->defaults); // test that an unmatched route does not change the current route Router::connect('/actor', $url); Router::parse('/government'); $route = Router::requestRoute(); - $this->assertEquals(array_merge($url, array('plugin' => null)), $route->defaults); + $this->assertEquals(array_merge($url, ['plugin' => null]), $route->defaults); } /** @@ -2329,15 +2329,15 @@ public function testRequestRoute() { * @return void */ public function testGetParams() { - $paths = array('base' => '/', 'here' => '/products/display/5', 'webroot' => '/webroot'); - $params = array('param1' => '1', 'param2' => '2'); - Router::setRequestInfo(array($params, $paths)); + $paths = ['base' => '/', 'here' => '/products/display/5', 'webroot' => '/webroot']; + $params = ['param1' => '1', 'param2' => '2']; + Router::setRequestInfo([$params, $paths]); - $expected = array( + $expected = [ 'plugin' => null, 'controller' => false, 'action' => false, - 'named' => array(), 'pass' => array(), + 'named' => [], 'pass' => [], 'param1' => '1', 'param2' => '2', - ); + ]; $this->assertEquals($expected, Router::getParams()); $this->assertEquals(false, Router::getParam('controller')); $this->assertEquals('1', Router::getParam('param1')); @@ -2345,12 +2345,12 @@ public function testGetParams() { Router::reload(); - $params = array('controller' => 'pages', 'action' => 'display'); - Router::setRequestInfo(array($params, $paths)); - $expected = array( + $params = ['controller' => 'pages', 'action' => 'display']; + Router::setRequestInfo([$params, $paths]); + $expected = [ 'plugin' => null, 'controller' => 'pages', 'action' => 'display', - 'named' => array(), 'pass' => array(), - ); + 'named' => [], 'pass' => [], + ]; $this->assertEquals($expected, Router::getParams()); $this->assertEquals($expected, Router::getParams(true)); } @@ -2361,7 +2361,7 @@ public function testGetParams() { * @return void */ public function testDefaultsMethod() { - Router::connect('/test/*', array('controller' => 'pages', 'action' => 'display', 2)); + Router::connect('/test/*', ['controller' => 'pages', 'action' => 'display', 2]); $result = Router::parse('/posts/edit/5'); $this->assertFalse(isset($result['controller'])); $this->assertFalse(isset($result['action'])); @@ -2373,33 +2373,33 @@ public function testDefaultsMethod() { * @return void */ public function testConnectDefaultRoutes() { - App::build(array( - 'plugins' => array( + App::build([ + 'plugins' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'PluginJs')); + ] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'PluginJs']); Router::reload(); require CAKE . 'Config' . DS . 'routes.php'; - $result = Router::url(array('plugin' => 'plugin_js', 'controller' => 'js_file', 'action' => 'index')); + $result = Router::url(['plugin' => 'plugin_js', 'controller' => 'js_file', 'action' => 'index']); $this->assertEquals('/plugin_js/js_file', $result); $result = Router::parse('/plugin_js/js_file'); - $expected = array( + $expected = [ 'plugin' => 'plugin_js', 'controller' => 'js_file', 'action' => 'index', - 'named' => array(), 'pass' => array() - ); + 'named' => [], 'pass' => [] + ]; $this->assertEquals($expected, $result); - $result = Router::url(array('plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index')); + $result = Router::url(['plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index']); $this->assertEquals('/test_plugin', $result); $result = Router::parse('/test_plugin'); - $expected = array( + $expected = [ 'plugin' => 'test_plugin', 'controller' => 'test_plugin', 'action' => 'index', - 'named' => array(), 'pass' => array() - ); + 'named' => [], 'pass' => [] + ]; $this->assertEquals($expected, $result, 'Plugin shortcut route broken. %s'); } @@ -2410,14 +2410,14 @@ public function testConnectDefaultRoutes() { * @return void */ public function testUsingCustomRouteClass() { - $this->getMock('CakeRoute', array(), array(), 'MockConnectedRoute', false); + $this->getMock('CakeRoute', [], [], 'MockConnectedRoute', false); $routes = Router::connect( '/:slug', - array('controller' => 'posts', 'action' => 'view'), - array('routeClass' => 'MockConnectedRoute', 'slug' => '[a-z_-]+') + ['controller' => 'posts', 'action' => 'view'], + ['routeClass' => 'MockConnectedRoute', 'slug' => '[a-z_-]+'] ); $this->assertInstanceOf('MockConnectedRoute', $routes[0], 'Incorrect class used. %s'); - $expected = array('controller' => 'posts', 'action' => 'view', 'slug' => 'test'); + $expected = ['controller' => 'posts', 'action' => 'view', 'slug' => 'test']; $routes[0]->expects($this->any()) ->method('parse') ->will($this->returnValue($expected)); @@ -2431,17 +2431,17 @@ public function testUsingCustomRouteClass() { * @return void */ public function testUsingCustomRouteClassPluginDotSyntax() { - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ) - )); + ] + ]); CakePlugin::load('TestPlugin'); App::uses('TestRoute', 'TestPlugin.Routing/Route'); $routes = Router::connect( '/:slug', - array('controller' => 'posts', 'action' => 'view'), - array('routeClass' => 'TestPlugin.TestRoute', 'slug' => '[a-z_-]+') + ['controller' => 'posts', 'action' => 'view'], + ['routeClass' => 'TestPlugin.TestRoute', 'slug' => '[a-z_-]+'] ); $this->assertInstanceOf('TestRoute', $routes[0]); CakePlugin::unload('TestPlugin'); @@ -2454,7 +2454,7 @@ public function testUsingCustomRouteClassPluginDotSyntax() { */ public function testCustomRouteException() { $this->expectException(RouterException::class); - Router::connect('/:controller', array(), array('routeClass' => 'CakeObject')); + Router::connect('/:controller', [], ['routeClass' => 'CakeObject']); } /** @@ -2466,133 +2466,133 @@ public function testCustomRouteException() { */ public function testReverseToken() { Router::$initialized = true; - $params = array( + $params = [ 'controller' => 'posts', 'action' => 'view', - 'pass' => array(1), - 'named' => array(), - 'url' => array(), + 'pass' => [1], + 'named' => [], + 'url' => [], 'autoRender' => 1, 'bare' => 1, 'return' => 1, 'requested' => 1, - '_Token' => array('key' => 'sekret') - ); + '_Token' => ['key' => 'sekret'] + ]; $result = Router::reverse($params); $this->assertEquals('/posts/view/1', $result); } public function testReverseNamed() { - $params = array( + $params = [ 'controller' => 'posts', 'action' => 'index', - 'pass' => array(1), - 'named' => array('page' => 1, 'sort' => 'Article.title', 'direction' => 'desc'), - 'url' => array(), - ); + 'pass' => [1], + 'named' => ['page' => 1, 'sort' => 'Article.title', 'direction' => 'desc'], + 'url' => [], + ]; $result = Router::reverse($params); $this->assertEquals('/posts/index/1/page:1/sort:Article.title/direction:desc', $result); } public function testReverseLocalized() { - Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}')); - $params = array( + Router::connect('/:lang/:controller/:action/*', [], ['lang' => '[a-z]{3}']); + $params = [ 'lang' => 'eng', 'controller' => 'posts', 'action' => 'view', - 'pass' => array(1), - 'named' => array(), - 'url' => array('url' => 'eng/posts/view/1'), - ); + 'pass' => [1], + 'named' => [], + 'url' => ['url' => 'eng/posts/view/1'], + ]; $result = Router::reverse($params); $this->assertEquals('/eng/posts/view/1', $result); } public function testReverseArrayQuery() { - Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}')); - $params = array( + Router::connect('/:lang/:controller/:action/*', [], ['lang' => '[a-z]{3}']); + $params = [ 'lang' => 'eng', 'controller' => 'posts', 'action' => 'view', - 'pass' => array(1), - 'named' => array(), - 'url' => array('url' => 'eng/posts/view/1', 'foo' => 'bar', 'baz' => 'quu'), - 'paging' => array(), - 'models' => array(), - ); + 'pass' => [1], + 'named' => [], + 'url' => ['url' => 'eng/posts/view/1', 'foo' => 'bar', 'baz' => 'quu'], + 'paging' => [], + 'models' => [], + ]; $result = Router::reverse($params); $this->assertEquals('/eng/posts/view/1?foo=bar&baz=quu', $result); } public function testReverseCakeRequestQuery() { - Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}')); + Router::connect('/:lang/:controller/:action/*', [], ['lang' => '[a-z]{3}']); $request = new CakeRequest('/eng/posts/view/1'); - $request->addParams(array( + $request->addParams([ 'lang' => 'eng', 'controller' => 'posts', 'action' => 'view', - 'pass' => array(1), - 'named' => array(), - )); - $request->query = array('url' => 'eng/posts/view/1', 'test' => 'value'); + 'pass' => [1], + 'named' => [], + ]); + $request->query = ['url' => 'eng/posts/view/1', 'test' => 'value']; $result = Router::reverse($request); $expected = '/eng/posts/view/1?test=value'; $this->assertEquals($expected, $result); } public function testReverseFull() { - Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}')); - $params = array( + Router::connect('/:lang/:controller/:action/*', [], ['lang' => '[a-z]{3}']); + $params = [ 'lang' => 'eng', 'controller' => 'posts', 'action' => 'view', - 'pass' => array(1), - 'named' => array(), - 'url' => array('url' => 'eng/posts/view/1'), - ); + 'pass' => [1], + 'named' => [], + 'url' => ['url' => 'eng/posts/view/1'], + ]; $result = Router::reverse($params, true); $this->assertMatchesRegularExpression('/^http(s)?:\/\//', $result); } public function testReverseToArrayNamed() { - $params = array( + $params = [ 'controller' => 'posts', 'action' => 'index', - 'pass' => array(123), - 'named' => array('page' => 123, 'sort' => 'Article.title', 'direction' => 'desc'), - 'url' => array(), - ); + 'pass' => [123], + 'named' => ['page' => 123, 'sort' => 'Article.title', 'direction' => 'desc'], + 'url' => [], + ]; $result = Router::reverseToArray($params); - $expected = array( + $expected = [ 'controller' => 'posts', 'action' => 'index', 123, 'page' => 123, 'sort' => 'Article.title', 'direction' => 'desc', - ); + ]; $this->assertEquals($expected, $result); } public function testReverseToArrayCakeRequestQuery() { $request = new CakeRequest('/posts/view/123'); - $request->addParams(array( + $request->addParams([ 'controller' => 'posts', 'action' => 'view', - 'pass' => array(123), - 'named' => array(), - )); - $request->query = array('url' => 'eng/posts/view/123', 'test' => 'value'); + 'pass' => [123], + 'named' => [], + ]); + $request->query = ['url' => 'eng/posts/view/123', 'test' => 'value']; $result = Router::reverseToArray($request); - $expected = array( + $expected = [ 'plugin' => null, 'controller' => 'posts', 'action' => 'view', 123, - '?' => array( + '?' => [ 'test' => 'value', - ), - ); + ], + ]; $this->assertEquals($expected, $result); } @@ -2605,14 +2605,14 @@ public function testReverseWithExtension() { Router::parseExtensions('json'); $request = new CakeRequest('/posts/view/1.json'); - $request->addParams(array( + $request->addParams([ 'controller' => 'posts', 'action' => 'view', - 'pass' => array(1), - 'named' => array(), + 'pass' => [1], + 'named' => [], 'ext' => 'json', - )); - $request->query = array(); + ]); + $request->query = []; $result = Router::reverse($request); $expected = '/posts/view/1.json'; $this->assertEquals($expected, $result); @@ -2624,17 +2624,17 @@ public function testReverseWithExtension() { * @return void */ public function testSetRequestInfoLegacy() { - Router::setRequestInfo(array( - array( + Router::setRequestInfo([ + [ 'plugin' => null, 'controller' => 'images', 'action' => 'index', - 'url' => array('url' => 'protected/images/index') - ), - array( + 'url' => ['url' => 'protected/images/index'] + ], + [ 'base' => '', 'here' => '/protected/images/index', 'webroot' => '/', - ) - )); + ] + ]); $result = Router::getRequest(); $this->assertEquals('images', $result->controller); $this->assertEquals('index', $result->action); @@ -2650,28 +2650,28 @@ public function testSetRequestInfoLegacy() { */ public function testUrlWithRequestAction() { $firstRequest = new CakeRequest('/posts/index'); - $firstRequest->addParams(array( + $firstRequest->addParams([ 'plugin' => null, 'controller' => 'posts', 'action' => 'index' - ))->addPaths(array('base' => '')); + ])->addPaths(['base' => '']); $secondRequest = new CakeRequest('/posts/index'); - $secondRequest->addParams(array( + $secondRequest->addParams([ 'requested' => 1, 'plugin' => null, 'controller' => 'comments', 'action' => 'listing' - ))->addPaths(array('base' => '')); + ])->addPaths(['base' => '']); Router::setRequestInfo($firstRequest); Router::setRequestInfo($secondRequest); - $result = Router::url(array('base' => false)); + $result = Router::url(['base' => false]); $this->assertEquals('/comments/listing', $result, 'with second requests, the last should win.'); Router::popRequest(); - $result = Router::url(array('base' => false)); + $result = Router::url(['base' => false]); $this->assertEquals('/posts', $result, 'with second requests, the last should win.'); } @@ -2683,12 +2683,12 @@ public function testUrlWithRequestAction() { public function testUrlFullUrlReturnFromRoute() { $url = 'http://example.com/posts/view/1'; - $this->getMock('CakeRoute', array(), array('/'), 'MockReturnRoute'); - $routes = Router::connect('/:controller/:action', array(), array('routeClass' => 'MockReturnRoute')); + $this->getMock('CakeRoute', [], ['/'], 'MockReturnRoute'); + $routes = Router::connect('/:controller/:action', [], ['routeClass' => 'MockReturnRoute']); $routes[0]->expects($this->any())->method('match') ->will($this->returnValue($url)); - $result = Router::url(array('controller' => 'posts', 'action' => 'view', 1)); + $result = Router::url(['controller' => 'posts', 'action' => 'view', 1]); $this->assertEquals($url, $result); } @@ -2741,17 +2741,17 @@ public function testUrlProtocol() { public function testPatternOnAction() { $route = new CakeRoute( '/blog/:action/*', - array('controller' => 'blog_posts'), - array('action' => 'other|actions') + ['controller' => 'blog_posts'], + ['action' => 'other|actions'] ); - $result = $route->match(array('controller' => 'blog_posts', 'action' => 'foo')); + $result = $route->match(['controller' => 'blog_posts', 'action' => 'foo']); $this->assertFalse($result); - $result = $route->match(array('controller' => 'blog_posts', 'action' => 'actions')); + $result = $route->match(['controller' => 'blog_posts', 'action' => 'actions']); $this->assertEquals('/blog/actions/', $result); $result = $route->parse('/blog/other'); - $expected = array('controller' => 'blog_posts', 'action' => 'other', 'pass' => array(), 'named' => array()); + $expected = ['controller' => 'blog_posts', 'action' => 'other', 'pass' => [], 'named' => []]; $this->assertEquals($expected, $result); $result = $route->parse('/blog/foobar'); @@ -2765,24 +2765,24 @@ public function testPatternOnAction() { */ public function testResourceMap() { $default = Router::resourceMap(); - $expected = array( - array('action' => 'index', 'method' => 'GET', 'id' => false), - array('action' => 'view', 'method' => 'GET', 'id' => true), - array('action' => 'add', 'method' => 'POST', 'id' => false), - array('action' => 'edit', 'method' => 'PUT', 'id' => true), - array('action' => 'delete', 'method' => 'DELETE', 'id' => true), - array('action' => 'edit', 'method' => 'POST', 'id' => true) - ); + $expected = [ + ['action' => 'index', 'method' => 'GET', 'id' => false], + ['action' => 'view', 'method' => 'GET', 'id' => true], + ['action' => 'add', 'method' => 'POST', 'id' => false], + ['action' => 'edit', 'method' => 'PUT', 'id' => true], + ['action' => 'delete', 'method' => 'DELETE', 'id' => true], + ['action' => 'edit', 'method' => 'POST', 'id' => true] + ]; $this->assertEquals($expected, $default); - $custom = array( - array('action' => 'index', 'method' => 'GET', 'id' => false), - array('action' => 'view', 'method' => 'GET', 'id' => true), - array('action' => 'add', 'method' => 'POST', 'id' => false), - array('action' => 'edit', 'method' => 'PUT', 'id' => true), - array('action' => 'delete', 'method' => 'DELETE', 'id' => true), - array('action' => 'update', 'method' => 'POST', 'id' => true) - ); + $custom = [ + ['action' => 'index', 'method' => 'GET', 'id' => false], + ['action' => 'view', 'method' => 'GET', 'id' => true], + ['action' => 'add', 'method' => 'POST', 'id' => false], + ['action' => 'edit', 'method' => 'PUT', 'id' => true], + ['action' => 'delete', 'method' => 'DELETE', 'id' => true], + ['action' => 'update', 'method' => 'POST', 'id' => true] + ]; Router::resourceMap($custom); $this->assertEquals(Router::resourceMap(), $custom); @@ -2795,9 +2795,9 @@ public function testResourceMap() { * @return void */ public function testRouteRedirection() { - Router::redirect('/blog', array('controller' => 'posts'), array('status' => 302)); + Router::redirect('/blog', ['controller' => 'posts'], ['status' => 302]); $this->assertEquals(1, count(Router::$routes)); - Router::$routes[0]->response = $this->getMock('CakeResponse', array('_sendHeader')); + Router::$routes[0]->response = $this->getMock('CakeResponse', ['_sendHeader']); Router::$routes[0]->stop = false; $this->assertEquals(302, Router::$routes[0]->options['status']); @@ -2806,9 +2806,9 @@ public function testRouteRedirection() { $this->assertEquals(Router::url('/posts', true), $header['Location']); $this->assertEquals(302, Router::$routes[0]->response->statusCode()); - Router::$routes[0]->response = $this->getMock('CakeResponse', array('_sendHeader')); + Router::$routes[0]->response = $this->getMock('CakeResponse', ['_sendHeader']); Router::parse('/not-a-match'); - $this->assertEquals(array(), Router::$routes[0]->response->header()); + $this->assertEquals([], Router::$routes[0]->response->header()); } /** @@ -2817,10 +2817,10 @@ public function testRouteRedirection() { * @return void */ public function testDefaultRouteClass() { - $this->getMock('CakeRoute', array(), array('/test'), 'TestDefaultRouteClass'); + $this->getMock('CakeRoute', [], ['/test'], 'TestDefaultRouteClass'); Router::defaultRouteClass('TestDefaultRouteClass'); - $result = Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home')); + $result = Router::connect('/', ['controller' => 'pages', 'action' => 'display', 'home']); $this->assertInstanceOf('TestDefaultRouteClass', $result[0]); } @@ -2845,7 +2845,7 @@ public function testDefaultRouteClassGetter() { public function testDefaultRouteException() { $this->expectException(RouterException::class); Router::defaultRouteClass(''); - Router::connect('/:controller', array()); + Router::connect('/:controller', []); } /** @@ -2874,26 +2874,26 @@ public function testSettingNonExistentDefaultRouteException() { * @return void */ public function testQueryString() { - $result = Router::queryString(array('var' => 'foo bar')); + $result = Router::queryString(['var' => 'foo bar']); $expected = '?var=foo+bar'; $this->assertEquals($expected, $result); - $result = Router::queryString(false, array('some' => 'param', 'foo' => 'bar')); + $result = Router::queryString(false, ['some' => 'param', 'foo' => 'bar']); $expected = '?some=param&foo=bar'; $this->assertEquals($expected, $result); - $existing = array('apple' => 'red', 'pear' => 'green'); - $result = Router::queryString($existing, array('some' => 'param', 'foo' => 'bar')); + $existing = ['apple' => 'red', 'pear' => 'green']; + $result = Router::queryString($existing, ['some' => 'param', 'foo' => 'bar']); $expected = '?apple=red&pear=green&some=param&foo=bar'; $this->assertEquals($expected, $result); $existing = 'apple=red&pear=green'; - $result = Router::queryString($existing, array('some' => 'param', 'foo' => 'bar')); + $result = Router::queryString($existing, ['some' => 'param', 'foo' => 'bar']); $expected = '?apple=red&pear=green&some=param&foo=bar'; $this->assertEquals($expected, $result); $existing = '?apple=red&pear=green'; - $result = Router::queryString($existing, array('some' => 'param', 'foo' => 'bar')); + $result = Router::queryString($existing, ['some' => 'param', 'foo' => 'bar']); $expected = '?apple=red&pear=green&some=param&foo=bar'; $this->assertEquals($expected, $result); @@ -2901,15 +2901,15 @@ public function testQueryString() { $expected = '?apple=red&pear=green'; $this->assertEquals($expected, $result); - $result = Router::queryString('foo=bar', array('php' => 'nut', 'jose' => 'zap'), true); + $result = Router::queryString('foo=bar', ['php' => 'nut', 'jose' => 'zap'], true); $expected = '?foo=bar&php=nut&jose=zap'; $this->assertEquals($expected, $result); - $result = Router::queryString('foo=bar&', array('php' => 'nut', 'jose' => 'zap'), true); + $result = Router::queryString('foo=bar&', ['php' => 'nut', 'jose' => 'zap'], true); $expected = '?foo=bar&php=nut&jose=zap'; $this->assertEquals($expected, $result); - $result = Router::queryString('foo=bar&', array('php' => 'nut', 'jose' => 'zap')); + $result = Router::queryString('foo=bar&', ['php' => 'nut', 'jose' => 'zap']); $expected = '?foo=bar&php=nut&jose=zap'; $this->assertEquals($expected, $result); } diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php index 3319333618..56c7d3e9a5 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestCaseTest.php @@ -67,7 +67,7 @@ class CakeTestCaseTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.post', 'core.author', 'core.test_plugin_comment'); + public $fixtures = ['core.post', 'core.author', 'core.test_plugin_comment']; /** * CakeTestCaseTest::setUpBeforeClass() @@ -109,47 +109,47 @@ public function testAssertTagsBasic() { */ public function testAssertTagsQuoting() { $input = 'My link'; - $pattern = array( - 'a' => array('href' => '/test.html', 'class' => 'active'), + $pattern = [ + 'a' => ['href' => '/test.html', 'class' => 'active'], 'My link', '/a' - ); + ]; $this->assertTags($input, $pattern); $input = "My link"; - $pattern = array( - 'a' => array('href' => '/test.html', 'class' => 'active'), + $pattern = [ + 'a' => ['href' => '/test.html', 'class' => 'active'], 'My link', '/a' - ); + ]; $this->assertTags($input, $pattern); $input = "My link"; - $pattern = array( - 'a' => array('href' => 'preg:/.*\.html/', 'class' => 'active'), + $pattern = [ + 'a' => ['href' => 'preg:/.*\.html/', 'class' => 'active'], 'My link', '/a' - ); + ]; $this->assertTags($input, $pattern); $input = "Text"; - $pattern = array( + $pattern = [ 'assertTags($input, $pattern); $input = "Text"; - $pattern = array( - 'span' => array('class'), + $pattern = [ + 'span' => ['class'], 'assertTags($input, $pattern); } @@ -159,8 +159,8 @@ public function testAssertTagsQuoting() { * @return void */ public function testAssertTagsRuntimeComplexity() { - $pattern = array( - 'div' => array( + $pattern = [ + 'div' => [ 'attr1' => 'val1', 'attr2' => 'val2', 'attr3' => 'val3', @@ -169,10 +169,10 @@ public function testAssertTagsRuntimeComplexity() { 'attr6' => 'val6', 'attr7' => 'val7', 'attr8' => 'val8', - ), + ], 'My div', '/div' - ); + ]; $input = '
' . 'My div' . @@ -401,21 +401,21 @@ public function testAssertTextNotContains() { * @return void */ public function testGetMockForModel() { - App::build(array( - 'Model' => array( + App::build([ + 'Model' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS - ) - ), App::RESET); + ] + ], App::RESET); $Post = $this->getMockForModel('Post'); $this->assertEquals('test', $Post->useDbConfig); $this->assertInstanceOf('Post', $Post); - $this->assertNull($Post->save(array())); + $this->assertNull($Post->save([])); $this->assertNull($Post->find('all')); $this->assertEquals('posts', $Post->useTable); - $Post = $this->getMockForModel('Post', array('save')); + $Post = $this->getMockForModel('Post', ['save']); - $this->assertNull($Post->save(array())); + $this->assertNull($Post->save([])); $this->assertIsArray($Post->find('all')); } @@ -425,18 +425,18 @@ public function testGetMockForModel() { * @return void */ public function testGetMockForModelSecondaryDatasource() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Model/Datasource/Database' => array( + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Model/Datasource/Database' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS . 'Datasource' . DS . 'Database' . DS - ) - ), App::RESET); + ] + ], App::RESET); CakePlugin::load('TestPlugin'); - ConnectionManager::create('test_secondary', array( + ConnectionManager::create('test_secondary', [ 'datasource' => 'Database/TestLocalDriver', 'prefix' => '' - )); - $post = $this->getMockForModel('SecondaryPost', array('save')); + ]); + $post = $this->getMockForModel('SecondaryPost', ['save']); $this->assertEquals('test_secondary', $post->useDbConfig); ConnectionManager::drop('test_secondary'); } @@ -447,7 +447,7 @@ public function testGetMockForModelSecondaryDatasource() { * @return void */ public function testGetMockForModelConstructorDatasource() { - $post = $this->getMockForModel('ConstructorPost', array('save'), array('ds' => 'test')); + $post = $this->getMockForModel('ConstructorPost', ['save'], ['ds' => 'test']); $this->assertEquals('test', $post->useDbConfig); } @@ -457,11 +457,11 @@ public function testGetMockForModelConstructorDatasource() { * @return void */ public function testGetMockForModelWithPlugin() { - App::build(array( - 'Plugin' => array( + App::build([ + 'Plugin' => [ CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS - ) - ), App::RESET); + ] + ], App::RESET); CakePlugin::load('TestPlugin'); $this->getMockForModel('TestPlugin.TestPluginAppModel'); $this->getMockForModel('TestPlugin.TestPluginComment'); @@ -470,7 +470,7 @@ public function testGetMockForModelWithPlugin() { $this->assertInstanceOf('TestPluginComment', $result); $this->assertEquals('test', $result->useDbConfig); - $TestPluginComment = $this->getMockForModel('TestPlugin.TestPluginComment', array('save')); + $TestPluginComment = $this->getMockForModel('TestPlugin.TestPluginComment', ['save']); $this->assertInstanceOf('TestPluginComment', $TestPluginComment); $TestPluginComment->expects($this->at(0)) @@ -479,8 +479,8 @@ public function testGetMockForModelWithPlugin() { $TestPluginComment->expects($this->at(1)) ->method('save') ->will($this->returnValue(false)); - $this->assertTrue($TestPluginComment->save(array())); - $this->assertFalse($TestPluginComment->save(array())); + $this->assertTrue($TestPluginComment->save([])); + $this->assertFalse($TestPluginComment->save([])); } /** @@ -489,7 +489,7 @@ public function testGetMockForModelWithPlugin() { * @return void */ public function testGetMockForModelModel() { - $Mock = $this->getMockForModel('Model', array('save', 'setDataSource'), array('name' => 'Comment')); + $Mock = $this->getMockForModel('Model', ['save', 'setDataSource'], ['name' => 'Comment']); $result = ClassRegistry::init('Comment'); $this->assertInstanceOf('Model', $result); @@ -501,8 +501,8 @@ public function testGetMockForModelModel() { ->method('save') ->will($this->returnValue(false)); - $this->assertTrue($Mock->save(array())); - $this->assertFalse($Mock->save(array())); + $this->assertTrue($Mock->save([])); + $this->assertFalse($Mock->save([])); } /** diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php index e501b50ac2..9ac5561cf3 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestFixtureTest.php @@ -46,22 +46,22 @@ class CakeTestFixtureTestFixture extends CakeTestFixture { * * @var array */ - public $fields = array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'name' => array('type' => 'string', 'length' => '255'), - 'created' => array('type' => 'datetime') - ); + public $fields = [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'name' => ['type' => 'string', 'length' => '255'], + 'created' => ['type' => 'datetime'] + ]; /** * Records property * * @var array */ - public $records = array( - array('name' => 'Gandalf', 'created' => '2009-04-28 19:20:00'), - array('name' => 'Captain Picard', 'created' => '2009-04-28 19:20:00'), - array('name' => 'Chewbacca', 'created' => '2009-04-28 19:20:00') - ); + public $records = [ + ['name' => 'Gandalf', 'created' => '2009-04-28 19:20:00'], + ['name' => 'Captain Picard', 'created' => '2009-04-28 19:20:00'], + ['name' => 'Chewbacca', 'created' => '2009-04-28 19:20:00'] + ]; } /** @@ -90,23 +90,23 @@ class StringsTestFixture extends CakeTestFixture { * * @var array */ - public $fields = array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'name' => array('type' => 'string', 'length' => '255'), - 'email' => array('type' => 'string', 'length' => '255'), - 'age' => array('type' => 'integer', 'default' => 10) - ); + public $fields = [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'name' => ['type' => 'string', 'length' => '255'], + 'email' => ['type' => 'string', 'length' => '255'], + 'age' => ['type' => 'integer', 'default' => 10] + ]; /** * Records property * * @var array */ - public $records = array( - array('name' => 'Mark Doe', 'email' => 'mark.doe@email.com'), - array('name' => 'John Doe', 'email' => 'john.doe@email.com', 'age' => 20), - array('email' => 'jane.doe@email.com', 'name' => 'Jane Doe', 'age' => 30) - ); + public $records = [ + ['name' => 'Mark Doe', 'email' => 'mark.doe@email.com'], + ['name' => 'John Doe', 'email' => 'john.doe@email.com', 'age' => 20], + ['email' => 'jane.doe@email.com', 'name' => 'Jane Doe', 'age' => 30] + ]; } /** @@ -135,22 +135,22 @@ class InvalidTestFixture extends CakeTestFixture { * * @var array */ - public $fields = array( - 'id' => array('type' => 'integer', 'key' => 'primary'), - 'name' => array('type' => 'string', 'length' => '255'), - 'age' => array('type' => 'integer', 'default' => 10) - ); + public $fields = [ + 'id' => ['type' => 'integer', 'key' => 'primary'], + 'name' => ['type' => 'string', 'length' => '255'], + 'age' => ['type' => 'integer', 'default' => 10] + ]; /** * Records property * * @var array */ - public $records = array( - array('name' => 'Mark Doe', 'email' => 'mark.doe@email.com'), - array('name' => 'John Doe', 'email' => 'john.doe@email.com', 'age' => 20), - array('email' => 'jane.doe@email.com', 'name' => 'Jane Doe', 'age' => 30) - ); + public $records = [ + ['name' => 'Mark Doe', 'email' => 'mark.doe@email.com'], + ['name' => 'John Doe', 'email' => 'john.doe@email.com', 'age' => 20], + ['email' => 'jane.doe@email.com', 'name' => 'Jane Doe', 'age' => 30] + ]; } /** @@ -172,7 +172,7 @@ class CakeTestFixtureImportFixture extends CakeTestFixture { * * @var mixed */ - public $import = array('table' => 'fixture_tests', 'connection' => 'fixture_test_suite'); + public $import = ['table' => 'fixture_tests', 'connection' => 'fixture_test_suite']; } /** @@ -230,7 +230,7 @@ class CakeTestFixtureTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - $methods = array_diff(get_class_methods('DboSource'), array('enabled')); + $methods = array_diff(get_class_methods('DboSource'), ['enabled']); $this->criticDb = $this->getMock('DboSource', $methods); $this->criticDb->fullDebug = true; @@ -282,7 +282,7 @@ public function testInitDbPrefix() { $Source->insert($db); $Fixture = new CakeTestFixtureTestFixture(); - $expected = array('id', 'name', 'created'); + $expected = ['id', 'name', 'created']; $this->assertEquals($expected, array_keys($Fixture->fields)); $config = $db->config; @@ -290,16 +290,16 @@ public function testInitDbPrefix() { ConnectionManager::create('fixture_test_suite', $config); $Fixture->fields = $Fixture->records = null; - $Fixture->import = array('table' => 'fixture_tests', 'connection' => 'test', 'records' => true); + $Fixture->import = ['table' => 'fixture_tests', 'connection' => 'test', 'records' => true]; $Fixture->init(); $this->assertEquals(count($Fixture->records), count($Source->records)); $Fixture->create(ConnectionManager::getDataSource('fixture_test_suite')); $Fixture = new CakeTestFixtureImportFixture(); $Fixture->fields = $Fixture->records = $Fixture->table = null; - $Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test'); + $Fixture->import = ['model' => 'FixtureImportTestModel', 'connection' => 'test']; $Fixture->init(); - $this->assertEquals(array('id', 'name', 'created'), array_keys($Fixture->fields)); + $this->assertEquals(['id', 'name', 'created'], array_keys($Fixture->fields)); $this->assertEquals('fixture_tests', $Fixture->table); $keys = array_flip(ClassRegistry::keys()); @@ -329,10 +329,10 @@ public function testInitDbPrefixDuplication() { $Fixture = new CakeTestFixtureImportFixture(); $Fixture->fields = $Fixture->records = $Fixture->table = null; - $Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'test'); + $Fixture->import = ['model' => 'FixtureImportTestModel', 'connection' => 'test']; $Fixture->init(); - $this->assertEquals(array('id', 'name', 'created'), array_keys($Fixture->fields)); + $this->assertEquals(['id', 'name', 'created'], array_keys($Fixture->fields)); $this->assertEquals('fixture_tests', $Fixture->table); $Source->drop($db); @@ -355,7 +355,7 @@ public function testInitModelTablePrefix() { $Fixture = new CakeTestFixtureTestFixture(); unset($Fixture->table); $Fixture->fields = $Fixture->records = null; - $Fixture->import = array('model' => 'FixturePrefixTest', 'connection' => 'test', 'records' => false); + $Fixture->import = ['model' => 'FixturePrefixTest', 'connection' => 'test', 'records' => false]; $Fixture->init(); $this->assertEquals('fixture_tests', $Fixture->table); @@ -373,7 +373,7 @@ public function testInitModelTablePrefix() { public function testImport() { $testSuiteDb = ConnectionManager::getDataSource('test'); $testSuiteConfig = $testSuiteDb->config; - ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix']))); + ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, ['prefix' => 'new_' . $testSuiteConfig['prefix']])); $newTestSuiteDb = ConnectionManager::getDataSource('new_test_suite'); $Source = new CakeTestFixtureTestFixture(); @@ -382,9 +382,9 @@ public function testImport() { $Fixture = new CakeTestFixtureDefaultImportFixture(); $Fixture->fields = $Fixture->records = null; - $Fixture->import = array('model' => 'FixtureImportTestModel', 'connection' => 'new_test_suite'); + $Fixture->import = ['model' => 'FixtureImportTestModel', 'connection' => 'new_test_suite']; $Fixture->init(); - $this->assertEquals(array('id', 'name', 'created'), array_keys($Fixture->fields)); + $this->assertEquals(['id', 'name', 'created'], array_keys($Fixture->fields)); $keys = array_flip(ClassRegistry::keys()); $this->assertFalse(array_key_exists('fixtureimporttestmodel', $keys)); @@ -401,7 +401,7 @@ public function testImport() { public function testImportWithRecords() { $testSuiteDb = ConnectionManager::getDataSource('test'); $testSuiteConfig = $testSuiteDb->config; - ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, array('prefix' => 'new_' . $testSuiteConfig['prefix']))); + ConnectionManager::create('new_test_suite', array_merge($testSuiteConfig, ['prefix' => 'new_' . $testSuiteConfig['prefix']])); $newTestSuiteDb = ConnectionManager::getDataSource('new_test_suite'); $Source = new CakeTestFixtureTestFixture(); @@ -410,11 +410,11 @@ public function testImportWithRecords() { $Fixture = new CakeTestFixtureDefaultImportFixture(); $Fixture->fields = $Fixture->records = null; - $Fixture->import = array( + $Fixture->import = [ 'model' => 'FixtureImportTestModel', 'connection' => 'new_test_suite', 'records' => true - ); + ]; $Fixture->init(); - $this->assertEquals(array('id', 'name', 'created'), array_keys($Fixture->fields)); + $this->assertEquals(['id', 'name', 'created'], array_keys($Fixture->fields)); $this->assertFalse(empty($Fixture->records[0]), 'No records loaded on importing fixture.'); $this->assertTrue(isset($Fixture->records[0]['name']), 'No name loaded for first record'); @@ -448,19 +448,19 @@ public function testInsert() { $Fixture = new CakeTestFixtureTestFixture(); $this->criticDb->expects($this->atLeastOnce()) ->method('insertMulti') - ->will($this->returnCallback(array($this, 'insertCallback'))); + ->will($this->returnCallback([$this, 'insertCallback'])); $return = $Fixture->insert($this->criticDb); $this->assertTrue(!empty($this->insertMulti)); $this->assertTrue($this->criticDb->fullDebug); $this->assertTrue($return); $this->assertEquals('fixture_tests', $this->insertMulti['table']); - $this->assertEquals(array('name', 'created'), $this->insertMulti['fields']); - $expected = array( - array('Gandalf', '2009-04-28 19:20:00'), - array('Captain Picard', '2009-04-28 19:20:00'), - array('Chewbacca', '2009-04-28 19:20:00') - ); + $this->assertEquals(['name', 'created'], $this->insertMulti['fields']); + $expected = [ + ['Gandalf', '2009-04-28 19:20:00'], + ['Captain Picard', '2009-04-28 19:20:00'], + ['Chewbacca', '2009-04-28 19:20:00'] + ]; $this->assertEquals($expected, $this->insertMulti['values']); } @@ -476,7 +476,7 @@ public function insertCallback($table, $fields, $values) { $this->insertMulti['table'] = $table; $this->insertMulti['fields'] = $fields; $this->insertMulti['values'] = $values; - $this->insertMulti['fields_values'] = array(); + $this->insertMulti['fields_values'] = []; foreach ($values as $record) { $this->insertMulti['fields_values'][] = array_combine($fields, $record); } @@ -492,36 +492,36 @@ public function testInsertStrings() { $Fixture = new StringsTestFixture(); $this->criticDb->expects($this->atLeastOnce()) ->method('insertMulti') - ->will($this->returnCallback(array($this, 'insertCallback'))); + ->will($this->returnCallback([$this, 'insertCallback'])); $return = $Fixture->insert($this->criticDb); $this->assertTrue($this->criticDb->fullDebug); $this->assertTrue($return); $this->assertEquals('strings', $this->insertMulti['table']); - $this->assertEquals(array('name', 'email', 'age'), array_values($this->insertMulti['fields'])); - $expected = array( - array('Mark Doe', 'mark.doe@email.com', null), - array('John Doe', 'john.doe@email.com', 20), - array('Jane Doe', 'jane.doe@email.com', 30), - ); + $this->assertEquals(['name', 'email', 'age'], array_values($this->insertMulti['fields'])); + $expected = [ + ['Mark Doe', 'mark.doe@email.com', null], + ['John Doe', 'john.doe@email.com', 20], + ['Jane Doe', 'jane.doe@email.com', 30], + ]; $this->assertEquals($expected, $this->insertMulti['values']); - $expected = array( - array( + $expected = [ + [ 'name' => 'Mark Doe', 'email' => 'mark.doe@email.com', 'age' => null - ), - array( + ], + [ 'name' => 'John Doe', 'email' => 'john.doe@email.com', 'age' => 20 - ), - array( + ], + [ 'name' => 'Jane Doe', 'email' => 'jane.doe@email.com', 'age' => 30 - ), - ); + ], + ]; $this->assertEquals($expected, $this->insertMulti['fields_values']); } diff --git a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php index 0843945705..d235b7a570 100644 --- a/lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php +++ b/lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php @@ -30,7 +30,7 @@ public function testAddTestDirectory() { $testFolder = CORE_TEST_CASES . DS . 'TestSuite'; $count = count(glob($testFolder . DS . '*Test.php')); - $suite = $this->getMock('CakeTestSuite', array('addTestFile')); + $suite = $this->getMock('CakeTestSuite', ['addTestFile']); $suite ->expects($this->exactly($count)) ->method('addTestFile'); @@ -48,7 +48,7 @@ public function testAddTestDirectoryRecursive() { $count = count(glob($testFolder . DS . '*Test.php')); $count += count(glob($testFolder . DS . 'Engine' . DS . '*Test.php')); - $suite = $this->getMock('CakeTestSuite', array('addTestFile')); + $suite = $this->getMock('CakeTestSuite', ['addTestFile']); $suite ->expects($this->exactly($count)) ->method('addTestFile'); @@ -70,7 +70,7 @@ public function testAddTestDirectoryRecursiveWithHidden() { touch($Folder->path . DS . 'NotHiddenTest.php'); touch($Folder->path . DS . '.HiddenTest.php'); - $suite = $this->getMock('CakeTestSuite', array('addTestFile')); + $suite = $this->getMock('CakeTestSuite', ['addTestFile']); $suite ->expects($this->exactly(1)) ->method('addTestFile'); @@ -93,7 +93,7 @@ public function testAddTestDirectoryRecursiveWithNonPhp() { touch($Folder->path . DS . 'SomeNotesTest.txt'); touch($Folder->path . DS . 'NotHiddenTest.php'); - $suite = $this->getMock('CakeTestSuite', array('addTestFile')); + $suite = $this->getMock('CakeTestSuite', ['addTestFile']); $suite ->expects($this->exactly(1)) ->method('addTestFile'); diff --git a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php index a0a7f57e97..497663ca24 100644 --- a/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php +++ b/lib/Cake/Test/Case/TestSuite/ControllerTestCaseTest.php @@ -23,7 +23,7 @@ App::uses('AppModel', 'Model'); App::uses('CakeHtmlReporter', 'TestSuite/Reporter'); -require_once dirname(dirname(__FILE__)) . DS . 'Model' . DS . 'models.php'; +require_once dirname(__FILE__, 2) . DS . 'Model' . DS . 'models.php'; if (!class_exists('AppController', false)) { /** @@ -38,21 +38,21 @@ class AppController extends Controller { * * @var array */ - public $helpers = array('Html'); + public $helpers = ['Html']; /** * uses property * * @var array */ - public $uses = array('ControllerPost'); + public $uses = ['ControllerPost']; /** * components property * * @var array */ - public $components = array('Cookie'); + public $components = ['Cookie']; } } elseif (!defined('APP_CONTROLLER_EXISTS')) { @@ -76,17 +76,17 @@ class PostsController extends AppController { * * @var array */ - public $components = array( + public $components = [ 'RequestHandler', 'Email', - 'AliasedEmail' => array( + 'AliasedEmail' => [ 'className' => 'Email', - ), - 'AliasedPluginEmail' => array( + ], + 'AliasedPluginEmail' => [ 'className' => 'TestPlugin.TestPluginEmail', - ), + ], 'Auth' - ); + ]; } } @@ -102,7 +102,7 @@ class ControllerTestCaseTestController extends AppController { * * @param array */ - public $uses = array('TestPlugin.TestPluginComment'); + public $uses = ['TestPlugin.TestPluginComment']; } @@ -118,7 +118,7 @@ class ControllerTestCaseTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.post', 'core.author', 'core.test_plugin_comment'); + public $fixtures = ['core.post', 'core.author', 'core.test_plugin_comment']; /** * reset environment. @@ -127,13 +127,13 @@ class ControllerTestCaseTest extends CakeTestCase { */ public function setUp() : void { parent::setUp(); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS), - 'Controller' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS), - 'Model' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS), - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin', 'TestPluginTwo')); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS], + 'Controller' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS], + 'Model' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS], + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin', 'TestPluginTwo']); $this->Case = $this->getMockForAbstractClass('ControllerTestCase'); Router::reload(); } @@ -163,48 +163,48 @@ public function testGenerate() { $this->assertEquals('Post', $Posts->modelClass); $this->assertNull($Posts->response->send()); - $Posts = $this->Case->generate('Posts', array( - 'methods' => array( + $Posts = $this->Case->generate('Posts', [ + 'methods' => [ 'render' - ) - )); + ] + ]); $this->assertNull($Posts->render('index')); - $Posts = $this->Case->generate('Posts', array( - 'models' => array('Post'), - 'components' => array('RequestHandler') - )); + $Posts = $this->Case->generate('Posts', [ + 'models' => ['Post'], + 'components' => ['RequestHandler'] + ]); $this->assertInstanceOf('Post', $Posts->Post); - $this->assertNull($Posts->Post->save(array())); + $this->assertNull($Posts->Post->save([])); $this->assertNull($Posts->Post->find('all')); $this->assertEquals('posts', $Posts->Post->useTable); $this->assertNull($Posts->RequestHandler->isAjax()); - $Posts = $this->Case->generate('Posts', array( - 'models' => array( + $Posts = $this->Case->generate('Posts', [ + 'models' => [ 'Post' => true - ) - )); - $this->assertNull($Posts->Post->save(array())); + ] + ]); + $this->assertNull($Posts->Post->save([])); $this->assertNull($Posts->Post->find('all')); - $Posts = $this->Case->generate('Posts', array( - 'models' => array( - 'Post' => array('save'), - ) - )); - $this->assertNull($Posts->Post->save(array())); + $Posts = $this->Case->generate('Posts', [ + 'models' => [ + 'Post' => ['save'], + ] + ]); + $this->assertNull($Posts->Post->save([])); $this->assertIsArray($Posts->Post->find('all')); - $Posts = $this->Case->generate('Posts', array( - 'models' => array('Post'), - 'components' => array( - 'RequestHandler' => array('isPut'), - 'Email' => array('send'), + $Posts = $this->Case->generate('Posts', [ + 'models' => ['Post'], + 'components' => [ + 'RequestHandler' => ['isPut'], + 'Email' => ['send'], 'Session' - ) - )); + ] + ]); $Posts->RequestHandler->expects($this->once()) ->method('isPut') ->will($this->returnValue(true)); @@ -222,21 +222,21 @@ public function testGenerate() { * @return void */ public function testGenerateWithComponentConfig() { - $Tests = $this->Case->generate('TestConfigs', array( - )); + $Tests = $this->Case->generate('TestConfigs', [ + ]); - $expected = array('some' => 'config'); - $settings = array_intersect_key($Tests->RequestHandler->settings, array('some' => 'foo')); + $expected = ['some' => 'config']; + $settings = array_intersect_key($Tests->RequestHandler->settings, ['some' => 'foo']); $this->assertSame($expected, $settings, 'A mocked component should have the same config as an unmocked component'); - $Tests = $this->Case->generate('TestConfigs', array( - 'components' => array( - 'RequestHandler' => array('isPut') - ) - )); + $Tests = $this->Case->generate('TestConfigs', [ + 'components' => [ + 'RequestHandler' => ['isPut'] + ] + ]); - $expected = array('some' => 'config'); - $settings = array_intersect_key($Tests->RequestHandler->settings, array('some' => 'foo')); + $expected = ['some' => 'config']; + $settings = array_intersect_key($Tests->RequestHandler->settings, ['some' => 'foo']); $this->assertSame($expected, $settings, 'A mocked component should have the same config as an unmocked component'); } @@ -246,25 +246,25 @@ public function testGenerateWithComponentConfig() { * @return void */ public function testGenerateWithPlugin() { - $Tests = $this->Case->generate('TestPlugin.Tests', array( - 'models' => array( + $Tests = $this->Case->generate('TestPlugin.Tests', [ + 'models' => [ 'TestPlugin.TestPluginComment' - ), - 'components' => array( + ], + 'components' => [ 'TestPlugin.Plugins' - ) - )); + ] + ]); $this->assertEquals('Tests', $Tests->name); $this->assertInstanceOf('PluginsComponent', $Tests->Plugins); $result = ClassRegistry::init('TestPlugin.TestPluginComment'); $this->assertInstanceOf('TestPluginComment', $result); - $Tests = $this->Case->generate('ControllerTestCaseTest', array( - 'models' => array( - 'TestPlugin.TestPluginComment' => array('save') - ) - )); + $Tests = $this->Case->generate('ControllerTestCaseTest', [ + 'models' => [ + 'TestPlugin.TestPluginComment' => ['save'] + ] + ]); $this->assertInstanceOf('TestPluginComment', $Tests->TestPluginComment); $Tests->TestPluginComment->expects($this->at(0)) ->method('save') @@ -272,8 +272,8 @@ public function testGenerateWithPlugin() { $Tests->TestPluginComment->expects($this->at(1)) ->method('save') ->will($this->returnValue(false)); - $this->assertTrue($Tests->TestPluginComment->save(array())); - $this->assertFalse($Tests->TestPluginComment->save(array())); + $this->assertTrue($Tests->TestPluginComment->save([])); + $this->assertFalse($Tests->TestPluginComment->save([])); } /** @@ -282,11 +282,11 @@ public function testGenerateWithPlugin() { * @return void */ public function testGenerateWithMockedAliasedComponent() { - $Posts = $this->Case->generate('Posts', array( - 'components' => array( - 'AliasedEmail' => array('send') - ) - )); + $Posts = $this->Case->generate('Posts', [ + 'components' => [ + 'AliasedEmail' => ['send'] + ] + ]); $Posts->AliasedEmail->expects($this->once()) ->method('send') ->will($this->returnValue(true)); @@ -301,11 +301,11 @@ public function testGenerateWithMockedAliasedComponent() { * @return void */ public function testGenerateWithMockedAliasedPluginComponent() { - $Posts = $this->Case->generate('Posts', array( - 'components' => array( - 'AliasedPluginEmail' => array('send') - ) - )); + $Posts = $this->Case->generate('Posts', [ + 'components' => [ + 'AliasedPluginEmail' => ['send'] + ] + ]); $Posts->AliasedPluginEmail->expects($this->once()) ->method('send') ->will($this->returnValue(true)); @@ -326,9 +326,9 @@ public function testTestAction() { $this->Case->testAction('/tests_apps/set_action'); $results = $this->Case->controller->viewVars; - $expected = array( + $expected = [ 'var' => 'string' - ); + ]; $this->assertEquals($expected, $results); $result = $this->Case->controller->response->body(); @@ -337,9 +337,9 @@ public function testTestAction() { $Controller = $this->Case->generate('TestsApps'); $this->Case->testAction('/tests_apps/redirect_to'); $results = $this->Case->headers; - $expected = array( + $expected = [ 'Location' => 'https://cakephp.org' - ); + ]; $this->assertEquals($expected, $results); $this->assertSame(302, $Controller->response->statusCode()); } @@ -351,7 +351,7 @@ public function testTestAction() { */ public function testTestActionArrayUrls() { $this->Case->generate('TestsApps'); - $this->Case->testAction(array('controller' => 'tests_apps', 'action' => 'index')); + $this->Case->testAction(['controller' => 'tests_apps', 'action' => 'index']); $this->assertIsArray($this->Case->controller->viewVars); } @@ -389,9 +389,9 @@ public function testUseRoutes() { $controller = $this->Case->generate('TestsApps'); $controller->Components->load('RequestHandler'); - $result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'contents')); + $result = $this->Case->testAction('/tests_apps/index.json', ['return' => 'contents']); $result = json_decode($result, true); - $expected = array('cakephp' => 'cool'); + $expected = ['cakephp' => 'cool']; $this->assertEquals($expected, $result); include CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'routes.php'; @@ -410,7 +410,7 @@ public function testSkipRoutes() { include CAKE . 'Test' . DS . 'test_app' . DS . 'Config' . DS . 'routes.php'; $this->Case->loadRoutes = false; - $this->Case->testAction('/tests_apps/missing_action.json', array('return' => 'view')); + $this->Case->testAction('/tests_apps/missing_action.json', ['return' => 'view']); } /** @@ -424,21 +424,21 @@ public function testBCSetReturn() { $result = $this->Case->testAction('/tests_apps/some_method'); $this->assertEquals(5, $result); - $data = array('var' => 'set'); - $result = $this->Case->testAction('/tests_apps_posts/post_var', array( + $data = ['var' => 'set']; + $result = $this->Case->testAction('/tests_apps_posts/post_var', [ 'data' => $data, 'return' => 'vars' - )); + ]); $this->assertEquals($data, $result['data']); - $result = $this->Case->testAction('/tests_apps/set_action', array( + $result = $this->Case->testAction('/tests_apps/set_action', [ 'return' => 'view' - )); + ]); $this->assertEquals('This is the TestsAppsController index view string', $result); - $result = $this->Case->testAction('/tests_apps/set_action', array( + $result = $this->Case->testAction('/tests_apps/set_action', [ 'return' => 'contents' - )); + ]); $this->assertMatchesRegularExpression('/assertMatchesRegularExpression('/This is the TestsAppsController index view/', $result); $this->assertMatchesRegularExpression('/<\/html>/', $result); @@ -452,37 +452,37 @@ public function testBCSetReturn() { public function testTestActionPostData() { $this->Case->autoMock = true; - $data = array( - 'Post' => array( + $data = [ + 'Post' => [ 'name' => 'Some Post' - ) - ); - $this->Case->testAction('/tests_apps_posts/post_var', array( + ] + ]; + $this->Case->testAction('/tests_apps_posts/post_var', [ 'data' => $data - )); + ]); $this->assertEquals($this->Case->controller->viewVars['data'], $data); $this->assertEquals($this->Case->controller->data, $data); - $this->Case->testAction('/tests_apps_posts/post_var/named:param', array( + $this->Case->testAction('/tests_apps_posts/post_var/named:param', [ 'data' => $data - )); - $expected = array( + ]); + $expected = [ 'named' => 'param' - ); + ]; $this->assertEquals($expected, $this->Case->controller->request->named); $this->assertEquals($this->Case->controller->data, $data); - $result = $this->Case->testAction('/tests_apps_posts/post_var', array( + $result = $this->Case->testAction('/tests_apps_posts/post_var', [ 'return' => 'vars', 'method' => 'post', - 'data' => array( + 'data' => [ 'name' => 'is jonas', 'pork' => 'and beans', - ) - )); - $this->assertEquals(array('name', 'pork'), array_keys($result['data'])); + ] + ]); + $this->assertEquals(['name', 'pork'], array_keys($result['data'])); - $result = $this->Case->testAction('/tests_apps_posts/add', array('return' => 'vars')); + $result = $this->Case->testAction('/tests_apps_posts/add', ['return' => 'vars']); $this->assertTrue(array_key_exists('posts', $result)); $this->assertEquals(4, count($result['posts'])); $this->assertTrue($this->Case->controller->request->is('post')); @@ -496,36 +496,36 @@ public function testTestActionPostData() { public function testTestActionGetData() { $this->Case->autoMock = true; - $this->Case->testAction('/tests_apps_posts/url_var', array( + $this->Case->testAction('/tests_apps_posts/url_var', [ 'method' => 'get', - 'data' => array( + 'data' => [ 'some' => 'var', 'lackof' => 'creativity' - ) - )); + ] + ]); $this->assertEquals('var', $this->Case->controller->request->query['some']); $this->assertEquals('creativity', $this->Case->controller->request->query['lackof']); - $result = $this->Case->testAction('/tests_apps_posts/url_var/var1:value1/var2:val2', array( + $result = $this->Case->testAction('/tests_apps_posts/url_var/var1:value1/var2:val2', [ 'return' => 'vars', 'method' => 'get', - )); - $this->assertEquals(array('var1', 'var2'), array_keys($result['params']['named'])); + ]); + $this->assertEquals(['var1', 'var2'], array_keys($result['params']['named'])); - $result = $this->Case->testAction('/tests_apps_posts/url_var/gogo/val2', array( + $result = $this->Case->testAction('/tests_apps_posts/url_var/gogo/val2', [ 'return' => 'vars', 'method' => 'get', - )); - $this->assertEquals(array('gogo', 'val2'), $result['params']['pass']); + ]); + $this->assertEquals(['gogo', 'val2'], $result['params']['pass']); - $this->Case->testAction('/tests_apps_posts/url_var', array( + $this->Case->testAction('/tests_apps_posts/url_var', [ 'return' => 'vars', 'method' => 'get', - 'data' => array( + 'data' => [ 'red' => 'health', 'blue' => 'mana' - ) - )); + ] + ]); $query = $this->Case->controller->request->query; $this->assertTrue(isset($query['red'])); $this->assertTrue(isset($query['blue'])); @@ -537,11 +537,11 @@ public function testTestActionGetData() { * @return void */ public function testTestActionJsonData() { - $result = $this->Case->testAction('/tests_apps_posts/input_data', array( + $result = $this->Case->testAction('/tests_apps_posts/input_data', [ 'return' => 'vars', 'method' => 'post', 'data' => '{"key":"value","json":true}' - )); + ]); $this->assertEquals('value', $result['data']['key']); $this->assertTrue($result['data']['json']); } @@ -555,9 +555,9 @@ public function testAutoMock() { $this->Case->autoMock = true; $this->Case->testAction('/tests_apps/set_action'); $results = $this->Case->controller->viewVars; - $expected = array( + $expected = [ 'var' => 'string' - ); + ]; $this->assertEquals($expected, $results); } @@ -570,21 +570,21 @@ public function testNoMocking() { $result = $this->Case->testAction('/tests_apps/some_method'); $this->Case->assertEquals(5, $result); - $data = array('var' => 'set'); - $result = $this->Case->testAction('/tests_apps_posts/post_var', array( + $data = ['var' => 'set']; + $result = $this->Case->testAction('/tests_apps_posts/post_var', [ 'data' => $data, 'return' => 'vars' - )); + ]); $this->assertEquals($data, $result['data']); - $result = $this->Case->testAction('/tests_apps/set_action', array( + $result = $this->Case->testAction('/tests_apps/set_action', [ 'return' => 'view' - )); + ]); $this->assertEquals('This is the TestsAppsController index view string', $result); - $result = $this->Case->testAction('/tests_apps/set_action', array( + $result = $this->Case->testAction('/tests_apps/set_action', [ 'return' => 'contents' - )); + ]); $this->assertMatchesRegularExpression('/assertMatchesRegularExpression('/This is the TestsAppsController index view/', $result); $this->assertMatchesRegularExpression('/<\/html>/', $result); @@ -597,28 +597,28 @@ public function testNoMocking() { */ public function testNoControllerReuse() { $this->Case->autoMock = true; - $result = $this->Case->testAction('/tests_apps/index', array( - 'data' => array('var' => 'first call'), + $result = $this->Case->testAction('/tests_apps/index', [ + 'data' => ['var' => 'first call'], 'method' => 'get', 'return' => 'contents', - )); + ]); $this->assertStringContainsString('assertStringContainsString('This is the TestsAppsController index view', $result); $this->assertStringContainsString('first call', $result); $this->assertStringContainsString('', $result); - $result = $this->Case->testAction('/tests_apps/index', array( - 'data' => array('var' => 'second call'), + $result = $this->Case->testAction('/tests_apps/index', [ + 'data' => ['var' => 'second call'], 'method' => 'get', 'return' => 'contents' - )); + ]); $this->assertStringContainsString('second call', $result); - $result = $this->Case->testAction('/tests_apps/index', array( - 'data' => array('var' => 'third call'), + $result = $this->Case->testAction('/tests_apps/index', [ + 'data' => ['var' => 'third call'], 'method' => 'get', 'return' => 'contents' - )); + ]); $this->assertStringContainsString('third call', $result); } @@ -630,7 +630,7 @@ public function testNoControllerReuse() { public function testTestActionWithMultipleRedirect() { $this->Case->generate('TestsApps'); - $options = array('method' => 'get'); + $options = ['method' => 'get']; $this->Case->testAction('/tests_apps/redirect_to', $options); $this->Case->testAction('/tests_apps/redirect_to', $options); } @@ -643,7 +643,7 @@ public function testTestActionWithMultipleRedirect() { */ public function testComponentsSameRequestAndResponse() { $this->Case->generate('TestsApps'); - $options = array('method' => 'get'); + $options = ['method' => 'get']; $this->Case->testAction('/tests_apps/index', $options); $this->assertSame($this->Case->controller->response, $this->Case->controller->RequestHandler->response); $this->assertSame($this->Case->controller->request, $this->Case->controller->RequestHandler->request); @@ -655,13 +655,13 @@ public function testComponentsSameRequestAndResponse() { * @return void */ public function testRestoreGetPost() { - $restored = array('new' => 'value'); + $restored = ['new' => 'value']; $_GET = $restored; $_POST = $restored; $this->Case->generate('TestsApps'); - $options = array('method' => 'get'); + $options = ['method' => 'get']; $this->Case->testAction('/tests_apps/index', $options); $this->assertEquals($restored, $_GET); @@ -678,20 +678,20 @@ public function testAppBaseConfigCompatibilityWithArrayUrls() { Configure::write('App.base', '/cakephp'); $this->Case->generate('TestsApps'); - $this->Case->testAction(array('controller' => 'tests_apps', 'action' => 'index')); + $this->Case->testAction(['controller' => 'tests_apps', 'action' => 'index']); $this->assertEquals('/cakephp', $this->Case->controller->request->base); $this->assertEquals('/cakephp/', $this->Case->controller->request->webroot); $this->assertEquals('/cakephp/tests_apps', $this->Case->controller->request->here); $this->assertEquals('tests_apps', $this->Case->controller->request->url); - $expected = array( + $expected = [ 'plugin' => null, 'controller' => 'tests_apps', 'action' => 'index', - 'named' => array(), - 'pass' => array(), - ); + 'named' => [], + 'pass' => [], + ]; $this->assertEquals($expected, array_intersect_key($this->Case->controller->request->params, $expected)); } @@ -702,18 +702,18 @@ public function testAppBaseConfigCompatibilityWithArrayUrls() { * @return void */ public function testTestActionWithArrayUrlQueryStringDataViaGetRequest() { - $query = array('foo' => 'bar'); + $query = ['foo' => 'bar']; $this->Case->generate('TestsApps'); $this->Case->testAction( - array( + [ 'controller' => 'tests_apps', 'action' => 'index', '?' => $query - ), - array( + ], + [ 'method' => 'get' - ) + ] ); $this->assertEquals('tests_apps', $this->Case->controller->request->url); @@ -727,18 +727,18 @@ public function testTestActionWithArrayUrlQueryStringDataViaGetRequest() { * @return void */ public function testTestActionWithArrayUrlQueryStringDataViaPostRequest() { - $query = array('foo' => 'bar'); + $query = ['foo' => 'bar']; $this->Case->generate('TestsApps'); $this->Case->testAction( - array( + [ 'controller' => 'tests_apps', 'action' => 'index', '?' => $query - ), - array( + ], + [ 'method' => 'post' - ) + ] ); $this->assertEquals('tests_apps', $this->Case->controller->request->url); @@ -752,20 +752,20 @@ public function testTestActionWithArrayUrlQueryStringDataViaPostRequest() { * @return void */ public function testTestActionWithArrayUrlQueryStringDataAndDataOptionViaGetRequest() { - $query = array('foo' => 'bar'); - $data = array('bar' => 'foo'); + $query = ['foo' => 'bar']; + $data = ['bar' => 'foo']; $this->Case->generate('TestsApps'); $this->Case->testAction( - array( + [ 'controller' => 'tests_apps', 'action' => 'index', '?' => $query - ), - array( + ], + [ 'method' => 'get', 'data' => $data - ) + ] ); $this->assertEquals('tests_apps', $this->Case->controller->request->url); diff --git a/lib/Cake/Test/Case/TestSuite/Fixture/CakeFixtureManagerTest.php b/lib/Cake/Test/Case/TestSuite/Fixture/CakeFixtureManagerTest.php index 433065bab4..2a1e872187 100644 --- a/lib/Cake/Test/Case/TestSuite/Fixture/CakeFixtureManagerTest.php +++ b/lib/Cake/Test/Case/TestSuite/Fixture/CakeFixtureManagerTest.php @@ -53,7 +53,7 @@ public function tearDown() : void { * @return void */ public function testLoadTruncatesTable() { - $MockFixture = $this->getMock('UuidFixture', array('truncate')); + $MockFixture = $this->getMock('UuidFixture', ['truncate']); $MockFixture ->expects($this->once()) ->method('truncate') @@ -64,10 +64,10 @@ public function testLoadTruncatesTable() { $loadedProperty = $fixtureManagerReflection->getProperty('_loaded'); $loadedProperty->setAccessible(true); - $loadedProperty->setValue($fixtureManager, array('core.uuid' => $MockFixture)); + $loadedProperty->setValue($fixtureManager, ['core.uuid' => $MockFixture]); $TestCase = $this->getMock('CakeTestCase'); - $TestCase->fixtures = array('core.uuid'); + $TestCase->fixtures = ['core.uuid']; $TestCase->autoFixtures = true; $TestCase->dropTables = false; @@ -80,7 +80,7 @@ public function testLoadTruncatesTable() { * @return void */ public function testLoadSingleTruncatesTable() { - $MockFixture = $this->getMock('UuidFixture', array('truncate')); + $MockFixture = $this->getMock('UuidFixture', ['truncate']); $MockFixture ->expects($this->once()) ->method('truncate') @@ -91,9 +91,9 @@ public function testLoadSingleTruncatesTable() { $fixtureMapProperty = $fixtureManagerReflection->getProperty('_fixtureMap'); $fixtureMapProperty->setAccessible(true); - $fixtureMapProperty->setValue($fixtureManager, array('UuidFixture' => $MockFixture)); + $fixtureMapProperty->setValue($fixtureManager, ['UuidFixture' => $MockFixture]); - $dboMethods = array_diff(get_class_methods('DboSource'), array('enabled')); + $dboMethods = array_diff(get_class_methods('DboSource'), ['enabled']); $dboMethods[] = 'connect'; $db = $this->getMock('DboSource', $dboMethods); $db->config['prefix'] = ''; diff --git a/lib/Cake/Test/Case/TestSuite/HtmlCoverageReportTest.php b/lib/Cake/Test/Case/TestSuite/HtmlCoverageReportTest.php index d8299e0ed3..5cc8d2ad6c 100644 --- a/lib/Cake/Test/Case/TestSuite/HtmlCoverageReportTest.php +++ b/lib/Cake/Test/Case/TestSuite/HtmlCoverageReportTest.php @@ -40,13 +40,13 @@ public function setUp() : void { // Therefore, CakeBaseReporter are unnecessary. $this->skipIf(version_compare(\PHPUnit\Runner\Version::id(), '9.0.0', '>='), 'This test can not be run with PHPUnit 9+'); parent::setUp(); - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - ), App::RESET); - CakePlugin::load(array('TestPlugin')); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ], App::RESET); + CakePlugin::load(['TestPlugin']); $reporter = new CakeBaseReporter(); - $reporter->params = array('app' => false, 'plugin' => false, 'group' => false); - $coverage = array(); + $reporter->params = ['app' => false, 'plugin' => false, 'group' => false]; + $coverage = []; $this->Coverage = new HtmlCoverageReport($coverage, $reporter); } @@ -76,16 +76,16 @@ public function testGetPathFilter() { * @return void */ public function testFilterCoverageDataByPathRemovingElements() { - $data = array( - CAKE . 'dispatcher.php' => array( + $data = [ + CAKE . 'dispatcher.php' => [ 10 => -1, 12 => 1 - ), - APP . 'app_model.php' => array( + ], + APP . 'app_model.php' => [ 50 => 1, 52 => -1 - ) - ); + ] + ]; $this->Coverage->setCoverage($data); $result = $this->Coverage->filterCoverageDataByPath(CAKE); $this->assertTrue(isset($result[CAKE . 'dispatcher.php'])); @@ -98,7 +98,7 @@ public function testFilterCoverageDataByPathRemovingElements() { * @return void */ public function testGenerateDiff() { - $file = array( + $file = [ 'line 1', 'line 2', 'line 3', @@ -109,33 +109,33 @@ public function testGenerateDiff() { 'line 8', 'line 9', 'line 10', - ); - $coverage = array( - 1 => array(array('id' => 'HtmlCoverageReportTest::testGenerateDiff')), + ]; + $coverage = [ + 1 => [['id' => 'HtmlCoverageReportTest::testGenerateDiff']], 2 => -2, - 3 => array(array('id' => 'HtmlCoverageReportTest::testGenerateDiff')), - 4 => array(array('id' => 'HtmlCoverageReportTest::testGenerateDiff')), + 3 => [['id' => 'HtmlCoverageReportTest::testGenerateDiff']], + 4 => [['id' => 'HtmlCoverageReportTest::testGenerateDiff']], 5 => -1, - 6 => array(array('id' => 'HtmlCoverageReportTest::testGenerateDiff')), - 7 => array(array('id' => 'HtmlCoverageReportTest::testGenerateDiff')), - 8 => array(array('id' => 'HtmlCoverageReportTest::testGenerateDiff')), + 6 => [['id' => 'HtmlCoverageReportTest::testGenerateDiff']], + 7 => [['id' => 'HtmlCoverageReportTest::testGenerateDiff']], + 8 => [['id' => 'HtmlCoverageReportTest::testGenerateDiff']], 9 => -1, - 10 => array(array('id' => 'HtmlCoverageReportTest::testGenerateDiff')) - ); + 10 => [['id' => 'HtmlCoverageReportTest::testGenerateDiff']] + ]; $result = $this->Coverage->generateDiff('myfile.php', $file, $coverage); $this->assertMatchesRegularExpression('/myfile\.php Code coverage\: \d+\.?\d*\%/', $result); $this->assertMatchesRegularExpression('/
assertMatchesRegularExpression('/
/', $result);
 		foreach ($file as $i => $line) {
-			$this->assertTrue(strpos($line, $result) !== 0, 'Content is missing ' . $i);
+			$this->assertTrue(!str_starts_with($line, $result), 'Content is missing ' . $i);
 			$class = 'covered';
-			if (in_array($i + 1, array(5, 9, 2))) {
+			if (in_array($i + 1, [5, 9, 2])) {
 				$class = 'uncovered';
 			}
 			if ($i + 1 === 2) {
 				$class .= ' dead';
 			}
-			$this->assertTrue(strpos($class, $result) !== 0, 'Class name is wrong ' . $i);
+			$this->assertTrue(!str_starts_with($class, $result), 'Class name is wrong ' . $i);
 		}
 	}
 
@@ -145,7 +145,7 @@ public function testGenerateDiff() {
  * @return void
  */
 	public function testPhpunit36Compatibility() {
-		$file = array(
+		$file = [
 			'line 1',
 			'line 2',
 			'line 3',
@@ -156,34 +156,34 @@ public function testPhpunit36Compatibility() {
 			'line 8',
 			'line 9',
 			'line 10',
-		);
-		$coverage = array(
-			1 => array('HtmlCoverageReportTest::testGenerateDiff'),
+		];
+		$coverage = [
+			1 => ['HtmlCoverageReportTest::testGenerateDiff'],
 			2 => null,
-			3 => array('HtmlCoverageReportTest::testGenerateDiff'),
-			4 => array('HtmlCoverageReportTest::testGenerateDiff'),
-			5 => array(),
-			6 => array('HtmlCoverageReportTest::testGenerateDiff'),
-			7 => array('HtmlCoverageReportTest::testGenerateDiff'),
-			8 => array('HtmlCoverageReportTest::testGenerateDiff'),
-			9 => array(),
-			10 => array('HtmlCoverageReportTest::testSomething', 'HtmlCoverageReportTest::testGenerateDiff')
-		);
+			3 => ['HtmlCoverageReportTest::testGenerateDiff'],
+			4 => ['HtmlCoverageReportTest::testGenerateDiff'],
+			5 => [],
+			6 => ['HtmlCoverageReportTest::testGenerateDiff'],
+			7 => ['HtmlCoverageReportTest::testGenerateDiff'],
+			8 => ['HtmlCoverageReportTest::testGenerateDiff'],
+			9 => [],
+			10 => ['HtmlCoverageReportTest::testSomething', 'HtmlCoverageReportTest::testGenerateDiff']
+		];
 
 		$result = $this->Coverage->generateDiff('myfile.php', $file, $coverage);
 		$this->assertMatchesRegularExpression('/myfile\.php Code coverage\: \d+\.?\d*\%/', $result);
 		$this->assertMatchesRegularExpression('/
assertMatchesRegularExpression('/
/', $result);
 		foreach ($file as $i => $line) {
-			$this->assertTrue(strpos($line, $result) !== 0, 'Content is missing ' . $i);
+			$this->assertTrue(!str_starts_with($line, $result), 'Content is missing ' . $i);
 			$class = 'covered';
-			if (in_array($i + 1, array(5, 9, 2))) {
+			if (in_array($i + 1, [5, 9, 2])) {
 				$class = 'uncovered';
 			}
 			if ($i + 1 === 2) {
 				$class .= ' dead';
 			}
-			$this->assertTrue(strpos($class, $result) !== 0, 'Class name is wrong ' . $i);
+			$this->assertTrue(!str_starts_with($class, $result), 'Class name is wrong ' . $i);
 		}
 	}
 
@@ -193,38 +193,38 @@ public function testPhpunit36Compatibility() {
  * @return void
  */
 	public function testCoveredLinesTitleAttributes() {
-		$file = array(
+		$file = [
 			'line 1',
 			'line 2',
 			'line 3',
 			'line 4',
 			'line 5',
-		);
+		];
 
-		$coverage = array(
-			1 => array(array('id' => 'HtmlCoverageReportTest::testAwesomeness')),
+		$coverage = [
+			1 => [['id' => 'HtmlCoverageReportTest::testAwesomeness']],
 			2 => -2,
-			3 => array(array('id' => 'HtmlCoverageReportTest::testCakeIsSuperior')),
-			4 => array(array('id' => 'HtmlCoverageReportTest::testOther')),
+			3 => [['id' => 'HtmlCoverageReportTest::testCakeIsSuperior']],
+			4 => [['id' => 'HtmlCoverageReportTest::testOther']],
 			5 => -1
-		);
+		];
 
 		$result = $this->Coverage->generateDiff('myfile.php', $file, $coverage);
 
 		$this->assertTrue(
-			strpos($result, "title=\"Covered by:\nHtmlCoverageReportTest::testAwesomeness\n\">1") !== false,
+			str_contains($result, "title=\"Covered by:\nHtmlCoverageReportTest::testAwesomeness\n\">1"),
 			'Missing method coverage for line 1'
 		);
 		$this->assertTrue(
-			strpos($result, "title=\"Covered by:\nHtmlCoverageReportTest::testCakeIsSuperior\n\">3") !== false,
+			str_contains($result, "title=\"Covered by:\nHtmlCoverageReportTest::testCakeIsSuperior\n\">3"),
 			'Missing method coverage for line 3'
 		);
 		$this->assertTrue(
-			strpos($result, "title=\"Covered by:\nHtmlCoverageReportTest::testOther\n\">4") !== false,
+			str_contains($result, "title=\"Covered by:\nHtmlCoverageReportTest::testOther\n\">4"),
 			'Missing method coverage for line 4'
 		);
 		$this->assertTrue(
-			strpos($result, "title=\"\">5") !== false,
+			str_contains($result, "title=\"\">5"),
 			'Coverage report is wrong for line 5'
 		);
 	}
diff --git a/lib/Cake/Test/Case/TestSuite/Stub/ConsoleOutputStubTest.php b/lib/Cake/Test/Case/TestSuite/Stub/ConsoleOutputStubTest.php
index 95e90f971c..01d73d44ad 100644
--- a/lib/Cake/Test/Case/TestSuite/Stub/ConsoleOutputStubTest.php
+++ b/lib/Cake/Test/Case/TestSuite/Stub/ConsoleOutputStubTest.php
@@ -45,8 +45,8 @@ public function testCanActAsConsoleOutput() {
  * @return void
  */
 	public function testWrite() {
-		$this->stub->write(array("foo", "bar", "baz"));
-		$this->assertEquals(array("foo", "bar", "baz"), $this->stub->messages());
+		$this->stub->write(["foo", "bar", "baz"]);
+		$this->assertEquals(["foo", "bar", "baz"], $this->stub->messages());
 	}
 
 /**
@@ -55,8 +55,8 @@ public function testWrite() {
  * @return void
  */
 	public function testOverwrite() {
-		$this->stub->write(array("foo", "bar", "baz"));
+		$this->stub->write(["foo", "bar", "baz"]);
 		$this->stub->overwrite("bat");
-		$this->assertEquals(array("foo", "bar", "baz", "", "bat"), $this->stub->messages());
+		$this->assertEquals(["foo", "bar", "baz", "", "bat"], $this->stub->messages());
 	}
 }
diff --git a/lib/Cake/Test/Case/Utility/CakeNumberTest.php b/lib/Cake/Test/Case/Utility/CakeNumberTest.php
index bf6576821e..d3812f9fb0 100644
--- a/lib/Cake/Test/Case/Utility/CakeNumberTest.php
+++ b/lib/Cake/Test/Case/Utility/CakeNumberTest.php
@@ -71,17 +71,17 @@ public function testFormat() {
 		$this->assertEquals($expected, $result);
 
 		$value = 0.00001;
-		$result = $this->Number->format($value, array('places' => 1));
+		$result = $this->Number->format($value, ['places' => 1]);
 		$expected = '$0.0';
 		$this->assertEquals($expected, $result);
 
 		$value = -0.00001;
-		$result = $this->Number->format($value, array('places' => 1));
+		$result = $this->Number->format($value, ['places' => 1]);
 		$expected = '$0.0';
 		$this->assertEquals($expected, $result);
 
 		$value = 1.23;
-		$options = array('decimals' => ',', 'thousands' => '.', 'before' => '', 'after' => ' €');
+		$options = ['decimals' => ',', 'thousands' => '.', 'before' => '', 'after' => ' €'];
 		$result = $this->Number->format($value, $options);
 		$expected = '1,23 €';
 		$this->assertEquals($expected, $result);
@@ -99,34 +99,34 @@ public function testFormatDelta() {
 		$expected = '+100,100,100.00';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->formatDelta($value, array('before' => '', 'after' => ''));
+		$result = $this->Number->formatDelta($value, ['before' => '', 'after' => '']);
 		$expected = '+100,100,100.00';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->formatDelta($value, array('before' => '[', 'after' => ']'));
+		$result = $this->Number->formatDelta($value, ['before' => '[', 'after' => ']']);
 		$expected = '[+100,100,100.00]';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->formatDelta(-$value, array('before' => '[', 'after' => ']'));
+		$result = $this->Number->formatDelta(-$value, ['before' => '[', 'after' => ']']);
 		$expected = '[-100,100,100.00]';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->formatDelta(-$value, array('before' => '[ ', 'after' => ' ]'));
+		$result = $this->Number->formatDelta(-$value, ['before' => '[ ', 'after' => ' ]']);
 		$expected = '[ -100,100,100.00 ]';
 		$this->assertEquals($expected, $result);
 
 		$value = 0;
-		$result = $this->Number->formatDelta($value, array('places' => 1, 'before' => '[', 'after' => ']'));
+		$result = $this->Number->formatDelta($value, ['places' => 1, 'before' => '[', 'after' => ']']);
 		$expected = '[0.0]';
 		$this->assertEquals($expected, $result);
 
 		$value = 0.0001;
-		$result = $this->Number->formatDelta($value, array('places' => 1, 'before' => '[', 'after' => ']'));
+		$result = $this->Number->formatDelta($value, ['places' => 1, 'before' => '[', 'after' => ']']);
 		$expected = '[0.0]';
 		$this->assertEquals($expected, $result);
 
 		$value = 9876.1234;
-		$result = $this->Number->formatDelta($value, array('places' => 1, 'decimals' => ',', 'thousands' => '.'));
+		$result = $this->Number->formatDelta($value, ['places' => 1, 'decimals' => ',', 'thousands' => '.']);
 		$expected = '+9.876,1';
 		$this->assertEquals($expected, $result);
 	}
@@ -138,43 +138,43 @@ public function testFormatDelta() {
  */
 	public function testMultibyteFormat() {
 		$value = '5199100.0006';
-		$result = $this->Number->format($value, array(
+		$result = $this->Number->format($value, [
 			'thousands' => ' ',
 			'decimals' => '&',
 			'places' => 3,
 			'escape' => false,
 			'before' => '',
-		));
+		]);
 		$expected = '5 199 100&001';
 		$this->assertEquals($expected, $result);
 
 		$value = 1000.45;
-		$result = $this->Number->format($value, array(
+		$result = $this->Number->format($value, [
 			'thousands' => ',,',
 			'decimals' => '.a',
 			'escape' => false,
-		));
+		]);
 		$expected = '$1,,000.a45';
 		$this->assertEquals($expected, $result);
 
 		$value = 519919827593784.00;
-		$this->Number->addFormat('RUR', array(
+		$this->Number->addFormat('RUR', [
 			'thousands' => 'ø€ƒ‡™',
 			'decimals' => '(§.§)',
 			'escape' => false,
 			'wholeSymbol' => '€',
 			'wholePosition' => 'after',
-		));
+		]);
 		$result = $this->Number->currency($value, 'RUR');
 		$expected = '519ø€ƒ‡™919ø€ƒ‡™827ø€ƒ‡™593ø€ƒ‡™784(§.§)00€';
 		$this->assertEquals($expected, $result);
 
 		$value = '13371337.1337';
-		$result = CakeNumber::format($value, array(
+		$result = CakeNumber::format($value, [
 			'thousands' => '- |-| /-\ >< () |2 -',
 			'decimals' => '- £€€† -',
 			'before' => ''
-		));
+		]);
 		$expected = '13- |-| /-\ >< () |2 -371- |-| /-\ >< () |2 -337- £€€† -13';
 		$this->assertEquals($expected, $result);
 	}
@@ -211,13 +211,13 @@ public function testCurrency() {
 		$expected = '£100,100,100.00';
 		$this->assertEquals($expected, $result);
 
-		$options = array('thousands' => ' ', 'wholeSymbol' => 'EUR ', 'wholePosition' => 'before',
-			'decimals' => ',', 'zero' => 'Gratuit');
+		$options = ['thousands' => ' ', 'wholeSymbol' => 'EUR ', 'wholePosition' => 'before',
+			'decimals' => ',', 'zero' => 'Gratuit'];
 		$result = $this->Number->currency($value, '', $options);
 		$expected = 'EUR 100 100 100,00';
 		$this->assertEquals($expected, $result);
 
-		$options = array('after' => 'øre', 'before' => 'Kr.', 'decimals' => ',', 'thousands' => '.');
+		$options = ['after' => 'øre', 'before' => 'Kr.', 'decimals' => ',', 'thousands' => '.'];
 		$result = $this->Number->currency(1000.45, null, $options);
 		$expected = 'Kr.1.000,45';
 		$this->assertEquals($expected, $result);
@@ -226,30 +226,30 @@ public function testCurrency() {
 		$expected = '50c';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency(0.5, null, array('after' => 'øre'));
+		$result = $this->Number->currency(0.5, null, ['after' => 'øre']);
 		$expected = '50øre';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency(1, null, array('wholeSymbol' => '$ '));
+		$result = $this->Number->currency(1, null, ['wholeSymbol' => '$ ']);
 		$expected = '$ 1.00';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency(1, null, array('wholeSymbol' => ' $', 'wholePosition' => 'after'));
+		$result = $this->Number->currency(1, null, ['wholeSymbol' => ' $', 'wholePosition' => 'after']);
 		$expected = '1.00 $';
 		$this->assertEquals($expected, $result);
 
-		$options = array('wholeSymbol' => '$', 'wholePosition' => 'after', 'fractionSymbol' => ' cents');
+		$options = ['wholeSymbol' => '$', 'wholePosition' => 'after', 'fractionSymbol' => ' cents'];
 		$result = $this->Number->currency(0.2, null, $options);
 		$expected = '20 cents';
 		$this->assertEquals($expected, $result);
 
-		$options = array('wholeSymbol' => '$', 'wholePosition' => 'after', 'fractionSymbol' => 'cents ',
-			'fractionPosition' => 'before');
+		$options = ['wholeSymbol' => '$', 'wholePosition' => 'after', 'fractionSymbol' => 'cents ',
+			'fractionPosition' => 'before'];
 		$result = $this->Number->currency(0.2, null, $options);
 		$expected = 'cents 20';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency(311, 'USD', array('wholePosition' => 'after'));
+		$result = $this->Number->currency(311, 'USD', ['wholePosition' => 'after']);
 		$expected = '311.00$';
 		$this->assertEquals($expected, $result);
 
@@ -257,19 +257,19 @@ public function testCurrency() {
 		$expected = '€0,20';
 		$this->assertEquals($expected, $result);
 
-		$options = array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents',
-			'fractionPosition' => 'after');
+		$options = ['wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents',
+			'fractionPosition' => 'after'];
 		$result = $this->Number->currency(12, null, $options);
 		$expected = '12.00 dollars';
 		$this->assertEquals($expected, $result);
 
-		$options = array('wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents',
-			'fractionPosition' => 'after');
+		$options = ['wholeSymbol' => ' dollars', 'wholePosition' => 'after', 'fractionSymbol' => ' cents',
+			'fractionPosition' => 'after'];
 		$result = $this->Number->currency(0.12, null, $options);
 		$expected = '12 cents';
 		$this->assertEquals($expected, $result);
 
-		$options = array('fractionSymbol' => false, 'fractionPosition' => 'before', 'wholeSymbol' => '$');
+		$options = ['fractionSymbol' => false, 'fractionPosition' => 'before', 'wholeSymbol' => '$'];
 		$result = $this->Number->currency(0.5, null, $options);
 		$expected = '$0.50';
 		$this->assertEquals($expected, $result);
@@ -306,29 +306,29 @@ public function testCurrency() {
  * @return void
  */
 	public function testCurrencyWithFractionAndPlaces() {
-		$result = $this->Number->currency('1.23', 'GBP', array('places' => 3));
+		$result = $this->Number->currency('1.23', 'GBP', ['places' => 3]);
 		$expected = '£1.230';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency('0.23', 'GBP', array('places' => 3));
+		$result = $this->Number->currency('0.23', 'GBP', ['places' => 3]);
 		$expected = '23p';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency('0.001', 'GBP', array('places' => 3));
+		$result = $this->Number->currency('0.001', 'GBP', ['places' => 3]);
 		$expected = '0p';
 		$this->assertEquals($expected, $result);
 
-		$this->Number->addFormat('BHD', array('before' => 'BD ', 'fractionSymbol' => ' fils',
-			'fractionExponent' => 3));
-		$result = $this->Number->currency('1.234', 'BHD', array('places' => 2));
+		$this->Number->addFormat('BHD', ['before' => 'BD ', 'fractionSymbol' => ' fils',
+			'fractionExponent' => 3]);
+		$result = $this->Number->currency('1.234', 'BHD', ['places' => 2]);
 		$expected = 'BD 1.23';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency('0.234', 'BHD', array('places' => 2));
+		$result = $this->Number->currency('0.234', 'BHD', ['places' => 2]);
 		$expected = '234 fils';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency('0.001', 'BHD', array('places' => 2));
+		$result = $this->Number->currency('0.001', 'BHD', ['places' => 2]);
 		$expected = '1 fils';
 		$this->assertEquals($expected, $result);
 	}
@@ -339,10 +339,10 @@ public function testCurrencyWithFractionAndPlaces() {
  * @return void
  */
 	public function testCurrencyFractionSymbol() {
-		$result = $this->Number->currency(0.2, '', array(
+		$result = $this->Number->currency(0.2, '', [
 			'places' => 2,
 			'decimal' => '.'
-		));
+		]);
 		$this->assertEquals('0.20', $result);
 	}
 
@@ -352,12 +352,12 @@ public function testCurrencyFractionSymbol() {
  * @return void
  */
 	public function testCurrencyAddFormat() {
-		$this->Number->addFormat('NOK', array('before' => 'Kr. '));
+		$this->Number->addFormat('NOK', ['before' => 'Kr. ']);
 		$result = $this->Number->currency(1000, 'NOK');
 		$expected = 'Kr. 1,000.00';
 		$this->assertEquals($expected, $result);
 
-		$this->Number->addFormat('Other', array('before' => '$$ ', 'after' => 'c!'));
+		$this->Number->addFormat('Other', ['before' => '$$ ', 'after' => 'c!']);
 		$result = $this->Number->currency(0.22, 'Other');
 		$expected = '22c!';
 		$this->assertEquals($expected, $result);
@@ -366,7 +366,7 @@ public function testCurrencyAddFormat() {
 		$expected = '($$ 10.00)';
 		$this->assertEquals($expected, $result);
 
-		$this->Number->addFormat('Other2', array('before' => '$ ', 'after' => false));
+		$this->Number->addFormat('Other2', ['before' => '$ ', 'after' => false]);
 		$result = $this->Number->currency(0.22, 'Other2');
 		$expected = '$ 0.22';
 		$this->assertEquals($expected, $result);
@@ -380,7 +380,7 @@ public function testCurrencyAddFormat() {
 	public function testDefaultCurrency() {
 		$result = $this->Number->defaultCurrency();
 		$this->assertEquals('USD', $result);
-		$this->Number->addFormat('NOK', array('before' => 'Kr. '));
+		$this->Number->addFormat('NOK', ['before' => 'Kr. ']);
 
 		$this->Number->defaultCurrency('NOK');
 		$result = $this->Number->defaultCurrency();
@@ -417,7 +417,7 @@ public function testCurrencyPositive() {
 		$expected = '$100,100,100.00';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'USD', array('before' => '#'));
+		$result = $this->Number->currency($value, 'USD', ['before' => '#']);
 		$expected = '#100,100,100.00';
 		$this->assertEquals($expected, $result);
 
@@ -458,15 +458,15 @@ public function testCurrencyNegative() {
 		$expected = '(£100,100,100.00)';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'USD', array('negative' => '-'));
+		$result = $this->Number->currency($value, 'USD', ['negative' => '-']);
 		$expected = '-$100,100,100.00';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'EUR', array('negative' => '-'));
+		$result = $this->Number->currency($value, 'EUR', ['negative' => '-']);
 		$expected = '-€100.100.100,00';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'GBP', array('negative' => '-'));
+		$result = $this->Number->currency($value, 'GBP', ['negative' => '-']);
 		$expected = '-£100,100,100.00';
 		$this->assertEquals($expected, $result);
 	}
@@ -512,15 +512,15 @@ public function testCurrencyCentsNegative() {
 		$expected = '(99p)';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'USD', array('negative' => '-'));
+		$result = $this->Number->currency($value, 'USD', ['negative' => '-']);
 		$expected = '-99c';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'EUR', array('negative' => '-'));
+		$result = $this->Number->currency($value, 'EUR', ['negative' => '-']);
 		$expected = '-€0,99';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'GBP', array('negative' => '-'));
+		$result = $this->Number->currency($value, 'GBP', ['negative' => '-']);
 		$expected = '-99p';
 		$this->assertEquals($expected, $result);
 	}
@@ -545,7 +545,7 @@ public function testCurrencyZero() {
 		$expected = '£0.00';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'GBP', array('zero' => 'FREE!'));
+		$result = $this->Number->currency($value, 'GBP', ['zero' => 'FREE!']);
 		$expected = 'FREE!';
 		$this->assertEquals($expected, $result);
 	}
@@ -558,31 +558,31 @@ public function testCurrencyZero() {
 	public function testCurrencyOptions() {
 		$value = '1234567.89';
 
-		$result = $this->Number->currency($value, null, array('before' => 'GBP'));
+		$result = $this->Number->currency($value, null, ['before' => 'GBP']);
 		$expected = 'GBP1,234,567.89';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'GBP', array('places' => 0));
+		$result = $this->Number->currency($value, 'GBP', ['places' => 0]);
 		$expected = '£1,234,568';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency('1234567.8912345', null, array('before' => 'GBP', 'places' => 3));
+		$result = $this->Number->currency('1234567.8912345', null, ['before' => 'GBP', 'places' => 3]);
 		$expected = 'GBP1,234,567.891';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency('650.120001', null, array('before' => 'GBP', 'places' => 4));
+		$result = $this->Number->currency('650.120001', null, ['before' => 'GBP', 'places' => 4]);
 		$expected = 'GBP650.1200';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency($value, 'GBP', array('before' => '£ ', 'escape' => true));
+		$result = $this->Number->currency($value, 'GBP', ['before' => '£ ', 'escape' => true]);
 		$expected = '&#163; 1,234,567.89';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency('0.35', 'USD', array('after' => false));
+		$result = $this->Number->currency('0.35', 'USD', ['after' => false]);
 		$expected = '$0.35';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->currency('0.35', 'GBP', array('before' => '£', 'after' => false, 'escape' => false));
+		$result = $this->Number->currency('0.35', 'GBP', ['before' => '£', 'after' => false, 'escape' => false]);
 		$expected = '£0.35';
 		$this->assertEquals($expected, $result);
 
@@ -713,27 +713,27 @@ public function testToPercentage() {
 		$expected = '0.0000%';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->toPercentage(45, 0, array('multiply' => false));
+		$result = $this->Number->toPercentage(45, 0, ['multiply' => false]);
 		$expected = '45%';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->toPercentage(45, 2, array('multiply' => false));
+		$result = $this->Number->toPercentage(45, 2, ['multiply' => false]);
 		$expected = '45.00%';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->toPercentage(0, 0, array('multiply' => false));
+		$result = $this->Number->toPercentage(0, 0, ['multiply' => false]);
 		$expected = '0%';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->toPercentage(0, 4, array('multiply' => false));
+		$result = $this->Number->toPercentage(0, 4, ['multiply' => false]);
 		$expected = '0.0000%';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->toPercentage(0.456, 0, array('multiply' => true));
+		$result = $this->Number->toPercentage(0.456, 0, ['multiply' => true]);
 		$expected = '46%';
 		$this->assertEquals($expected, $result);
 
-		$result = $this->Number->toPercentage(0.456, 2, array('multiply' => true));
+		$result = $this->Number->toPercentage(0.456, 2, ['multiply' => true]);
 		$expected = '45.60%';
 		$this->assertEquals($expected, $result);
 	}
@@ -765,25 +765,25 @@ public function testFromReadableSizeException() {
  * @return array
  */
 	public function filesizes() {
-		return array(
-			array(array('size' => '512B', 'default' => false), 512),
-			array(array('size' => '1KB', 'default' => false), 1024),
-			array(array('size' => '1.5KB', 'default' => false), 1536),
-			array(array('size' => '1MB', 'default' => false), 1048576),
-			array(array('size' => '1mb', 'default' => false), 1048576),
-			array(array('size' => '1.5MB', 'default' => false), 1572864),
-			array(array('size' => '1GB', 'default' => false), 1073741824),
-			array(array('size' => '1.5GB', 'default' => false), 1610612736),
-			array(array('size' => '1K', 'default' => false), 1024),
-			array(array('size' => '1.5K', 'default' => false), 1536),
-			array(array('size' => '1M', 'default' => false), 1048576),
-			array(array('size' => '1m', 'default' => false), 1048576),
-			array(array('size' => '1.5M', 'default' => false), 1572864),
-			array(array('size' => '1G', 'default' => false), 1073741824),
-			array(array('size' => '1.5G', 'default' => false), 1610612736),
-			array(array('size' => '512', 'default' => 'Unknown type'), 512),
-			array(array('size' => '2VB', 'default' => 'Unknown type'), 'Unknown type')
-		);
+		return [
+			[['size' => '512B', 'default' => false], 512],
+			[['size' => '1KB', 'default' => false], 1024],
+			[['size' => '1.5KB', 'default' => false], 1536],
+			[['size' => '1MB', 'default' => false], 1048576],
+			[['size' => '1mb', 'default' => false], 1048576],
+			[['size' => '1.5MB', 'default' => false], 1572864],
+			[['size' => '1GB', 'default' => false], 1073741824],
+			[['size' => '1.5GB', 'default' => false], 1610612736],
+			[['size' => '1K', 'default' => false], 1024],
+			[['size' => '1.5K', 'default' => false], 1536],
+			[['size' => '1M', 'default' => false], 1048576],
+			[['size' => '1m', 'default' => false], 1048576],
+			[['size' => '1.5M', 'default' => false], 1572864],
+			[['size' => '1G', 'default' => false], 1073741824],
+			[['size' => '1.5G', 'default' => false], 1610612736],
+			[['size' => '512', 'default' => 'Unknown type'], 512],
+			[['size' => '2VB', 'default' => 'Unknown type'], 'Unknown type']
+		];
 	}
 
 }
diff --git a/lib/Cake/Test/Case/Utility/CakeTextTest.php b/lib/Cake/Test/Case/Utility/CakeTextTest.php
index 185ade4e7a..9655e3b885 100644
--- a/lib/Cake/Test/Case/Utility/CakeTextTest.php
+++ b/lib/Cake/Test/Case/Utility/CakeTextTest.php
@@ -66,7 +66,7 @@ public function testUuidGeneration() {
  * @covers ::uuid
  */
 	public function testMultipleUuidGeneration() {
-		$check = array();
+		$check = [];
 		$count = mt_rand(10, 1000);
 		$pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/";
 
@@ -88,156 +88,156 @@ public function testMultipleUuidGeneration() {
 	public function testInsert() {
 		$string = 'some string';
 		$expected = 'some string';
-		$result = CakeText::insert($string, array());
+		$result = CakeText::insert($string, []);
 		$this->assertEquals($expected, $result);
 
 		$string = '2 + 2 = :sum. Cake is :adjective.';
 		$expected = '2 + 2 = 4. Cake is yummy.';
-		$result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'));
+		$result = CakeText::insert($string, ['sum' => '4', 'adjective' => 'yummy']);
 		$this->assertEquals($expected, $result);
 
 		$string = '2 + 2 = %sum. Cake is %adjective.';
-		$result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%'));
+		$result = CakeText::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['before' => '%']);
 		$this->assertEquals($expected, $result);
 
 		$string = '2 + 2 = 2sum2. Cake is 9adjective9.';
-		$result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])%s\\1/'));
+		$result = CakeText::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['format' => '/([\d])%s\\1/']);
 		$this->assertEquals($expected, $result);
 
 		$string = '2 + 2 = 12sum21. Cake is 23adjective45.';
 		$expected = '2 + 2 = 4. Cake is 23adjective45.';
-		$result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('format' => '/([\d])([\d])%s\\2\\1/'));
+		$result = CakeText::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['format' => '/([\d])([\d])%s\\2\\1/']);
 		$this->assertEquals($expected, $result);
 
 		$string = ':web :web_site';
 		$expected = 'www http';
-		$result = CakeText::insert($string, array('web' => 'www', 'web_site' => 'http'));
+		$result = CakeText::insert($string, ['web' => 'www', 'web_site' => 'http']);
 		$this->assertEquals($expected, $result);
 
 		$string = '2 + 2 = .';
 		$expected = '2 + 2 =  '4', 'adjective' => 'yummy'), array('before' => '<', 'after' => '>'));
+		$result = CakeText::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['before' => '<', 'after' => '>']);
 		$this->assertEquals($expected, $result);
 
 		$string = '2 + 2 = \:sum. Cake is :adjective.';
 		$expected = '2 + 2 = :sum. Cake is yummy.';
-		$result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'));
+		$result = CakeText::insert($string, ['sum' => '4', 'adjective' => 'yummy']);
 		$this->assertEquals($expected, $result);
 
 		$string = '2 + 2 = !:sum. Cake is :adjective.';
-		$result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('escape' => '!'));
+		$result = CakeText::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['escape' => '!']);
 		$this->assertEquals($expected, $result);
 
 		$string = '2 + 2 = \%sum. Cake is %adjective.';
 		$expected = '2 + 2 = %sum. Cake is yummy.';
-		$result = CakeText::insert($string, array('sum' => '4', 'adjective' => 'yummy'), array('before' => '%'));
+		$result = CakeText::insert($string, ['sum' => '4', 'adjective' => 'yummy'], ['before' => '%']);
 		$this->assertEquals($expected, $result);
 
 		$string = ':a :b \:a :a';
 		$expected = '1 2 :a 1';
-		$result = CakeText::insert($string, array('a' => 1, 'b' => 2));
+		$result = CakeText::insert($string, ['a' => 1, 'b' => 2]);
 		$this->assertEquals($expected, $result);
 
 		$string = ':a :b :c';
 		$expected = '2 3';
-		$result = CakeText::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
+		$result = CakeText::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]);
 		$this->assertEquals($expected, $result);
 
 		$string = ':a :b :c';
 		$expected = '1 3';
-		$result = CakeText::insert($string, array('a' => 1, 'c' => 3), array('clean' => true));
+		$result = CakeText::insert($string, ['a' => 1, 'c' => 3], ['clean' => true]);
 		$this->assertEquals($expected, $result);
 
 		$string = ':a :b :c';
 		$expected = '2 3';
-		$result = CakeText::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
+		$result = CakeText::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]);
 		$this->assertEquals($expected, $result);
 
 		$string = ':a, :b and :c';
 		$expected = '2 and 3';
-		$result = CakeText::insert($string, array('b' => 2, 'c' => 3), array('clean' => true));
+		$result = CakeText::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]);
 		$this->assertEquals($expected, $result);
 
 		$string = '":a, :b and :c"';
 		$expected = '"1, 2"';
-		$result = CakeText::insert($string, array('a' => 1, 'b' => 2), array('clean' => true));
+		$result = CakeText::insert($string, ['a' => 1, 'b' => 2], ['clean' => true]);
 		$this->assertEquals($expected, $result);
 
 		$string = '"${a}, ${b} and ${c}"';
 		$expected = '"1, 2"';
-		$result = CakeText::insert($string, array('a' => 1, 'b' => 2), array('before' => '${', 'after' => '}', 'clean' => true));
+		$result = CakeText::insert($string, ['a' => 1, 'b' => 2], ['before' => '${', 'after' => '}', 'clean' => true]);
 		$this->assertEquals($expected, $result);
 
 		$string = ':alt';
 		$expected = '';
-		$result = CakeText::insert($string, array('src' => 'foo'), array('clean' => 'html'));
+		$result = CakeText::insert($string, ['src' => 'foo'], ['clean' => 'html']);
 
 		$this->assertEquals($expected, $result);
 
 		$string = '';
 		$expected = '';
-		$result = CakeText::insert($string, array('src' => 'foo'), array('clean' => 'html'));
+		$result = CakeText::insert($string, ['src' => 'foo'], ['clean' => 'html']);
 		$this->assertEquals($expected, $result);
 
 		$string = '';
 		$expected = '';
-		$result = CakeText::insert($string, array('src' => 'foo', 'extra' => 'bar'), array('clean' => 'html'));
+		$result = CakeText::insert($string, ['src' => 'foo', 'extra' => 'bar'], ['clean' => 'html']);
 		$this->assertEquals($expected, $result);
 
 		$result = CakeText::insert("this is a ? string", "test");
 		$expected = "this is a test string";
 		$this->assertEquals($expected, $result);
 
-		$result = CakeText::insert("this is a ? string with a ? ? ?", array('long', 'few?', 'params', 'you know'));
+		$result = CakeText::insert("this is a ? string with a ? ? ?", ['long', 'few?', 'params', 'you know']);
 		$expected = "this is a long string with a few? params you know";
 		$this->assertEquals($expected, $result);
 
-		$result = CakeText::insert('update saved_urls set url = :url where id = :id', array('url' => 'http://www.testurl.com/param1:url/param2:id', 'id' => 1));
+		$result = CakeText::insert('update saved_urls set url = :url where id = :id', ['url' => 'http://www.testurl.com/param1:url/param2:id', 'id' => 1]);
 		$expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1";
 		$this->assertEquals($expected, $result);
 
-		$result = CakeText::insert('update saved_urls set url = :url where id = :id', array('id' => 1, 'url' => 'http://www.testurl.com/param1:url/param2:id'));
+		$result = CakeText::insert('update saved_urls set url = :url where id = :id', ['id' => 1, 'url' => 'http://www.testurl.com/param1:url/param2:id']);
 		$expected = "update saved_urls set url = http://www.testurl.com/param1:url/param2:id where id = 1";
 		$this->assertEquals($expected, $result);
 
-		$result = CakeText::insert(':me cake. :subject :verb fantastic.', array('me' => 'I :verb', 'subject' => 'cake', 'verb' => 'is'));
+		$result = CakeText::insert(':me cake. :subject :verb fantastic.', ['me' => 'I :verb', 'subject' => 'cake', 'verb' => 'is']);
 		$expected = "I :verb cake. cake is fantastic.";
 		$this->assertEquals($expected, $result);
 
-		$result = CakeText::insert(':I.am: :not.yet: passing.', array('I.am' => 'We are'), array('before' => ':', 'after' => ':', 'clean' => array('replacement' => ' of course', 'method' => 'text')));
+		$result = CakeText::insert(':I.am: :not.yet: passing.', ['I.am' => 'We are'], ['before' => ':', 'after' => ':', 'clean' => ['replacement' => ' of course', 'method' => 'text']]);
 		$expected = "We are of course passing.";
 		$this->assertEquals($expected, $result);
 
 		$result = CakeText::insert(
 			':I.am: :not.yet: passing.',
-			array('I.am' => 'We are'),
-			array('before' => ':', 'after' => ':', 'clean' => true)
+			['I.am' => 'We are'],
+			['before' => ':', 'after' => ':', 'clean' => true]
 		);
 		$expected = "We are passing.";
 		$this->assertEquals($expected, $result);
 
-		$result = CakeText::insert('?-pended result', array('Pre'));
+		$result = CakeText::insert('?-pended result', ['Pre']);
 		$expected = "Pre-pended result";
 		$this->assertEquals($expected, $result);
 
 		$string = 'switching :timeout / :timeout_count';
 		$expected = 'switching 5 / 10';
-		$result = CakeText::insert($string, array('timeout' => 5, 'timeout_count' => 10));
+		$result = CakeText::insert($string, ['timeout' => 5, 'timeout_count' => 10]);
 		$this->assertEquals($expected, $result);
 
 		$string = 'switching :timeout / :timeout_count';
 		$expected = 'switching 5 / 10';
-		$result = CakeText::insert($string, array('timeout_count' => 10, 'timeout' => 5));
+		$result = CakeText::insert($string, ['timeout_count' => 10, 'timeout' => 5]);
 		$this->assertEquals($expected, $result);
 
 		$string = 'switching :timeout_count by :timeout';
 		$expected = 'switching 10 by 5';
-		$result = CakeText::insert($string, array('timeout' => 5, 'timeout_count' => 10));
+		$result = CakeText::insert($string, ['timeout' => 5, 'timeout_count' => 10]);
 		$this->assertEquals($expected, $result);
 
 		$string = 'switching :timeout_count by :timeout';
 		$expected = 'switching 10 by 5';
-		$result = CakeText::insert($string, array('timeout_count' => 10, 'timeout' => 5));
+		$result = CakeText::insert($string, ['timeout_count' => 10, 'timeout' => 5]);
 		$this->assertEquals($expected, $result);
 	}
 
@@ -248,35 +248,35 @@ public function testInsert() {
  * @covers ::cleanInsert
  */
 	public function testCleanInsert() {
-		$result = CakeText::cleanInsert(':incomplete', array(
+		$result = CakeText::cleanInsert(':incomplete', [
 			'clean' => true, 'before' => ':', 'after' => ''
-		));
+		]);
 		$this->assertEquals('', $result);
 
-		$result = CakeText::cleanInsert(':incomplete', array(
-			'clean' => array('method' => 'text', 'replacement' => 'complete'),
-			'before' => ':', 'after' => '')
+		$result = CakeText::cleanInsert(':incomplete', [
+			'clean' => ['method' => 'text', 'replacement' => 'complete'],
+			'before' => ':', 'after' => '']
 		);
 		$this->assertEquals('complete', $result);
 
-		$result = CakeText::cleanInsert(':in.complete', array(
+		$result = CakeText::cleanInsert(':in.complete', [
 			'clean' => true, 'before' => ':', 'after' => ''
-		));
+		]);
 		$this->assertEquals('', $result);
 
-		$result = CakeText::cleanInsert(':in.complete and', array(
-			'clean' => true, 'before' => ':', 'after' => '')
+		$result = CakeText::cleanInsert(':in.complete and', [
+			'clean' => true, 'before' => ':', 'after' => '']
 		);
 		$this->assertEquals('', $result);
 
-		$result = CakeText::cleanInsert(':in.complete or stuff', array(
+		$result = CakeText::cleanInsert(':in.complete or stuff', [
 			'clean' => true, 'before' => ':', 'after' => ''
-		));
+		]);
 		$this->assertEquals('stuff', $result);
 
 		$result = CakeText::cleanInsert(
 			'

Text here

', - array('clean' => 'html', 'before' => ':', 'after' => '') + ['clean' => 'html', 'before' => ':', 'after' => ''] ); $this->assertEquals('

Text here

', $result); } @@ -289,8 +289,8 @@ public function testCleanInsert() { * @covers ::insert */ public function testAutoIgnoreBadInsertData() { - $data = array('foo' => 'alpha', 'bar' => 'beta', 'fale' => array()); - $result = CakeText::insert('(:foo > :bar || :fale!)', $data, array('clean' => 'text')); + $data = ['foo' => 'alpha', 'bar' => 'beta', 'fale' => []]; + $result = CakeText::insert('(:foo > :bar || :fale!)', $data, ['clean' => 'text']); $this->assertEquals('(alpha > beta || !)', $result); } @@ -302,32 +302,32 @@ public function testAutoIgnoreBadInsertData() { */ public function testTokenize() { $result = CakeText::tokenize('A,(short,boring test)'); - $expected = array('A', '(short,boring test)'); + $expected = ['A', '(short,boring test)']; $this->assertEquals($expected, $result); $result = CakeText::tokenize('A,(short,more interesting( test)'); - $expected = array('A', '(short,more interesting( test)'); + $expected = ['A', '(short,more interesting( test)']; $this->assertEquals($expected, $result); $result = CakeText::tokenize('A,(short,very interesting( test))'); - $expected = array('A', '(short,very interesting( test))'); + $expected = ['A', '(short,very interesting( test))']; $this->assertEquals($expected, $result); $result = CakeText::tokenize('"single tag"', ' ', '"', '"'); - $expected = array('"single tag"'); + $expected = ['"single tag"']; $this->assertEquals($expected, $result); $result = CakeText::tokenize('tagA "single tag" tagB', ' ', '"', '"'); - $expected = array('tagA', '"single tag"', 'tagB'); + $expected = ['tagA', '"single tag"', 'tagB']; $this->assertEquals($expected, $result); // Ideographic width space. $result = CakeText::tokenize("tagA\xe3\x80\x80\"single\xe3\x80\x80tag\"\xe3\x80\x80tagB", "\xe3\x80\x80", '"', '"'); - $expected = array('tagA', '"single tag"', 'tagB'); + $expected = ['tagA', '"single tag"', 'tagB']; $this->assertEquals($expected, $result); $result = CakeText::tokenize(''); - $expected = array(); + $expected = []; $this->assertEquals($expected, $result); } @@ -340,7 +340,7 @@ public function testTokenize() { public function testReplaceWithQuestionMarkInString() { $string = ':a, :b and :c?'; $expected = '2 and 3?'; - $result = CakeText::insert($string, array('b' => 2, 'c' => 3), array('clean' => true)); + $result = CakeText::insert($string, ['b' => 2, 'c' => 3], ['clean' => true]); $this->assertEquals($expected, $result); } @@ -364,20 +364,20 @@ public function testWordWrap($text, $width, $break = "\n", $cut = false) { * @return array */ public function wordWrapProvider() { - return array( - array( + return [ + [ 'The quick brown fox jumped over the lazy dog.', 33 - ), - array( + ], + [ 'A very long woooooooooooord.', 8 - ), - array( + ], + [ 'A very long woooooooooooord. Right.', 8 - ), - ); + ], + ]; } /** @@ -446,7 +446,7 @@ public function testWrap() { TEXT; $this->assertTextEquals($expected, $result, 'Text not wrapped.'); - $result = CakeText::wrap($text, array('width' => 20, 'wordWrap' => false)); + $result = CakeText::wrap($text, ['width' => 20, 'wordWrap' => false]); $expected = 'This is the song th' . "\n" . 'at never ends. This' . "\n" . ' is the song that n' . "\n" . @@ -476,7 +476,7 @@ public function testWrap() { */ public function testWrapIndent() { $text = 'This is the song that never ends. This is the song that never ends. This is the song that never ends.'; - $result = CakeText::wrap($text, array('width' => 33, 'indent' => "\t", 'indentAt' => 1)); + $result = CakeText::wrap($text, ['width' => 33, 'indent' => "\t", 'indentAt' => 1]); $expected = <<assertSame($this->Text->truncate($text1, 15), 'The quick br...'); - $this->assertSame($this->Text->truncate($text1, 15, array('exact' => false)), 'The quick...'); + $this->assertSame($this->Text->truncate($text1, 15, ['exact' => false]), 'The quick...'); $this->assertSame($this->Text->truncate($text1, 100), 'The quick brown fox jumps over the lazy dog'); $this->assertSame($this->Text->truncate($text2, 10), 'Heiz&ou...'); - $this->assertSame($this->Text->truncate($text2, 10, array('exact' => false)), '...'); + $this->assertSame($this->Text->truncate($text2, 10, ['exact' => false]), '...'); $this->assertSame($this->Text->truncate($text3, 20), '© 2005-20...'); $this->assertSame($this->Text->truncate($text4, 15), ' This image ta' . $elipsis); - $this->assertSame($this->Text->truncate($text4, 45, array('html' => true)), ' This image tag is not XHTML conform!

But the' . $elipsis . ''); - $this->assertSame($this->Text->truncate($text4, 90, array('html' => true)), ' This image tag is not XHTML conform!

But the following image tag should be conform Me, myself and I
Great,' . $elipsis); - $this->assertSame($this->Text->truncate($text5, 6, array('ellipsis' => '', 'html' => true)), '012345'); - $this->assertSame($this->Text->truncate($text5, 20, array('ellipsis' => '', 'html' => true)), $text5); - $this->assertSame($this->Text->truncate($text6, 57, array('exact' => false, 'html' => true)), "

Extra dates have been announced for this year's" . $elipsis . "

"); + $this->assertSame($this->Text->truncate($text5, 6, ['ellipsis' => '']), '01<'); + $this->assertSame($this->Text->truncate($text1, 15, ['html' => true]), 'The quick brow' . $elipsis); + $this->assertSame($this->Text->truncate($text1, 15, ['exact' => false, 'html' => true]), 'The quick' . $elipsis); + $this->assertSame($this->Text->truncate($text2, 10, ['html' => true]), 'Heizölrüc' . $elipsis); + $this->assertSame($this->Text->truncate($text2, 10, ['exact' => false, 'html' => true]), $elipsis); + $this->assertSame($this->Text->truncate($text3, 20, ['html' => true]), '© 2005-2007, Cake S' . $elipsis . ''); + $this->assertSame($this->Text->truncate($text4, 15, ['html' => true]), ' This image ta' . $elipsis); + $this->assertSame($this->Text->truncate($text4, 45, ['html' => true]), ' This image tag is not XHTML conform!

But the' . $elipsis . ''); + $this->assertSame($this->Text->truncate($text4, 90, ['html' => true]), ' This image tag is not XHTML conform!

But the following image tag should be conform Me, myself and I
Great,' . $elipsis); + $this->assertSame($this->Text->truncate($text5, 6, ['ellipsis' => '', 'html' => true]), '012345'); + $this->assertSame($this->Text->truncate($text5, 20, ['ellipsis' => '', 'html' => true]), $text5); + $this->assertSame($this->Text->truncate($text6, 57, ['exact' => false, 'html' => true]), "

Extra dates have been announced for this year's" . $elipsis . "

"); $this->assertSame($this->Text->truncate($text7, 255), $text7); $this->assertSame($this->Text->truncate($text7, 15), 'El moño está...'); $this->assertSame($this->Text->truncate($text8, 15), 'Vive la R' . chr(195) . chr(169) . 'pu...'); @@ -530,11 +530,11 @@ public function testTruncate() { $this->assertSame($this->Text->truncate($text10, 30), 'http://example.com/somethin...'); $text = '

Iamatestwithnospacesandhtml

'; - $result = $this->Text->truncate($text, 10, array( + $result = $this->Text->truncate($text, 10, [ 'ellipsis' => '...', 'exact' => false, 'html' => true - )); + ]); $expected = '

...

'; $this->assertEquals($expected, $result); @@ -553,11 +553,11 @@ public function testTruncate() { podeís adquirirla.

http://www.amazon.com/Steve- Jobs-Walter-Isaacson/dp/1451648537

'; - $result = $this->Text->truncate($text, 500, array( + $result = $this->Text->truncate($text, 500, [ 'ellipsis' => '... ', 'exact' => false, 'html' => true - )); + ]); $expected = '

El biógrafo de Steve Jobs, Walter Isaacson, explica porqué Jobs le pidió que le hiciera su biografía en este artículo de El País.

@@ -575,18 +575,18 @@ public function testTruncate() { $this->assertEquals($expected, $result); // test deprecated `ending` (`ellipsis` taking precedence if both are defined) - $result = $this->Text->truncate($text1, 31, array( + $result = $this->Text->truncate($text1, 31, [ 'ending' => '.', 'exact' => false, - )); + ]); $expected = 'The quick brown fox jumps.'; $this->assertEquals($expected, $result); - $result = $this->Text->truncate($text1, 31, array( + $result = $this->Text->truncate($text1, 31, [ 'ellipsis' => '..', 'ending' => '.', 'exact' => false, - )); + ]); $expected = 'The quick brown fox jumps..'; $this->assertEquals($expected, $result); } @@ -600,17 +600,17 @@ public function testTruncate() { public function testTruncateLegacy() { Configure::write('App.encoding', 'ISO-8859-1'); $text = '© 2005-2007, Cake Software Foundation, Inc.
written by Alexander Wegener'; - $result = $this->Text->truncate($text, 31, array( + $result = $this->Text->truncate($text, 31, [ 'html' => true, 'exact' => false, - )); + ]); $expected = '© 2005-2007, Cake Software...'; $this->assertEquals($expected, $result); - $result = $this->Text->truncate($text, 31, array( + $result = $this->Text->truncate($text, 31, [ 'html' => true, 'exact' => true, - )); + ]); $expected = '© 2005-2007, Cake Software F...'; $this->assertEquals($expected, $result); } @@ -631,7 +631,7 @@ public function testTail() { $result = $this->Text->tail($text1, 13); $this->assertEquals('...e lazy dog', $result); - $result = $this->Text->tail($text1, 13, array('exact' => false)); + $result = $this->Text->tail($text1, 13, ['exact' => false]); $this->assertEquals('...lazy dog', $result); $result = $this->Text->tail($text1, 100); @@ -640,7 +640,7 @@ public function testTail() { $result = $this->Text->tail($text2, 10); $this->assertEquals('...;mpfung', $result); - $result = $this->Text->tail($text2, 10, array('exact' => false)); + $result = $this->Text->tail($text2, 10, ['exact' => false]); $this->assertEquals('...', $result); $result = $this->Text->tail($text3, 255); @@ -655,7 +655,7 @@ public function testTail() { $result = $this->Text->tail($text5, 10); $this->assertEquals('...цчшщъыь', $result); - $result = $this->Text->tail($text5, 6, array('ellipsis' => '')); + $result = $this->Text->tail($text5, 6, ['ellipsis' => '']); $this->assertEquals('чшщъыь', $result); } @@ -667,30 +667,30 @@ public function testTail() { */ public function testHighlight() { $text = 'This is a test text'; - $phrases = array('This', 'text'); - $result = $this->Text->highlight($text, $phrases, array('format' => '\1')); + $phrases = ['This', 'text']; + $result = $this->Text->highlight($text, $phrases, ['format' => '\1']); $expected = 'This is a test text'; $this->assertEquals($expected, $result); - $phrases = array('is', 'text'); - $result = $this->Text->highlight($text, $phrases, array('format' => '\1', 'regex' => "|\b%s\b|iu")); + $phrases = ['is', 'text']; + $result = $this->Text->highlight($text, $phrases, ['format' => '\1', 'regex' => "|\b%s\b|iu"]); $expected = 'This is a test text'; $this->assertEquals($expected, $result); $text = 'This is a test text'; $phrases = null; - $result = $this->Text->highlight($text, $phrases, array('format' => '\1')); + $result = $this->Text->highlight($text, $phrases, ['format' => '\1']); $this->assertEquals($text, $result); $text = 'This is a (test) text'; $phrases = '(test'; - $result = $this->Text->highlight($text, $phrases, array('format' => '\1')); + $result = $this->Text->highlight($text, $phrases, ['format' => '\1']); $this->assertEquals('This is a (test) text', $result); $text = 'Ich saß in einem Café am Übergang'; $expected = 'Ich saß in einem Café am Übergang'; - $phrases = array('saß', 'café', 'übergang'); - $result = $this->Text->highlight($text, $phrases, array('format' => '\1')); + $phrases = ['saß', 'café', 'übergang']; + $result = $this->Text->highlight($text, $phrases, ['format' => '\1']); $this->assertEquals($expected, $result); } @@ -705,7 +705,7 @@ public function testHighlightHtml() { $text2 = '

strongbow isn’t real cider

'; $text3 = 'What a strong mouse!'; $text4 = 'What a strong mouse: What a strong mouse!'; - $options = array('format' => '\1', 'html' => true); + $options = ['format' => '\1', 'html' => true]; $expected = '

strongbow isn’t real cider

'; $this->assertEquals($expected, $this->Text->highlight($text1, 'strong', $options)); @@ -715,10 +715,10 @@ public function testHighlightHtml() { $this->assertEquals($this->Text->highlight($text3, 'strong', $options), $text3); - $this->assertEquals($this->Text->highlight($text3, array('strong', 'what'), $options), $text3); + $this->assertEquals($this->Text->highlight($text3, ['strong', 'what'], $options), $text3); $expected = 'What a strong mouse: What a strong mouse!'; - $this->assertEquals($expected, $this->Text->highlight($text4, array('strong', 'what'), $options)); + $this->assertEquals($expected, $this->Text->highlight($text4, ['strong', 'what'], $options)); } /** @@ -729,8 +729,8 @@ public function testHighlightHtml() { */ public function testHighlightMulti() { $text = 'This is a test text'; - $phrases = array('This', 'text'); - $result = $this->Text->highlight($text, $phrases, array('format' => array('\1', '\1'))); + $phrases = ['This', 'text']; + $result = $this->Text->highlight($text, $phrases, ['format' => ['\1', '\1']]); $expected = 'This is a test text'; $this->assertEquals($expected, $result); } @@ -773,10 +773,10 @@ public function testHighlightCaseInsensitivity() { $text = 'This is a Test text'; $expected = 'This is a Test text'; - $result = $this->Text->highlight($text, 'test', array('format' => '\1')); + $result = $this->Text->highlight($text, 'test', ['format' => '\1']); $this->assertEquals($expected, $result); - $result = $this->Text->highlight($text, array('test'), array('format' => '\1')); + $result = $this->Text->highlight($text, ['test'], ['format' => '\1']); $this->assertEquals($expected, $result); } @@ -846,28 +846,28 @@ public function testExcerptCaseInsensitivity() { * @covers ::toList */ public function testListGeneration() { - $result = $this->Text->toList(array()); + $result = $this->Text->toList([]); $this->assertEquals('', $result); - $result = $this->Text->toList(array('One')); + $result = $this->Text->toList(['One']); $this->assertEquals('One', $result); - $result = $this->Text->toList(array('Larry', 'Curly', 'Moe')); + $result = $this->Text->toList(['Larry', 'Curly', 'Moe']); $this->assertEquals('Larry, Curly and Moe', $result); - $result = $this->Text->toList(array('Dusty', 'Lucky', 'Ned'), 'y'); + $result = $this->Text->toList(['Dusty', 'Lucky', 'Ned'], 'y'); $this->assertEquals('Dusty, Lucky y Ned', $result); - $result = $this->Text->toList(array(1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y'); + $result = $this->Text->toList([1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'], 'y'); $this->assertEquals('Dusty, Lucky y Ned', $result); - $result = $this->Text->toList(array(1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'and', ' + '); + $result = $this->Text->toList([1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'], 'and', ' + '); $this->assertEquals('Dusty + Lucky and Ned', $result); - $result = $this->Text->toList(array('name1' => 'Dusty', 'name2' => 'Lucky')); + $result = $this->Text->toList(['name1' => 'Dusty', 'name2' => 'Lucky']); $this->assertEquals('Dusty and Lucky', $result); - $result = $this->Text->toList(array('test_0' => 'banana', 'test_1' => 'apple', 'test_2' => 'lemon')); + $result = $this->Text->toList(['test_0' => 'banana', 'test_1' => 'apple', 'test_2' => 'lemon']); $this->assertEquals('banana, apple and lemon', $result); } diff --git a/lib/Cake/Test/Case/Utility/CakeTimeTest.php b/lib/Cake/Test/Case/Utility/CakeTimeTest.php index 3ff7fb1fdb..e0ac9a8c39 100644 --- a/lib/Cake/Test/Case/Utility/CakeTimeTest.php +++ b/lib/Cake/Test/Case/Utility/CakeTimeTest.php @@ -81,16 +81,16 @@ public function testToQuarter() { $this->assertSame(1, $result); $result = $this->Time->toQuarter('2007-3-25', true); - $this->assertEquals(array('2007-01-01', '2007-03-31'), $result); + $this->assertEquals(['2007-01-01', '2007-03-31'], $result); $result = $this->Time->toQuarter('2007-5-25', true); - $this->assertEquals(array('2007-04-01', '2007-06-30'), $result); + $this->assertEquals(['2007-04-01', '2007-06-30'], $result); $result = $this->Time->toQuarter('2007-8-25', true); - $this->assertEquals(array('2007-07-01', '2007-09-30'), $result); + $this->assertEquals(['2007-07-01', '2007-09-30'], $result); $result = $this->Time->toQuarter('2007-12-25', true); - $this->assertEquals(array('2007-10-01', '2007-12-31'), $result); + $this->assertEquals(['2007-10-01', '2007-12-31'], $result); } /** @@ -99,21 +99,21 @@ public function testToQuarter() { * @return array */ public static function timeAgoProvider() { - return array( - array('-12 seconds', '12 seconds ago'), - array('-12 minutes', '12 minutes ago'), - array('-2 hours', '2 hours ago'), - array('-1 day', '1 day ago'), - array('-2 days', '2 days ago'), - array('-2 days -3 hours', '2 days, 3 hours ago'), - array('-1 week', '1 week ago'), - array('-2 weeks -2 days', '2 weeks, 2 days ago'), - array('+1 week', 'in 1 week'), - array('+1 week 1 day', 'in 1 week, 1 day'), - array('+2 weeks 2 day', 'in 2 weeks, 2 days'), - array('2007-9-24', 'on 24/9/07'), - array('now', 'just now'), - ); + return [ + ['-12 seconds', '12 seconds ago'], + ['-12 minutes', '12 minutes ago'], + ['-2 hours', '2 hours ago'], + ['-1 day', '1 day ago'], + ['-2 days', '2 days ago'], + ['-2 days -3 hours', '2 days, 3 hours ago'], + ['-1 week', '1 week ago'], + ['-2 weeks -2 days', '2 weeks, 2 days ago'], + ['+1 week', 'in 1 week'], + ['+1 week 1 day', 'in 1 week, 1 day'], + ['+2 weeks 2 day', 'in 2 weeks, 2 days'], + ['2007-9-24', 'on 24/9/07'], + ['now', 'just now'], + ]; } /** @@ -133,43 +133,43 @@ public function testTimeAgoInWords($input, $expected) { * @return void */ public function timeAgoEndProvider() { - return array( - array( + return [ + [ '+4 months +2 weeks +3 days', 'in 4 months, 2 weeks, 3 days', '8 years' - ), - array( + ], + [ '+4 months +2 weeks +1 day', 'in 4 months, 2 weeks, 1 day', '8 years' - ), - array( + ], + [ '+3 months +2 weeks', 'in 3 months, 2 weeks', '8 years' - ), - array( + ], + [ '+3 months +2 weeks +1 day', 'in 3 months, 2 weeks, 1 day', '8 years' - ), - array( + ], + [ '+1 months +1 week +1 day', 'in 1 month, 1 week, 1 day', '8 years' - ), - array( + ], + [ '+2 months +2 days', 'in 2 months, 2 days', 'on ' . date('j/n/y', strtotime('+2 months +2 days')) - ), - array( + ], + [ '+2 months +12 days', 'in 2 months, 1 week, 5 days', '3 months' - ), - ); + ], + ]; } /** @@ -180,7 +180,7 @@ public function timeAgoEndProvider() { */ public function testTimeAgoInWordsEnd($input, $expected, $end) { $result = $this->Time->timeAgoInWords( - $input, array('end' => $end) + $input, ['end' => $end] ); $this->assertEquals($expected, $result); } @@ -193,21 +193,21 @@ public function testTimeAgoInWordsEnd($input, $expected, $end) { public function testTimeAgoInWordsCustomStrings() { $result = $this->Time->timeAgoInWords( strtotime('-8 years -4 months -2 weeks -3 days'), - array('relativeString' => 'at least %s ago', 'accuracy' => array('year' => 'year'), 'end' => '+10 years') + ['relativeString' => 'at least %s ago', 'accuracy' => ['year' => 'year'], 'end' => '+10 years'] ); $expected = 'at least 8 years ago'; $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('+8 years +4 months +2 weeks +3 days'), - array('relativeStringFuture' => 'not in the next %s', 'accuracy' => array('year' => 'year'), 'end' => '+10 years') + ['relativeStringFuture' => 'not in the next %s', 'accuracy' => ['year' => 'year'], 'end' => '+10 years'] ); $expected = 'not in the next 8 years'; $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('+4 months +2 weeks +3 days'), - array('absoluteString' => 'exactly on %s', 'accuracy' => array('year' => 'year'), 'end' => '+2 months') + ['absoluteString' => 'exactly on %s', 'accuracy' => ['year' => 'year'], 'end' => '+2 months'] ); $expected = 'exactly on ' . date('j/n/y', strtotime('+4 months +2 weeks +3 days')); $this->assertEquals($expected, $result); @@ -221,49 +221,49 @@ public function testTimeAgoInWordsCustomStrings() { public function testTimeAgoInWordsAccuracy() { $result = $this->Time->timeAgoInWords( strtotime('+8 years +4 months +2 weeks +3 days'), - array('accuracy' => array('year' => 'year'), 'end' => '+10 years') + ['accuracy' => ['year' => 'year'], 'end' => '+10 years'] ); $expected = 'in 8 years'; $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('+8 years +4 months +2 weeks +3 days'), - array('accuracy' => array('year' => 'month'), 'end' => '+10 years') + ['accuracy' => ['year' => 'month'], 'end' => '+10 years'] ); $expected = 'in 8 years, 4 months'; $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('+8 years +4 months +2 weeks +3 days'), - array('accuracy' => array('year' => 'week'), 'end' => '+10 years') + ['accuracy' => ['year' => 'week'], 'end' => '+10 years'] ); $expected = 'in 8 years, 4 months, 2 weeks'; $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('+8 years +4 months +2 weeks +3 days'), - array('accuracy' => array('year' => 'day'), 'end' => '+10 years') + ['accuracy' => ['year' => 'day'], 'end' => '+10 years'] ); $expected = 'in 8 years, 4 months, 2 weeks, 3 days'; $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('+1 years +5 weeks'), - array('accuracy' => array('year' => 'year'), 'end' => '+10 years') + ['accuracy' => ['year' => 'year'], 'end' => '+10 years'] ); $expected = 'in 1 year'; $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('+58 minutes'), - array('accuracy' => 'hour') + ['accuracy' => 'hour'] ); $expected = 'in about an hour'; $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('+23 hours'), - array('accuracy' => 'day') + ['accuracy' => 'day'] ); $expected = 'in about a day'; $this->assertEquals($expected, $result); @@ -295,13 +295,13 @@ public function testTimeAgoInWordsWithFormat() { $result = $this->Time->timeAgoInWords( strtotime('+2 months +2 days'), - array('end' => '1 month', 'format' => 'Y-m-d') + ['end' => '1 month', 'format' => 'Y-m-d'] ); $this->assertEquals('on ' . date('Y-m-d', strtotime('+2 months +2 days')), $result); $result = $this->Time->timeAgoInWords( strtotime('+2 months +2 days'), - array('end' => '1 month', 'format' => '%x') + ['end' => '1 month', 'format' => '%x'] ); // @codingStandardsIgnoreStart $this->assertEquals('on ' . PHP81_BC\strftime('%x', strtotime('+2 months +2 days')), $result); @@ -316,25 +316,25 @@ public function testTimeAgoInWordsWithFormat() { public function testTimeAgoInWordsNegativeValues() { $result = $this->Time->timeAgoInWords( strtotime('-2 months -2 days'), - array('end' => '3 month') + ['end' => '3 month'] ); $this->assertEquals('2 months, 2 days ago', $result); $result = $this->Time->timeAgoInWords( strtotime('-2 months -2 days'), - array('end' => '3 month') + ['end' => '3 month'] ); $this->assertEquals('2 months, 2 days ago', $result); $result = $this->Time->timeAgoInWords( strtotime('-2 months -2 days'), - array('end' => '1 month', 'format' => 'Y-m-d') + ['end' => '1 month', 'format' => 'Y-m-d'] ); $this->assertEquals('on ' . date('Y-m-d', strtotime('-2 months -2 days')), $result); $result = $this->Time->timeAgoInWords( strtotime('-2 years -5 months -2 days'), - array('end' => '3 years') + ['end' => '3 years'] ); $this->assertEquals('2 years, 5 months, 2 days ago', $result); @@ -351,33 +351,33 @@ public function testTimeAgoInWordsNegativeValues() { $result = $this->Time->timeAgoInWords( strtotime('-1 month -1 week -6 days'), - array('end' => '1 year', 'accuracy' => array('month' => 'month')) + ['end' => '1 year', 'accuracy' => ['month' => 'month']] ); $this->assertEquals('1 month ago', $result); $timestamp = strtotime('-1 years -2 weeks -3 days'); $result = $this->Time->timeAgoInWords( $timestamp, - array('accuracy' => array('year' => 'year')) + ['accuracy' => ['year' => 'year']] ); $expected = 'on ' . date('j/n/y', $timestamp); $this->assertEquals($expected, $result); $result = $this->Time->timeAgoInWords( strtotime('-13 months -5 days'), - array('end' => '2 years') + ['end' => '2 years'] ); $this->assertEquals('1 year, 1 month, 5 days ago', $result); $result = $this->Time->timeAgoInWords( strtotime('-58 minutes'), - array('accuracy' => 'hour') + ['accuracy' => 'hour'] ); $this->assertEquals('about an hour ago', $result); $result = $this->Time->timeAgoInWords( strtotime('-23 hours'), - array('accuracy' => 'day') + ['accuracy' => 'day'] ); $this->assertEquals('about a day ago', $result); } @@ -578,7 +578,7 @@ public function testToServer() { $serverTime = new DateTime('2012-12-11 14:15:20'); - $timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu'); + $timezones = ['Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu']; foreach ($timezones as $timezone) { $result = $this->Time->toServer($serverTime->format('Y-m-d H:i:s'), $timezone, 'U'); $tz = new DateTimeZone($timezone); @@ -615,7 +615,7 @@ public function testToRss() { $time = strtotime($date); $this->assertEquals(date('r', $time), $this->Time->toRss($time)); - $timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu'); + $timezones = ['Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu']; foreach ($timezones as $timezone) { $yourTimezone = new DateTimeZone($timezone); $yourTime = new DateTime($date, $yourTimezone); @@ -634,7 +634,7 @@ public function testToRss() { public function testFormat() { $format = 'D-M-Y'; $tz = date_default_timezone_get(); - $arr = array(time(), strtotime('+1 days'), strtotime('+1 days'), strtotime('+0 days')); + $arr = [time(), strtotime('+1 days'), strtotime('+1 days'), strtotime('+0 days')]; foreach ($arr as $val) { $this->assertEquals(date($format, $val), $this->Time->format($format, $val)); $this->assertEquals(date($format, $val), $this->Time->format($format, $val, false, $tz)); @@ -742,11 +742,11 @@ public function testIsPast() { */ public function testIsThisWeek() { // A map of days which goes from -1 day of week to +1 day of week - $map = array( - 'Mon' => array(-1, 7), 'Tue' => array(-2, 6), 'Wed' => array(-3, 5), - 'Thu' => array(-4, 4), 'Fri' => array(-5, 3), 'Sat' => array(-6, 2), - 'Sun' => array(-7, 1) - ); + $map = [ + 'Mon' => [-1, 7], 'Tue' => [-2, 6], 'Wed' => [-3, 5], + 'Thu' => [-4, 4], 'Fri' => [-5, 3], 'Sat' => [-6, 2], + 'Sun' => [-7, 1] + ]; $days = $map[date('D')]; for ($day = $days[0] + 1; $day < $days[1]; $day++) { @@ -1057,9 +1057,9 @@ public function testConvertToBangkok() { * @return void */ public function testConvertSpecifiers() { - App::build(array( - 'Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS) - ), App::RESET); + App::build([ + 'Locale' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS] + ], App::RESET); Configure::write('Config.language', 'time_test'); $time = strtotime('Thu Jan 14 11:43:39 2010'); @@ -1165,9 +1165,9 @@ public function testConvertPercentE() { */ public function testI18nFormat() { $resetLocale = Locale::getDefault(); - App::build(array( - 'Locale' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS) - ), App::RESET); + App::build([ + 'Locale' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Locale' . DS] + ], App::RESET); Configure::write('Config.language', 'time_test'); $time = strtotime('Thu Jan 14 13:59:28 2010'); @@ -1264,16 +1264,16 @@ public function testListTimezones() { $this->assertTrue(isset($return['Asia']['Asia/Bangkok'])); $this->assertFalse(isset($return['Pacific'])); - $return = CakeTime::listTimezones(null, null, array('abbr' => true)); + $return = CakeTime::listTimezones(null, null, ['abbr' => true]); $this->assertTrue(isset($return['Asia']['Asia/Jakarta'])); $this->assertEquals('Jakarta - WIB', $return['Asia']['Asia/Jakarta']); $this->assertEquals('Regina - CST', $return['America']['America/Regina']); - $return = CakeTime::listTimezones(null, null, array( + $return = CakeTime::listTimezones(null, null, [ 'abbr' => true, 'before' => ' (', 'after' => ')', - )); + ]); $this->assertEquals('Jayapura (WIT)', $return['Asia']['Asia/Jayapura']); $this->assertEquals('Regina (CST)', $return['America']['America/Regina']); diff --git a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php index 6f0a2d7e8a..c378874970 100644 --- a/lib/Cake/Test/Case/Utility/ClassRegistryTest.php +++ b/lib/Cake/Test/Case/Utility/ClassRegistryTest.php @@ -146,10 +146,10 @@ public function testAddModel() { $this->assertInstanceOf('RegisterArticleTag', $TagCopy); $this->assertSame($Tag, $TagCopy); - $NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); + $NewTag = ClassRegistry::init(['class' => 'RegisterArticleTag', 'alias' => 'NewTag']); $this->assertInstanceOf('RegisterArticleTag', $NewTag); - $NewTagCopy = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); + $NewTagCopy = ClassRegistry::init(['class' => 'RegisterArticleTag', 'alias' => 'NewTag']); $this->assertNotSame($Tag, $NewTag); $this->assertSame($NewTag, $NewTagCopy); @@ -163,17 +163,17 @@ public function testAddModel() { $this->assertTrue($TagCopy->name === 'SomeOtherName'); - $User = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false)); + $User = ClassRegistry::init(['class' => 'RegisterUser', 'alias' => 'User', 'table' => false]); $this->assertInstanceOf('AppModel', $User); - $UserCopy = ClassRegistry::init(array('class' => 'RegisterUser', 'alias' => 'User', 'table' => false)); + $UserCopy = ClassRegistry::init(['class' => 'RegisterUser', 'alias' => 'User', 'table' => false]); $this->assertInstanceOf('AppModel', $UserCopy); $this->assertEquals($User, $UserCopy); - $Category = ClassRegistry::init(array('class' => 'RegisterCategory')); + $Category = ClassRegistry::init(['class' => 'RegisterCategory']); $this->assertInstanceOf('RegisterCategory', $Category); - $ParentCategory = ClassRegistry::init(array('class' => 'RegisterCategory', 'alias' => 'ParentCategory')); + $ParentCategory = ClassRegistry::init(['class' => 'RegisterCategory', 'alias' => 'ParentCategory']); $this->assertInstanceOf('RegisterCategory', $ParentCategory); $this->assertNotSame($Category, $ParentCategory); @@ -188,12 +188,12 @@ public function testAddModel() { * @return void */ public function testAddModelWithAlias() { - $tag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag')); + $tag = ClassRegistry::init(['class' => 'RegisterArticleTag', 'alias' => 'NewTag']); $this->assertInstanceOf('RegisterArticleTag', $tag); $this->assertSame('NewTag', $tag->alias); $this->assertSame('RegisterArticleTag', $tag->name); - $newTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'OtherTag')); + $newTag = ClassRegistry::init(['class' => 'RegisterArticleTag', 'alias' => 'OtherTag']); $this->assertInstanceOf('RegisterArticleTag', $tag); $this->assertSame('OtherTag', $newTag->alias); $this->assertSame('RegisterArticleTag', $newTag->name); @@ -205,7 +205,7 @@ public function testAddModelWithAlias() { * @return void */ public function testAddModelWithAliasAco() { - $aco = ClassRegistry::init(array('class' => 'Aco', 'alias' => 'CustomAco')); + $aco = ClassRegistry::init(['class' => 'Aco', 'alias' => 'CustomAco']); $this->assertInstanceOf('Aco', $aco); $this->assertSame('Aco', $aco->name); $this->assertSame('CustomAco', $aco->alias); @@ -243,9 +243,9 @@ public function testAddMultipleModels() { $Tag = ClassRegistry::isKeySet('Tag'); $this->assertFalse($Tag); - $models = array(array('class' => 'RegisterArticle', 'alias' => 'Article'), - array('class' => 'RegisterArticleFeatured', 'alias' => 'Featured'), - array('class' => 'RegisterArticleTag', 'alias' => 'Tag')); + $models = [['class' => 'RegisterArticle', 'alias' => 'Article'], + ['class' => 'RegisterArticleFeatured', 'alias' => 'Featured'], + ['class' => 'RegisterArticleTag', 'alias' => 'Tag']]; $added = ClassRegistry::init($models); $this->assertTrue($added); @@ -279,13 +279,13 @@ public function testPluginAppModel() { $this->assertFalse($TestRegistryPluginModel); //Faking a plugin - CakePlugin::load('RegistryPlugin', array('path' => '/fake/path')); + CakePlugin::load('RegistryPlugin', ['path' => '/fake/path']); $TestRegistryPluginModel = ClassRegistry::init('RegistryPlugin.TestRegistryPluginModel'); $this->assertInstanceOf('TestRegistryPluginModel', $TestRegistryPluginModel); $this->assertEquals('something_', $TestRegistryPluginModel->tablePrefix); - $PluginUser = ClassRegistry::init(array('class' => 'RegistryPlugin.RegisterUser', 'alias' => 'RegistryPluginUser', 'table' => false)); + $PluginUser = ClassRegistry::init(['class' => 'RegistryPlugin.RegisterUser', 'alias' => 'RegistryPluginUser', 'table' => false]); $this->assertInstanceOf('RegistryPluginAppModel', $PluginUser); $PluginUserCopy = ClassRegistry::getObject('RegistryPluginUser'); @@ -300,7 +300,7 @@ public function testPluginAppModel() { * @return void */ public function testPrefixedTestDatasource() { - ClassRegistry::config(array('testing' => true)); + ClassRegistry::config(['testing' => true]); $Model = ClassRegistry::init('RegisterPrefixedDs'); $this->assertEquals('test', $Model->useDbConfig); ClassRegistry::removeObject('RegisterPrefixedDs'); diff --git a/lib/Cake/Test/Case/Utility/DebuggerTest.php b/lib/Cake/Test/Case/Utility/DebuggerTest.php index a14fd8110b..c7b394c951 100644 --- a/lib/Cake/Test/Case/Utility/DebuggerTest.php +++ b/lib/Cake/Test/Case/Utility/DebuggerTest.php @@ -148,16 +148,16 @@ public function testOutput() { Debugger::output('js'); $buzz .= ''; $result = explode('', ob_get_clean()); - $this->assertTags($result[0], array( - 'pre' => array('class' => 'cake-error'), - 'a' => array( + $this->assertTags($result[0], [ + 'pre' => ['class' => 'cake-error'], + 'a' => [ 'href' => "javascript:void(0);", 'onclick' => "preg:/document\.getElementById\('cakeErr[a-z0-9]+\-trace'\)\.style\.display = " . "\(document\.getElementById\('cakeErr[a-z0-9]+\-trace'\)\.style\.display == 'none'" . " \? '' \: 'none'\);/" - ), - 'b' => array(), 'Notice', '/b', ' (8)', - )); + ], + 'b' => [], 'Notice', '/b', ' (8)', + ]); $this->assertMatchesRegularExpression('/Undefined variable:\s+buzz/', $result[1]); $this->assertMatchesRegularExpression('/]+>Code/', $result[1]); @@ -176,7 +176,7 @@ public function testOutputEncodeDescription() { ob_start(); Debugger::output('js'); - $a = array(); + $a = []; $b = $a['']; $result = ob_get_clean(); @@ -193,34 +193,34 @@ public function testChangeOutputFormats() { set_error_handler('Debugger::showError'); $this->_restoreError = true; - Debugger::output('js', array( + Debugger::output('js', [ 'traceLine' => '{:reference} - {:path}, line {:line}' - )); + ]); Debugger::output('js'); $result = Debugger::trace(); $this->assertMatchesRegularExpression('/' . preg_quote('txmt://open?url=file://', '/') . '(\/|[A-Z]:\\\\)' . '/', $result); - Debugger::output('xml', array( + Debugger::output('xml', [ 'error' => '{:code}{:file}{:line}' . '{:description}', 'context' => "{:context}", 'trace' => "{:trace}", - )); + ]); Debugger::output('xml'); ob_start(); $foo .= ''; $result = ob_get_clean(); - $data = array( - 'error' => array(), - 'code' => array(), '2', '/code', - 'file' => array(), 'preg:/[^<]+/', '/file', - 'line' => array(), '' . ((int)__LINE__ - 7), '/line', + $data = [ + 'error' => [], + 'code' => [], '2', '/code', + 'file' => [], 'preg:/[^<]+/', '/file', + 'line' => [], '' . ((int)__LINE__ - 7), '/line', 'preg:/Undefined variable\s+\$foo/', '/error' - ); + ]; $this->assertTags($result, $data, true); } @@ -253,33 +253,33 @@ public function testAddFormat() { set_error_handler('Debugger::showError'); $this->_restoreError = true; - Debugger::addFormat('js', array( + Debugger::addFormat('js', [ 'traceLine' => '{:reference} - {:path}, line {:line}' - )); + ]); Debugger::outputAs('js'); $result = Debugger::trace(); $this->assertMatchesRegularExpression('/' . preg_quote('txmt://open?url=file://', '/') . '(\/|[A-Z]:\\\\)' . '/', $result); - Debugger::addFormat('xml', array( + Debugger::addFormat('xml', [ 'error' => '{:code}{:file}{:line}' . '{:description}', - )); + ]); Debugger::outputAs('xml'); ob_start(); $foo .= ''; $result = ob_get_clean(); - $data = array( + $data = [ 'assertTags($result, $data, true); } @@ -292,7 +292,7 @@ public function testAddFormatCallback() { set_error_handler('Debugger::showError'); $this->_restoreError = true; - Debugger::addFormat('callback', array('callback' => array($this, 'customFormat'))); + Debugger::addFormat('callback', ['callback' => [$this, 'customFormat']]); Debugger::outputAs('callback'); ob_start(); @@ -332,7 +332,7 @@ public function testTrimPath() { public function testExportVar() { App::uses('Controller', 'Controller'); $Controller = new Controller(); - $Controller->helpers = array('Html', 'Form'); + $Controller->helpers = ['Html', 'Form']; $View = new View($Controller); $View->int = 2; $View->float = 1.333; @@ -408,10 +408,10 @@ public function testExportVar() { $this->assertTextEquals($expected, $result); - $data = array( + $data = [ 1 => 'Index one', 5 => 'Index five' - ); + ]; $result = Debugger::exportVar($data); $expected = <<assertTextEquals($expected, $result); - $data = array( - 'key' => array( + $data = [ + 'key' => [ 'value' - ) - ); + ] + ]; $result = Debugger::exportVar($data, 1); $expected = << '', 'null' => null, 'false' => false, 'szero' => '0', 'zero' => 0 - ); + ]; $result = Debugger::exportVar($data); $expected = << 'File', 'path' => TMP . 'logs' . DS)); + CakeLog::config('file', ['engine' => 'File', 'path' => TMP . 'logs' . DS]); Debugger::log('cool'); $result = file_get_contents(LOGS . 'debug.log'); @@ -493,7 +493,7 @@ public function testLog() { unlink(LOGS . 'debug.log'); - Debugger::log(array('whatever', 'here')); + Debugger::log(['whatever', 'here']); $result = file_get_contents(LOGS . 'debug.log'); $this->assertStringContainsString('DebuggerTest::testLog', $result); $this->assertStringContainsString('[main]', $result); @@ -511,11 +511,11 @@ public function testLogDepth() { if (file_exists(LOGS . 'debug.log')) { unlink(LOGS . 'debug.log'); } - CakeLog::config('file', array('engine' => 'File', 'path' => TMP . 'logs' . DS)); + CakeLog::config('file', ['engine' => 'File', 'path' => TMP . 'logs' . DS]); - $val = array( - 'test' => array('key' => 'val') - ); + $val = [ + 'test' => ['key' => 'val'] + ]; Debugger::log($val, LOG_DEBUG, 0); $result = file_get_contents(LOGS . 'debug.log'); $this->assertStringContainsString('DebuggerTest::testLog', $result); @@ -530,18 +530,18 @@ public function testLogDepth() { * @return void */ public function testDump() { - $var = array('People' => array( - array( + $var = ['People' => [ + [ 'name' => 'joeseph', 'coat' => 'technicolor', 'hair_color' => 'brown' - ), - array( + ], + [ 'name' => 'Shaft', 'coat' => 'black', 'hair' => 'black' - ) - )); + ] + ]]; ob_start(); Debugger::dump($var); $result = ob_get_clean(); @@ -610,7 +610,7 @@ public function testGetInstance() { * @return void */ public function testNoDbCredentials() { - $config = array( + $config = [ 'datasource' => 'mysql', 'persistent' => false, 'host' => 'void.cakephp.org', @@ -618,11 +618,11 @@ public function testNoDbCredentials() { 'password' => 'cakephp-password', 'database' => 'cakephp-database', 'prefix' => '' - ); + ]; $output = Debugger::exportVar($config); - $expectedArray = array( + $expectedArray = [ 'datasource' => 'mysql', 'persistent' => false, 'host' => '*****', @@ -630,7 +630,7 @@ public function testNoDbCredentials() { 'password' => '*****', 'database' => '*****', 'prefix' => '' - ); + ]; $expected = Debugger::exportVar($expectedArray); $this->assertEquals($expected, $output); @@ -659,9 +659,9 @@ public function testTraceExclude() { $result = Debugger::trace(); $this->assertMatchesRegularExpression('/^DebuggerTest::testTraceExclude/', $result); - $result = Debugger::trace(array( - 'exclude' => array('DebuggerTest::testTraceExclude') - )); + $result = Debugger::trace([ + 'exclude' => ['DebuggerTest::testTraceExclude'] + ]); $this->assertDoesNotMatchRegularExpression('/^DebuggerTest::testTraceExclude/', $result); } } diff --git a/lib/Cake/Test/Case/Utility/FileTest.php b/lib/Cake/Test/Case/Utility/FileTest.php index b095277e42..339a87c510 100644 --- a/lib/Cake/Test/Case/Utility/FileTest.php +++ b/lib/Cake/Test/Case/Utility/FileTest.php @@ -83,14 +83,14 @@ public function testBasic() { $this->assertEquals($expecting, $result); $result = $this->File->info(); - $expecting = array( + $expecting = [ 'dirname' => dirname($file), 'basename' => basename($file), 'extension' => 'txt', 'filename' => 'LICENSE', 'filesize' => filesize($file), 'mime' => 'text/plain' - ); + ]; if (!function_exists('finfo_open') && (!function_exists('mime_content_type') || function_exists('mime_content_type') && @@ -448,7 +448,7 @@ public function testWrite() { $this->assertFalse(file_exists($tmpFile)); $this->assertFalse(is_resource($TmpFile->handle)); - $testData = array('CakePHP\'s', ' test suite', ' was here ...', ''); + $testData = ['CakePHP\'s', ' test suite', ' was here ...', '']; foreach ($testData as $data) { $r = $TmpFile->write($data); $this->assertTrue($r); @@ -478,7 +478,7 @@ public function testAppend() { $TmpFile = new File($tmpFile); $this->assertFalse(file_exists($tmpFile)); - $fragments = array('CakePHP\'s', ' test suite', ' was here ...'); + $fragments = ['CakePHP\'s', ' test suite', ' was here ...']; $data = null; $size = 0; foreach ($fragments as $fragment) { @@ -618,7 +618,7 @@ protected function _getTmpFile($paintSkip = true) { * @covers ::replaceText */ public function testReplaceText() { - $TestFile = new File(dirname(__FILE__) . '/../../test_app/Vendor/welcome.php'); + $TestFile = new File(__DIR__ . '/../../test_app/Vendor/welcome.php'); $TmpFile = new File(TMP . 'tests' . DS . 'cakephp.file.test.tmp'); // Copy the test file to the temporary location @@ -633,8 +633,8 @@ public function testReplaceText() { $contents = $TmpFile->read(); $this->assertStringContainsString($expected, $contents); - $search = array('This is the', 'welcome.php file', 'in tmp directory'); - $replace = array('This should be a', 'welcome.tmp file', 'in the Lib directory'); + $search = ['This is the', 'welcome.php file', 'in tmp directory']; + $replace = ['This should be a', 'welcome.tmp file', 'in the Lib directory']; // Replace the contents of the tempory file $result = $TmpFile->replaceText($search, $replace); diff --git a/lib/Cake/Test/Case/Utility/FolderTest.php b/lib/Cake/Test/Case/Utility/FolderTest.php index 800aa1f79e..60dd036749 100644 --- a/lib/Cake/Test/Case/Utility/FolderTest.php +++ b/lib/Cake/Test/Case/Utility/FolderTest.php @@ -26,7 +26,7 @@ */ class FolderTest extends CakeTestCase { - protected static $_tmp = array(); + protected static $_tmp = []; /** * Save the directory names in TMP and make sure default directories exist @@ -34,13 +34,13 @@ class FolderTest extends CakeTestCase { * @return void */ public static function setUpBeforeClass() : void { - $dirs = array('cache', 'logs', 'sessions', 'tests'); + $dirs = ['cache', 'logs', 'sessions', 'tests']; foreach ($dirs as $dir) { new Folder(TMP . $dir, true); } foreach (scandir(TMP) as $file) { - if (is_dir(TMP . $file) && !in_array($file, array('.', '..'))) { + if (is_dir(TMP . $file) && !in_array($file, ['.', '..'])) { static::$_tmp[] = $file; } } @@ -62,14 +62,14 @@ public function setUp() : void { * @return void */ public function tearDown() : void { - $exclude = array_merge(static::$_tmp, array('.', '..')); + $exclude = array_merge(static::$_tmp, ['.', '..']); foreach (scandir(TMP) as $dir) { if (is_dir(TMP . $dir) && !in_array($dir, $exclude)) { $iterator = new RecursiveDirectoryIterator(TMP . $dir); foreach (new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::CHILD_FIRST) as $file) { if ($file->isFile() || $file->isLink()) { unlink($file->getPathname()); - } elseif ($file->isDir() && !in_array($file->getFilename(), array('.', '..'))) { + } elseif ($file->isDir() && !in_array($file->getFilename(), ['.', '..'])) { rmdir($file->getPathname()); } } @@ -85,7 +85,7 @@ public function tearDown() : void { * @return void */ public function testBasic() { - $path = dirname(__FILE__); + $path = __DIR__; $Folder = new Folder($path); $result = $Folder->pwd(); @@ -173,11 +173,11 @@ public function testInPath() { * @return array */ public function inPathInvalidPathArgumentDataProvider() { - return array( - array(''), - array('relative/path/'), - array('unknown://stream-wrapper') - ); + return [ + [''], + ['relative/path/'], + ['unknown://stream-wrapper'] + ]; } /** @@ -260,7 +260,7 @@ public function testRecursiveCreateFailure() { $Folder = new Folder($path); $result = $Folder->create($path . DS . 'two' . DS . 'three'); $this->assertFalse($result); - } catch (\PHPUnit\Framework\Error\Error $e) { + } catch (\PHPUnit\Framework\Error\Error) { $this->assertTrue(true); } @@ -369,7 +369,7 @@ public function testChmod() { $perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4); $this->assertEquals('0755', $perms); - $this->assertTrue($Folder->chmod($new, 0744, true, array('skip_me.php', 'test2'))); + $this->assertTrue($Folder->chmod($new, 0744, true, ['skip_me.php', 'test2'])); $perms = substr(sprintf('%o', fileperms($new . DS . 'test2')), -4); $this->assertEquals('0755', $perms); @@ -401,11 +401,11 @@ public function testZeroAsDirectory() { $this->assertTrue($Folder->create($new)); $result = $Folder->read(true, true); - $expected = array('0', 'cache', 'logs', 'sessions', 'tests'); + $expected = ['0', 'cache', 'logs', 'sessions', 'tests']; $this->assertEquals($expected, $result[0]); - $result = $Folder->read(true, array('logs')); - $expected = array('0', 'cache', 'sessions', 'tests'); + $result = $Folder->read(true, ['logs']); + $expected = ['0', 'cache', 'sessions', 'tests']; $this->assertEquals($expected, $result[0]); $result = $Folder->delete($new); @@ -426,15 +426,15 @@ public function testAddPathElement() { $result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, 'another_path'); $this->assertEquals($expected, $result); - $result = Folder::addPathElement(DS . 'some' . DS . 'dir', array('another_path')); + $result = Folder::addPathElement(DS . 'some' . DS . 'dir', ['another_path']); $this->assertEquals($expected, $result); - $result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, array('another_path')); + $result = Folder::addPathElement(DS . 'some' . DS . 'dir' . DS, ['another_path']); $this->assertEquals($expected, $result); $expected = DS . 'some' . DS . 'dir' . DS . 'another_path' . DS . 'and' . DS . 'another'; - $result = Folder::addPathElement(DS . 'some' . DS . 'dir', array('another_path', 'and', 'another')); + $result = Folder::addPathElement(DS . 'some' . DS . 'dir', ['another_path', 'and', 'another']); $this->assertEquals($expected, $result); } @@ -446,12 +446,12 @@ public function testAddPathElement() { public function testFolderRead() { $Folder = new Folder(TMP); - $expected = array('cache', 'logs', 'sessions', 'tests'); + $expected = ['cache', 'logs', 'sessions', 'tests']; $result = $Folder->read(true, true); $this->assertEquals($expected, $result[0]); $Folder->path = TMP . 'non-existent'; - $expected = array(array(), array()); + $expected = [[], []]; $result = $Folder->read(true, true); $this->assertEquals($expected, $result); } @@ -470,23 +470,23 @@ public function testFolderReadWithHiddenFiles() { touch($Folder->path . DS . 'not_hidden.txt'); touch($Folder->path . DS . '.hidden.txt'); - $expected = array( - array('some_folder'), - array('not_hidden.txt'), - ); + $expected = [ + ['some_folder'], + ['not_hidden.txt'], + ]; $result = $Folder->read(true, true); $this->assertEquals($expected, $result); - $expected = array( - array( + $expected = [ + [ '.svn', 'some_folder' - ), - array( + ], + [ '.hidden.txt', 'not_hidden.txt' - ), - ); + ], + ]; $result = $Folder->read(true); $this->assertEquals($expected, $result); } @@ -498,13 +498,13 @@ public function testFolderReadWithHiddenFiles() { */ public function testFolderTree() { $Folder = new Folder(); - $expected = array( - array( + $expected = [ + [ CAKE . 'Config', CAKE . 'Config' . DS . 'unicode', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' - ), - array( + ], + [ CAKE . 'Config' . DS . 'config.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0080_00ff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '0100_017f.php', @@ -523,20 +523,20 @@ public function testFolderTree() { CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c60_2c7f.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . '2c80_2cff.php', CAKE . 'Config' . DS . 'unicode' . DS . 'casefolding' . DS . 'ff00_ffef.php' - ) - ); + ] + ]; $result = $Folder->tree(CAKE . 'Config', false); - $this->assertSame(array(), array_diff($expected[0], $result[0])); - $this->assertSame(array(), array_diff($result[0], $expected[0])); + $this->assertSame([], array_diff($expected[0], $result[0])); + $this->assertSame([], array_diff($result[0], $expected[0])); $result = $Folder->tree(CAKE . 'Config', false, 'dir'); - $this->assertSame(array(), array_diff($expected[0], $result)); - $this->assertSame(array(), array_diff($expected[0], $result)); + $this->assertSame([], array_diff($expected[0], $result)); + $this->assertSame([], array_diff($expected[0], $result)); $result = $Folder->tree(CAKE . 'Config', false, 'files'); - $this->assertSame(array(), array_diff($expected[1], $result)); - $this->assertSame(array(), array_diff($expected[1], $result)); + $this->assertSame([], array_diff($expected[1], $result)); + $this->assertSame([], array_diff($expected[1], $result)); } /** @@ -556,37 +556,37 @@ public function testFolderTreeWithHiddenFiles() { touch($Folder->path . DS . '.hidden.txt'); mkdir($Folder->path . DS . 'visible_folder' . DS . '.git', 0777, true); - $expected = array( - array( + $expected = [ + [ $Folder->path, $Folder->path . DS . 'visible_folder', - ), - array( + ], + [ $Folder->path . DS . 'not_hidden.txt', - ), - ); + ], + ]; $result = $Folder->tree(null, true); $this->assertEquals($expected, $result); - $result = $Folder->tree(null, array('.')); + $result = $Folder->tree(null, ['.']); $this->assertEquals($expected, $result); - $expected = array( - array( + $expected = [ + [ $Folder->path, $Folder->path . DS . 'visible_folder', $Folder->path . DS . 'visible_folder' . DS . '.git', $Folder->path . DS . '.svn', $Folder->path . DS . '.svn' . DS . 'inhiddenfolder', - ), - array( + ], + [ $Folder->path . DS . 'not_hidden.txt', $Folder->path . DS . '.hidden.txt', $Folder->path . DS . '.svn' . DS . 'inhiddenfolder' . DS . 'NestedInHiddenFolder.php', $Folder->path . DS . '.svn' . DS . 'InHiddenFolder.php', - ), - ); + ], + ]; $result = $Folder->tree(null, false); sort($result[0]); @@ -726,29 +726,29 @@ public function testFind() { $Folder = new Folder(); $Folder->cd(CAKE . 'Config'); $result = $Folder->find(); - $expected = array('config.php'); - $this->assertSame(array_diff($expected, $result), array()); - $this->assertSame(array_diff($expected, $result), array()); + $expected = ['config.php']; + $this->assertSame(array_diff($expected, $result), []); + $this->assertSame(array_diff($expected, $result), []); $result = $Folder->find('.*', true); - $expected = array('cacert.pem', 'config.php', 'routes.php'); + $expected = ['cacert.pem', 'config.php', 'routes.php']; $this->assertSame($expected, $result); $result = $Folder->find('.*\.php'); - $expected = array('config.php'); - $this->assertSame(array_diff($expected, $result), array()); - $this->assertSame(array_diff($expected, $result), array()); + $expected = ['config.php']; + $this->assertSame(array_diff($expected, $result), []); + $this->assertSame(array_diff($expected, $result), []); $result = $Folder->find('.*\.php', true); - $expected = array('config.php', 'routes.php'); + $expected = ['config.php', 'routes.php']; $this->assertSame($expected, $result); $result = $Folder->find('.*ig\.php'); - $expected = array('config.php'); + $expected = ['config.php']; $this->assertSame($expected, $result); $result = $Folder->find('config\.php'); - $expected = array('config.php'); + $expected = ['config.php']; $this->assertSame($expected, $result); $Folder->cd(TMP); @@ -756,12 +756,12 @@ public function testFind() { $Folder->create($Folder->pwd() . DS . 'testme'); $Folder->cd('testme'); $result = $Folder->find('paths\.php'); - $expected = array(); + $expected = []; $this->assertSame($expected, $result); $Folder->cd($Folder->pwd() . '/..'); $result = $Folder->find('paths\.php'); - $expected = array('paths.php'); + $expected = ['paths.php']; $this->assertSame($expected, $result); $Folder->cd(TMP); @@ -778,16 +778,16 @@ public function testFindRecursive() { $Folder = new Folder(); $Folder->cd(CAKE); $result = $Folder->findRecursive('(config|paths)\.php'); - $expected = array( + $expected = [ CAKE . 'Config' . DS . 'config.php' - ); - $this->assertSame(array_diff($expected, $result), array()); - $this->assertSame(array_diff($expected, $result), array()); + ]; + $this->assertSame(array_diff($expected, $result), []); + $this->assertSame(array_diff($expected, $result), []); $result = $Folder->findRecursive('(config|paths)\.php', true); - $expected = array( + $expected = [ CAKE . 'Config' . DS . 'config.php' - ); + ]; $this->assertSame($expected, $result); $Folder->cd(TMP); @@ -797,7 +797,7 @@ public function testFindRecursive() { $File->create(); $Folder->cd(TMP . 'sessions'); $result = $Folder->findRecursive('paths\.php'); - $expected = array(); + $expected = []; $this->assertSame($expected, $result); $Folder->cd(TMP . 'testme'); @@ -806,18 +806,18 @@ public function testFindRecursive() { $Folder->cd($Folder->pwd() . '/../..'); $result = $Folder->findRecursive('(paths|my)\.php'); - $expected = array( + $expected = [ TMP . 'testme' . DS . 'my.php', TMP . 'testme' . DS . 'paths.php' - ); - $this->assertSame(array_diff($expected, $result), array()); - $this->assertSame(array_diff($expected, $result), array()); + ]; + $this->assertSame(array_diff($expected, $result), []); + $this->assertSame(array_diff($expected, $result), []); $result = $Folder->findRecursive('(paths|my)\.php', true); - $expected = array( + $expected = [ TMP . 'testme' . DS . 'my.php', TMP . 'testme' . DS . 'paths.php' - ); + ]; $this->assertSame($expected, $result); $Folder->cd(CAKE . 'Config'); @@ -879,10 +879,10 @@ public function testReset() { $messages = $Folder->messages(); $errors = $Folder->errors(); - $expected = array( + $expected = [ $file . ' NOT removed', $folder . ' NOT removed', - ); + ]; sort($expected); sort($errors); $this->assertEmpty($messages); @@ -896,10 +896,10 @@ public function testReset() { $messages = $Folder->messages(); $errors = $Folder->errors(); - $expected = array( + $expected = [ $file . ' removed', $folder . ' removed', - ); + ]; sort($expected); sort($messages); $this->assertEmpty($errors); @@ -928,9 +928,9 @@ public function testDelete() { $messages = $Folder->messages(); $errors = $Folder->errors(); - $this->assertEquals(array(), $errors); + $this->assertEquals([], $errors); - $expected = array( + $expected = [ $path . DS . 'file_1 removed', $path . DS . 'level_1_1' . DS . 'file_1_1 removed', $path . DS . 'level_1_1' . DS . 'level_2_1' . DS . 'file_2_1 removed', @@ -939,7 +939,7 @@ public function testDelete() { $path . DS . 'level_1_1' . DS . 'level_2_2 removed', $path . DS . 'level_1_1 removed', $path . ' removed' - ); + ]; sort($expected); sort($messages); $this->assertEquals($expected, $messages); @@ -992,7 +992,7 @@ public function testCopyWithMerge() { $this->assertTrue(file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php')); $Folder = new Folder($folderTwo); - $result = $Folder->copy(array('to' => $folderThree, 'scheme' => Folder::MERGE)); + $result = $Folder->copy(['to' => $folderThree, 'scheme' => Folder::MERGE]); $this->assertTrue($result); $this->assertTrue(file_exists($folderThree . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'file2.php')); @@ -1017,7 +1017,7 @@ public function testCopyWithSkip() { extract($this->_setupFilesystem()); $Folder = new Folder($folderOne); - $result = $Folder->copy(array('to' => $folderTwo, 'scheme' => Folder::SKIP)); + $result = $Folder->copy(['to' => $folderTwo, 'scheme' => Folder::SKIP]); $this->assertTrue($result); $this->assertTrue(file_exists($folderTwo . DS . 'file1.php')); $this->assertTrue(file_exists($folderTwo . DS . 'folderA' . DS . 'fileA.php')); @@ -1026,7 +1026,7 @@ public function testCopyWithSkip() { $Folder->delete(); $Folder = new Folder($folderOne); - $result = $Folder->copy(array('to' => $folderTwo, 'scheme' => Folder::SKIP)); + $result = $Folder->copy(['to' => $folderTwo, 'scheme' => Folder::SKIP]); $this->assertTrue($result); $this->assertTrue(file_exists($folderTwo . DS . 'file1.php')); $this->assertTrue(file_exists($folderTwo . DS . 'folderA' . DS . 'fileA.php')); @@ -1040,7 +1040,7 @@ public function testCopyWithSkip() { file_put_contents($folderTwo . DS . 'folderB' . DS . 'fileB.php', 'untouched'); $Folder = new Folder($folderTwo); - $result = $Folder->copy(array('to' => $folderThree, 'scheme' => Folder::SKIP)); + $result = $Folder->copy(['to' => $folderThree, 'scheme' => Folder::SKIP]); $this->assertTrue($result); $this->assertTrue(file_exists($folderThree . DS . 'file2.php')); $this->assertEquals('touched', file_get_contents($folderThree . DS . 'file2.php')); @@ -1067,7 +1067,7 @@ public function testCopyWithSkipFileSkipped() { file_put_contents($folderTwo . DS . 'fileA.txt', 'Folder Two File'); $Folder = new Folder($folderOne); - $result = $Folder->copy(array('to' => $folderTwo, 'scheme' => Folder::SKIP)); + $result = $Folder->copy(['to' => $folderTwo, 'scheme' => Folder::SKIP]); $this->assertTrue($result); $this->assertEquals('Folder Two File', file_get_contents($folderTwo . DS . 'fileA.txt')); } @@ -1084,20 +1084,20 @@ public function testCopyWithOverwrite() { extract($this->_setupFilesystem()); $Folder = new Folder($folderOne); - $Folder->copy(array('to' => $folderThree, 'scheme' => Folder::OVERWRITE)); + $Folder->copy(['to' => $folderThree, 'scheme' => Folder::OVERWRITE]); $this->assertTrue(file_exists($folderThree . DS . 'file1.php')); $this->assertTrue(file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php')); $Folder = new Folder($folderTwo); - $result = $Folder->copy(array('to' => $folderThree, 'scheme' => Folder::OVERWRITE)); + $result = $Folder->copy(['to' => $folderThree, 'scheme' => Folder::OVERWRITE]); $this->assertTrue($result); $this->assertTrue(file_exists($folderThree . DS . 'folderA' . DS . 'fileA.php')); $Folder = new Folder($folderOne); unlink($fileOneA); - $result = $Folder->copy(array('to' => $folderThree, 'scheme' => Folder::OVERWRITE)); + $result = $Folder->copy(['to' => $folderThree, 'scheme' => Folder::OVERWRITE]); $this->assertTrue($result); $this->assertTrue(file_exists($folderThree . DS . 'file1.php')); @@ -1233,7 +1233,7 @@ public function testMoveWithSkip() { extract($this->_setupFilesystem()); $Folder = new Folder($folderOne); - $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP)); + $result = $Folder->move(['to' => $folderTwo, 'scheme' => Folder::SKIP]); $this->assertTrue($result); $this->assertTrue(file_exists($folderTwo . DS . 'file1.php')); $this->assertTrue(is_dir($folderTwo . DS . 'folderB')); @@ -1252,7 +1252,7 @@ public function testMoveWithSkip() { touch($fileOneA); $Folder = new Folder($folderOne); - $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP)); + $result = $Folder->move(['to' => $folderTwo, 'scheme' => Folder::SKIP]); $this->assertTrue($result); $this->assertTrue(file_exists($folderTwo . DS . 'file1.php')); $this->assertTrue(is_dir($folderTwo . DS . 'folderA')); @@ -1273,7 +1273,7 @@ public function testMoveWithSkip() { file_put_contents($folderTwoB . DS . 'fileB.php', 'untouched'); $Folder = new Folder($folderOne); - $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP)); + $result = $Folder->move(['to' => $folderTwo, 'scheme' => Folder::SKIP]); $this->assertTrue($result); $this->assertTrue(file_exists($folderTwo . DS . 'file1.php')); $this->assertEquals('untouched', file_get_contents($folderTwoB . DS . 'fileB.php')); @@ -1303,7 +1303,7 @@ public function testSortByTime() { $file1 = new File($Folder->pwd() . DS . 'file_1.tmp'); $file1->create(); - $expected = array('file_2.tmp', 'file_1.tmp'); + $expected = ['file_2.tmp', 'file_1.tmp']; $result = $Folder->find('.*', Folder::SORT_TIME); $this->assertSame($expected, $result); @@ -1333,7 +1333,7 @@ public function testSortByTime2() { $fileB = new File($Folder->pwd() . DS . 'b.txt'); $fileB->create(); - $expected = array('c.txt', 'a.txt', 'b.txt'); + $expected = ['c.txt', 'a.txt', 'b.txt']; $result = $Folder->find('.*', Folder::SORT_TIME); $this->assertSame($expected, $result); @@ -1359,7 +1359,7 @@ public function testSortByName() { $fileB = new File($Folder->pwd() . DS . 'b.txt'); $fileB->create(); - $expected = array('a.txt', 'b.txt', 'c.txt'); + $expected = ['a.txt', 'b.txt', 'c.txt']; $result = $Folder->find('.*', Folder::SORT_NAME); $this->assertSame($expected, $result); diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index be6c881e6f..18a049a5d6 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -29,116 +29,116 @@ class HashTest extends CakeTestCase { * @return array */ public static function articleData() { - return array( - array( - 'Article' => array( + return [ + [ + 'Article' => [ 'id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body' - ), - 'User' => array( + ], + 'User' => [ 'id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', - ), - array( + ], + [ 'id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', - ), - ), - 'Tag' => array( - array( + ], + ], + 'Tag' => [ + [ 'id' => '1', 'tag' => 'tag1', - ), - array( + ], + [ 'id' => '2', 'tag' => 'tag2', - ) - ), - 'Deep' => array( - 'Nesting' => array( - 'test' => array( + ] + ], + 'Deep' => [ + 'Nesting' => [ + 'test' => [ 1 => 'foo', - 2 => array( - 'and' => array('more' => 'stuff') - ) - ) - ) - ) - ), - array( - 'Article' => array( + 2 => [ + 'and' => ['more' => 'stuff'] + ] + ] + ] + ] + ], + [ + 'Article' => [ 'id' => '2', 'user_id' => '1', 'title' => 'Second Article', 'body' => 'Second Article Body', 'published' => 'Y', - ), - 'User' => array( + ], + 'User' => [ 'id' => '2', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', - ), - 'Comment' => array(), - 'Tag' => array() - ), - array( - 'Article' => array( + ], + 'Comment' => [], + 'Tag' => [] + ], + [ + 'Article' => [ 'id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', - ), - 'User' => array( + ], + 'User' => [ 'id' => '3', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', - ), - 'Comment' => array(), - 'Tag' => array() - ), - array( - 'Article' => array( + ], + 'Comment' => [], + 'Tag' => [] + ], + [ + 'Article' => [ 'id' => '4', 'user_id' => '1', 'title' => 'Fourth Article', 'body' => 'Fourth Article Body', - ), - 'User' => array( + ], + 'User' => [ 'id' => '4', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', - ), - 'Comment' => array(), - 'Tag' => array() - ), - array( - 'Article' => array( + ], + 'Comment' => [], + 'Tag' => [] + ], + [ + 'Article' => [ 'id' => '5', 'user_id' => '1', 'title' => 'Fifth Article', 'body' => 'Fifth Article Body', - ), - 'User' => array( + ], + 'User' => [ 'id' => '5', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', - ), - 'Comment' => array(), - 'Tag' => array() - ) - ); + ], + 'Comment' => [], + 'Tag' => [] + ] + ]; } /** @@ -147,38 +147,38 @@ public static function articleData() { * @return array */ public static function userData() { - return array( - array( - 'User' => array( + return [ + [ + 'User' => [ 'id' => 2, 'group_id' => 1, - 'Data' => array( + 'Data' => [ 'user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias' - ) - ) - ), - array( - 'User' => array( + ] + ] + ], + [ + 'User' => [ 'id' => 14, 'group_id' => 2, - 'Data' => array( + 'Data' => [ 'user' => 'phpnut', 'name' => 'Larry E. Masters' - ) - ) - ), - array( - 'User' => array( + ] + ] + ], + [ + 'User' => [ 'id' => 25, 'group_id' => 1, - 'Data' => array( + 'Data' => [ 'user' => 'gwoo', 'name' => 'The Gwoo' - ) - ) - ) - ); + ] + ] + ] + ]; } /** @@ -187,7 +187,7 @@ public static function userData() { * @return void */ public function testGet() { - $data = array('abc', 'def'); + $data = ['abc', 'def']; $result = Hash::get($data, '0'); $this->assertEquals('abc', $result); @@ -200,7 +200,7 @@ public function testGet() { $data = static::articleData(); - $result = Hash::get(array(), '1.Article.title'); + $result = Hash::get([], '1.Article.title'); $this->assertNull($result); $result = Hash::get($data, ''); @@ -215,9 +215,9 @@ public function testGet() { $result = Hash::get($data, '5.Article.title'); $this->assertNull($result); - $default = array('empty'); + $default = ['empty']; $this->assertEquals($default, Hash::get($data, '5.Article.title', $default)); - $this->assertEquals($default, Hash::get(array(), '5.Article.title', $default)); + $this->assertEquals($default, Hash::get([], '5.Article.title', $default)); $result = Hash::get($data, '1.Article.title.not_there'); $this->assertNull($result); @@ -225,7 +225,7 @@ public function testGet() { $result = Hash::get($data, '1.Article'); $this->assertEquals($data[1]['Article'], $result); - $result = Hash::get($data, array('1', 'Article')); + $result = Hash::get($data, ['1', 'Article']); $this->assertEquals($data[1]['Article'], $result); } @@ -235,11 +235,11 @@ public function testGet() { * @return void */ public function testGetEmptyKey() { - $data = array( + $data = [ true => 'true value', false => 'false value', '' => 'some value', - ); + ]; $this->assertSame($data[''], Hash::get($data, '')); $this->assertSame($data[false], Hash::get($data, false)); $this->assertSame($data[true], Hash::get($data, true)); @@ -252,7 +252,7 @@ public function testGetEmptyKey() { */ public function testGetInvalidPath() { $this->expectException(InvalidArgumentException::class); - Hash::get(array('one' => 'two'), new StdClass()); + Hash::get(['one' => 'two'], new StdClass()); } /** @@ -261,10 +261,10 @@ public function testGetInvalidPath() { * @return void */ public function testGetNullPath() { - $result = Hash::get(array('one' => 'two'), null, '-'); + $result = Hash::get(['one' => 'two'], null, '-'); $this->assertEquals('-', $result); - $result = Hash::get(array('one' => 'two'), '', '-'); + $result = Hash::get(['one' => 'two'], '', '-'); $this->assertEquals('-', $result); } @@ -274,26 +274,26 @@ public function testGetNullPath() { * @return void */ public function testDimensions() { - $result = Hash::dimensions(array()); + $result = Hash::dimensions([]); $this->assertEquals($result, 0); - $data = array('one', '2', 'three'); + $data = ['one', '2', 'three']; $result = Hash::dimensions($data); $this->assertEquals($result, 1); - $data = array('1' => '1.1', '2', '3'); + $data = ['1' => '1.1', '2', '3']; $result = Hash::dimensions($data); $this->assertEquals($result, 1); - $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => '3.1.1')); + $data = ['1' => ['1.1' => '1.1.1'], '2', '3' => ['3.1' => '3.1.1']]; $result = Hash::dimensions($data); $this->assertEquals($result, 2); - $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1')); + $data = ['1' => '1.1', '2', '3' => ['3.1' => '3.1.1']]; $result = Hash::dimensions($data); $this->assertEquals($result, 1); - $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); + $data = ['1' => ['1.1' => '1.1.1'], '2', '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Hash::dimensions($data); $this->assertEquals($result, 2); } @@ -304,38 +304,38 @@ public function testDimensions() { * @return void */ public function testMaxDimensions() { - $data = array(); + $data = []; $result = Hash::maxDimensions($data); $this->assertEquals(0, $result); - $data = array('a', 'b'); + $data = ['a', 'b']; $result = Hash::maxDimensions($data); $this->assertEquals(1, $result); - $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1')); + $data = ['1' => '1.1', '2', '3' => ['3.1' => '3.1.1']]; $result = Hash::maxDimensions($data); $this->assertEquals($result, 2); - $data = array( - '1' => array('1.1' => '1.1.1'), + $data = [ + '1' => ['1.1' => '1.1.1'], '2', - '3' => array('3.1' => array('3.1.1' => '3.1.1.1')) - ); + '3' => ['3.1' => ['3.1.1' => '3.1.1.1']] + ]; $result = Hash::maxDimensions($data); $this->assertEquals($result, 3); - $data = array( - '1' => array( + $data = [ + '1' => [ '1.1' => '1.1.1', - '1.2' => array( - '1.2.1' => array( + '1.2' => [ + '1.2.1' => [ '1.2.1.1', - array('1.2.2.1') - ) - ) - ), - '2' => array('2.1' => '2.1.1') - ); + ['1.2.2.1'] + ] + ] + ], + '2' => ['2.1' => '2.1.1'] + ]; $result = Hash::maxDimensions($data); $this->assertEquals($result, 5); } @@ -346,7 +346,7 @@ public function testMaxDimensions() { * @return void */ public function testFlatten() { - $data = array('Larry', 'Curly', 'Moe'); + $data = ['Larry', 'Curly', 'Moe']; $result = Hash::flatten($data); $this->assertEquals($result, $data); @@ -354,18 +354,18 @@ public function testFlatten() { $result = Hash::flatten($data); $this->assertEquals($result, $data); - $data = array( - array( - 'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post'), - 'Author' => array('id' => '1', 'user' => 'nate', 'password' => 'foo'), - ), - array( - 'Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body'), - 'Author' => array('id' => '3', 'user' => 'larry', 'password' => null), - ) - ); + $data = [ + [ + 'Post' => ['id' => '1', 'author_id' => '1', 'title' => 'First Post'], + 'Author' => ['id' => '1', 'user' => 'nate', 'password' => 'foo'], + ], + [ + 'Post' => ['id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body'], + 'Author' => ['id' => '3', 'user' => 'larry', 'password' => null], + ] + ]; $result = Hash::flatten($data); - $expected = array( + $expected = [ '0.Post.id' => '1', '0.Post.author_id' => '1', '0.Post.title' => 'First Post', @@ -379,33 +379,33 @@ public function testFlatten() { '1.Author.id' => '3', '1.Author.user' => 'larry', '1.Author.password' => null - ); + ]; $this->assertEquals($expected, $result); - $data = array( - array( - 'Post' => array('id' => '1', 'author_id' => null, 'title' => 'First Post'), - 'Author' => array(), - ) - ); + $data = [ + [ + 'Post' => ['id' => '1', 'author_id' => null, 'title' => 'First Post'], + 'Author' => [], + ] + ]; $result = Hash::flatten($data); - $expected = array( + $expected = [ '0.Post.id' => '1', '0.Post.author_id' => null, '0.Post.title' => 'First Post', - '0.Author' => array() - ); + '0.Author' => [] + ]; $this->assertEquals($expected, $result); - $data = array( - array('Post' => array('id' => 1)), - array('Post' => array('id' => 2)), - ); + $data = [ + ['Post' => ['id' => 1]], + ['Post' => ['id' => 2]], + ]; $result = Hash::flatten($data, '/'); - $expected = array( + $expected = [ '0/Post/id' => '1', '1/Post/id' => '2', - ); + ]; $this->assertEquals($expected, $result); } @@ -415,77 +415,77 @@ public function testFlatten() { * @return void */ public function testDiff() { - $a = array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about') - ); - $b = array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about'), - 2 => array('name' => 'contact') - ); - - $result = Hash::diff($a, array()); + $a = [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'] + ]; + $b = [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'], + 2 => ['name' => 'contact'] + ]; + + $result = Hash::diff($a, []); $expected = $a; $this->assertEquals($expected, $result); - $result = Hash::diff(array(), $b); + $result = Hash::diff([], $b); $expected = $b; $this->assertEquals($expected, $result); $result = Hash::diff($a, $b); - $expected = array( - 2 => array('name' => 'contact') - ); + $expected = [ + 2 => ['name' => 'contact'] + ]; $this->assertEquals($expected, $result); - $b = array( - 0 => array('name' => 'me'), - 1 => array('name' => 'about') - ); + $b = [ + 0 => ['name' => 'me'], + 1 => ['name' => 'about'] + ]; $result = Hash::diff($a, $b); - $expected = array( - 0 => array('name' => 'main') - ); + $expected = [ + 0 => ['name' => 'main'] + ]; $this->assertEquals($expected, $result); - $a = array(); - $b = array('name' => 'bob', 'address' => 'home'); + $a = []; + $b = ['name' => 'bob', 'address' => 'home']; $result = Hash::diff($a, $b); $this->assertEquals($result, $b); - $a = array('name' => 'bob', 'address' => 'home'); - $b = array(); + $a = ['name' => 'bob', 'address' => 'home']; + $b = []; $result = Hash::diff($a, $b); $this->assertEquals($result, $a); - $a = array('key' => true, 'another' => false, 'name' => 'me'); - $b = array('key' => 1, 'another' => 0); - $expected = array('name' => 'me'); + $a = ['key' => true, 'another' => false, 'name' => 'me']; + $b = ['key' => 1, 'another' => 0]; + $expected = ['name' => 'me']; $result = Hash::diff($a, $b); $this->assertEquals($expected, $result); - $a = array('key' => 'value', 'another' => null, 'name' => 'me'); - $b = array('key' => 'differentValue', 'another' => null); - $expected = array('key' => 'value', 'name' => 'me'); + $a = ['key' => 'value', 'another' => null, 'name' => 'me']; + $b = ['key' => 'differentValue', 'another' => null]; + $expected = ['key' => 'value', 'name' => 'me']; $result = Hash::diff($a, $b); $this->assertEquals($expected, $result); - $a = array('key' => 'value', 'another' => null, 'name' => 'me'); - $b = array('key' => 'differentValue', 'another' => 'value'); - $expected = array('key' => 'value', 'another' => null, 'name' => 'me'); + $a = ['key' => 'value', 'another' => null, 'name' => 'me']; + $b = ['key' => 'differentValue', 'another' => 'value']; + $expected = ['key' => 'value', 'another' => null, 'name' => 'me']; $result = Hash::diff($a, $b); $this->assertEquals($expected, $result); - $a = array('key' => 'value', 'another' => null, 'name' => 'me'); - $b = array('key' => 'differentValue', 'another' => 'value'); - $expected = array('key' => 'differentValue', 'another' => 'value', 'name' => 'me'); + $a = ['key' => 'value', 'another' => null, 'name' => 'me']; + $b = ['key' => 'differentValue', 'another' => 'value']; + $expected = ['key' => 'differentValue', 'another' => 'value', 'name' => 'me']; $result = Hash::diff($b, $a); $this->assertEquals($expected, $result); - $a = array('key' => 'value', 'another' => null, 'name' => 'me'); - $b = array(0 => 'differentValue', 1 => 'value'); + $a = ['key' => 'value', 'another' => null, 'name' => 'me']; + $b = [0 => 'differentValue', 1 => 'value']; $expected = $a + $b; $result = Hash::diff($a, $b); $this->assertEquals($expected, $result); @@ -497,84 +497,84 @@ public function testDiff() { * @return void */ public function testMerge() { - $result = Hash::merge(array('foo'), array('bar')); - $this->assertEquals($result, array('foo', 'bar')); + $result = Hash::merge(['foo'], ['bar']); + $this->assertEquals($result, ['foo', 'bar']); - $result = Hash::merge(array('foo'), array('user' => 'bob', 'no-bar'), 'bar'); - $this->assertEquals($result, array('foo', 'user' => 'bob', 'no-bar', 'bar')); + $result = Hash::merge(['foo'], ['user' => 'bob', 'no-bar'], 'bar'); + $this->assertEquals($result, ['foo', 'user' => 'bob', 'no-bar', 'bar']); - $a = array('foo', 'foo2'); - $b = array('bar', 'bar2'); - $expected = array('foo', 'foo2', 'bar', 'bar2'); + $a = ['foo', 'foo2']; + $b = ['bar', 'bar2']; + $expected = ['foo', 'foo2', 'bar', 'bar2']; $this->assertEquals($expected, Hash::merge($a, $b)); - $a = array('foo' => 'bar', 'bar' => 'foo'); - $b = array('foo' => 'no-bar', 'bar' => 'no-foo'); - $expected = array('foo' => 'no-bar', 'bar' => 'no-foo'); + $a = ['foo' => 'bar', 'bar' => 'foo']; + $b = ['foo' => 'no-bar', 'bar' => 'no-foo']; + $expected = ['foo' => 'no-bar', 'bar' => 'no-foo']; $this->assertEquals($expected, Hash::merge($a, $b)); - $a = array('users' => array('bob', 'jim')); - $b = array('users' => array('lisa', 'tina')); - $expected = array('users' => array('bob', 'jim', 'lisa', 'tina')); + $a = ['users' => ['bob', 'jim']]; + $b = ['users' => ['lisa', 'tina']]; + $expected = ['users' => ['bob', 'jim', 'lisa', 'tina']]; $this->assertEquals($expected, Hash::merge($a, $b)); - $a = array('users' => array('jim', 'bob')); - $b = array('users' => 'none'); - $expected = array('users' => 'none'); + $a = ['users' => ['jim', 'bob']]; + $b = ['users' => 'none']; + $expected = ['users' => 'none']; $this->assertEquals($expected, Hash::merge($a, $b)); - $a = array('users' => array('lisa' => array('id' => 5, 'pw' => 'secret')), 'cakephp'); - $b = array('users' => array('lisa' => array('pw' => 'new-pass', 'age' => 23)), 'ice-cream'); - $expected = array( - 'users' => array('lisa' => array('id' => 5, 'pw' => 'new-pass', 'age' => 23)), + $a = ['users' => ['lisa' => ['id' => 5, 'pw' => 'secret']], 'cakephp']; + $b = ['users' => ['lisa' => ['pw' => 'new-pass', 'age' => 23]], 'ice-cream']; + $expected = [ + 'users' => ['lisa' => ['id' => 5, 'pw' => 'new-pass', 'age' => 23]], 'cakephp', 'ice-cream' - ); + ]; $result = Hash::merge($a, $b); $this->assertEquals($expected, $result); - $c = array( - 'users' => array('lisa' => array('pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog')), + $c = [ + 'users' => ['lisa' => ['pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog']], 'chocolate' - ); - $expected = array( - 'users' => array('lisa' => array('id' => 5, 'pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog')), + ]; + $expected = [ + 'users' => ['lisa' => ['id' => 5, 'pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog']], 'cakephp', 'ice-cream', 'chocolate' - ); + ]; $this->assertEquals($expected, Hash::merge($a, $b, $c)); - $this->assertEquals($expected, Hash::merge($a, $b, array(), $c)); + $this->assertEquals($expected, Hash::merge($a, $b, [], $c)); - $a = array( + $a = [ 'Tree', 'CounterCache', - 'Upload' => array( + 'Upload' => [ 'folder' => 'products', - 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id') - ) - ); - $b = array( - 'Cacheable' => array('enabled' => false), + 'fields' => ['image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id'] + ] + ]; + $b = [ + 'Cacheable' => ['enabled' => false], 'Limit', 'Bindable', 'Validator', 'Transactional' - ); - $expected = array( + ]; + $expected = [ 'Tree', 'CounterCache', - 'Upload' => array( + 'Upload' => [ 'folder' => 'products', - 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id') - ), - 'Cacheable' => array('enabled' => false), + 'fields' => ['image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id'] + ], + 'Cacheable' => ['enabled' => false], 'Limit', 'Bindable', 'Validator', 'Transactional' - ); + ]; $this->assertEquals($expected, Hash::merge($a, $b)); } @@ -584,24 +584,24 @@ public function testMerge() { * @return void */ public function testNormalize() { - $result = Hash::normalize(array('one', 'two', 'three')); - $expected = array('one' => null, 'two' => null, 'three' => null); + $result = Hash::normalize(['one', 'two', 'three']); + $expected = ['one' => null, 'two' => null, 'three' => null]; $this->assertEquals($expected, $result); - $result = Hash::normalize(array('one', 'two', 'three'), false); - $expected = array('one', 'two', 'three'); + $result = Hash::normalize(['one', 'two', 'three'], false); + $expected = ['one', 'two', 'three']; $this->assertEquals($expected, $result); - $result = Hash::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four'), false); - $expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null); + $result = Hash::normalize(['one' => 1, 'two' => 2, 'three' => 3, 'four'], false); + $expected = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => null]; $this->assertEquals($expected, $result); - $result = Hash::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four')); - $expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null); + $result = Hash::normalize(['one' => 1, 'two' => 2, 'three' => 3, 'four']); + $expected = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => null]; $this->assertEquals($expected, $result); - $result = Hash::normalize(array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three')); - $expected = array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three' => null); + $result = Hash::normalize(['one' => ['a', 'b', 'c' => 'cee'], 'two' => 2, 'three']); + $expected = ['one' => ['a', 'b', 'c' => 'cee'], 'two' => 2, 'three' => null]; $this->assertEquals($expected, $result); } @@ -611,42 +611,42 @@ public function testNormalize() { * @return void */ public function testContains() { - $data = array('apple', 'bee', 'cyclops'); - $this->assertTrue(Hash::contains($data, array('apple'))); - $this->assertFalse(Hash::contains($data, array('data'))); - - $a = array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about') - ); - $b = array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about'), - 2 => array('name' => 'contact'), + $data = ['apple', 'bee', 'cyclops']; + $this->assertTrue(Hash::contains($data, ['apple'])); + $this->assertFalse(Hash::contains($data, ['data'])); + + $a = [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'] + ]; + $b = [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'], + 2 => ['name' => 'contact'], 'a' => 'b' - ); + ]; $this->assertTrue(Hash::contains($a, $a)); $this->assertFalse(Hash::contains($a, $b)); $this->assertTrue(Hash::contains($b, $a)); - $a = array( - array('User' => array('id' => 1)), - array('User' => array('id' => 2)), - ); - $b = array( - array('User' => array('id' => 1)), - array('User' => array('id' => 2)), - array('User' => array('id' => 3)) - ); + $a = [ + ['User' => ['id' => 1]], + ['User' => ['id' => 2]], + ]; + $b = [ + ['User' => ['id' => 1]], + ['User' => ['id' => 2]], + ['User' => ['id' => 3]] + ]; $this->assertTrue(Hash::contains($b, $a)); $this->assertFalse(Hash::contains($a, $b)); - $a = array(0 => 'test', 'string' => null); - $this->assertTrue(Hash::contains($a, array('string' => null))); + $a = [0 => 'test', 'string' => null]; + $this->assertTrue(Hash::contains($a, ['string' => null])); - $a = array(0 => 'test', 'string' => null); - $this->assertTrue(Hash::contains($a, array('test'))); + $a = [0 => 'test', 'string' => null]; + $this->assertTrue(Hash::contains($a, ['test'])); } /** @@ -655,40 +655,40 @@ public function testContains() { * @return void */ public function testFilter() { - $result = Hash::filter(array( + $result = Hash::filter([ '0', false, true, 0, 0.0, - array('one thing', 'I can tell you', 'is you got to be', false) - )); - $expected = array( + ['one thing', 'I can tell you', 'is you got to be', false] + ]); + $expected = [ '0', 2 => true, 3 => 0, 4 => 0.0, - 5 => array('one thing', 'I can tell you', 'is you got to be') - ); + 5 => ['one thing', 'I can tell you', 'is you got to be'] + ]; $this->assertSame($expected, $result); - $result = Hash::filter(array(1, array(false))); - $expected = array(1); + $result = Hash::filter([1, [false]]); + $expected = [1]; $this->assertEquals($expected, $result); - $result = Hash::filter(array(1, array(false, false))); - $expected = array(1); + $result = Hash::filter([1, [false, false]]); + $expected = [1]; $this->assertEquals($expected, $result); - $result = Hash::filter(array(1, array('empty', false))); - $expected = array(1, array('empty')); + $result = Hash::filter([1, ['empty', false]]); + $expected = [1, ['empty']]; $this->assertEquals($expected, $result); - $result = Hash::filter(array(1, array('2', false, array(3, null)))); - $expected = array(1, array('2', 2 => array(3))); + $result = Hash::filter([1, ['2', false, [3, null]]]); + $expected = [1, ['2', 2 => [3]]]; $this->assertEquals($expected, $result); - $this->assertSame(array(), Hash::filter(array())); + $this->assertSame([], Hash::filter([])); } /** @@ -697,37 +697,37 @@ public function testFilter() { * @return void */ public function testNumeric() { - $data = array('one'); + $data = ['one']; $this->assertTrue(Hash::numeric(array_keys($data))); - $data = array(1 => 'one'); + $data = [1 => 'one']; $this->assertFalse(Hash::numeric($data)); - $data = array('one'); + $data = ['one']; $this->assertFalse(Hash::numeric($data)); - $data = array('one' => 'two'); + $data = ['one' => 'two']; $this->assertFalse(Hash::numeric($data)); - $data = array('one' => 1); + $data = ['one' => 1]; $this->assertTrue(Hash::numeric($data)); - $data = array(0); + $data = [0]; $this->assertTrue(Hash::numeric($data)); - $data = array('one', 'two', 'three', 'four', 'five'); + $data = ['one', 'two', 'three', 'four', 'five']; $this->assertTrue(Hash::numeric(array_keys($data))); - $data = array(1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five'); + $data = [1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five']; $this->assertTrue(Hash::numeric(array_keys($data))); - $data = array('1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five'); + $data = ['1' => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five']; $this->assertTrue(Hash::numeric(array_keys($data))); - $data = array('one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five'); + $data = ['one', 2 => 'two', 3 => 'three', 4 => 'four', 'a' => 'five']; $this->assertFalse(Hash::numeric(array_keys($data))); - $data = array(2.4, 1, 0, -1, -2); + $data = [2.4, 1, 0, -1, -2]; $this->assertTrue(Hash::numeric($data)); } @@ -743,13 +743,13 @@ public function testExtractBasic() { $this->assertEquals($data, $result); $result = Hash::extract($data, '0.Article.title'); - $this->assertEquals(array('First Article'), $result); + $this->assertEquals(['First Article'], $result); $result = Hash::extract($data, '1.Article.title'); - $this->assertEquals(array('Second Article'), $result); + $this->assertEquals(['Second Article'], $result); - $result = Hash::extract(array(false), '{n}.Something.another_thing'); - $this->assertEquals(array(), $result); + $result = Hash::extract([false], '{n}.Something.another_thing'); + $this->assertEquals([], $result); } /** @@ -760,17 +760,17 @@ public function testExtractBasic() { public function testExtractNumericKey() { $data = static::articleData(); $result = Hash::extract($data, '{n}.Article.title'); - $expected = array( + $expected = [ 'First Article', 'Second Article', 'Third Article', 'Fourth Article', 'Fifth Article' - ); + ]; $this->assertEquals($expected, $result); $result = Hash::extract($data, '0.Comment.{n}.user_id'); - $expected = array( + $expected = [ '2', '4' - ); + ]; $this->assertEquals($expected, $result); } @@ -780,23 +780,23 @@ public function testExtractNumericKey() { * @return void */ public function testExtractNumericMixedKeys() { - $data = array( - 'User' => array( - 0 => array( + $data = [ + 'User' => [ + 0 => [ 'id' => 4, 'name' => 'Neo' - ), - 1 => array( + ], + 1 => [ 'id' => 5, 'name' => 'Morpheus' - ), - 'stringKey' => array( + ], + 'stringKey' => [ 'name' => 'Fail' - ) - ) - ); + ] + ] + ]; $result = Hash::extract($data, 'User.{n}.name'); - $expected = array('Neo', 'Morpheus'); + $expected = ['Neo', 'Morpheus']; $this->assertEquals($expected, $result); } @@ -806,28 +806,28 @@ public function testExtractNumericMixedKeys() { * @return void */ public function testExtractNumericNonZero() { - $data = array( - 1 => array( - 'User' => array( + $data = [ + 1 => [ + 'User' => [ 'id' => 1, 'name' => 'John', - ) - ), - 2 => array( - 'User' => array( + ] + ], + 2 => [ + 'User' => [ 'id' => 2, 'name' => 'Bob', - ) - ), - 3 => array( - 'User' => array( + ] + ], + 3 => [ + 'User' => [ 'id' => 3, 'name' => 'Tony', - ) - ) - ); + ] + ] + ]; $result = Hash::extract($data, '{n}.User.name'); - $expected = array('John', 'Bob', 'Tony'); + $expected = ['John', 'Bob', 'Tony']; $this->assertEquals($expected, $result); } @@ -839,17 +839,17 @@ public function testExtractNumericNonZero() { public function testExtractStringKey() { $data = static::articleData(); $result = Hash::extract($data, '{n}.{s}.user'); - $expected = array( + $expected = [ 'mariano', 'mariano', 'mariano', 'mariano', 'mariano' - ); + ]; $this->assertEquals($expected, $result); $result = Hash::extract($data, '{n}.{s}.Nesting.test.1'); - $this->assertEquals(array('foo'), $result); + $this->assertEquals(['foo'], $result); } /** @@ -858,23 +858,23 @@ public function testExtractStringKey() { * @return void */ public function testExtractWildcard() { - $data = array( - '02000009C5560001' => array('name' => 'Mr. Alphanumeric'), - '2300000918020101' => array('name' => 'Mr. Numeric'), - '390000096AB30001' => array('name' => 'Mrs. Alphanumeric'), - 'stuff' => array('name' => 'Ms. Word'), - 123 => array('name' => 'Mr. Number'), - true => array('name' => 'Ms. Bool'), - ); + $data = [ + '02000009C5560001' => ['name' => 'Mr. Alphanumeric'], + '2300000918020101' => ['name' => 'Mr. Numeric'], + '390000096AB30001' => ['name' => 'Mrs. Alphanumeric'], + 'stuff' => ['name' => 'Ms. Word'], + 123 => ['name' => 'Mr. Number'], + true => ['name' => 'Ms. Bool'], + ]; $result = Hash::extract($data, '{*}.name'); - $expected = array( + $expected = [ 'Mr. Alphanumeric', 'Mr. Numeric', 'Mrs. Alphanumeric', 'Ms. Word', 'Mr. Number', 'Ms. Bool', - ); + ]; $this->assertEquals($expected, $result); } @@ -887,11 +887,11 @@ public function testExtractAttributePresence() { $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[published]'); - $expected = array($data[1]['Article']); + $expected = [$data[1]['Article']]; $this->assertEquals($expected, $result); $result = Hash::extract($data, '{n}.Article[id][published]'); - $expected = array($data[1]['Article']); + $expected = [$data[1]['Article']]; $this->assertEquals($expected, $result); } @@ -904,11 +904,11 @@ public function testExtractAttributeEquality() { $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[id=3]'); - $expected = array($data[2]['Article']); + $expected = [$data[2]['Article']]; $this->assertEquals($expected, $result); $result = Hash::extract($data, '{n}.Article[id = 3]'); - $expected = array($data[2]['Article']); + $expected = [$data[2]['Article']]; $this->assertEquals($expected, $result, 'Whitespace should not matter.'); $result = Hash::extract($data, '{n}.Article[id!=3]'); @@ -924,23 +924,23 @@ public function testExtractAttributeEquality() { * @return void */ public function testExtractAttributeBoolean() { - $users = array( - array( + $users = [ + [ 'id' => 2, 'username' => 'johndoe', 'active' => true - ), - array( + ], + [ 'id' => 5, 'username' => 'kevin', 'active' => true - ), - array( + ], + [ 'id' => 9, 'username' => 'samantha', 'active' => false - ), - ); + ], + ]; $result = Hash::extract($users, '{n}[active=0]'); $this->assertCount(1, $result); $this->assertEquals($users[2], $result[0]); @@ -966,18 +966,18 @@ public function testExtractAttributeBoolean() { * @return void */ public function testExtractAttributeEqualityOnScalarValue() { - $data = array( - 'Entity' => array( + $data = [ + 'Entity' => [ 'id' => 1, 'data1' => 'value', - ) - ); + ] + ]; $result = Hash::extract($data, 'Entity[id=1].data1'); - $this->assertEquals(array('value'), $result); + $this->assertEquals(['value'], $result); - $data = array('Entity' => false ); + $data = ['Entity' => false ]; $result = Hash::extract($data, 'Entity[id=1].data1'); - $this->assertEquals(array(), $result); + $this->assertEquals([], $result); } /** @@ -989,22 +989,22 @@ public function testExtractAttributeComparison() { $data = static::articleData(); $result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2]'); - $expected = array($data[0]['Comment'][1]); + $expected = [$data[0]['Comment'][1]]; $this->assertEquals($expected, $result); $this->assertEquals(4, $expected[0]['user_id']); $result = Hash::extract($data, '{n}.Comment.{n}[user_id >= 4]'); - $expected = array($data[0]['Comment'][1]); + $expected = [$data[0]['Comment'][1]]; $this->assertEquals($expected, $result); $this->assertEquals(4, $expected[0]['user_id']); $result = Hash::extract($data, '{n}.Comment.{n}[user_id < 3]'); - $expected = array($data[0]['Comment'][0]); + $expected = [$data[0]['Comment'][0]]; $this->assertEquals($expected, $result); $this->assertEquals(2, $expected[0]['user_id']); $result = Hash::extract($data, '{n}.Comment.{n}[user_id <= 2]'); - $expected = array($data[0]['Comment'][0]); + $expected = [$data[0]['Comment'][0]]; $this->assertEquals($expected, $result); $this->assertEquals(2, $expected[0]['user_id']); } @@ -1021,7 +1021,7 @@ public function testExtractAttributeMultiple() { $this->assertEmpty($result); $result = Hash::extract($data, '{n}.Comment.{n}[user_id > 2][id=2]'); - $expected = array($data[0]['Comment'][1]); + $expected = [$data[0]['Comment'][1]]; $this->assertEquals($expected, $result); $this->assertEquals(4, $expected[0]['user_id']); } @@ -1035,11 +1035,11 @@ public function testExtractAttributePattern() { $data = static::articleData(); $result = Hash::extract($data, '{n}.Article[title=/^First/]'); - $expected = array($data[0]['Article']); + $expected = [$data[0]['Article']]; $this->assertEquals($expected, $result); $result = Hash::extract($data, '{n}.Article[title=/^Fir[a-z]+/]'); - $expected = array($data[0]['Article']); + $expected = [$data[0]['Article']]; $this->assertEquals($expected, $result); } @@ -1049,22 +1049,22 @@ public function testExtractAttributePattern() { * @return void */ public function testExtractMatchesNull() { - $data = array( - 'Country' => array( - array('name' => 'Canada'), - array('name' => 'Australia'), - array('name' => null), - ) - ); + $data = [ + 'Country' => [ + ['name' => 'Canada'], + ['name' => 'Australia'], + ['name' => null], + ] + ]; $result = Hash::extract($data, 'Country.{n}[name=/Canada|^$/]'); - $expected = array( - array( + $expected = [ + [ 'name' => 'Canada', - ), - array( + ], + [ 'name' => null, - ), - ); + ], + ]; $this->assertEquals($expected, $result); } @@ -1074,36 +1074,36 @@ public function testExtractMatchesNull() { * @return void */ public function testExtractUnevenKeys() { - $data = array( - 'Level1' => array( - 'Level2' => array('test1', 'test2'), - 'Level2bis' => array('test3', 'test4') - ) - ); + $data = [ + 'Level1' => [ + 'Level2' => ['test1', 'test2'], + 'Level2bis' => ['test3', 'test4'] + ] + ]; $this->assertEquals( - array('test1', 'test2'), + ['test1', 'test2'], Hash::extract($data, 'Level1.Level2') ); $this->assertEquals( - array('test3', 'test4'), + ['test3', 'test4'], Hash::extract($data, 'Level1.Level2bis') ); - $data = array( - 'Level1' => array( - 'Level2bis' => array( - array('test3', 'test4'), - array('test5', 'test6') - ) - ) - ); - $expected = array( - array('test3', 'test4'), - array('test5', 'test6') - ); + $data = [ + 'Level1' => [ + 'Level2bis' => [ + ['test3', 'test4'], + ['test5', 'test6'] + ] + ] + ]; + $expected = [ + ['test3', 'test4'], + ['test5', 'test6'] + ]; $this->assertEquals($expected, Hash::extract($data, 'Level1.Level2bis')); - $data['Level1']['Level2'] = array('test1', 'test2'); + $data['Level1']['Level2'] = ['test1', 'test2']; $this->assertEquals($expected, Hash::extract($data, 'Level1.Level2bis')); } @@ -1113,148 +1113,148 @@ public function testExtractUnevenKeys() { * @return void */ public function testSort() { - $result = Hash::sort(array(), '{n}.name'); - $this->assertEquals(array(), $result); - - $a = array( - 0 => array( - 'Person' => array('name' => 'Jeff'), - 'Friend' => array(array('name' => 'Nate')) - ), - 1 => array( - 'Person' => array('name' => 'Tracy'), - 'Friend' => array(array('name' => 'Lindsay')) - ) - ); - $b = array( - 0 => array( - 'Person' => array('name' => 'Tracy'), - 'Friend' => array(array('name' => 'Lindsay')) - ), - 1 => array( - 'Person' => array('name' => 'Jeff'), - 'Friend' => array(array('name' => 'Nate')) - ) - ); + $result = Hash::sort([], '{n}.name'); + $this->assertEquals([], $result); + + $a = [ + 0 => [ + 'Person' => ['name' => 'Jeff'], + 'Friend' => [['name' => 'Nate']] + ], + 1 => [ + 'Person' => ['name' => 'Tracy'], + 'Friend' => [['name' => 'Lindsay']] + ] + ]; + $b = [ + 0 => [ + 'Person' => ['name' => 'Tracy'], + 'Friend' => [['name' => 'Lindsay']] + ], + 1 => [ + 'Person' => ['name' => 'Jeff'], + 'Friend' => [['name' => 'Nate']] + ] + ]; $a = Hash::sort($a, '{n}.Friend.{n}.name'); $this->assertEquals($a, $b); - $b = array( - 0 => array( - 'Person' => array('name' => 'Jeff'), - 'Friend' => array(array('name' => 'Nate')) - ), - 1 => array( - 'Person' => array('name' => 'Tracy'), - 'Friend' => array(array('name' => 'Lindsay')) - ) - ); - $a = array( - 0 => array( - 'Person' => array('name' => 'Tracy'), - 'Friend' => array(array('name' => 'Lindsay')) - ), - 1 => array( - 'Person' => array('name' => 'Jeff'), - 'Friend' => array(array('name' => 'Nate')) - ) - ); + $b = [ + 0 => [ + 'Person' => ['name' => 'Jeff'], + 'Friend' => [['name' => 'Nate']] + ], + 1 => [ + 'Person' => ['name' => 'Tracy'], + 'Friend' => [['name' => 'Lindsay']] + ] + ]; + $a = [ + 0 => [ + 'Person' => ['name' => 'Tracy'], + 'Friend' => [['name' => 'Lindsay']] + ], + 1 => [ + 'Person' => ['name' => 'Jeff'], + 'Friend' => [['name' => 'Nate']] + ] + ]; $a = Hash::sort($a, '{n}.Friend.{n}.name', 'desc'); $this->assertEquals($a, $b); - $a = array( - 0 => array( - 'Person' => array('name' => 'Jeff'), - 'Friend' => array(array('name' => 'Nate')) - ), - 1 => array( - 'Person' => array('name' => 'Tracy'), - 'Friend' => array(array('name' => 'Lindsay')) - ), - 2 => array( - 'Person' => array('name' => 'Adam'), - 'Friend' => array(array('name' => 'Bob')) - ) - ); - $b = array( - 0 => array( - 'Person' => array('name' => 'Adam'), - 'Friend' => array(array('name' => 'Bob')) - ), - 1 => array( - 'Person' => array('name' => 'Jeff'), - 'Friend' => array(array('name' => 'Nate')) - ), - 2 => array( - 'Person' => array('name' => 'Tracy'), - 'Friend' => array(array('name' => 'Lindsay')) - ) - ); + $a = [ + 0 => [ + 'Person' => ['name' => 'Jeff'], + 'Friend' => [['name' => 'Nate']] + ], + 1 => [ + 'Person' => ['name' => 'Tracy'], + 'Friend' => [['name' => 'Lindsay']] + ], + 2 => [ + 'Person' => ['name' => 'Adam'], + 'Friend' => [['name' => 'Bob']] + ] + ]; + $b = [ + 0 => [ + 'Person' => ['name' => 'Adam'], + 'Friend' => [['name' => 'Bob']] + ], + 1 => [ + 'Person' => ['name' => 'Jeff'], + 'Friend' => [['name' => 'Nate']] + ], + 2 => [ + 'Person' => ['name' => 'Tracy'], + 'Friend' => [['name' => 'Lindsay']] + ] + ]; $a = Hash::sort($a, '{n}.Person.name', 'asc'); $this->assertEquals($a, $b); - $a = array( - 0 => array('Person' => array('name' => 'Jeff')), - 1 => array('Shirt' => array('color' => 'black')) - ); - $b = array( - 0 => array('Shirt' => array('color' => 'black')), - 1 => array('Person' => array('name' => 'Jeff')), - ); + $a = [ + 0 => ['Person' => ['name' => 'Jeff']], + 1 => ['Shirt' => ['color' => 'black']] + ]; + $b = [ + 0 => ['Shirt' => ['color' => 'black']], + 1 => ['Person' => ['name' => 'Jeff']], + ]; $a = Hash::sort($a, '{n}.Person.name', 'ASC', 'STRING'); $this->assertSame($a, $b); - $names = array( - array('employees' => array( - array('name' => array('first' => 'John', 'last' => 'Doe'))) - ), - array('employees' => array( - array('name' => array('first' => 'Jane', 'last' => 'Doe'))) - ), - array('employees' => array(array('name' => array()))), - array('employees' => array(array('name' => array()))) - ); + $names = [ + ['employees' => [ + ['name' => ['first' => 'John', 'last' => 'Doe']]] + ], + ['employees' => [ + ['name' => ['first' => 'Jane', 'last' => 'Doe']]] + ], + ['employees' => [['name' => []]]], + ['employees' => [['name' => []]]] + ]; $result = Hash::sort($names, '{n}.employees.0.name', 'asc'); - $expected = array( - array('employees' => array( - array('name' => array('first' => 'John', 'last' => 'Doe'))) - ), - array('employees' => array( - array('name' => array('first' => 'Jane', 'last' => 'Doe'))) - ), - array('employees' => array(array('name' => array()))), - array('employees' => array(array('name' => array()))) - ); + $expected = [ + ['employees' => [ + ['name' => ['first' => 'John', 'last' => 'Doe']]] + ], + ['employees' => [ + ['name' => ['first' => 'Jane', 'last' => 'Doe']]] + ], + ['employees' => [['name' => []]]], + ['employees' => [['name' => []]]] + ]; $this->assertSame($expected, $result); - $a = array( - 'SU' => array( + $a = [ + 'SU' => [ 'total_fulfillable' => 2 - ), - 'AA' => array( + ], + 'AA' => [ 'total_fulfillable' => 1 - ), - 'LX' => array( + ], + 'LX' => [ 'total_fulfillable' => 0 - ), - 'BL' => array( + ], + 'BL' => [ 'total_fulfillable' => 3 - ), - ); - $expected = array( - 'LX' => array( + ], + ]; + $expected = [ + 'LX' => [ 'total_fulfillable' => 0 - ), - 'AA' => array( + ], + 'AA' => [ 'total_fulfillable' => 1 - ), - 'SU' => array( + ], + 'SU' => [ 'total_fulfillable' => 2 - ), - 'BL' => array( + ], + 'BL' => [ 'total_fulfillable' => 3 - ), - ); + ], + ]; $result = Hash::sort($a, '{s}.total_fulfillable', 'asc'); $this->assertSame($expected, $result); } @@ -1265,31 +1265,31 @@ public function testSort() { * @return void */ public function testSortNumeric() { - $items = array( - array('Item' => array('price' => '155,000')), - array('Item' => array('price' => '139,000')), - array('Item' => array('price' => '275,622')), - array('Item' => array('price' => '230,888')), - array('Item' => array('price' => '66,000')), - ); + $items = [ + ['Item' => ['price' => '155,000']], + ['Item' => ['price' => '139,000']], + ['Item' => ['price' => '275,622']], + ['Item' => ['price' => '230,888']], + ['Item' => ['price' => '66,000']], + ]; $result = Hash::sort($items, '{n}.Item.price', 'asc', 'numeric'); - $expected = array( - array('Item' => array('price' => '66,000')), - array('Item' => array('price' => '139,000')), - array('Item' => array('price' => '155,000')), - array('Item' => array('price' => '230,888')), - array('Item' => array('price' => '275,622')), - ); + $expected = [ + ['Item' => ['price' => '66,000']], + ['Item' => ['price' => '139,000']], + ['Item' => ['price' => '155,000']], + ['Item' => ['price' => '230,888']], + ['Item' => ['price' => '275,622']], + ]; $this->assertEquals($expected, $result); $result = Hash::sort($items, '{n}.Item.price', 'desc', 'numeric'); - $expected = array( - array('Item' => array('price' => '275,622')), - array('Item' => array('price' => '230,888')), - array('Item' => array('price' => '155,000')), - array('Item' => array('price' => '139,000')), - array('Item' => array('price' => '66,000')), - ); + $expected = [ + ['Item' => ['price' => '275,622']], + ['Item' => ['price' => '230,888']], + ['Item' => ['price' => '155,000']], + ['Item' => ['price' => '139,000']], + ['Item' => ['price' => '66,000']], + ]; $this->assertEquals($expected, $result); } @@ -1302,31 +1302,31 @@ public function testSortNatural() { if (version_compare(PHP_VERSION, '5.4.0', '<')) { $this->markTestSkipped('SORT_NATURAL is available since PHP 5.4.'); } - $items = array( - array('Item' => array('image' => 'img1.jpg')), - array('Item' => array('image' => 'img99.jpg')), - array('Item' => array('image' => 'img12.jpg')), - array('Item' => array('image' => 'img10.jpg')), - array('Item' => array('image' => 'img2.jpg')), - ); + $items = [ + ['Item' => ['image' => 'img1.jpg']], + ['Item' => ['image' => 'img99.jpg']], + ['Item' => ['image' => 'img12.jpg']], + ['Item' => ['image' => 'img10.jpg']], + ['Item' => ['image' => 'img2.jpg']], + ]; $result = Hash::sort($items, '{n}.Item.image', 'desc', 'natural'); - $expected = array( - array('Item' => array('image' => 'img99.jpg')), - array('Item' => array('image' => 'img12.jpg')), - array('Item' => array('image' => 'img10.jpg')), - array('Item' => array('image' => 'img2.jpg')), - array('Item' => array('image' => 'img1.jpg')), - ); + $expected = [ + ['Item' => ['image' => 'img99.jpg']], + ['Item' => ['image' => 'img12.jpg']], + ['Item' => ['image' => 'img10.jpg']], + ['Item' => ['image' => 'img2.jpg']], + ['Item' => ['image' => 'img1.jpg']], + ]; $this->assertEquals($expected, $result); $result = Hash::sort($items, '{n}.Item.image', 'asc', 'natural'); - $expected = array( - array('Item' => array('image' => 'img1.jpg')), - array('Item' => array('image' => 'img2.jpg')), - array('Item' => array('image' => 'img10.jpg')), - array('Item' => array('image' => 'img12.jpg')), - array('Item' => array('image' => 'img99.jpg')), - ); + $expected = [ + ['Item' => ['image' => 'img1.jpg']], + ['Item' => ['image' => 'img2.jpg']], + ['Item' => ['image' => 'img10.jpg']], + ['Item' => ['image' => 'img12.jpg']], + ['Item' => ['image' => 'img99.jpg']], + ]; $this->assertEquals($expected, $result); } @@ -1339,31 +1339,31 @@ public function testSortNaturalIgnoreCase() { if (version_compare(PHP_VERSION, '5.4.0', '<')) { $this->markTestSkipped('SORT_NATURAL is available since PHP 5.4.'); } - $items = array( - array('Item' => array('image' => 'img1.jpg')), - array('Item' => array('image' => 'img99.jpg')), - array('Item' => array('image' => 'Img12.jpg')), - array('Item' => array('image' => 'Img10.jpg')), - array('Item' => array('image' => 'img2.jpg')), - ); - $result = Hash::sort($items, '{n}.Item.image', 'desc', array('type' => 'natural', 'ignoreCase' => true)); - $expected = array( - array('Item' => array('image' => 'img99.jpg')), - array('Item' => array('image' => 'Img12.jpg')), - array('Item' => array('image' => 'Img10.jpg')), - array('Item' => array('image' => 'img2.jpg')), - array('Item' => array('image' => 'img1.jpg')), - ); - $this->assertEquals($expected, $result); - - $result = Hash::sort($items, '{n}.Item.image', 'asc', array('type' => 'NATURAL', 'ignoreCase' => true)); - $expected = array( - array('Item' => array('image' => 'img1.jpg')), - array('Item' => array('image' => 'img2.jpg')), - array('Item' => array('image' => 'Img10.jpg')), - array('Item' => array('image' => 'Img12.jpg')), - array('Item' => array('image' => 'img99.jpg')), - ); + $items = [ + ['Item' => ['image' => 'img1.jpg']], + ['Item' => ['image' => 'img99.jpg']], + ['Item' => ['image' => 'Img12.jpg']], + ['Item' => ['image' => 'Img10.jpg']], + ['Item' => ['image' => 'img2.jpg']], + ]; + $result = Hash::sort($items, '{n}.Item.image', 'desc', ['type' => 'natural', 'ignoreCase' => true]); + $expected = [ + ['Item' => ['image' => 'img99.jpg']], + ['Item' => ['image' => 'Img12.jpg']], + ['Item' => ['image' => 'Img10.jpg']], + ['Item' => ['image' => 'img2.jpg']], + ['Item' => ['image' => 'img1.jpg']], + ]; + $this->assertEquals($expected, $result); + + $result = Hash::sort($items, '{n}.Item.image', 'asc', ['type' => 'NATURAL', 'ignoreCase' => true]); + $expected = [ + ['Item' => ['image' => 'img1.jpg']], + ['Item' => ['image' => 'img2.jpg']], + ['Item' => ['image' => 'Img10.jpg']], + ['Item' => ['image' => 'Img12.jpg']], + ['Item' => ['image' => 'img99.jpg']], + ]; $this->assertEquals($expected, $result); } @@ -1377,14 +1377,14 @@ public function testSortNaturalFallbackToRegular() { $this->markTestSkipped('Skipping SORT_NATURAL fallback test on PHP >= 5.4'); } - $a = array( - 0 => array('Person' => array('name' => 'Jeff')), - 1 => array('Shirt' => array('color' => 'black')) - ); - $b = array( - 0 => array('Shirt' => array('color' => 'black')), - 1 => array('Person' => array('name' => 'Jeff')), - ); + $a = [ + 0 => ['Person' => ['name' => 'Jeff']], + 1 => ['Shirt' => ['color' => 'black']] + ]; + $b = [ + 0 => ['Shirt' => ['color' => 'black']], + 1 => ['Person' => ['name' => 'Jeff']], + ]; $sorted = Hash::sort($a, '{n}.Person.name', 'asc', 'natural'); $this->assertEquals($sorted, $b); } @@ -1401,20 +1401,20 @@ public function testSortLocale() { $updated = setlocale(LC_COLLATE, 'de_DE.utf8'); $this->skipIf($updated === false, 'Could not set locale to de_DE.utf8, skipping test.'); - $items = array( - array('Item' => array('entry' => 'Übergabe')), - array('Item' => array('entry' => 'Ostfriesland')), - array('Item' => array('entry' => 'Äpfel')), - array('Item' => array('entry' => 'Apfel')), - ); + $items = [ + ['Item' => ['entry' => 'Übergabe']], + ['Item' => ['entry' => 'Ostfriesland']], + ['Item' => ['entry' => 'Äpfel']], + ['Item' => ['entry' => 'Apfel']], + ]; $result = Hash::sort($items, '{n}.Item.entry', 'asc', 'locale'); - $expected = array( - array('Item' => array('entry' => 'Apfel')), - array('Item' => array('entry' => 'Äpfel')), - array('Item' => array('entry' => 'Ostfriesland')), - array('Item' => array('entry' => 'Übergabe')), - ); + $expected = [ + ['Item' => ['entry' => 'Apfel']], + ['Item' => ['entry' => 'Äpfel']], + ['Item' => ['entry' => 'Ostfriesland']], + ['Item' => ['entry' => 'Übergabe']], + ]; $this->assertEquals($expected, $result); // change to the original locale @@ -1427,20 +1427,20 @@ public function testSortLocale() { * @return void */ public function testSortWithOutOfOrderKeys() { - $data = array( - 9 => array('class' => 510, 'test2' => 2), - 1 => array('class' => 500, 'test2' => 1), - 2 => array('class' => 600, 'test2' => 2), - 5 => array('class' => 625, 'test2' => 4), - 0 => array('class' => 605, 'test2' => 3), - ); - $expected = array( - array('class' => 500, 'test2' => 1), - array('class' => 510, 'test2' => 2), - array('class' => 600, 'test2' => 2), - array('class' => 605, 'test2' => 3), - array('class' => 625, 'test2' => 4), - ); + $data = [ + 9 => ['class' => 510, 'test2' => 2], + 1 => ['class' => 500, 'test2' => 1], + 2 => ['class' => 600, 'test2' => 2], + 5 => ['class' => 625, 'test2' => 4], + 0 => ['class' => 605, 'test2' => 3], + ]; + $expected = [ + ['class' => 500, 'test2' => 1], + ['class' => 510, 'test2' => 2], + ['class' => 600, 'test2' => 2], + ['class' => 605, 'test2' => 3], + ['class' => 625, 'test2' => 4], + ]; $result = Hash::sort($data, '{n}.class', 'asc'); $this->assertEquals($expected, $result); @@ -1454,33 +1454,33 @@ public function testSortWithOutOfOrderKeys() { * @return void */ public function testSortStringKeys() { - $toSort = array( - 'four' => array('number' => 4, 'some' => 'foursome'), - 'six' => array('number' => 6, 'some' => 'sixsome'), - 'five' => array('number' => 5, 'some' => 'fivesome'), - 'two' => array('number' => 2, 'some' => 'twosome'), - 'three' => array('number' => 3, 'some' => 'threesome') - ); + $toSort = [ + 'four' => ['number' => 4, 'some' => 'foursome'], + 'six' => ['number' => 6, 'some' => 'sixsome'], + 'five' => ['number' => 5, 'some' => 'fivesome'], + 'two' => ['number' => 2, 'some' => 'twosome'], + 'three' => ['number' => 3, 'some' => 'threesome'] + ]; $sorted = Hash::sort($toSort, '{s}.number', 'asc'); - $expected = array( - 'two' => array('number' => 2, 'some' => 'twosome'), - 'three' => array('number' => 3, 'some' => 'threesome'), - 'four' => array('number' => 4, 'some' => 'foursome'), - 'five' => array('number' => 5, 'some' => 'fivesome'), - 'six' => array('number' => 6, 'some' => 'sixsome') - ); + $expected = [ + 'two' => ['number' => 2, 'some' => 'twosome'], + 'three' => ['number' => 3, 'some' => 'threesome'], + 'four' => ['number' => 4, 'some' => 'foursome'], + 'five' => ['number' => 5, 'some' => 'fivesome'], + 'six' => ['number' => 6, 'some' => 'sixsome'] + ]; $this->assertEquals($expected, $sorted); - $menus = array( - 'blogs' => array('title' => 'Blogs', 'weight' => 3), - 'comments' => array('title' => 'Comments', 'weight' => 2), - 'users' => array('title' => 'Users', 'weight' => 1), - ); - $expected = array( - 'users' => array('title' => 'Users', 'weight' => 1), - 'comments' => array('title' => 'Comments', 'weight' => 2), - 'blogs' => array('title' => 'Blogs', 'weight' => 3), - ); + $menus = [ + 'blogs' => ['title' => 'Blogs', 'weight' => 3], + 'comments' => ['title' => 'Comments', 'weight' => 2], + 'users' => ['title' => 'Users', 'weight' => 1], + ]; + $expected = [ + 'users' => ['title' => 'Users', 'weight' => 1], + 'comments' => ['title' => 'Comments', 'weight' => 2], + 'blogs' => ['title' => 'Blogs', 'weight' => 3], + ]; $result = Hash::sort($menus, '{s}.weight', 'ASC'); $this->assertEquals($expected, $result); } @@ -1491,19 +1491,19 @@ public function testSortStringKeys() { * @return void */ public function testSortStringIgnoreCase() { - $toSort = array( - array('Item' => array('name' => 'bar')), - array('Item' => array('name' => 'Baby')), - array('Item' => array('name' => 'Baz')), - array('Item' => array('name' => 'bat')), - ); - $sorted = Hash::sort($toSort, '{n}.Item.name', 'asc', array('type' => 'string', 'ignoreCase' => true)); - $expected = array( - array('Item' => array('name' => 'Baby')), - array('Item' => array('name' => 'bar')), - array('Item' => array('name' => 'bat')), - array('Item' => array('name' => 'Baz')), - ); + $toSort = [ + ['Item' => ['name' => 'bar']], + ['Item' => ['name' => 'Baby']], + ['Item' => ['name' => 'Baz']], + ['Item' => ['name' => 'bat']], + ]; + $sorted = Hash::sort($toSort, '{n}.Item.name', 'asc', ['type' => 'string', 'ignoreCase' => true]); + $expected = [ + ['Item' => ['name' => 'Baby']], + ['Item' => ['name' => 'bar']], + ['Item' => ['name' => 'bat']], + ['Item' => ['name' => 'Baz']], + ]; $this->assertEquals($expected, $sorted); } @@ -1513,19 +1513,19 @@ public function testSortStringIgnoreCase() { * @return void */ public function testSortRegularIgnoreCase() { - $toSort = array( - array('Item' => array('name' => 'bar')), - array('Item' => array('name' => 'Baby')), - array('Item' => array('name' => 'Baz')), - array('Item' => array('name' => 'bat')), - ); - $sorted = Hash::sort($toSort, '{n}.Item.name', 'asc', array('type' => 'regular', 'ignoreCase' => true)); - $expected = array( - array('Item' => array('name' => 'Baby')), - array('Item' => array('name' => 'bar')), - array('Item' => array('name' => 'bat')), - array('Item' => array('name' => 'Baz')), - ); + $toSort = [ + ['Item' => ['name' => 'bar']], + ['Item' => ['name' => 'Baby']], + ['Item' => ['name' => 'Baz']], + ['Item' => ['name' => 'bat']], + ]; + $sorted = Hash::sort($toSort, '{n}.Item.name', 'asc', ['type' => 'regular', 'ignoreCase' => true]); + $expected = [ + ['Item' => ['name' => 'Baby']], + ['Item' => ['name' => 'bar']], + ['Item' => ['name' => 'bat']], + ['Item' => ['name' => 'Baz']], + ]; $this->assertEquals($expected, $sorted); } @@ -1535,49 +1535,49 @@ public function testSortRegularIgnoreCase() { * @return void */ public function testSortSparse() { - $data = array( - array( + $data = [ + [ 'id' => 1, 'title' => 'element 1', 'extra' => 1, - ), - array( + ], + [ 'id' => 2, 'title' => 'element 2', 'extra' => 2, - ), - array( + ], + [ 'id' => 3, 'title' => 'element 3', - ), - array( + ], + [ 'id' => 4, 'title' => 'element 4', 'extra' => 4, - ) - ); + ] + ]; $result = Hash::sort($data, '{n}.extra', 'desc', 'natural'); - $expected = array( - array( + $expected = [ + [ 'id' => 4, 'title' => 'element 4', 'extra' => 4, - ), - array( + ], + [ 'id' => 2, 'title' => 'element 2', 'extra' => 2, - ), - array( + ], + [ 'id' => 1, 'title' => 'element 1', 'extra' => 1, - ), - array( + ], + [ 'id' => 3, 'title' => 'element 3', - ), - ); + ], + ]; $this->assertSame($expected, $result); } @@ -1587,30 +1587,30 @@ public function testSortSparse() { * @return void */ public function testInsertSimple() { - $a = array( - 'pages' => array('name' => 'page') - ); - $result = Hash::insert($a, 'files', array('name' => 'files')); - $expected = array( - 'pages' => array('name' => 'page'), - 'files' => array('name' => 'files') - ); - $this->assertEquals($expected, $result); - - $a = array( - 'pages' => array('name' => 'page') - ); - $result = Hash::insert($a, 'pages.name', array()); - $expected = array( - 'pages' => array('name' => array()), - ); - $this->assertEquals($expected, $result); - - $a = array( - 'foo' => array('bar' => 'baz') - ); - $result = Hash::insert($a, 'some.0123.path', array('foo' => array('bar' => 'baz'))); - $expected = array('foo' => array('bar' => 'baz')); + $a = [ + 'pages' => ['name' => 'page'] + ]; + $result = Hash::insert($a, 'files', ['name' => 'files']); + $expected = [ + 'pages' => ['name' => 'page'], + 'files' => ['name' => 'files'] + ]; + $this->assertEquals($expected, $result); + + $a = [ + 'pages' => ['name' => 'page'] + ]; + $result = Hash::insert($a, 'pages.name', []); + $expected = [ + 'pages' => ['name' => []], + ]; + $this->assertEquals($expected, $result); + + $a = [ + 'foo' => ['bar' => 'baz'] + ]; + $result = Hash::insert($a, 'some.0123.path', ['foo' => ['bar' => 'baz']]); + $expected = ['foo' => ['bar' => 'baz']]; $this->assertEquals($expected, Hash::get($result, 'some.0123.path')); } @@ -1630,32 +1630,32 @@ public function testInsertMulti() { $this->assertEquals('value', $result[0]['Comment'][0]['insert']); $this->assertEquals('value', $result[0]['Comment'][1]['insert']); - $data = array( - 0 => array('Item' => array('id' => 1, 'title' => 'first')), - 1 => array('Item' => array('id' => 2, 'title' => 'second')), - 2 => array('Item' => array('id' => 3, 'title' => 'third')), - 3 => array('Item' => array('id' => 4, 'title' => 'fourth')), - 4 => array('Item' => array('id' => 5, 'title' => 'fifth')), - ); - $result = Hash::insert($data, '{n}.Item[id=/\b2|\b4/]', array('test' => 2)); - $expected = array( - 0 => array('Item' => array('id' => 1, 'title' => 'first')), - 1 => array('Item' => array('id' => 2, 'title' => 'second', 'test' => 2)), - 2 => array('Item' => array('id' => 3, 'title' => 'third')), - 3 => array('Item' => array('id' => 4, 'title' => 'fourth', 'test' => 2)), - 4 => array('Item' => array('id' => 5, 'title' => 'fifth')), - ); + $data = [ + 0 => ['Item' => ['id' => 1, 'title' => 'first']], + 1 => ['Item' => ['id' => 2, 'title' => 'second']], + 2 => ['Item' => ['id' => 3, 'title' => 'third']], + 3 => ['Item' => ['id' => 4, 'title' => 'fourth']], + 4 => ['Item' => ['id' => 5, 'title' => 'fifth']], + ]; + $result = Hash::insert($data, '{n}.Item[id=/\b2|\b4/]', ['test' => 2]); + $expected = [ + 0 => ['Item' => ['id' => 1, 'title' => 'first']], + 1 => ['Item' => ['id' => 2, 'title' => 'second', 'test' => 2]], + 2 => ['Item' => ['id' => 3, 'title' => 'third']], + 3 => ['Item' => ['id' => 4, 'title' => 'fourth', 'test' => 2]], + 4 => ['Item' => ['id' => 5, 'title' => 'fifth']], + ]; $this->assertEquals($expected, $result); $data[3]['testable'] = true; $result = Hash::insert($data, '{n}[testable].Item[id=/\b2|\b4/].test', 2); - $expected = array( - 0 => array('Item' => array('id' => 1, 'title' => 'first')), - 1 => array('Item' => array('id' => 2, 'title' => 'second')), - 2 => array('Item' => array('id' => 3, 'title' => 'third')), - 3 => array('Item' => array('id' => 4, 'title' => 'fourth', 'test' => 2), 'testable' => true), - 4 => array('Item' => array('id' => 5, 'title' => 'fifth')), - ); + $expected = [ + 0 => ['Item' => ['id' => 1, 'title' => 'first']], + 1 => ['Item' => ['id' => 2, 'title' => 'second']], + 2 => ['Item' => ['id' => 3, 'title' => 'third']], + 3 => ['Item' => ['id' => 4, 'title' => 'fourth', 'test' => 2], 'testable' => true], + 4 => ['Item' => ['id' => 5, 'title' => 'fifth']], + ]; $this->assertEquals($expected, $result); } @@ -1665,19 +1665,19 @@ public function testInsertMulti() { * @return void */ public function testInsertOverwriteStringValue() { - $data = array( - 'Some' => array( + $data = [ + 'Some' => [ 'string' => 'value' - ) - ); - $result = Hash::insert($data, 'Some.string.value', array('values')); - $expected = array( - 'Some' => array( - 'string' => array( - 'value' => array('values') - ) - ) - ); + ] + ]; + $result = Hash::insert($data, 'Some.string.value', ['values']); + $expected = [ + 'Some' => [ + 'string' => [ + 'value' => ['values'] + ] + ] + ]; $this->assertEquals($expected, $result); } @@ -1687,103 +1687,103 @@ public function testInsertOverwriteStringValue() { * @return void */ public function testRemove() { - $a = array( - 'pages' => array('name' => 'page'), - 'files' => array('name' => 'files') - ); + $a = [ + 'pages' => ['name' => 'page'], + 'files' => ['name' => 'files'] + ]; $result = Hash::remove($a, 'files'); - $expected = array( - 'pages' => array('name' => 'page') - ); + $expected = [ + 'pages' => ['name' => 'page'] + ]; $this->assertEquals($expected, $result); - $a = array( - 'pages' => array( - 0 => array('name' => 'main'), - 1 => array( + $a = [ + 'pages' => [ + 0 => ['name' => 'main'], + 1 => [ 'name' => 'about', - 'vars' => array('title' => 'page title') - ) - ) - ); + 'vars' => ['title' => 'page title'] + ] + ] + ]; $result = Hash::remove($a, 'pages.1.vars'); - $expected = array( - 'pages' => array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about') - ) - ); + $expected = [ + 'pages' => [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'] + ] + ]; $this->assertEquals($expected, $result); $result = Hash::remove($a, 'pages.2.vars'); $expected = $a; $this->assertEquals($expected, $result); - $a = array( - 0 => array( + $a = [ + 0 => [ 'name' => 'pages' - ), - 1 => array( + ], + 1 => [ 'name' => 'files' - ) - ); + ] + ]; $result = Hash::remove($a, '{n}[name=files]'); - $expected = array( - 0 => array( + $expected = [ + 0 => [ 'name' => 'pages' - ) - ); + ] + ]; $this->assertEquals($expected, $result); - $array = array( + $array = [ 0 => 'foo', - 1 => array( + 1 => [ 0 => 'baz' - ) - ); + ] + ]; $expected = $array; $result = Hash::remove($array, '{n}.part'); $this->assertEquals($expected, $result); $result = Hash::remove($array, '{n}.{n}.part'); $this->assertEquals($expected, $result); - $array = array( + $array = [ 'foo' => 'string', - ); + ]; $expected = $array; $result = Hash::remove($array, 'foo.bar'); $this->assertEquals($expected, $result); - $array = array( + $array = [ 'foo' => 'string', - 'bar' => array( + 'bar' => [ 0 => 'a', 1 => 'b', - ), - ); - $expected = array( + ], + ]; + $expected = [ 'foo' => 'string', - 'bar' => array( + 'bar' => [ 1 => 'b', - ), - ); + ], + ]; $result = Hash::remove($array, '{s}.0'); $this->assertEquals($expected, $result); - $array = array( - 'foo' => array( + $array = [ + 'foo' => [ 0 => 'a', 1 => 'b', - ), - ); - $expected = array( - 'foo' => array( + ], + ]; + $expected = [ + 'foo' => [ 1 => 'b', - ), - ); + ], + ]; $result = Hash::remove($array, 'foo[1=b].0'); $this->assertEquals($expected, $result); } @@ -1806,31 +1806,31 @@ public function testRemoveMulti() { $this->assertFalse(isset($result[0]['Article']['title'])); $this->assertFalse(isset($result[0]['Article']['body'])); - $data = array( - 0 => array('Item' => array('id' => 1, 'title' => 'first')), - 1 => array('Item' => array('id' => 2, 'title' => 'second')), - 2 => array('Item' => array('id' => 3, 'title' => 'third')), - 3 => array('Item' => array('id' => 4, 'title' => 'fourth')), - 4 => array('Item' => array('id' => 5, 'title' => 'fifth')), - ); + $data = [ + 0 => ['Item' => ['id' => 1, 'title' => 'first']], + 1 => ['Item' => ['id' => 2, 'title' => 'second']], + 2 => ['Item' => ['id' => 3, 'title' => 'third']], + 3 => ['Item' => ['id' => 4, 'title' => 'fourth']], + 4 => ['Item' => ['id' => 5, 'title' => 'fifth']], + ]; $result = Hash::remove($data, '{n}.Item[id=/\b2|\b4/]'); - $expected = array( - 0 => array('Item' => array('id' => 1, 'title' => 'first')), - 2 => array('Item' => array('id' => 3, 'title' => 'third')), - 4 => array('Item' => array('id' => 5, 'title' => 'fifth')), - ); + $expected = [ + 0 => ['Item' => ['id' => 1, 'title' => 'first']], + 2 => ['Item' => ['id' => 3, 'title' => 'third']], + 4 => ['Item' => ['id' => 5, 'title' => 'fifth']], + ]; $this->assertEquals($expected, $result); $data[3]['testable'] = true; $result = Hash::remove($data, '{n}[testable].Item[id=/\b2|\b4/].title'); - $expected = array( - 0 => array('Item' => array('id' => 1, 'title' => 'first')), - 1 => array('Item' => array('id' => 2, 'title' => 'second')), - 2 => array('Item' => array('id' => 3, 'title' => 'third')), - 3 => array('Item' => array('id' => 4), 'testable' => true), - 4 => array('Item' => array('id' => 5, 'title' => 'fifth')), - ); + $expected = [ + 0 => ['Item' => ['id' => 1, 'title' => 'first']], + 1 => ['Item' => ['id' => 2, 'title' => 'second']], + 2 => ['Item' => ['id' => 3, 'title' => 'third']], + 3 => ['Item' => ['id' => 4], 'testable' => true], + 4 => ['Item' => ['id' => 5, 'title' => 'fifth']], + ]; $this->assertEquals($expected, $result); } @@ -1840,23 +1840,23 @@ public function testRemoveMulti() { * @return void */ public function testCheck() { - $set = array( - 'My Index 1' => array('First' => 'The first item') - ); + $set = [ + 'My Index 1' => ['First' => 'The first item'] + ]; $this->assertTrue(Hash::check($set, 'My Index 1.First')); $this->assertTrue(Hash::check($set, 'My Index 1')); - $set = array( - 'My Index 1' => array( - 'First' => array( - 'Second' => array( - 'Third' => array( + $set = [ + 'My Index 1' => [ + 'First' => [ + 'Second' => [ + 'Third' => [ 'Fourth' => 'Heavy. Nesting.' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $this->assertTrue(Hash::check($set, 'My Index 1.First.Second')); $this->assertTrue(Hash::check($set, 'My Index 1.First.Second.Third')); $this->assertTrue(Hash::check($set, 'My Index 1.First.Second.Third.Fourth')); @@ -1869,31 +1869,31 @@ public function testCheck() { * @return void */ public function testCombine() { - $result = Hash::combine(array(), '{n}.User.id', '{n}.User.Data'); + $result = Hash::combine([], '{n}.User.id', '{n}.User.Data'); $this->assertTrue(empty($result)); $a = static::userData(); $result = Hash::combine($a, '{n}.User.id'); - $expected = array(2 => null, 14 => null, 25 => null); + $expected = [2 => null, 14 => null, 25 => null]; $this->assertEquals($expected, $result); $result = Hash::combine($a, '{n}.User.id', '{n}.User.non-existant'); - $expected = array(2 => null, 14 => null, 25 => null); + $expected = [2 => null, 14 => null, 25 => null]; $this->assertEquals($expected, $result); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data'); - $expected = array( - 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), - 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'), - 25 => array('user' => 'gwoo', 'name' => 'The Gwoo')); + $expected = [ + 2 => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'], + 14 => ['user' => 'phpnut', 'name' => 'Larry E. Masters'], + 25 => ['user' => 'gwoo', 'name' => 'The Gwoo']]; $this->assertEquals($expected, $result); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data.name'); - $expected = array( + $expected = [ 2 => 'Mariano Iglesias', 14 => 'Larry E. Masters', - 25 => 'The Gwoo'); + 25 => 'The Gwoo']; $this->assertEquals($expected, $result); } @@ -1904,10 +1904,10 @@ public function testCombine() { */ public function testCombineErrorMissingValue() { $this->expectException(CakeException::class); - $data = array( - array('User' => array('id' => 1, 'name' => 'mark')), - array('User' => array('name' => 'jose')), - ); + $data = [ + ['User' => ['id' => 1, 'name' => 'mark']], + ['User' => ['name' => 'jose']], + ]; Hash::combine($data, '{n}.User.id', '{n}.User.name'); } @@ -1918,10 +1918,10 @@ public function testCombineErrorMissingValue() { */ public function testCombineErrorMissingKey() { $this->expectException(CakeException::class); - $data = array( - array('User' => array('id' => 1, 'name' => 'mark')), - array('User' => array('id' => 2)), - ); + $data = [ + ['User' => ['id' => 1, 'name' => 'mark']], + ['User' => ['id' => 2]], + ]; Hash::combine($data, '{n}.User.id', '{n}.User.name'); } @@ -1934,51 +1934,51 @@ public function testCombineWithGroupPath() { $a = static::userData(); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); - $expected = array( - 1 => array( - 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), - 25 => array('user' => 'gwoo', 'name' => 'The Gwoo') - ), - 2 => array( - 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters') - ) - ); + $expected = [ + 1 => [ + 2 => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'], + 25 => ['user' => 'gwoo', 'name' => 'The Gwoo'] + ], + 2 => [ + 14 => ['user' => 'phpnut', 'name' => 'Larry E. Masters'] + ] + ]; $this->assertEquals($expected, $result); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data.name', '{n}.User.group_id'); - $expected = array( - 1 => array( + $expected = [ + 1 => [ 2 => 'Mariano Iglesias', 25 => 'The Gwoo' - ), - 2 => array( + ], + 2 => [ 14 => 'Larry E. Masters' - ) - ); + ] + ]; $this->assertEquals($expected, $result); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); - $expected = array( - 1 => array( - 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), - 25 => array('user' => 'gwoo', 'name' => 'The Gwoo') - ), - 2 => array( - 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters') - ) - ); + $expected = [ + 1 => [ + 2 => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'], + 25 => ['user' => 'gwoo', 'name' => 'The Gwoo'] + ], + 2 => [ + 14 => ['user' => 'phpnut', 'name' => 'Larry E. Masters'] + ] + ]; $this->assertEquals($expected, $result); $result = Hash::combine($a, '{n}.User.id', '{n}.User.Data.name', '{n}.User.group_id'); - $expected = array( - 1 => array( + $expected = [ + 1 => [ 2 => 'Mariano Iglesias', 25 => 'The Gwoo' - ), - 2 => array( + ], + 2 => [ 14 => 'Larry E. Masters' - ) - ); + ] + ]; $this->assertEquals($expected, $result); } @@ -1993,58 +1993,58 @@ public function testCombineWithFormatting() { $result = Hash::combine( $a, '{n}.User.id', - array('%1$s: %2$s', '{n}.User.Data.user', '{n}.User.Data.name'), + ['%1$s: %2$s', '{n}.User.Data.user', '{n}.User.Data.name'], '{n}.User.group_id' ); - $expected = array( - 1 => array( + $expected = [ + 1 => [ 2 => 'mariano.iglesias: Mariano Iglesias', 25 => 'gwoo: The Gwoo' - ), - 2 => array( + ], + 2 => [ 14 => 'phpnut: Larry E. Masters' - ) - ); + ] + ]; $this->assertEquals($expected, $result); $result = Hash::combine( $a, - array( + [ '%s: %s', '{n}.User.Data.user', '{n}.User.Data.name' - ), + ], '{n}.User.id' ); - $expected = array( + $expected = [ 'mariano.iglesias: Mariano Iglesias' => 2, 'phpnut: Larry E. Masters' => 14, 'gwoo: The Gwoo' => 25 - ); + ]; $this->assertEquals($expected, $result); $result = Hash::combine( $a, - array('%1$s: %2$d', '{n}.User.Data.user', '{n}.User.id'), + ['%1$s: %2$d', '{n}.User.Data.user', '{n}.User.id'], '{n}.User.Data.name' ); - $expected = array( + $expected = [ 'mariano.iglesias: 2' => 'Mariano Iglesias', 'phpnut: 14' => 'Larry E. Masters', 'gwoo: 25' => 'The Gwoo' - ); + ]; $this->assertEquals($expected, $result); $result = Hash::combine( $a, - array('%2$d: %1$s', '{n}.User.Data.user', '{n}.User.id'), + ['%2$d: %1$s', '{n}.User.Data.user', '{n}.User.id'], '{n}.User.Data.name' ); - $expected = array( + $expected = [ '2: mariano.iglesias' => 'Mariano Iglesias', '14: phpnut' => 'Larry E. Masters', '25: gwoo' => 'The Gwoo' - ); + ]; $this->assertEquals($expected, $result); } @@ -2058,26 +2058,26 @@ public function testFormat() { $result = Hash::format( $data, - array('{n}.User.Data.user', '{n}.User.id'), + ['{n}.User.Data.user', '{n}.User.id'], '%s, %s' ); - $expected = array( + $expected = [ 'mariano.iglesias, 2', 'phpnut, 14', 'gwoo, 25' - ); + ]; $this->assertEquals($expected, $result); $result = Hash::format( $data, - array('{n}.User.Data.user', '{n}.User.id'), + ['{n}.User.Data.user', '{n}.User.id'], '%2$s, %1$s' ); - $expected = array( + $expected = [ '2, mariano.iglesias', '14, phpnut', '25, gwoo' - ); + ]; $this->assertEquals($expected, $result); } @@ -2087,24 +2087,24 @@ public function testFormat() { * @return void */ public function testFormatNullValues() { - $data = array( - array('Person' => array( + $data = [ + ['Person' => [ 'first_name' => 'Nate', 'last_name' => 'Abele', 'city' => 'Boston', 'state' => 'MA', 'something' => '42' - )), - array('Person' => array( + ]], + ['Person' => [ 'first_name' => 'Larry', 'last_name' => 'Masters', 'city' => 'Boondock', 'state' => 'TN', 'something' => null - )), - array('Person' => array( + ]], + ['Person' => [ 'first_name' => 'Garrett', 'last_name' => 'Woodworth', 'city' => 'Venice Beach', 'state' => 'CA', 'something' => null - )) - ); + ]] + ]; - $result = Hash::format($data, array('{n}.Person.something'), '%s'); - $expected = array('42', '', ''); + $result = Hash::format($data, ['{n}.Person.something'], '%s'); + $expected = ['42', '', '']; $this->assertEquals($expected, $result); - $result = Hash::format($data, array('{n}.Person.city', '{n}.Person.something'), '%s, %s'); - $expected = array('Boston, 42', 'Boondock, ', 'Venice Beach, '); + $result = Hash::format($data, ['{n}.Person.city', '{n}.Person.something'], '%s, %s'); + $expected = ['Boston, 42', 'Boondock, ', 'Venice Beach, ']; $this->assertEquals($expected, $result); } @@ -2116,8 +2116,8 @@ public function testFormatNullValues() { public function testMap() { $data = static::articleData(); - $result = Hash::map($data, '{n}.Article.id', array($this, 'mapCallback')); - $expected = array(2, 4, 6, 8, 10); + $result = Hash::map($data, '{n}.Article.id', [$this, 'mapCallback']); + $expected = [2, 4, 6, 8, 10]; $this->assertEquals($expected, $result); } @@ -2141,7 +2141,7 @@ public function testApply() { public function testReduce() { $data = static::articleData(); - $result = Hash::reduce($data, '{n}.Article.id', array($this, 'reduceCallback')); + $result = Hash::reduce($data, '{n}.Article.id', [$this, 'reduceCallback']); $this->assertEquals(15, $result); } @@ -2173,143 +2173,143 @@ public function reduceCallback($one, $two) { * @return void */ public function testNestModel() { - $input = array( - array( - 'ModelName' => array( + $input = [ + [ + 'ModelName' => [ 'id' => 1, 'parent_id' => null - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 2, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 3, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 4, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 5, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 6, 'parent_id' => null - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 7, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 8, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 9, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 10, 'parent_id' => 6 - ) - ) - ); - $expected = array( - array( - 'ModelName' => array( + ] + ] + ]; + $expected = [ + [ + 'ModelName' => [ 'id' => 1, 'parent_id' => null - ), - 'children' => array( - array( - 'ModelName' => array( + ], + 'children' => [ + [ + 'ModelName' => [ 'id' => 2, 'parent_id' => 1 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 3, 'parent_id' => 1 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 4, 'parent_id' => 1 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 5, 'parent_id' => 1 - ), - 'children' => array() - ), - - ) - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + + ] + ], + [ + 'ModelName' => [ 'id' => 6, 'parent_id' => null - ), - 'children' => array( - array( - 'ModelName' => array( + ], + 'children' => [ + [ + 'ModelName' => [ 'id' => 7, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 8, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 9, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 10, 'parent_id' => 6 - ), - 'children' => array() - ) - ) - ) - ); + ], + 'children' => [] + ] + ] + ] + ]; $result = Hash::nest($input); $this->assertEquals($expected, $result); } @@ -2320,107 +2320,107 @@ public function testNestModel() { * @return void */ public function testNestModelExplicitRoot() { - $input = array( - array( - 'ModelName' => array( + $input = [ + [ + 'ModelName' => [ 'id' => 1, 'parent_id' => null - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 2, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 3, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 4, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 5, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 6, 'parent_id' => null - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 7, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 8, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 9, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 10, 'parent_id' => 6 - ) - ) - ); - $expected = array( - array( - 'ModelName' => array( + ] + ] + ]; + $expected = [ + [ + 'ModelName' => [ 'id' => 6, 'parent_id' => null - ), - 'children' => array( - array( - 'ModelName' => array( + ], + 'children' => [ + [ + 'ModelName' => [ 'id' => 7, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 8, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 9, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 10, 'parent_id' => 6 - ), - 'children' => array() - ) - ) - ) - ); - $result = Hash::nest($input, array('root' => 6)); + ], + 'children' => [] + ] + ] + ] + ]; + $result = Hash::nest($input, ['root' => 6]); $this->assertEquals($expected, $result); } @@ -2430,104 +2430,104 @@ public function testNestModelExplicitRoot() { * @return void */ public function testNest1Dimensional() { - $input = array( - array( + $input = [ + [ 'id' => 1, 'parent_id' => null - ), - array( + ], + [ 'id' => 2, 'parent_id' => 1 - ), - array( + ], + [ 'id' => 3, 'parent_id' => 1 - ), - array( + ], + [ 'id' => 4, 'parent_id' => 1 - ), - array( + ], + [ 'id' => 5, 'parent_id' => 1 - ), - array( + ], + [ 'id' => 6, 'parent_id' => null - ), - array( + ], + [ 'id' => 7, 'parent_id' => 6 - ), - array( + ], + [ 'id' => 8, 'parent_id' => 6 - ), - array( + ], + [ 'id' => 9, 'parent_id' => 6 - ), - array( + ], + [ 'id' => 10, 'parent_id' => 6 - ) - ); - $expected = array( - array( + ] + ]; + $expected = [ + [ 'id' => 1, 'parent_id' => null, - 'children' => array( - array( + 'children' => [ + [ 'id' => 2, 'parent_id' => 1, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 3, 'parent_id' => 1, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 4, 'parent_id' => 1, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 5, 'parent_id' => 1, - 'children' => array() - ), + 'children' => [] + ], - ) - ), - array( + ] + ], + [ 'id' => 6, 'parent_id' => null, - 'children' => array( - array( + 'children' => [ + [ 'id' => 7, 'parent_id' => 6, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 8, 'parent_id' => 6, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 9, 'parent_id' => 6, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 10, 'parent_id' => 6, - 'children' => array() - ) - ) - ) - ); - $result = Hash::nest($input, array('idPath' => '{n}.id', 'parentPath' => '{n}.parent_id')); + 'children' => [] + ] + ] + ] + ]; + $result = Hash::nest($input, ['idPath' => '{n}.id', 'parentPath' => '{n}.parent_id']); $this->assertEquals($expected, $result); } @@ -2540,40 +2540,40 @@ public function testNest1Dimensional() { * @return void */ public function testMissingParent() { - $input = array( - array( + $input = [ + [ 'id' => 1, - ), - array( + ], + [ 'id' => 2, - ), - array( + ], + [ 'id' => 3, - ), - array( + ], + [ 'id' => 4, - ), - array( + ], + [ 'id' => 5, - ), - array( + ], + [ 'id' => 6, - ), - array( + ], + [ 'id' => 7, - ), - array( + ], + [ 'id' => 8, - ), - array( + ], + [ 'id' => 9, - ), - array( + ], + [ 'id' => 10, - ) - ); + ] + ]; - $result = Hash::nest($input, array('idPath' => '{n}.id', 'parentPath' => '{n}.parent_id')); + $result = Hash::nest($input, ['idPath' => '{n}.id', 'parentPath' => '{n}.parent_id']); foreach ($result as &$row) { if (empty($row['children'])) { unset($row['children']); @@ -2589,15 +2589,15 @@ public function testMissingParent() { */ public function testNestInvalid() { $this->expectException(InvalidArgumentException::class); - $input = array( - array( - 'ParentCategory' => array( + $input = [ + [ + 'ParentCategory' => [ 'id' => '1', 'name' => 'Lorem ipsum dolor sit amet', 'parent_id' => '1' - ) - ) - ); + ] + ] + ]; Hash::nest($input); } @@ -2607,92 +2607,92 @@ public function testNestInvalid() { * @return void */ public function testMergeDiff() { - $first = array( - 'ModelOne' => array( + $first = [ + 'ModelOne' => [ 'id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2' - ) - ); - $second = array( - 'ModelTwo' => array( + ] + ]; + $second = [ + 'ModelTwo' => [ 'id' => 1002, 'field_one' => 'a2.m2.f1', 'field_two' => 'a2.m2.f2' - ) - ); + ] + ]; $result = Hash::mergeDiff($first, $second); $this->assertEquals($result, $first + $second); - $result = Hash::mergeDiff($first, array()); + $result = Hash::mergeDiff($first, []); $this->assertEquals($result, $first); - $result = Hash::mergeDiff(array(), $first); + $result = Hash::mergeDiff([], $first); $this->assertEquals($result, $first); - $third = array( - 'ModelOne' => array( + $third = [ + 'ModelOne' => [ 'id' => 1003, 'field_one' => 'a3.m1.f1', 'field_two' => 'a3.m1.f2', 'field_three' => 'a3.m1.f3' - ) - ); + ] + ]; $result = Hash::mergeDiff($first, $third); - $expected = array( - 'ModelOne' => array( + $expected = [ + 'ModelOne' => [ 'id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2', 'field_three' => 'a3.m1.f3' - ) - ); + ] + ]; $this->assertEquals($expected, $result); - $first = array( - 0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2')), - 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2')) - ); - $second = array( - 0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's2.0.m1.f1', 'field_two' => 's2.0.m1.f2')), - 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's2.1.m2.f2', 'field_two' => 's2.1.m2.f2')) - ); + $first = [ + 0 => ['ModelOne' => ['id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2']], + 1 => ['ModelTwo' => ['id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2']] + ]; + $second = [ + 0 => ['ModelOne' => ['id' => 1001, 'field_one' => 's2.0.m1.f1', 'field_two' => 's2.0.m1.f2']], + 1 => ['ModelTwo' => ['id' => 1002, 'field_one' => 's2.1.m2.f2', 'field_two' => 's2.1.m2.f2']] + ]; $result = Hash::mergeDiff($first, $second); $this->assertEquals($result, $first); - $third = array( - 0 => array( - 'ModelThree' => array( + $third = [ + 0 => [ + 'ModelThree' => [ 'id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2' - ) - ) - ); + ] + ] + ]; $result = Hash::mergeDiff($first, $third); - $expected = array( - 0 => array( - 'ModelOne' => array( + $expected = [ + 0 => [ + 'ModelOne' => [ 'id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2' - ), - 'ModelThree' => array( + ], + 'ModelThree' => [ 'id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2' - ) - ), - 1 => array( - 'ModelTwo' => array( + ] + ], + 1 => [ + 'ModelTwo' => [ 'id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $result = Hash::mergeDiff($first, null); @@ -2708,54 +2708,54 @@ public function testMergeDiff() { * @return void */ public function testExpand() { - $data = array('My', 'Array', 'To', 'Flatten'); + $data = ['My', 'Array', 'To', 'Flatten']; $flat = Hash::flatten($data); $result = Hash::expand($flat); $this->assertEquals($data, $result); - $data = array( + $data = [ '0.Post.id' => '1', '0.Post.author_id' => '1', '0.Post.title' => 'First Post', '0.Author.id' => '1', '0.Author.user' => 'nate', '0.Author.password' => 'foo', '1.Post.id' => '2', '1.Post.author_id' => '3', '1.Post.title' => 'Second Post', '1.Post.body' => 'Second Post Body', '1.Author.id' => '3', '1.Author.user' => 'larry', '1.Author.password' => null - ); + ]; $result = Hash::expand($data); - $expected = array( - array( - 'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post'), - 'Author' => array('id' => '1', 'user' => 'nate', 'password' => 'foo'), - ), - array( - 'Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body'), - 'Author' => array('id' => '3', 'user' => 'larry', 'password' => null), - ) - ); - $this->assertEquals($expected, $result); - - $data = array( + $expected = [ + [ + 'Post' => ['id' => '1', 'author_id' => '1', 'title' => 'First Post'], + 'Author' => ['id' => '1', 'user' => 'nate', 'password' => 'foo'], + ], + [ + 'Post' => ['id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body'], + 'Author' => ['id' => '3', 'user' => 'larry', 'password' => null], + ] + ]; + $this->assertEquals($expected, $result); + + $data = [ '0/Post/id' => 1, '0/Post/name' => 'test post' - ); + ]; $result = Hash::expand($data, '/'); - $expected = array( - array( - 'Post' => array( + $expected = [ + [ + 'Post' => [ 'id' => 1, 'name' => 'test post' - ) - ) - ); - $this->assertEquals($expected, $result); - - $data = array('a.b.100.a' => null, 'a.b.200.a' => null); - $expected = array( - 'a' => array( - 'b' => array( - 100 => array('a' => null), - 200 => array('a' => null) - ) - ) - ); + ] + ] + ]; + $this->assertEquals($expected, $result); + + $data = ['a.b.100.a' => null, 'a.b.200.a' => null]; + $expected = [ + 'a' => [ + 'b' => [ + 100 => ['a' => null], + 200 => ['a' => null] + ] + ] + ]; $result = Hash::expand($data); $this->assertEquals($expected, $result); } @@ -2766,7 +2766,7 @@ public function testExpand() { * @return void */ public function testFlattenInfiniteLoop() { - $data = array( + $data = [ 'Order.ASI' => '0', 'Order.Accounting' => '0', 'Order.Admin' => '0', @@ -2892,7 +2892,7 @@ public function testFlattenInfiniteLoop() { 'Order.slug' => 'test-2', 'Order.title' => 'test job 2', 'Order.type' => 'ttt' - ); + ]; $expanded = Hash::expand($data); $flattened = Hash::flatten($expanded); $this->assertEquals($data, $flattened); diff --git a/lib/Cake/Test/Case/Utility/InflectorTest.php b/lib/Cake/Test/Case/Utility/InflectorTest.php index 22029d2240..6271fcf806 100644 --- a/lib/Cake/Test/Case/Utility/InflectorTest.php +++ b/lib/Cake/Test/Case/Utility/InflectorTest.php @@ -35,12 +35,12 @@ class InflectorTest extends CakeTestCase { * * @var array */ - public static $maps = array ( - 'de' => array ( /* German */ + public static $maps = [ + 'de' => [ /* German */ 'Ä' => 'Ae', 'Ö' => 'Oe', 'Ü' => 'Ue', 'ä' => 'ae', 'ö' => 'oe', 'ü' => 'ue', 'ß' => 'ss', 'ẞ' => 'SS' - ), - 'latin' => array ( + ], + 'latin' => [ 'À' => 'A', 'Á' => 'A', 'Â' => 'A', 'Ã' => 'A', 'Å' => 'A', 'Ă' => 'A', 'Æ' => 'AE', 'Ç' => 'C', 'È' => 'E', 'É' => 'E', 'Ê' => 'E', 'Ë' => 'E', 'Ì' => 'I', 'Í' => 'I', 'Î' => 'I', 'Ï' => 'I', 'Ð' => 'D', 'Ñ' => 'N', 'Ò' => 'O', 'Ó' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ő' => 'O', 'Ø' => 'O', @@ -50,36 +50,36 @@ class InflectorTest extends CakeTestCase { 'ì' => 'i', 'í' => 'i', 'î' => 'i', 'ï' => 'i', 'ð' => 'd', 'ñ' => 'n', 'ò' => 'o', 'ó' => 'o', 'ô' => 'o', 'õ' => 'o', 'ő' => 'o', 'ø' => 'o', 'ș' => 's', 'ț' => 't', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'ű' => 'u', 'ý' => 'y', 'þ' => 'th', 'ÿ' => 'y' - ), - 'tr' => array ( /* Turkish */ + ], + 'tr' => [ /* Turkish */ 'ş' => 's', 'Ş' => 'S', 'ı' => 'i', 'İ' => 'I', 'ç' => 'c', 'Ç' => 'C', 'ğ' => 'g', 'Ğ' => 'G' - ), - 'uk' => array ( /* Ukrainian */ + ], + 'uk' => [ /* Ukrainian */ 'Є' => 'Ye', 'І' => 'I', 'Ї' => 'Yi', 'Ґ' => 'G', 'є' => 'ye', 'і' => 'i', 'ї' => 'yi', 'ґ' => 'g' - ), - 'cs' => array ( /* Czech */ + ], + 'cs' => [ /* Czech */ 'č' => 'c', 'ď' => 'd', 'ě' => 'e', 'ň' => 'n', 'ř' => 'r', 'š' => 's', 'ť' => 't', 'ů' => 'u', 'ž' => 'z', 'Č' => 'C', 'Ď' => 'D', 'Ě' => 'E', 'Ň' => 'N', 'Ř' => 'R', 'Š' => 'S', 'Ť' => 'T', 'Ů' => 'U', 'Ž' => 'Z' - ), - 'pl' => array ( /* Polish */ + ], + 'pl' => [ /* Polish */ 'ą' => 'a', 'ć' => 'c', 'ę' => 'e', 'ł' => 'l', 'ń' => 'n', 'ó' => 'o', 'ś' => 's', 'ź' => 'z', 'ż' => 'z', 'Ą' => 'A', 'Ć' => 'C', 'Ł' => 'L', 'Ń' => 'N', 'Ó' => 'O', 'Ś' => 'S', 'Ź' => 'Z', 'Ż' => 'Z' - ), - 'ro' => array ( /* Romanian */ + ], + 'ro' => [ /* Romanian */ 'ă' => 'a', 'â' => 'a', 'î' => 'i', 'ș' => 's', 'ț' => 't', 'Ţ' => 'T', 'ţ' => 't' - ), - 'lv' => array ( /* Latvian */ + ], + 'lv' => [ /* Latvian */ 'ā' => 'a', 'č' => 'c', 'ē' => 'e', 'ģ' => 'g', 'ī' => 'i', 'ķ' => 'k', 'ļ' => 'l', 'ņ' => 'n', 'š' => 's', 'ū' => 'u', 'ž' => 'z', 'Ā' => 'A', 'Č' => 'C', 'Ē' => 'E', 'Ģ' => 'G', 'Ī' => 'I', 'Ķ' => 'K', 'Ļ' => 'L', 'Ņ' => 'N', 'Š' => 'S', 'Ū' => 'U', 'Ž' => 'Z' - ), - 'lt' => array ( /* Lithuanian */ + ], + 'lt' => [ /* Lithuanian */ 'ą' => 'a', 'č' => 'c', 'ę' => 'e', 'ė' => 'e', 'į' => 'i', 'š' => 's', 'ų' => 'u', 'ū' => 'u', 'ž' => 'z', 'Ą' => 'A', 'Č' => 'C', 'Ę' => 'E', 'Ė' => 'E', 'Į' => 'I', 'Š' => 'S', 'Ų' => 'U', 'Ū' => 'U', 'Ž' => 'Z' - ) - ); + ] + ]; /** * tearDown @@ -189,12 +189,12 @@ public function testInflectingSingulars() { * @return void */ public function testSingularizeMultiWordIrregular() { - Inflector::rules('singular', array( - 'irregular' => array( + Inflector::rules('singular', [ + 'irregular' => [ 'preguntas_frecuentes' => 'pregunta_frecuente', 'categorias_preguntas_frecuentes' => 'categoria_pregunta_frecuente', - ) - )); + ] + ]); $this->assertEquals('pregunta_frecuente', Inflector::singularize('preguntas_frecuentes')); $this->assertEquals( 'categoria_pregunta_frecuente', @@ -285,15 +285,15 @@ public function testInflectingPlurals() { * @return void */ public function testPluralizeMultiWordIrregular() { - Inflector::rules('plural', array( - 'irregular' => array( + Inflector::rules('plural', [ + 'irregular' => [ 'mytable1' => 'mytables1', 'mytable2' => 'mytables2', 'mytable1_mytable2' => 'mytables1_mytables2', 'pregunta_frecuente' => 'preguntas_frecuentes', 'categoria_pregunta_frecuente' => 'categorias_preguntas_frecuentes', - ) - )); + ] + ]); $this->assertEquals('preguntas_frecuentes', Inflector::pluralize('pregunta_frecuente')); $this->assertEquals( 'categorias_preguntas_frecuentes', @@ -318,12 +318,12 @@ public function testInflectingMultiWordIrregulars() { // unset the default rules in order to avoid them possibly matching // the words in case the irregular regex won't match, the tests // should fail in that case - Inflector::rules('plural', array( - 'rules' => array(), - )); - Inflector::rules('singular', array( - 'rules' => array(), - )); + Inflector::rules('plural', [ + 'rules' => [], + ]); + Inflector::rules('singular', [ + 'rules' => [], + ]); $this->assertEquals(Inflector::singularize('wisdom teeth'), 'wisdom tooth'); $this->assertEquals(Inflector::singularize('wisdom-teeth'), 'wisdom-tooth'); @@ -420,7 +420,7 @@ public function testInflectorSlugCharList() { * @return void */ public function testInflectorSlugWithMap() { - Inflector::rules('transliteration', array('/r/' => '1')); + Inflector::rules('transliteration', ['/r/' => '1']); $result = Inflector::slug('replace every r'); $expected = '1eplace_eve1y_1'; $this->assertEquals($expected, $result); @@ -436,7 +436,7 @@ public function testInflectorSlugWithMap() { * @return void */ public function testInflectorSlugWithMapOverridingDefault() { - Inflector::rules('transliteration', array('/å/' => 'aa', '/ø/' => 'oe')); + Inflector::rules('transliteration', ['/å/' => 'aa', '/ø/' => 'oe']); $result = Inflector::slug('Testing æ ø å', '-'); $expected = 'Testing-ae-oe-aa'; $this->assertEquals($expected, $result); @@ -536,17 +536,17 @@ public function testHumanization() { * @return void */ public function testCustomPluralRule() { - Inflector::rules('plural', array('/^(custom)$/i' => '\1izables')); + Inflector::rules('plural', ['/^(custom)$/i' => '\1izables']); $this->assertEquals(Inflector::pluralize('custom'), 'customizables'); - Inflector::rules('plural', array('uninflected' => array('uninflectable'))); + Inflector::rules('plural', ['uninflected' => ['uninflectable']]); $this->assertEquals(Inflector::pluralize('uninflectable'), 'uninflectable'); - Inflector::rules('plural', array( - 'rules' => array('/^(alert)$/i' => '\1ables'), - 'uninflected' => array('noflect', 'abtuse'), - 'irregular' => array('amaze' => 'amazable', 'phone' => 'phonezes') - )); + Inflector::rules('plural', [ + 'rules' => ['/^(alert)$/i' => '\1ables'], + 'uninflected' => ['noflect', 'abtuse'], + 'irregular' => ['amaze' => 'amazable', 'phone' => 'phonezes'] + ]); $this->assertEquals(Inflector::pluralize('noflect'), 'noflect'); $this->assertEquals(Inflector::pluralize('abtuse'), 'abtuse'); $this->assertEquals(Inflector::pluralize('alert'), 'alertables'); @@ -560,16 +560,16 @@ public function testCustomPluralRule() { * @return void */ public function testCustomSingularRule() { - Inflector::rules('singular', array('/(eple)r$/i' => '\1', '/(jente)r$/i' => '\1')); + Inflector::rules('singular', ['/(eple)r$/i' => '\1', '/(jente)r$/i' => '\1']); $this->assertEquals(Inflector::singularize('epler'), 'eple'); $this->assertEquals(Inflector::singularize('jenter'), 'jente'); - Inflector::rules('singular', array( - 'rules' => array('/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'), - 'uninflected' => array('singulars'), - 'irregular' => array('spins' => 'spinor') - )); + Inflector::rules('singular', [ + 'rules' => ['/^(bil)er$/i' => '\1', '/^(inflec|contribu)tors$/i' => '\1ta'], + 'uninflected' => ['singulars'], + 'irregular' => ['spins' => 'spinor'] + ]); $this->assertEquals(Inflector::singularize('inflectors'), 'inflecta'); $this->assertEquals(Inflector::singularize('contributors'), 'contributa'); @@ -585,10 +585,10 @@ public function testCustomSingularRule() { public function testCustomTransliterationRule() { $this->assertEquals(Inflector::slug('Testing æ ø å'), 'Testing_ae_o_a'); - Inflector::rules('transliteration', array('/å/' => 'aa', '/ø/' => 'oe')); + Inflector::rules('transliteration', ['/å/' => 'aa', '/ø/' => 'oe']); $this->assertEquals(Inflector::slug('Testing æ ø å'), 'Testing_ae_oe_aa'); - Inflector::rules('transliteration', array('/ä|æ/' => 'ae', '/å/' => 'aa'), true); + Inflector::rules('transliteration', ['/ä|æ/' => 'ae', '/å/' => 'aa'], true); $this->assertEquals(Inflector::slug('Testing æ ø å'), 'Testing_ae_ø_aa'); } @@ -602,15 +602,15 @@ public function testRulesClearsCaches() { $this->assertEquals(Inflector::tableize('Banana'), 'bananas'); $this->assertEquals(Inflector::pluralize('Banana'), 'Bananas'); - Inflector::rules('singular', array( - 'rules' => array('/(.*)nas$/i' => '\1zzz') - )); + Inflector::rules('singular', [ + 'rules' => ['/(.*)nas$/i' => '\1zzz'] + ]); $this->assertEquals('Banazzz', Inflector::singularize('Bananas'), 'Was inflected with old rules.'); - Inflector::rules('plural', array( - 'rules' => array('/(.*)na$/i' => '\1zzz'), - 'irregular' => array('corpus' => 'corpora') - )); + Inflector::rules('plural', [ + 'rules' => ['/(.*)na$/i' => '\1zzz'], + 'irregular' => ['corpus' => 'corpora'] + ]); $this->assertEquals(Inflector::pluralize('Banana'), 'Banazzz', 'Was inflected with old rules.'); $this->assertEquals(Inflector::pluralize('corpus'), 'corpora', 'Was inflected with old irregular form.'); } @@ -621,21 +621,21 @@ public function testRulesClearsCaches() { * @return void */ public function testCustomRuleWithReset() { - $uninflected = array('atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x'); - $pluralIrregular = array('as' => 'ases'); + $uninflected = ['atlas', 'lapis', 'onibus', 'pires', 'virus', '.*x']; + $pluralIrregular = ['as' => 'ases']; - Inflector::rules('singular', array( - 'rules' => array('/^(.*)(a|e|o|u)is$/i' => '\1\2l'), + Inflector::rules('singular', [ + 'rules' => ['/^(.*)(a|e|o|u)is$/i' => '\1\2l'], 'uninflected' => $uninflected, - ), true); + ], true); - Inflector::rules('plural', array( - 'rules' => array( + Inflector::rules('plural', [ + 'rules' => [ '/^(.*)(a|e|o|u)l$/i' => '\1\2is', - ), + ], 'uninflected' => $uninflected, 'irregular' => $pluralIrregular - ), true); + ], true); $this->assertEquals(Inflector::pluralize('Alcool'), 'Alcoois'); $this->assertEquals(Inflector::pluralize('Atlas'), 'Atlas'); diff --git a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php index dc0c9ec925..6b19ae4e72 100644 --- a/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php +++ b/lib/Cake/Test/Case/Utility/ObjectCollectionTest.php @@ -30,7 +30,7 @@ class GenericObject { * @param GenericObjectCollection $collection A collection. * @param array $settings Settings. */ - public function __construct(GenericObjectCollection $collection, $settings = array()) { + public function __construct(GenericObjectCollection $collection, $settings = []) { $this->_Collection = $collection; $this->settings = $settings; } @@ -90,14 +90,14 @@ class GenericObjectCollection extends ObjectCollection { * @param array $settings Settings array * @return array List of loaded objects */ - public function load($object, $settings = array()) { - list(, $name) = pluginSplit($object); + public function load($object, $settings = []) { + [, $name] = pluginSplit($object); if (isset($this->_loaded[$name])) { return $this->_loaded[$name]; } $objectClass = $name . 'GenericObject'; $this->_loaded[$name] = new $objectClass($this, $settings); - $enable = isset($settings['enabled']) ? $settings['enabled'] : true; + $enable = $settings['enabled'] ?? true; if ($enable === true) { $this->enable($name); } @@ -113,12 +113,12 @@ public function load($object, $settings = array()) { * @param array $settings Settings to apply for the object * @return array Loaded objects */ - public function setObject($name, $object, $settings = array()) { + public function setObject($name, $object, $settings = []) { $this->_loaded[$name] = $object; if (isset($settings['priority'])) { $this->setPriority($name, $settings['priority']); } - $enable = isset($settings['enabled']) ? $settings['enabled'] : true; + $enable = $settings['enabled'] ?? true; if ($enable === true) { $this->enable($name); } @@ -160,7 +160,7 @@ public function testLoad() { $this->assertInstanceOf('FirstGenericObject', $this->Objects->First); $result = $this->Objects->loaded(); - $this->assertEquals(array('First'), $result, 'loaded() results are wrong.'); + $this->assertEquals(['First'], $result, 'loaded() results are wrong.'); $this->assertTrue($this->Objects->enabled('First')); @@ -178,17 +178,17 @@ public function testUnload() { $this->Objects->load('Second'); $result = $this->Objects->loaded(); - $this->assertEquals(array('First', 'Second'), $result, 'loaded objects are wrong'); + $this->assertEquals(['First', 'Second'], $result, 'loaded objects are wrong'); $this->Objects->unload('First'); $this->assertFalse(isset($this->Objects->First)); $this->assertTrue(isset($this->Objects->Second)); $result = $this->Objects->loaded(); - $this->assertEquals(array('Second'), $result, 'loaded objects are wrong'); + $this->assertEquals(['Second'], $result, 'loaded objects are wrong'); $result = $this->Objects->loaded(); - $this->assertEquals(array('Second'), $result, 'enabled objects are wrong'); + $this->assertEquals(['Second'], $result, 'enabled objects are wrong'); } /** @@ -200,7 +200,7 @@ public function testSet() { $this->Objects->load('First'); $result = $this->Objects->loaded(); - $this->assertEquals(array('First'), $result, 'loaded objects are wrong'); + $this->assertEquals(['First'], $result, 'loaded objects are wrong'); $result = $this->Objects->set('First', new SecondGenericObject($this->Objects)); $this->assertInstanceOf('SecondGenericObject', $result['First'], 'set failed'); @@ -217,9 +217,9 @@ public function testSet() { * @return void */ protected function _makeMockClasses() { - $this->FirstGenericObject = $this->getMock('FirstGenericObject', array(), array(), '', false); - $this->SecondGenericObject = $this->getMock('SecondGenericObject', array(), array(), '', false); - $this->ThirdGenericObject = $this->getMock('ThirdGenericObject', array(), array(), '', false); + $this->FirstGenericObject = $this->getMock('FirstGenericObject', [], [], '', false); + $this->SecondGenericObject = $this->getMock('SecondGenericObject', [], [], '', false); + $this->ThirdGenericObject = $this->getMock('ThirdGenericObject', [], [], '', false); } /** @@ -250,7 +250,7 @@ public function testTrigger() { public function testTriggerWithDisabledObjects() { $this->_makeMockClasses(); $this->Objects->setObject('TriggerMockFirst', $this->FirstGenericObject); - $this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject, array('enabled' => false)); + $this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject, ['enabled' => false]); $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') @@ -259,7 +259,7 @@ public function testTriggerWithDisabledObjects() { ->method('callback') ->will($this->returnValue(true)); - $this->assertTrue($this->Objects->trigger('callback', array())); + $this->assertTrue($this->Objects->trigger('callback', [])); } /** @@ -274,16 +274,16 @@ public function testTriggerWithCollectReturn() { $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') - ->will($this->returnValue(array('one', 'two'))); + ->will($this->returnValue(['one', 'two'])); $this->Objects->TriggerMockSecond->expects($this->once()) ->method('callback') - ->will($this->returnValue(array('three', 'four'))); + ->will($this->returnValue(['three', 'four'])); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( - array('one', 'two'), - array('three', 'four') - ); + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ + ['one', 'two'], + ['three', 'four'] + ]; $this->assertEquals($expected, $result); } @@ -305,8 +305,8 @@ public function testTriggerWithBreak() { $result = $this->Objects->trigger( 'callback', - array(), - array('break' => true, 'breakOn' => false) + [], + ['break' => true, 'breakOn' => false] ); $this->assertFalse($result); } @@ -323,20 +323,20 @@ public function testTriggerWithModParams() { $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') - ->with(array('value')) - ->will($this->returnValue(array('new value'))); + ->with(['value']) + ->will($this->returnValue(['new value'])); $this->Objects->TriggerMockSecond->expects($this->once()) ->method('callback') - ->with(array('new value')) - ->will($this->returnValue(array('newer value'))); + ->with(['new value']) + ->will($this->returnValue(['newer value'])); $result = $this->Objects->trigger( 'callback', - array(array('value')), - array('modParams' => 0) + [['value']], + ['modParams' => 0] ); - $this->assertEquals(array('newer value'), $result); + $this->assertEquals(['newer value'], $result); } /** @@ -358,8 +358,8 @@ public function testTriggerModParamsInvalidIndex() { $this->Objects->trigger( 'callback', - array(array('value')), - array('modParams' => 2) + [['value']], + ['modParams' => 2] ); } @@ -375,20 +375,20 @@ public function testTriggerModParamsNullIgnored() { $this->Objects->TriggerMockFirst->expects($this->once()) ->method('callback') - ->with(array('value')) + ->with(['value']) ->will($this->returnValue(null)); $this->Objects->TriggerMockSecond->expects($this->once()) ->method('callback') - ->with(array('value')) - ->will($this->returnValue(array('new value'))); + ->with(['value']) + ->will($this->returnValue(['new value'])); $result = $this->Objects->trigger( 'callback', - array(array('value')), - array('modParams' => 0) + [['value']], + ['modParams' => 0] ); - $this->assertEquals(array('new value'), $result); + $this->assertEquals(['new value'], $result); } /** @@ -399,7 +399,7 @@ public function testTriggerModParamsNullIgnored() { public function testTriggerPriority() { $this->_makeMockClasses(); $this->Objects->setObject('TriggerMockFirst', $this->FirstGenericObject); - $this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject, array('priority' => 5)); + $this->Objects->setObject('TriggerMockSecond', $this->SecondGenericObject, ['priority' => 5]); $this->Objects->TriggerMockFirst->expects($this->any()) ->method('callback') @@ -408,94 +408,94 @@ public function testTriggerPriority() { ->method('callback') ->will($this->returnValue('2nd')); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '1st' - ); + ]; $this->assertEquals($expected, $result); - $this->Objects->setObject('TriggerMockThird', $this->ThirdGenericObject, array('priority' => 7)); + $this->Objects->setObject('TriggerMockThird', $this->ThirdGenericObject, ['priority' => 7]); $this->Objects->TriggerMockThird->expects($this->any()) ->method('callback') ->will($this->returnValue('3rd')); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '3rd', '1st' - ); + ]; $this->assertEquals($expected, $result); $this->Objects->disable('TriggerMockFirst'); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '3rd' - ); + ]; $this->assertEquals($expected, $result); $this->Objects->enable('TriggerMockFirst'); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '3rd', '1st' - ); + ]; $this->assertEquals($expected, $result); $this->Objects->disable('TriggerMockThird'); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '1st' - ); + ]; $this->assertEquals($expected, $result); $this->Objects->enable('TriggerMockThird', false); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '1st', '3rd' - ); + ]; $this->assertEquals($expected, $result); $this->Objects->setPriority('TriggerMockThird', 1); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '3rd', '2nd', '1st' - ); + ]; $this->assertEquals($expected, $result); $this->Objects->disable('TriggerMockThird'); $this->Objects->setPriority('TriggerMockThird', 11); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '1st' - ); + ]; $this->assertEquals($expected, $result); $this->Objects->enable('TriggerMockThird'); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '1st', '3rd' - ); + ]; $this->assertEquals($expected, $result); $this->Objects->setPriority('TriggerMockThird'); - $result = $this->Objects->trigger('callback', array(), array('collectReturn' => true)); - $expected = array( + $result = $this->Objects->trigger('callback', [], ['collectReturn' => true]); + $expected = [ '2nd', '1st', '3rd' - ); + ]; $this->assertEquals($expected, $result); } @@ -505,28 +505,28 @@ public function testTriggerPriority() { * @return void */ public function testnormalizeObjectArray() { - $components = array( + $components = [ 'Html', - 'Foo.Bar' => array('one', 'two'), + 'Foo.Bar' => ['one', 'two'], 'Something', - 'Banana.Apple' => array('foo' => 'bar') - ); + 'Banana.Apple' => ['foo' => 'bar'] + ]; $result = ObjectCollection::normalizeObjectArray($components); - $expected = array( - 'Html' => array('class' => 'Html', 'settings' => array()), - 'Bar' => array('class' => 'Foo.Bar', 'settings' => array('one', 'two')), - 'Something' => array('class' => 'Something', 'settings' => array()), - 'Apple' => array('class' => 'Banana.Apple', 'settings' => array('foo' => 'bar')), - ); + $expected = [ + 'Html' => ['class' => 'Html', 'settings' => []], + 'Bar' => ['class' => 'Foo.Bar', 'settings' => ['one', 'two']], + 'Something' => ['class' => 'Something', 'settings' => []], + 'Apple' => ['class' => 'Banana.Apple', 'settings' => ['foo' => 'bar']], + ]; $this->assertEquals($expected, $result); // This is the result after Controller::_mergeVars - $components = array( + $components = [ 'Html' => null, - 'Foo.Bar' => array('one', 'two'), + 'Foo.Bar' => ['one', 'two'], 'Something' => null, - 'Banana.Apple' => array('foo' => 'bar') - ); + 'Banana.Apple' => ['foo' => 'bar'] + ]; $result = ObjectCollection::normalizeObjectArray($components); $this->assertEquals($expected, $result); } @@ -552,7 +552,7 @@ public function testDispatchEventWithSubject() { ->with($subjectClass, 'first argument') ->will($this->returnValue(true)); - $event = new CakeEvent('callback', $subjectClass, array('first argument')); + $event = new CakeEvent('callback', $subjectClass, ['first argument']); $this->assertTrue($this->Objects->trigger($event)); } @@ -578,7 +578,7 @@ public function testDispatchEventNoSubject() { ->with('first argument') ->will($this->returnValue(true)); - $event = new CakeEvent('callback', $subjectClass, array('first argument')); + $event = new CakeEvent('callback', $subjectClass, ['first argument']); $event->omitSubject = true; $this->assertTrue($this->Objects->trigger($event)); } diff --git a/lib/Cake/Test/Case/Utility/SanitizeTest.php b/lib/Cake/Test/Case/Utility/SanitizeTest.php index b53381ff74..2ba26f6513 100644 --- a/lib/Cake/Test/Case/Utility/SanitizeTest.php +++ b/lib/Cake/Test/Case/Utility/SanitizeTest.php @@ -67,7 +67,7 @@ class SanitizeTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.data_test', 'core.article'); + public $fixtures = ['core.data_test', 'core.article']; /** * testEscapeAlphaNumeric method @@ -108,56 +108,56 @@ public function testEscapeAlphaNumeric() { public function testClean() { $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" 'other' ;.$ symbol.another line'; - $result = Sanitize::clean($string, array('connection' => 'test')); + $result = Sanitize::clean($string, ['connection' => 'test']); $this->assertEquals($expected, $result); $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $expected = 'test & ' . Sanitize::escape('"quote"', 'test') . ' ' . Sanitize::escape('\'other\'', 'test') . ' ;.$ symbol.another line'; - $result = Sanitize::clean($string, array('encode' => false, 'connection' => 'test')); + $result = Sanitize::clean($string, ['encode' => false, 'connection' => 'test']); $this->assertEquals($expected, $result); $string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" \'other\' ;.$ $ symbol.another line'; - $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'connection' => 'test')); + $result = Sanitize::clean($string, ['encode' => false, 'escape' => false, 'connection' => 'test']); $this->assertEquals($expected, $result); $string = 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" \'other\' ;.$ \\$ symbol.another line'; - $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'dollar' => false, 'connection' => 'test')); + $result = Sanitize::clean($string, ['encode' => false, 'escape' => false, 'dollar' => false, 'connection' => 'test']); $this->assertEquals($expected, $result); $string = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; $expected = 'test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line'; - $result = Sanitize::clean($string, array('encode' => false, 'escape' => false, 'carriage' => false, 'connection' => 'test')); + $result = Sanitize::clean($string, ['encode' => false, 'escape' => false, 'carriage' => false, 'connection' => 'test']); $this->assertEquals($expected, $result); - $array = array(array('test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line')); - $expected = array(array('test & "quote" 'other' ;.$ symbol.another line')); - $result = Sanitize::clean($array, array('connection' => 'test')); + $array = [['test & "quote" \'other\' ;.$ symbol.' . "\r" . 'another line']]; + $expected = [['test & "quote" 'other' ;.$ symbol.another line']]; + $result = Sanitize::clean($array, ['connection' => 'test']); $this->assertEquals($expected, $result); - $array = array(array('test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line')); - $expected = array(array('test & "quote" \'other\' ;.$ $ symbol.another line')); - $result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test')); + $array = [['test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line']]; + $expected = [['test & "quote" \'other\' ;.$ $ symbol.another line']]; + $result = Sanitize::clean($array, ['encode' => false, 'escape' => false, 'connection' => 'test']); $this->assertEquals($expected, $result); - $array = array(array('test odd Ä spacesé')); - $expected = array(array('test odd Ä spacesé')); - $result = Sanitize::clean($array, array('odd_spaces' => false, 'escape' => false, 'connection' => 'test')); + $array = [['test odd Ä spacesé']]; + $expected = [['test odd Ä spacesé']]; + $result = Sanitize::clean($array, ['odd_spaces' => false, 'escape' => false, 'connection' => 'test']); $this->assertEquals($expected, $result); - $array = array(array('\\$', array('key' => 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line'))); - $expected = array(array('$', array('key' => 'test & "quote" \'other\' ;.$ $ symbol.another line'))); - $result = Sanitize::clean($array, array('encode' => false, 'escape' => false, 'connection' => 'test')); + $array = [['\\$', ['key' => 'test & "quote" \'other\' ;.$ \\$ symbol.' . "\r" . 'another line']]]; + $expected = [['$', ['key' => 'test & "quote" \'other\' ;.$ $ symbol.another line']]]; + $result = Sanitize::clean($array, ['encode' => false, 'escape' => false, 'connection' => 'test']); $this->assertEquals($expected, $result); $string = ''; $expected = ''; - $result = Sanitize::clean($string, array('connection' => 'test')); + $result = Sanitize::clean($string, ['connection' => 'test']); $this->assertEquals($expected, $result); - $data = array( - 'Grant' => array( + $data = [ + 'Grant' => [ 'title' => '2 o clock grant', 'grant_peer_review_id' => 3, 'institution_id' => 5, @@ -165,18 +165,18 @@ public function testClean() { 'modified_by' => 1, 'created' => '2010-07-15 14:11:00', 'modified' => '2010-07-19 10:45:41' - ), - 'GrantsMember' => array( - 0 => array( + ], + 'GrantsMember' => [ + 0 => [ 'id' => 68, 'grant_id' => 120, 'member_id' => 16, 'program_id' => 29, 'pi_percent_commitment' => 1 - ) - ) - ); - $result = Sanitize::clean($data, array('connection' => 'test')); + ] + ] + ]; + $result = Sanitize::clean($data, ['connection' => 'test']); $this->assertEquals($data, $result); } @@ -188,7 +188,7 @@ public function testClean() { public function testHtml() { $string = '

This is a test string & so is this

'; $expected = 'This is a test string & so is this'; - $result = Sanitize::html($string, array('remove' => true)); + $result = Sanitize::html($string, ['remove' => true]); $this->assertEquals($expected, $result); $string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 is true, (2-1) = 1 is also true'; @@ -198,11 +198,11 @@ public function testHtml() { $string = 'The "lazy" dog \'jumped\''; $expected = 'The "lazy" dog \'jumped\''; - $result = Sanitize::html($string, array('quotes' => ENT_COMPAT)); + $result = Sanitize::html($string, ['quotes' => ENT_COMPAT]); $this->assertEquals($expected, $result); $string = 'The "lazy" dog \'jumped\''; - $result = Sanitize::html($string, array('quotes' => ENT_NOQUOTES)); + $result = Sanitize::html($string, ['quotes' => ENT_NOQUOTES]); $this->assertEquals($string, $result); $string = 'The "lazy" dog \'jumped\' & flew over the moon. If (1+1) = 2 is true, (2-1) = 1 is also true'; @@ -217,7 +217,7 @@ public function testHtml() { $string = 'The "lazy" dog & his friend Apple® conquered the world'; $expected = 'The "lazy" dog & his friend Apple® conquered the world'; - $result = Sanitize::html($string, array('double' => false)); + $result = Sanitize::html($string, ['double' => false]); $this->assertEquals($expected, $result); } @@ -249,13 +249,13 @@ public function testParanoid() { $result = Sanitize::paranoid($string); $this->assertEquals($expected, $result); - $string = array('This |s th% s0ng that never ends it g*es', + $string = ['This |s th% s0ng that never ends it g*es', 'on and on my friends, b^ca#use it is the', - 'so&g th===t never ends.'); - $expected = array('This s th% s0ng that never ends it g*es', + 'so&g th===t never ends.']; + $expected = ['This s th% s0ng that never ends it g*es', 'on and on my friends bcause it is the', - 'sog tht never ends.'); - $result = Sanitize::paranoid($string, array('%', '*', '.', ' ')); + 'sog tht never ends.']; + $result = Sanitize::paranoid($string, ['%', '*', '.', ' ']); $this->assertEquals($expected, $result); $string = "anything' OR 1 = 1"; diff --git a/lib/Cake/Test/Case/Utility/SecurityTest.php b/lib/Cake/Test/Case/Utility/SecurityTest.php index aa6d2af042..c7e71387cd 100644 --- a/lib/Cake/Test/Case/Utility/SecurityTest.php +++ b/lib/Cake/Test/Case/Utility/SecurityTest.php @@ -178,7 +178,7 @@ public function testHash() { */ public function testHashBlowfishEmptySalt() { $test = Security::hash('password', 'blowfish'); - $this->skipIf(strpos($test, '$2a$') === false, 'Blowfish hashes are incorrect.'); + $this->skipIf(!str_contains($test, '$2a$'), 'Blowfish hashes are incorrect.'); $stored = ''; $hash = Security::hash('anything', 'blowfish', $stored); @@ -198,7 +198,7 @@ public function testHashBlowfishEmptySalt() { */ public function testHashBlowfish() { $test = Security::hash('password', 'blowfish'); - $this->skipIf(strpos($test, '$2a$') === false, 'Blowfish hashes are incorrect.'); + $this->skipIf(!str_contains($test, '$2a$'), 'Blowfish hashes are incorrect.'); Security::setCost(10); $_hashType = Security::$hashType; @@ -394,15 +394,15 @@ public function testEncryptDecryptCompatibility($txt) { * @return array */ public function plainTextProvider() { - return array( - array(''), - array('abcdefg'), - array('1234567890123456'), - array('The quick brown fox'), - array('12345678901234567890123456789012'), - array('The quick brown fox jumped over the lazy dog.'), - array('何らかのマルチバイト文字列'), - ); + return [ + [''], + ['abcdefg'], + ['1234567890123456'], + ['The quick brown fox'], + ['12345678901234567890123456789012'], + ['The quick brown fox jumped over the lazy dog.'], + ['何らかのマルチバイト文字列'], + ]; } /** diff --git a/lib/Cake/Test/Case/Utility/SetTest.php b/lib/Cake/Test/Case/Utility/SetTest.php index c2e9df9b41..e5c57ba57a 100644 --- a/lib/Cake/Test/Case/Utility/SetTest.php +++ b/lib/Cake/Test/Case/Utility/SetTest.php @@ -32,9 +32,9 @@ class SetTest extends CakeTestCase { * @return void */ public function testNumericKeyExtraction() { - $data = array('plugin' => null, 'controller' => '', 'action' => '', 1, 'whatever'); - $this->assertEquals(array(1, 'whatever'), Set::extract($data, '{n}')); - $this->assertEquals(array('plugin' => null, 'controller' => '', 'action' => ''), Set::diff($data, Set::extract($data, '{n}'))); + $data = ['plugin' => null, 'controller' => '', 'action' => '', 1, 'whatever']; + $this->assertEquals([1, 'whatever'], Set::extract($data, '{n}')); + $this->assertEquals(['plugin' => null, 'controller' => '', 'action' => ''], Set::diff($data, Set::extract($data, '{n}'))); } /** @@ -48,25 +48,25 @@ public function testEnum() { $result = Set::enum(2, 'one, two'); $this->assertNull($result); - $set = array('one', 'two'); + $set = ['one', 'two']; $result = Set::enum(0, $set); $this->assertEquals('one', $result); $result = Set::enum(1, $set); $this->assertEquals('two', $result); - $result = Set::enum(1, array('one', 'two')); + $result = Set::enum(1, ['one', 'two']); $this->assertEquals('two', $result); - $result = Set::enum(2, array('one', 'two')); + $result = Set::enum(2, ['one', 'two']); $this->assertNull($result); - $result = Set::enum('first', array('first' => 'one', 'second' => 'two')); + $result = Set::enum('first', ['first' => 'one', 'second' => 'two']); $this->assertEquals('one', $result); - $result = Set::enum('third', array('first' => 'one', 'second' => 'two')); + $result = Set::enum('third', ['first' => 'one', 'second' => 'two']); $this->assertNull($result); - $result = Set::enum('no', array('no' => 0, 'yes' => 1)); + $result = Set::enum('no', ['no' => 0, 'yes' => 1]); $this->assertEquals(0, $result); - $result = Set::enum('not sure', array('no' => 0, 'yes' => 1)); + $result = Set::enum('not sure', ['no' => 0, 'yes' => 1]); $this->assertNull($result); $result = Set::enum(0); @@ -84,8 +84,8 @@ public function testEnum() { * @return void */ public function testFilter() { - $result = Set::filter(array('0', false, true, 0, array('one thing', 'I can tell you', 'is you got to be', false))); - $expected = array('0', 2 => true, 3 => 0, 4 => array('one thing', 'I can tell you', 'is you got to be')); + $result = Set::filter(['0', false, true, 0, ['one thing', 'I can tell you', 'is you got to be', false]]); + $expected = ['0', 2 => true, 3 => 0, 4 => ['one thing', 'I can tell you', 'is you got to be']]; $this->assertSame($expected, $result); } @@ -96,7 +96,7 @@ public function testFilter() { * @return void */ public function testNumericArrayCheck() { - $data = array('one'); + $data = ['one']; $this->assertTrue(Set::numeric(array_keys($data))); } @@ -106,30 +106,30 @@ public function testNumericArrayCheck() { * @return void */ public function testKeyCheck() { - $data = array('Multi' => array('dimensonal' => array('array'))); + $data = ['Multi' => ['dimensonal' => ['array']]]; $this->assertTrue(Set::check($data, 'Multi.dimensonal')); $this->assertFalse(Set::check($data, 'Multi.dimensonal.array')); - $data = array( - array( - 'Article' => array('id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), - 'User' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), - 'Comment' => array( - array('id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), - array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'), - ), - 'Tag' => array( - array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), - array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31') - ) - ), - array( - 'Article' => array('id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'), - 'User' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), - 'Comment' => array(), - 'Tag' => array() - ) - ); + $data = [ + [ + 'Article' => ['id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'], + 'User' => ['id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'], + 'Comment' => [ + ['id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'], + ['id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'], + ], + 'Tag' => [ + ['id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'], + ['id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'] + ] + ], + [ + 'Article' => ['id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'], + 'User' => ['id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'], + 'Comment' => [], + 'Tag' => [] + ] + ]; $this->assertTrue(Set::check($data, '0.Article.user_id')); $this->assertTrue(Set::check($data, '0.Comment.0.id')); $this->assertFalse(Set::check($data, '0.Comment.0.id.0')); @@ -143,78 +143,78 @@ public function testKeyCheck() { * @return void */ public function testMerge() { - $r = Set::merge(array('foo')); - $this->assertEquals(array('foo'), $r); + $r = Set::merge(['foo']); + $this->assertEquals(['foo'], $r); $r = Set::merge('foo'); - $this->assertEquals(array('foo'), $r); + $this->assertEquals(['foo'], $r); $r = Set::merge('foo', 'bar'); - $this->assertEquals(array('foo', 'bar'), $r); + $this->assertEquals(['foo', 'bar'], $r); - $r = Set::merge(array('foo'), array(), array('bar')); - $this->assertEquals(array('foo', 'bar'), $r); + $r = Set::merge(['foo'], [], ['bar']); + $this->assertEquals(['foo', 'bar'], $r); - $r = Set::merge('foo', array('user' => 'bob', 'no-bar'), 'bar'); - $this->assertEquals(array('foo', 'user' => 'bob', 'no-bar', 'bar'), $r); + $r = Set::merge('foo', ['user' => 'bob', 'no-bar'], 'bar'); + $this->assertEquals(['foo', 'user' => 'bob', 'no-bar', 'bar'], $r); - $a = array('foo', 'foo2'); - $b = array('bar', 'bar2'); - $this->assertEquals(array('foo', 'foo2', 'bar', 'bar2'), Set::merge($a, $b)); + $a = ['foo', 'foo2']; + $b = ['bar', 'bar2']; + $this->assertEquals(['foo', 'foo2', 'bar', 'bar2'], Set::merge($a, $b)); - $a = array('foo' => 'bar', 'bar' => 'foo'); - $b = array('foo' => 'no-bar', 'bar' => 'no-foo'); - $this->assertEquals(array('foo' => 'no-bar', 'bar' => 'no-foo'), Set::merge($a, $b)); + $a = ['foo' => 'bar', 'bar' => 'foo']; + $b = ['foo' => 'no-bar', 'bar' => 'no-foo']; + $this->assertEquals(['foo' => 'no-bar', 'bar' => 'no-foo'], Set::merge($a, $b)); - $a = array('users' => array('bob', 'jim')); - $b = array('users' => array('lisa', 'tina')); - $this->assertEquals(array('users' => array('bob', 'jim', 'lisa', 'tina')), Set::merge($a, $b)); + $a = ['users' => ['bob', 'jim']]; + $b = ['users' => ['lisa', 'tina']]; + $this->assertEquals(['users' => ['bob', 'jim', 'lisa', 'tina']], Set::merge($a, $b)); - $a = array('users' => array('jim', 'bob')); - $b = array('users' => 'none'); - $this->assertEquals(array('users' => 'none'), Set::merge($a, $b)); + $a = ['users' => ['jim', 'bob']]; + $b = ['users' => 'none']; + $this->assertEquals(['users' => 'none'], Set::merge($a, $b)); - $a = array('users' => array('lisa' => array('id' => 5, 'pw' => 'secret')), 'cakephp'); - $b = array('users' => array('lisa' => array('pw' => 'new-pass', 'age' => 23)), 'ice-cream'); - $this->assertEquals(array('users' => array('lisa' => array('id' => 5, 'pw' => 'new-pass', 'age' => 23)), 'cakephp', 'ice-cream'), Set::merge($a, $b)); + $a = ['users' => ['lisa' => ['id' => 5, 'pw' => 'secret']], 'cakephp']; + $b = ['users' => ['lisa' => ['pw' => 'new-pass', 'age' => 23]], 'ice-cream']; + $this->assertEquals(['users' => ['lisa' => ['id' => 5, 'pw' => 'new-pass', 'age' => 23]], 'cakephp', 'ice-cream'], Set::merge($a, $b)); - $c = array('users' => array('lisa' => array('pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog')), 'chocolate'); - $expected = array('users' => array('lisa' => array('id' => 5, 'pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog')), 'cakephp', 'ice-cream', 'chocolate'); + $c = ['users' => ['lisa' => ['pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog']], 'chocolate']; + $expected = ['users' => ['lisa' => ['id' => 5, 'pw' => 'you-will-never-guess', 'age' => 25, 'pet' => 'dog']], 'cakephp', 'ice-cream', 'chocolate']; $this->assertEquals($expected, Set::merge($a, $b, $c)); - $this->assertEquals($expected, Set::merge($a, $b, array(), $c)); + $this->assertEquals($expected, Set::merge($a, $b, [], $c)); $r = Set::merge($a, $b, $c); $this->assertEquals($expected, $r); - $a = array('Tree', 'CounterCache', - 'Upload' => array('folder' => 'products', - 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id'))); - $b = array('Cacheable' => array('enabled' => false), + $a = ['Tree', 'CounterCache', + 'Upload' => ['folder' => 'products', + 'fields' => ['image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id']]]; + $b = ['Cacheable' => ['enabled' => false], 'Limit', 'Bindable', 'Validator', - 'Transactional'); + 'Transactional']; - $expected = array('Tree', 'CounterCache', - 'Upload' => array('folder' => 'products', - 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')), - 'Cacheable' => array('enabled' => false), + $expected = ['Tree', 'CounterCache', + 'Upload' => ['folder' => 'products', + 'fields' => ['image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id']], + 'Cacheable' => ['enabled' => false], 'Limit', 'Bindable', 'Validator', - 'Transactional'); + 'Transactional']; $this->assertEquals($expected, Set::merge($a, $b)); - $expected = array('Tree' => null, 'CounterCache' => null, - 'Upload' => array('folder' => 'products', - 'fields' => array('image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id')), - 'Cacheable' => array('enabled' => false), + $expected = ['Tree' => null, 'CounterCache' => null, + 'Upload' => ['folder' => 'products', + 'fields' => ['image_1_id', 'image_2_id', 'image_3_id', 'image_4_id', 'image_5_id']], + 'Cacheable' => ['enabled' => false], 'Limit' => null, 'Bindable' => null, 'Validator' => null, - 'Transactional' => null); + 'Transactional' => null]; $this->assertEquals($expected, Set::normalize(Set::merge($a, $b))); } @@ -225,112 +225,112 @@ public function testMerge() { * @return void */ public function testSort() { - $result = Set::sort(array(), '{n}.name', 'asc'); - $this->assertEquals(array(), $result); - - $a = array( - 0 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), - 1 => array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))) - ); - $b = array( - 0 => array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))), - 1 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))) - - ); + $result = Set::sort([], '{n}.name', 'asc'); + $this->assertEquals([], $result); + + $a = [ + 0 => ['Person' => ['name' => 'Jeff'], 'Friend' => [['name' => 'Nate']]], + 1 => ['Person' => ['name' => 'Tracy'], 'Friend' => [['name' => 'Lindsay']]] + ]; + $b = [ + 0 => ['Person' => ['name' => 'Tracy'], 'Friend' => [['name' => 'Lindsay']]], + 1 => ['Person' => ['name' => 'Jeff'], 'Friend' => [['name' => 'Nate']]] + + ]; $a = Set::sort($a, '{n}.Friend.{n}.name', 'asc'); $this->assertEquals($a, $b); - $b = array( - 0 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), - 1 => array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))) - ); - $a = array( - 0 => array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))), - 1 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))) + $b = [ + 0 => ['Person' => ['name' => 'Jeff'], 'Friend' => [['name' => 'Nate']]], + 1 => ['Person' => ['name' => 'Tracy'], 'Friend' => [['name' => 'Lindsay']]] + ]; + $a = [ + 0 => ['Person' => ['name' => 'Tracy'], 'Friend' => [['name' => 'Lindsay']]], + 1 => ['Person' => ['name' => 'Jeff'], 'Friend' => [['name' => 'Nate']]] - ); + ]; $a = Set::sort($a, '{n}.Friend.{n}.name', 'desc'); $this->assertEquals($a, $b); - $a = array( - 0 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), - 1 => array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))), - 2 => array('Person' => array('name' => 'Adam'), 'Friend' => array(array('name' => 'Bob'))) - ); - $b = array( - 0 => array('Person' => array('name' => 'Adam'), 'Friend' => array(array('name' => 'Bob'))), - 1 => array('Person' => array('name' => 'Jeff'), 'Friend' => array(array('name' => 'Nate'))), - 2 => array('Person' => array('name' => 'Tracy'), 'Friend' => array(array('name' => 'Lindsay'))) - ); + $a = [ + 0 => ['Person' => ['name' => 'Jeff'], 'Friend' => [['name' => 'Nate']]], + 1 => ['Person' => ['name' => 'Tracy'], 'Friend' => [['name' => 'Lindsay']]], + 2 => ['Person' => ['name' => 'Adam'], 'Friend' => [['name' => 'Bob']]] + ]; + $b = [ + 0 => ['Person' => ['name' => 'Adam'], 'Friend' => [['name' => 'Bob']]], + 1 => ['Person' => ['name' => 'Jeff'], 'Friend' => [['name' => 'Nate']]], + 2 => ['Person' => ['name' => 'Tracy'], 'Friend' => [['name' => 'Lindsay']]] + ]; $a = Set::sort($a, '{n}.Person.name', 'asc'); $this->assertEquals($a, $b); - $a = array( - array(7, 6, 4), - array(3, 4, 5), - array(3, 2, 1), - ); + $a = [ + [7, 6, 4], + [3, 4, 5], + [3, 2, 1], + ]; - $b = array( - array(3, 2, 1), - array(3, 4, 5), - array(7, 6, 4), - ); + $b = [ + [3, 2, 1], + [3, 4, 5], + [7, 6, 4], + ]; $a = Set::sort($a, '{n}.{n}', 'asc'); $this->assertEquals($a, $b); - $a = array( - array(7, 6, 4), - array(3, 4, 5), - array(3, 2, array(1, 1, 1)), - ); + $a = [ + [7, 6, 4], + [3, 4, 5], + [3, 2, [1, 1, 1]], + ]; - $b = array( - array(3, 2, array(1, 1, 1)), - array(3, 4, 5), - array(7, 6, 4), - ); + $b = [ + [3, 2, [1, 1, 1]], + [3, 4, 5], + [7, 6, 4], + ]; $a = Set::sort($a, '{n}', 'asc'); $this->assertEquals($a, $b); - $a = array( - 0 => array('Person' => array('name' => 'Jeff')), - 1 => array('Shirt' => array('color' => 'black')) - ); - $b = array( - 0 => array('Shirt' => array('color' => 'black')), - 1 => array('Person' => array('name' => 'Jeff')), - ); + $a = [ + 0 => ['Person' => ['name' => 'Jeff']], + 1 => ['Shirt' => ['color' => 'black']] + ]; + $b = [ + 0 => ['Shirt' => ['color' => 'black']], + 1 => ['Person' => ['name' => 'Jeff']], + ]; $a = Set::sort($a, '{n}.Person.name', 'ASC'); $this->assertEquals($a, $b); - $names = array( - array('employees' => array(array('name' => array('first' => 'John', 'last' => 'Doe')))), - array('employees' => array(array('name' => array('first' => 'Jane', 'last' => 'Doe')))), - array('employees' => array(array('name' => array()))), - array('employees' => array(array('name' => array()))) - ); - $result = Set::sort($names, '{n}.employees.0.name', 'asc', 1); - $expected = array( - array('employees' => array(array('name' => array('first' => 'John', 'last' => 'Doe')))), - array('employees' => array(array('name' => array('first' => 'Jane', 'last' => 'Doe')))), - array('employees' => array(array('name' => array()))), - array('employees' => array(array('name' => array()))) - ); - $this->assertEquals($expected, $result); - - $menus = array( - 'blogs' => array('title' => 'Blogs', 'weight' => 3), - 'comments' => array('title' => 'Comments', 'weight' => 2), - 'users' => array('title' => 'Users', 'weight' => 1), - ); - $expected = array( - 'users' => array('title' => 'Users', 'weight' => 1), - 'comments' => array('title' => 'Comments', 'weight' => 2), - 'blogs' => array('title' => 'Blogs', 'weight' => 3), - ); + $names = [ + ['employees' => [['name' => ['first' => 'John', 'last' => 'Doe']]]], + ['employees' => [['name' => ['first' => 'Jane', 'last' => 'Doe']]]], + ['employees' => [['name' => []]]], + ['employees' => [['name' => []]]] + ]; + $result = Set::sort($names, '{n}.employees.0.name', 'asc'); + $expected = [ + ['employees' => [['name' => ['first' => 'John', 'last' => 'Doe']]]], + ['employees' => [['name' => ['first' => 'Jane', 'last' => 'Doe']]]], + ['employees' => [['name' => []]]], + ['employees' => [['name' => []]]] + ]; + $this->assertEquals($expected, $result); + + $menus = [ + 'blogs' => ['title' => 'Blogs', 'weight' => 3], + 'comments' => ['title' => 'Comments', 'weight' => 2], + 'users' => ['title' => 'Users', 'weight' => 1], + ]; + $expected = [ + 'users' => ['title' => 'Users', 'weight' => 1], + 'comments' => ['title' => 'Comments', 'weight' => 2], + 'blogs' => ['title' => 'Blogs', 'weight' => 3], + ]; $result = Set::sort($menus, '{[a-z]+}.weight', 'ASC'); $this->assertEquals($expected, $result); } @@ -341,21 +341,21 @@ public function testSort() { * @return void */ public function testSortString() { - $toSort = array( - 'four' => array('number' => 4, 'some' => 'foursome'), - 'six' => array('number' => 6, 'some' => 'sixsome'), - 'five' => array('number' => 5, 'some' => 'fivesome'), - 'two' => array('number' => 2, 'some' => 'twosome'), - 'three' => array('number' => 3, 'some' => 'threesome') - ); + $toSort = [ + 'four' => ['number' => 4, 'some' => 'foursome'], + 'six' => ['number' => 6, 'some' => 'sixsome'], + 'five' => ['number' => 5, 'some' => 'fivesome'], + 'two' => ['number' => 2, 'some' => 'twosome'], + 'three' => ['number' => 3, 'some' => 'threesome'] + ]; $sorted = Set::sort($toSort, '{s}.number', 'asc'); - $expected = array( - 'two' => array('number' => 2, 'some' => 'twosome'), - 'three' => array('number' => 3, 'some' => 'threesome'), - 'four' => array('number' => 4, 'some' => 'foursome'), - 'five' => array('number' => 5, 'some' => 'fivesome'), - 'six' => array('number' => 6, 'some' => 'sixsome') - ); + $expected = [ + 'two' => ['number' => 2, 'some' => 'twosome'], + 'three' => ['number' => 3, 'some' => 'threesome'], + 'four' => ['number' => 4, 'some' => 'foursome'], + 'five' => ['number' => 5, 'some' => 'fivesome'], + 'six' => ['number' => 6, 'some' => 'sixsome'] + ]; $this->assertEquals($expected, $sorted); } @@ -365,20 +365,20 @@ public function testSortString() { * @return void */ public function testSortWithOutOfOrderKeys() { - $data = array( - 9 => array('class' => 510, 'test2' => 2), - 1 => array('class' => 500, 'test2' => 1), - 2 => array('class' => 600, 'test2' => 2), - 5 => array('class' => 625, 'test2' => 4), - 0 => array('class' => 605, 'test2' => 3), - ); - $expected = array( - array('class' => 500, 'test2' => 1), - array('class' => 510, 'test2' => 2), - array('class' => 600, 'test2' => 2), - array('class' => 605, 'test2' => 3), - array('class' => 625, 'test2' => 4), - ); + $data = [ + 9 => ['class' => 510, 'test2' => 2], + 1 => ['class' => 500, 'test2' => 1], + 2 => ['class' => 600, 'test2' => 2], + 5 => ['class' => 625, 'test2' => 4], + 0 => ['class' => 605, 'test2' => 3], + ]; + $expected = [ + ['class' => 500, 'test2' => 1], + ['class' => 510, 'test2' => 2], + ['class' => 600, 'test2' => 2], + ['class' => 605, 'test2' => 3], + ['class' => 625, 'test2' => 4], + ]; $result = Set::sort($data, '{n}.class', 'asc'); $this->assertEquals($expected, $result); @@ -392,324 +392,324 @@ public function testSortWithOutOfOrderKeys() { * @return void */ public function testExtract() { - $a = array( - array( - 'Article' => array('id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), - 'User' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), - 'Comment' => array( - array('id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'), - array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'), - ), - 'Tag' => array( - array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'), - array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31') - ), - 'Deep' => array( - 'Nesting' => array( - 'test' => array( + $a = [ + [ + 'Article' => ['id' => '1', 'user_id' => '1', 'title' => 'First Article', 'body' => 'First Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'], + 'User' => ['id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'], + 'Comment' => [ + ['id' => '1', 'article_id' => '1', 'user_id' => '2', 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:45:23', 'updated' => '2007-03-18 10:47:31'], + ['id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'], + ], + 'Tag' => [ + ['id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'], + ['id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'] + ], + 'Deep' => [ + 'Nesting' => [ + 'test' => [ 1 => 'foo', - 2 => array( - 'and' => array('more' => 'stuff') - ) - ) - ) - ) - ), - array( - 'Article' => array('id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'), - 'User' => array('id' => '2', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), - 'Comment' => array(), - 'Tag' => array() - ), - array( - 'Article' => array('id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'), - 'User' => array('id' => '3', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), - 'Comment' => array(), - 'Tag' => array() - ), - array( - 'Article' => array('id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'), - 'User' => array('id' => '4', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), - 'Comment' => array(), - 'Tag' => array() - ), - array( - 'Article' => array('id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'), - 'User' => array('id' => '5', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), - 'Comment' => array(), - 'Tag' => array() - ) - ); - $b = array('Deep' => $a[0]['Deep']); - $c = array( - array('a' => array('I' => array('a' => 1))), - array( - 'a' => array( + 2 => [ + 'and' => ['more' => 'stuff'] + ] + ] + ] + ] + ], + [ + 'Article' => ['id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'], + 'User' => ['id' => '2', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'], + 'Comment' => [], + 'Tag' => [] + ], + [ + 'Article' => ['id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'], + 'User' => ['id' => '3', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'], + 'Comment' => [], + 'Tag' => [] + ], + [ + 'Article' => ['id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'], + 'User' => ['id' => '4', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'], + 'Comment' => [], + 'Tag' => [] + ], + [ + 'Article' => ['id' => '3', 'user_id' => '1', 'title' => 'Third Article', 'body' => 'Third Article Body', 'published' => 'Y', 'created' => '2007-03-18 10:43:23', 'updated' => '2007-03-18 10:45:31'], + 'User' => ['id' => '5', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'], + 'Comment' => [], + 'Tag' => [] + ] + ]; + $b = ['Deep' => $a[0]['Deep']]; + $c = [ + ['a' => ['I' => ['a' => 1]]], + [ + 'a' => [ 2 - ) - ), - array('a' => array('II' => array('a' => 3, 'III' => array('a' => array('foo' => 4))))), - ); + ] + ], + ['a' => ['II' => ['a' => 3, 'III' => ['a' => ['foo' => 4]]]]], + ]; - $expected = array(array('a' => $c[2]['a'])); + $expected = [['a' => $c[2]['a']]]; $r = Set::extract('/a/II[a=3]/..', $c); $this->assertEquals($expected, $r); - $expected = array(1, 2, 3, 4, 5); + $expected = [1, 2, 3, 4, 5]; $this->assertEquals($expected, Set::extract('/User/id', $a)); - $expected = array(1, 2, 3, 4, 5); + $expected = [1, 2, 3, 4, 5]; $this->assertEquals($expected, Set::extract('/User/id', $a)); - $expected = array( - array('id' => 1), array('id' => 2), array('id' => 3), array('id' => 4), array('id' => 5) - ); + $expected = [ + ['id' => 1], ['id' => 2], ['id' => 3], ['id' => 4], ['id' => 5] + ]; - $r = Set::extract('/User/id', $a, array('flatten' => false)); + $r = Set::extract('/User/id', $a, ['flatten' => false]); $this->assertEquals($expected, $r); - $expected = array(array('test' => $a[0]['Deep']['Nesting']['test'])); + $expected = [['test' => $a[0]['Deep']['Nesting']['test']]]; $this->assertEquals($expected, Set::extract('/Deep/Nesting/test', $a)); $this->assertEquals($expected, Set::extract('/Deep/Nesting/test', $b)); - $expected = array(array('test' => $a[0]['Deep']['Nesting']['test'])); + $expected = [['test' => $a[0]['Deep']['Nesting']['test']]]; $r = Set::extract('/Deep/Nesting/test/1/..', $a); $this->assertEquals($expected, $r); - $expected = array(array('test' => $a[0]['Deep']['Nesting']['test'])); + $expected = [['test' => $a[0]['Deep']['Nesting']['test']]]; $r = Set::extract('/Deep/Nesting/test/2/and/../..', $a); $this->assertEquals($expected, $r); - $expected = array(array('test' => $a[0]['Deep']['Nesting']['test'])); + $expected = [['test' => $a[0]['Deep']['Nesting']['test']]]; $r = Set::extract('/Deep/Nesting/test/2/../../../Nesting/test/2/..', $a); $this->assertEquals($expected, $r); - $expected = array(2); + $expected = [2]; $r = Set::extract('/User[2]/id', $a); $this->assertEquals($expected, $r); - $expected = array(4, 5); + $expected = [4, 5]; $r = Set::extract('/User[id>3]/id', $a); $this->assertEquals($expected, $r); - $expected = array(2, 3); + $expected = [2, 3]; $r = Set::extract('/User[id>1][id<=3]/id', $a); $this->assertEquals($expected, $r); - $expected = array(array('I'), array('II')); + $expected = [['I'], ['II']]; $r = Set::extract('/a/@*', $c); $this->assertEquals($expected, $r); - $single = array( - 'User' => array( + $single = [ + 'User' => [ 'id' => 4, 'name' => 'Neo', - ) - ); - $tricky = array( - 0 => array( - 'User' => array( + ] + ]; + $tricky = [ + 0 => [ + 'User' => [ 'id' => 1, 'name' => 'John', - ) - ), - 1 => array( - 'User' => array( + ] + ], + 1 => [ + 'User' => [ 'id' => 2, 'name' => 'Bob', - ) - ), - 2 => array( - 'User' => array( + ] + ], + 2 => [ + 'User' => [ 'id' => 3, 'name' => 'Tony', - ) - ), - 'User' => array( + ] + ], + 'User' => [ 'id' => 4, 'name' => 'Neo', - ) - ); + ] + ]; - $expected = array(1, 2, 3, 4); + $expected = [1, 2, 3, 4]; $r = Set::extract('/User/id', $tricky); $this->assertEquals($expected, $r); - $expected = array(4); + $expected = [4]; $r = Set::extract('/User/id', $single); $this->assertEquals($expected, $r); - $expected = array(1, 3); + $expected = [1, 3]; $r = Set::extract('/User[name=/n/]/id', $tricky); $this->assertEquals($expected, $r); - $expected = array(4); + $expected = [4]; $r = Set::extract('/User[name=/N/]/id', $tricky); $this->assertEquals($expected, $r); - $expected = array(1, 3, 4); + $expected = [1, 3, 4]; $r = Set::extract('/User[name=/N/i]/id', $tricky); $this->assertEquals($expected, $r); - $expected = array(array('id', 'name'), array('id', 'name'), array('id', 'name'), array('id', 'name')); + $expected = [['id', 'name'], ['id', 'name'], ['id', 'name'], ['id', 'name']]; $r = Set::extract('/User/@*', $tricky); $this->assertEquals($expected, $r); - $common = array( - array( - 'Article' => array( + $common = [ + [ + 'Article' => [ 'id' => 1, 'name' => 'Article 1', - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 1, 'user_id' => 5, 'article_id' => 1, 'text' => 'Comment 1', - ), - array( + ], + [ 'id' => 2, 'user_id' => 23, 'article_id' => 1, 'text' => 'Comment 2', - ), - array( + ], + [ 'id' => 3, 'user_id' => 17, 'article_id' => 1, 'text' => 'Comment 3', - ), - ), - ), - array( - 'Article' => array( + ], + ], + ], + [ + 'Article' => [ 'id' => 2, 'name' => 'Article 2', - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 4, 'user_id' => 2, 'article_id' => 2, 'text' => 'Comment 4', 'addition' => '', - ), - array( + ], + [ 'id' => 5, 'user_id' => 23, 'article_id' => 2, 'text' => 'Comment 5', 'addition' => 'foo', - ), - ), - ), - array( - 'Article' => array( + ], + ], + ], + [ + 'Article' => [ 'id' => 3, 'name' => 'Article 3', - ), - 'Comment' => array(), - ) - ); + ], + 'Comment' => [], + ] + ]; $r = Set::extract('/Comment/id', $common); - $expected = array(1, 2, 3, 4, 5); + $expected = [1, 2, 3, 4, 5]; $this->assertEquals($expected, $r); - $expected = array(1, 2, 4, 5); + $expected = [1, 2, 4, 5]; $r = Set::extract('/Comment[id!=3]/id', $common); $this->assertEquals($expected, $r); $r = Set::extract('/', $common); $this->assertEquals($r, $common); - $expected = array(1, 2, 4, 5); + $expected = [1, 2, 4, 5]; $r = Set::extract($common, '/Comment[id!=3]/id'); $this->assertEquals($expected, $r); - $expected = array($common[0]['Comment'][2]); + $expected = [$common[0]['Comment'][2]]; $r = Set::extract($common, '/Comment/2'); $this->assertEquals($expected, $r); - $expected = array($common[0]['Comment'][0]); + $expected = [$common[0]['Comment'][0]]; $r = Set::extract($common, '/Comment[1]/.[id=1]'); $this->assertEquals($expected, $r); - $expected = array($common[1]['Comment'][1]); + $expected = [$common[1]['Comment'][1]]; $r = Set::extract($common, '/1/Comment/.[2]'); $this->assertEquals($expected, $r); - $expected = array(); - $r = Set::extract('/User/id', array()); + $expected = []; + $r = Set::extract('/User/id', []); $this->assertEquals($expected, $r); - $expected = array(5); + $expected = [5]; $r = Set::extract('/Comment/id[:last]', $common); $this->assertEquals($expected, $r); - $expected = array(1); + $expected = [1]; $r = Set::extract('/Comment/id[:first]', $common); $this->assertEquals($expected, $r); - $expected = array(3); + $expected = [3]; $r = Set::extract('/Article[:last]/id', $common); $this->assertEquals($expected, $r); - $expected = array(array('Comment' => $common[1]['Comment'][0])); + $expected = [['Comment' => $common[1]['Comment'][0]]]; $r = Set::extract('/Comment[addition=]', $common); $this->assertEquals($expected, $r); - $habtm = array( - array( - 'Post' => array( + $habtm = [ + [ + 'Post' => [ 'id' => 1, 'title' => 'great post', - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 1, 'text' => 'foo', - 'User' => array( + 'User' => [ 'id' => 1, 'name' => 'bob' - ), - ), - array( + ], + ], + [ 'id' => 2, 'text' => 'bar', - 'User' => array( + 'User' => [ 'id' => 2, 'name' => 'tod' - ), - ), - ), - ), - array( - 'Post' => array( + ], + ], + ], + ], + [ + 'Post' => [ 'id' => 2, 'title' => 'fun post', - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 3, 'text' => '123', - 'User' => array( + 'User' => [ 'id' => 3, 'name' => 'dan' - ), - ), - array( + ], + ], + [ 'id' => 4, 'text' => '987', - 'User' => array( + 'User' => [ 'id' => 4, 'name' => 'jim' - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; $r = Set::extract('/Comment/User[name=/bob|dan/]/..', $habtm); $this->assertEquals('bob', $r[0]['Comment']['User']['name']); @@ -722,91 +722,91 @@ public function testExtract() { $this->assertEquals('tod', $r[1]['Comment']['User']['name']); $this->assertEquals(2, count($r)); - $tree = array( - array( - 'Category' => array('name' => 'Category 1'), - 'children' => array(array('Category' => array('name' => 'Category 1.1'))) - ), - array( - 'Category' => array('name' => 'Category 2'), - 'children' => array( - array('Category' => array('name' => 'Category 2.1')), - array('Category' => array('name' => 'Category 2.2')) - ) - ), - array( - 'Category' => array('name' => 'Category 3'), - 'children' => array(array('Category' => array('name' => 'Category 3.1'))) - ) - ); - - $expected = array(array('Category' => $tree[1]['Category'])); + $tree = [ + [ + 'Category' => ['name' => 'Category 1'], + 'children' => [['Category' => ['name' => 'Category 1.1']]] + ], + [ + 'Category' => ['name' => 'Category 2'], + 'children' => [ + ['Category' => ['name' => 'Category 2.1']], + ['Category' => ['name' => 'Category 2.2']] + ] + ], + [ + 'Category' => ['name' => 'Category 3'], + 'children' => [['Category' => ['name' => 'Category 3.1']]] + ] + ]; + + $expected = [['Category' => $tree[1]['Category']]]; $r = Set::extract('/Category[name=Category 2]', $tree); $this->assertEquals($expected, $r); - $expected = array( - array('Category' => $tree[1]['Category'], 'children' => $tree[1]['children']) - ); + $expected = [ + ['Category' => $tree[1]['Category'], 'children' => $tree[1]['children']] + ]; $r = Set::extract('/Category[name=Category 2]/..', $tree); $this->assertEquals($expected, $r); - $expected = array( - array('children' => $tree[1]['children'][0]), - array('children' => $tree[1]['children'][1]) - ); + $expected = [ + ['children' => $tree[1]['children'][0]], + ['children' => $tree[1]['children'][1]] + ]; $r = Set::extract('/Category[name=Category 2]/../children', $tree); $this->assertEquals($expected, $r); - $habtm = array( - array( - 'Post' => array( + $habtm = [ + [ + 'Post' => [ 'id' => 1, 'title' => 'great post', - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 1, 'text' => 'foo', - 'User' => array( + 'User' => [ 'id' => 1, 'name' => 'bob' - ), - ), - array( + ], + ], + [ 'id' => 2, 'text' => 'bar', - 'User' => array( + 'User' => [ 'id' => 2, 'name' => 'tod' - ), - ), - ), - ), - array( - 'Post' => array( + ], + ], + ], + ], + [ + 'Post' => [ 'id' => 2, 'title' => 'fun post', - ), - 'Comment' => array( - array( + ], + 'Comment' => [ + [ 'id' => 3, 'text' => '123', - 'User' => array( + 'User' => [ 'id' => 3, 'name' => 'dan' - ), - ), - array( + ], + ], + [ 'id' => 4, 'text' => '987', - 'User' => array( + 'User' => [ 'id' => 4, 'name' => 'jim' - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; $r = Set::extract('/Comment/User[name=/\w+/]/..', $habtm); $this->assertEquals('bob', $r[0]['Comment']['User']['name']); @@ -832,175 +832,175 @@ public function testExtract() { $this->assertEquals('tod', $r[1]['Comment']['User']['name']); $this->assertEquals(2, count($r)); - $mixedKeys = array( - 'User' => array( - 0 => array( + $mixedKeys = [ + 'User' => [ + 0 => [ 'id' => 4, 'name' => 'Neo' - ), - 1 => array( + ], + 1 => [ 'id' => 5, 'name' => 'Morpheus' - ), - 'stringKey' => array() - ) - ); - $expected = array('Neo', 'Morpheus'); + ], + 'stringKey' => [] + ] + ]; + $expected = ['Neo', 'Morpheus']; $r = Set::extract('/User/name', $mixedKeys); $this->assertEquals($expected, $r); - $f = array( - array( - 'file' => array( + $f = [ + [ + 'file' => [ 'name' => 'zipfile.zip', 'type' => 'application/zip', 'tmp_name' => '/tmp/php178.tmp', 'error' => 0, 'size' => '564647' - ) - ), - array( - 'file' => array( + ] + ], + [ + 'file' => [ 'name' => 'zipfile2.zip', 'type' => 'application/x-zip-compressed', 'tmp_name' => '/tmp/php179.tmp', 'error' => 0, 'size' => '354784' - ) - ), - array( - 'file' => array( + ] + ], + [ + 'file' => [ 'name' => 'picture.jpg', 'type' => 'image/jpeg', 'tmp_name' => '/tmp/php180.tmp', 'error' => 0, 'size' => '21324' - ) - ) - ); - $expected = array(array('name' => 'zipfile2.zip', 'type' => 'application/x-zip-compressed', 'tmp_name' => '/tmp/php179.tmp', 'error' => 0, 'size' => '354784')); + ] + ] + ]; + $expected = [['name' => 'zipfile2.zip', 'type' => 'application/x-zip-compressed', 'tmp_name' => '/tmp/php179.tmp', 'error' => 0, 'size' => '354784']]; $r = Set::extract('/file/.[type=application/x-zip-compressed]', $f); $this->assertEquals($expected, $r); - $expected = array(array('name' => 'zipfile.zip', 'type' => 'application/zip', 'tmp_name' => '/tmp/php178.tmp', 'error' => 0, 'size' => '564647')); + $expected = [['name' => 'zipfile.zip', 'type' => 'application/zip', 'tmp_name' => '/tmp/php178.tmp', 'error' => 0, 'size' => '564647']]; $r = Set::extract('/file/.[type=application/zip]', $f); $this->assertEquals($expected, $r); - $f = array( - array( - 'file' => array( + $f = [ + [ + 'file' => [ 'name' => 'zipfile.zip', 'type' => 'application/zip', 'tmp_name' => '/tmp/php178.tmp', 'error' => 0, 'size' => '564647' - ) - ), - array( - 'file' => array( + ] + ], + [ + 'file' => [ 'name' => 'zipfile2.zip', 'type' => 'application/x zip compressed', 'tmp_name' => '/tmp/php179.tmp', 'error' => 0, 'size' => '354784' - ) - ), - array( - 'file' => array( + ] + ], + [ + 'file' => [ 'name' => 'picture.jpg', 'type' => 'image/jpeg', 'tmp_name' => '/tmp/php180.tmp', 'error' => 0, 'size' => '21324' - ) - ) - ); - $expected = array(array('name' => 'zipfile2.zip', 'type' => 'application/x zip compressed', 'tmp_name' => '/tmp/php179.tmp', 'error' => 0, 'size' => '354784')); + ] + ] + ]; + $expected = [['name' => 'zipfile2.zip', 'type' => 'application/x zip compressed', 'tmp_name' => '/tmp/php179.tmp', 'error' => 0, 'size' => '354784']]; $r = Set::extract('/file/.[type=application/x zip compressed]', $f); $this->assertEquals($expected, $r); - $expected = array( - array('name' => 'zipfile.zip', 'type' => 'application/zip', 'tmp_name' => '/tmp/php178.tmp', 'error' => 0, 'size' => '564647'), - array('name' => 'zipfile2.zip', 'type' => 'application/x zip compressed', 'tmp_name' => '/tmp/php179.tmp', 'error' => 0, 'size' => '354784') - ); + $expected = [ + ['name' => 'zipfile.zip', 'type' => 'application/zip', 'tmp_name' => '/tmp/php178.tmp', 'error' => 0, 'size' => '564647'], + ['name' => 'zipfile2.zip', 'type' => 'application/x zip compressed', 'tmp_name' => '/tmp/php179.tmp', 'error' => 0, 'size' => '354784'] + ]; $r = Set::extract('/file/.[tmp_name=/tmp\/php17/]', $f); $this->assertEquals($expected, $r); - $hasMany = array( - 'Node' => array( + $hasMany = [ + 'Node' => [ 'id' => 1, 'name' => 'First', 'state' => 50 - ), - 'ParentNode' => array( - 0 => array( + ], + 'ParentNode' => [ + 0 => [ 'id' => 2, 'name' => 'Second', 'state' => 60, - ) - ) - ); + ] + ] + ]; $result = Set::extract('/ParentNode/name', $hasMany); - $expected = array('Second'); + $expected = ['Second']; $this->assertEquals($expected, $result); - $data = array( - array( - 'Category' => array( + $data = [ + [ + 'Category' => [ 'id' => 1, 'name' => 'First' - ), - 0 => array( + ], + 0 => [ 'value' => 50 - ) - ), - array( - 'Category' => array( + ] + ], + [ + 'Category' => [ 'id' => 2, 'name' => 'Second' - ), - 0 => array( + ], + 0 => [ 'value' => 60 - ) - ) - ); - $expected = array( - array( - 'Category' => array( + ] + ] + ]; + $expected = [ + [ + 'Category' => [ 'id' => 1, 'name' => 'First' - ), - 0 => array( + ], + 0 => [ 'value' => 50 - ) - ) - ); + ] + ] + ]; $result = Set::extract('/Category[id=1]/..', $data); $this->assertEquals($expected, $result); - $data = array( - array( - 'ChildNode' => array('id' => 1), - array('name' => 'Item 1') - ), - array( - 'ChildNode' => array('id' => 2), - array('name' => 'Item 2') - ), - ); + $data = [ + [ + 'ChildNode' => ['id' => 1], + ['name' => 'Item 1'] + ], + [ + 'ChildNode' => ['id' => 2], + ['name' => 'Item 2'] + ], + ]; - $expected = array( + $expected = [ 'Item 1', 'Item 2' - ); + ]; $result = Set::extract('/0/name', $data); $this->assertEquals($expected, $result); - $data = array( - array('A1', 'B1'), - array('A2', 'B2') - ); - $expected = array('A1', 'A2'); + $data = [ + ['A1', 'B1'], + ['A2', 'B2'] + ]; + $expected = ['A1', 'A2']; $result = Set::extract('/0', $data); $this->assertEquals($expected, $result); } @@ -1011,172 +1011,172 @@ public function testExtract() { * @return void */ public function testExtractParentSelector() { - $tree = array( - array( - 'Category' => array( + $tree = [ + [ + 'Category' => [ 'name' => 'Category 1' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'name' => 'Category 1.1' - ) - ) - ) - ), - array( - 'Category' => array( + ] + ] + ] + ], + [ + 'Category' => [ 'name' => 'Category 2' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'name' => 'Category 2.1' - ) - ), - array( - 'Category' => array( + ] + ], + [ + 'Category' => [ 'name' => 'Category 2.2' - ) - ), - ) - ), - array( - 'Category' => array( + ] + ], + ] + ], + [ + 'Category' => [ 'name' => 'Category 3' - ), - 'children' => array( - array( - 'Category' => array( + ], + 'children' => [ + [ + 'Category' => [ 'name' => 'Category 3.1' - ) - ) - ) - ) - ); - $expected = array(array('Category' => $tree[1]['Category'])); + ] + ] + ] + ] + ]; + $expected = [['Category' => $tree[1]['Category']]]; $r = Set::extract('/Category[name=Category 2]', $tree); $this->assertEquals($expected, $r); - $expected = array(array('Category' => $tree[1]['Category'], 'children' => $tree[1]['children'])); + $expected = [['Category' => $tree[1]['Category'], 'children' => $tree[1]['children']]]; $r = Set::extract('/Category[name=Category 2]/..', $tree); $this->assertEquals($expected, $r); - $expected = array(array('children' => $tree[1]['children'][0]), array('children' => $tree[1]['children'][1])); + $expected = [['children' => $tree[1]['children'][0]], ['children' => $tree[1]['children'][1]]]; $r = Set::extract('/Category[name=Category 2]/../children', $tree); $this->assertEquals($expected, $r); - $single = array( - array( - 'CallType' => array( + $single = [ + [ + 'CallType' => [ 'name' => 'Internal Voice' - ), - 'x' => array( + ], + 'x' => [ 'hour' => 7 - ) - ) - ); + ] + ] + ]; - $expected = array(7); + $expected = [7]; $r = Set::extract('/CallType[name=Internal Voice]/../x/hour', $single); $this->assertEquals($expected, $r); - $multiple = array( - array( - 'CallType' => array( + $multiple = [ + [ + 'CallType' => [ 'name' => 'Internal Voice' - ), - 'x' => array( + ], + 'x' => [ 'hour' => 7 - ) - ), - array( - 'CallType' => array( + ] + ], + [ + 'CallType' => [ 'name' => 'Internal Voice' - ), - 'x' => array( + ], + 'x' => [ 'hour' => 2 - ) - ), - array( - 'CallType' => array( + ] + ], + [ + 'CallType' => [ 'name' => 'Internal Voice' - ), - 'x' => array( + ], + 'x' => [ 'hour' => 1 - ) - ) - ); + ] + ] + ]; - $expected = array(7, 2, 1); + $expected = [7, 2, 1]; $r = Set::extract('/CallType[name=Internal Voice]/../x/hour', $multiple); $this->assertEquals($expected, $r); - $a = array( - 'Model' => array( - '0' => array( + $a = [ + 'Model' => [ + '0' => [ 'id' => 18, - 'SubModelsModel' => array( + 'SubModelsModel' => [ 'id' => 1, 'submodel_id' => 66, 'model_id' => 18, 'type' => 1 - ), - ), - '1' => array( + ], + ], + '1' => [ 'id' => 0, - 'SubModelsModel' => array( + 'SubModelsModel' => [ 'id' => 2, 'submodel_id' => 66, 'model_id' => 0, 'type' => 1 - ), - ), - '2' => array( + ], + ], + '2' => [ 'id' => 17, - 'SubModelsModel' => array( + 'SubModelsModel' => [ 'id' => 3, 'submodel_id' => 66, 'model_id' => 17, 'type' => 2 - ), - ), - '3' => array( + ], + ], + '3' => [ 'id' => 0, - 'SubModelsModel' => array( + 'SubModelsModel' => [ 'id' => 4, 'submodel_id' => 66, 'model_id' => 0, 'type' => 2 - ) - ) - ) - ); - - $expected = array( - array( - 'Model' => array( + ] + ] + ] + ]; + + $expected = [ + [ + 'Model' => [ 'id' => 17, - 'SubModelsModel' => array( + 'SubModelsModel' => [ 'id' => 3, 'submodel_id' => 66, 'model_id' => 17, 'type' => 2 - ), - ) - ), - array( - 'Model' => array( + ], + ] + ], + [ + 'Model' => [ 'id' => 0, - 'SubModelsModel' => array( + 'SubModelsModel' => [ 'id' => 4, 'submodel_id' => 66, 'model_id' => 0, 'type' => 2 - ) - ) - ) - ); + ] + ] + ] + ]; $r = Set::extract('/Model/SubModelsModel[type=2]/..', $a); $this->assertEquals($expected, $r); } @@ -1187,99 +1187,99 @@ public function testExtractParentSelector() { * @return void */ public function testExtractWithNonZeroArrays() { - $nonZero = array( - 1 => array( - 'User' => array( + $nonZero = [ + 1 => [ + 'User' => [ 'id' => 1, 'name' => 'John', - ) - ), - 2 => array( - 'User' => array( + ] + ], + 2 => [ + 'User' => [ 'id' => 2, 'name' => 'Bob', - ) - ), - 3 => array( - 'User' => array( + ] + ], + 3 => [ + 'User' => [ 'id' => 3, 'name' => 'Tony', - ) - ) - ); - $expected = array(1, 2, 3); + ] + ] + ]; + $expected = [1, 2, 3]; $r = Set::extract('/User/id', $nonZero); $this->assertEquals($expected, $r); - $expected = array( - array('User' => array('id' => 1, 'name' => 'John')), - array('User' => array('id' => 2, 'name' => 'Bob')), - array('User' => array('id' => 3, 'name' => 'Tony')), - ); + $expected = [ + ['User' => ['id' => 1, 'name' => 'John']], + ['User' => ['id' => 2, 'name' => 'Bob']], + ['User' => ['id' => 3, 'name' => 'Tony']], + ]; $result = Set::extract('/User', $nonZero); $this->assertEquals($expected, $result); - $nonSequential = array( - 'User' => array( - 0 => array('id' => 1), - 2 => array('id' => 2), - 6 => array('id' => 3), - 9 => array('id' => 4), - 3 => array('id' => 5), - ), - ); - - $nonZero = array( - 'User' => array( - 2 => array('id' => 1), - 4 => array('id' => 2), - 6 => array('id' => 3), - 9 => array('id' => 4), - 3 => array('id' => 5), - ), - ); - - $expected = array(1, 2, 3, 4, 5); + $nonSequential = [ + 'User' => [ + 0 => ['id' => 1], + 2 => ['id' => 2], + 6 => ['id' => 3], + 9 => ['id' => 4], + 3 => ['id' => 5], + ], + ]; + + $nonZero = [ + 'User' => [ + 2 => ['id' => 1], + 4 => ['id' => 2], + 6 => ['id' => 3], + 9 => ['id' => 4], + 3 => ['id' => 5], + ], + ]; + + $expected = [1, 2, 3, 4, 5]; $this->assertEquals($expected, Set::extract('/User/id', $nonSequential)); $result = Set::extract('/User/id', $nonZero); $this->assertEquals($expected, $result, 'Failed non zero array key extract'); - $expected = array(1, 2, 3, 4, 5); + $expected = [1, 2, 3, 4, 5]; $this->assertEquals($expected, Set::extract('/User/id', $nonSequential)); $result = Set::extract('/User/id', $nonZero); $this->assertEquals($expected, $result, 'Failed non zero array key extract'); - $startingAtOne = array( - 'Article' => array( - 1 => array( + $startingAtOne = [ + 'Article' => [ + 1 => [ 'id' => 1, 'approved' => 1, - ), - ) - ); + ], + ] + ]; - $expected = array(0 => array('Article' => array('id' => 1, 'approved' => 1))); + $expected = [0 => ['Article' => ['id' => 1, 'approved' => 1]]]; $result = Set::extract('/Article[approved=1]', $startingAtOne); $this->assertEquals($expected, $result); - $items = array( - 240 => array( - 'A' => array( + $items = [ + 240 => [ + 'A' => [ 'field1' => 'a240', 'field2' => 'a240', - ), - 'B' => array( + ], + 'B' => [ 'field1' => 'b240', 'field2' => 'b240' - ), - ) - ); + ], + ] + ]; - $expected = array( + $expected = [ 0 => 'b240' - ); + ]; $result = Set::extract('/B/field1', $items); $this->assertSame($expected, $result); @@ -1292,14 +1292,14 @@ public function testExtractWithNonZeroArrays() { * @return void */ public function testExtractWithArrays() { - $data = array( - 'Level1' => array( - 'Level2' => array('test1', 'test2'), - 'Level2bis' => array('test3', 'test4') - ) - ); - $this->assertEquals(array(array('Level2' => array('test1', 'test2'))), Set::extract('/Level1/Level2', $data)); - $this->assertEquals(array(array('Level2bis' => array('test3', 'test4'))), Set::extract('/Level1/Level2bis', $data)); + $data = [ + 'Level1' => [ + 'Level2' => ['test1', 'test2'], + 'Level2bis' => ['test3', 'test4'] + ] + ]; + $this->assertEquals([['Level2' => ['test1', 'test2']]], Set::extract('/Level1/Level2', $data)); + $this->assertEquals([['Level2bis' => ['test3', 'test4']]], Set::extract('/Level1/Level2bis', $data)); } /** @@ -1308,45 +1308,45 @@ public function testExtractWithArrays() { * @return void */ public function testExtractWithNonArrayElements() { - $data = array( - 'node' => array( - array('foo'), + $data = [ + 'node' => [ + ['foo'], 'bar' - ) - ); + ] + ]; $result = Set::extract('/node', $data); - $expected = array( - array('node' => array('foo')), + $expected = [ + ['node' => ['foo']], 'bar' - ); + ]; $this->assertEquals($expected, $result); - $data = array( - 'node' => array( - 'foo' => array('bar'), - 'bar' => array('foo') - ) - ); + $data = [ + 'node' => [ + 'foo' => ['bar'], + 'bar' => ['foo'] + ] + ]; $result = Set::extract('/node', $data); - $expected = array( - array('foo' => array('bar')), - array('bar' => array('foo')), - ); + $expected = [ + ['foo' => ['bar']], + ['bar' => ['foo']], + ]; $this->assertEquals($expected, $result); - $data = array( - 'node' => array( - 'foo' => array( + $data = [ + 'node' => [ + 'foo' => [ 'bar' - ), + ], 'bar' => 'foo' - ) - ); + ] + ]; $result = Set::extract('/node', $data); - $expected = array( - array('foo' => array('bar')), + $expected = [ + ['foo' => ['bar']], 'foo' - ); + ]; $this->assertEquals($expected, $result); } @@ -1356,26 +1356,26 @@ public function testExtractWithNonArrayElements() { * @return void */ public function testExtractMatchesNull() { - $data = array( - 'Country' => array( - array('name' => 'Canada'), - array('name' => 'Australia'), - array('name' => null), - ) - ); + $data = [ + 'Country' => [ + ['name' => 'Canada'], + ['name' => 'Australia'], + ['name' => null], + ] + ]; $result = Set::extract('/Country[name=/Canada|^$/]', $data); - $expected = array( - array( - 'Country' => array( + $expected = [ + [ + 'Country' => [ 'name' => 'Canada', - ), - ), - array( - 'Country' => array( + ], + ], + [ + 'Country' => [ 'name' => null, - ), - ), - ); + ], + ], + ]; $this->assertEquals($expected, $result); } @@ -1385,68 +1385,68 @@ public function testExtractMatchesNull() { * @return void */ public function testMatches() { - $a = array( - array('Article' => array('id' => 1, 'title' => 'Article 1')), - array('Article' => array('id' => 2, 'title' => 'Article 2')), - array('Article' => array('id' => 3, 'title' => 'Article 3')) - ); - - $this->assertTrue(Set::matches(array('id=2'), $a[1]['Article'])); - $this->assertFalse(Set::matches(array('id>2'), $a[1]['Article'])); - $this->assertTrue(Set::matches(array('id>=2'), $a[1]['Article'])); - $this->assertFalse(Set::matches(array('id>=3'), $a[1]['Article'])); - $this->assertTrue(Set::matches(array('id<=2'), $a[1]['Article'])); - $this->assertFalse(Set::matches(array('id<2'), $a[1]['Article'])); - $this->assertTrue(Set::matches(array('id>1'), $a[1]['Article'])); - $this->assertTrue(Set::matches(array('id>1', 'id<3', 'id!=0'), $a[1]['Article'])); - - $this->assertTrue(Set::matches(array('3'), null, 3)); - $this->assertTrue(Set::matches(array('5'), null, 5)); - - $this->assertTrue(Set::matches(array('id'), $a[1]['Article'])); - $this->assertTrue(Set::matches(array('id', 'title'), $a[1]['Article'])); - $this->assertFalse(Set::matches(array('non-existant'), $a[1]['Article'])); + $a = [ + ['Article' => ['id' => 1, 'title' => 'Article 1']], + ['Article' => ['id' => 2, 'title' => 'Article 2']], + ['Article' => ['id' => 3, 'title' => 'Article 3']] + ]; + + $this->assertTrue(Set::matches(['id=2'], $a[1]['Article'])); + $this->assertFalse(Set::matches(['id>2'], $a[1]['Article'])); + $this->assertTrue(Set::matches(['id>=2'], $a[1]['Article'])); + $this->assertFalse(Set::matches(['id>=3'], $a[1]['Article'])); + $this->assertTrue(Set::matches(['id<=2'], $a[1]['Article'])); + $this->assertFalse(Set::matches(['id<2'], $a[1]['Article'])); + $this->assertTrue(Set::matches(['id>1'], $a[1]['Article'])); + $this->assertTrue(Set::matches(['id>1', 'id<3', 'id!=0'], $a[1]['Article'])); + + $this->assertTrue(Set::matches(['3'], null, 3)); + $this->assertTrue(Set::matches(['5'], null, 5)); + + $this->assertTrue(Set::matches(['id'], $a[1]['Article'])); + $this->assertTrue(Set::matches(['id', 'title'], $a[1]['Article'])); + $this->assertFalse(Set::matches(['non-existant'], $a[1]['Article'])); $this->assertTrue(Set::matches('/Article[id=2]', $a)); $this->assertFalse(Set::matches('/Article[id=4]', $a)); - $this->assertTrue(Set::matches(array(), $a)); - - $r = array( - 'Attachment' => array( - 'keep' => array() - ), - 'Comment' => array( - 'keep' => array( - 'Attachment' => array( - 'fields' => array( + $this->assertTrue(Set::matches([], $a)); + + $r = [ + 'Attachment' => [ + 'keep' => [] + ], + 'Comment' => [ + 'keep' => [ + 'Attachment' => [ + 'fields' => [ 0 => 'attachment', - ), - ), - ) - ), - 'User' => array( - 'keep' => array() - ), - 'Article' => array( - 'keep' => array( - 'Comment' => array( - 'fields' => array( + ], + ], + ] + ], + 'User' => [ + 'keep' => [] + ], + 'Article' => [ + 'keep' => [ + 'Comment' => [ + 'fields' => [ 0 => 'comment', 1 => 'published', - ), - ), - 'User' => array( - 'fields' => array( + ], + ], + 'User' => [ + 'fields' => [ 0 => 'user', - ), - ), - ) - ) - ); + ], + ], + ] + ] + ]; $this->assertTrue(Set::matches('/Article/keep/Comment', $r)); - $this->assertEquals(array('comment', 'published'), Set::extract('/Article/keep/Comment/fields', $r)); - $this->assertEquals(array('user'), Set::extract('/Article/keep/User/fields', $r)); + $this->assertEquals(['comment', 'published'], Set::extract('/Article/keep/Comment/fields', $r)); + $this->assertEquals(['user'], Set::extract('/Article/keep/User/fields', $r)); } /** @@ -1455,16 +1455,16 @@ public function testMatches() { * @return void */ public function testSetExtractReturnsEmptyArray() { - $this->assertEquals(Set::extract(array(), '/Post/id'), array()); + $this->assertEquals(Set::extract([], '/Post/id'), []); - $this->assertEquals(Set::extract('/Post/id', array()), array()); + $this->assertEquals(Set::extract('/Post/id', []), []); - $this->assertEquals(Set::extract('/Post/id', array( - array('Post' => array('name' => 'bob')), - array('Post' => array('name' => 'jim')) - )), array()); + $this->assertEquals(Set::extract('/Post/id', [ + ['Post' => ['name' => 'bob']], + ['Post' => ['name' => 'jim']] + ]), []); - $this->assertEquals(Set::extract(array(), 'Message.flash'), null); + $this->assertEquals(Set::extract([], 'Message.flash'), null); } /** @@ -1473,18 +1473,18 @@ public function testSetExtractReturnsEmptyArray() { * @return void */ public function testClassicExtract() { - $a = array( - array('Article' => array('id' => 1, 'title' => 'Article 1')), - array('Article' => array('id' => 2, 'title' => 'Article 2')), - array('Article' => array('id' => 3, 'title' => 'Article 3')) - ); + $a = [ + ['Article' => ['id' => 1, 'title' => 'Article 1']], + ['Article' => ['id' => 2, 'title' => 'Article 2']], + ['Article' => ['id' => 3, 'title' => 'Article 3']] + ]; $result = Set::extract($a, '{n}.Article.id'); - $expected = array(1, 2, 3); + $expected = [1, 2, 3]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{n}.Article.title'); - $expected = array('Article 1', 'Article 2', 'Article 3'); + $expected = ['Article 1', 'Article 2', 'Article 3']; $this->assertEquals($expected, $result); $result = Set::extract($a, '1.Article.title'); @@ -1495,153 +1495,153 @@ public function testClassicExtract() { $expected = null; $this->assertEquals($expected, $result); - $a = array( - array( - 'Article' => array('id' => 1, 'title' => 'Article 1', - 'User' => array('id' => 1, 'username' => 'mariano.iglesias')) - ), - array( - 'Article' => array('id' => 2, 'title' => 'Article 2', - 'User' => array('id' => 1, 'username' => 'mariano.iglesias')) - ), - array( - 'Article' => array('id' => 3, 'title' => 'Article 3', - 'User' => array('id' => 2, 'username' => 'phpnut')) - ) - ); + $a = [ + [ + 'Article' => ['id' => 1, 'title' => 'Article 1', + 'User' => ['id' => 1, 'username' => 'mariano.iglesias']] + ], + [ + 'Article' => ['id' => 2, 'title' => 'Article 2', + 'User' => ['id' => 1, 'username' => 'mariano.iglesias']] + ], + [ + 'Article' => ['id' => 3, 'title' => 'Article 3', + 'User' => ['id' => 2, 'username' => 'phpnut']] + ] + ]; $result = Set::extract($a, '{n}.Article.User.username'); - $expected = array('mariano.iglesias', 'mariano.iglesias', 'phpnut'); + $expected = ['mariano.iglesias', 'mariano.iglesias', 'phpnut']; $this->assertEquals($expected, $result); - $a = array( - array( - 'Article' => array( + $a = [ + [ + 'Article' => [ 'id' => 1, 'title' => 'Article 1', - 'Comment' => array( - array('id' => 10, 'title' => 'Comment 10'), - array('id' => 11, 'title' => 'Comment 11'), - array('id' => 12, 'title' => 'Comment 12') - ) - ) - ), - array( - 'Article' => array( + 'Comment' => [ + ['id' => 10, 'title' => 'Comment 10'], + ['id' => 11, 'title' => 'Comment 11'], + ['id' => 12, 'title' => 'Comment 12'] + ] + ] + ], + [ + 'Article' => [ 'id' => 2, 'title' => 'Article 2', - 'Comment' => array( - array('id' => 13, 'title' => 'Comment 13'), - array('id' => 14, 'title' => 'Comment 14') - ) - ) - ), - array('Article' => array('id' => 3, 'title' => 'Article 3')) - ); + 'Comment' => [ + ['id' => 13, 'title' => 'Comment 13'], + ['id' => 14, 'title' => 'Comment 14'] + ] + ] + ], + ['Article' => ['id' => 3, 'title' => 'Article 3']] + ]; $result = Set::extract($a, '{n}.Article.Comment.{n}.id'); - $expected = array(array(10, 11, 12), array(13, 14), null); + $expected = [[10, 11, 12], [13, 14], null]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{n}.Article.Comment.{n}.title'); - $expected = array( - array('Comment 10', 'Comment 11', 'Comment 12'), - array('Comment 13', 'Comment 14'), + $expected = [ + ['Comment 10', 'Comment 11', 'Comment 12'], + ['Comment 13', 'Comment 14'], null - ); + ]; $this->assertEquals($expected, $result); - $a = array(array('1day' => '20 sales'), array('1day' => '2 sales')); + $a = [['1day' => '20 sales'], ['1day' => '2 sales']]; $result = Set::extract($a, '{n}.1day'); - $expected = array('20 sales', '2 sales'); + $expected = ['20 sales', '2 sales']; $this->assertEquals($expected, $result); - $a = array( - 'pages' => array('name' => 'page'), - 'fruites' => array('name' => 'fruit'), - 0 => array('name' => 'zero') - ); + $a = [ + 'pages' => ['name' => 'page'], + 'fruites' => ['name' => 'fruit'], + 0 => ['name' => 'zero'] + ]; $result = Set::extract($a, '{s}.name'); - $expected = array('page', 'fruit'); + $expected = ['page', 'fruit']; $this->assertEquals($expected, $result); - $a = array( - 0 => array('pages' => array('name' => 'page')), - 1 => array('fruites' => array('name' => 'fruit')), - 'test' => array(array('name' => 'jippi')), - 'dot.test' => array(array('name' => 'jippi')) - ); + $a = [ + 0 => ['pages' => ['name' => 'page']], + 1 => ['fruites' => ['name' => 'fruit']], + 'test' => [['name' => 'jippi']], + 'dot.test' => [['name' => 'jippi']] + ]; $result = Set::extract($a, '{n}.{s}.name'); - $expected = array(0 => array('page'), 1 => array('fruit')); + $expected = [0 => ['page'], 1 => ['fruit']]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{s}.{n}.name'); - $expected = array(array('jippi'), array('jippi')); + $expected = [['jippi'], ['jippi']]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{\w+}.{\w+}.name'); - $expected = array( - array('pages' => 'page'), - array('fruites' => 'fruit'), - 'test' => array('jippi'), - 'dot.test' => array('jippi') - ); + $expected = [ + ['pages' => 'page'], + ['fruites' => 'fruit'], + 'test' => ['jippi'], + 'dot.test' => ['jippi'] + ]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{\d+}.{\w+}.name'); - $expected = array(array('pages' => 'page'), array('fruites' => 'fruit')); + $expected = [['pages' => 'page'], ['fruites' => 'fruit']]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{n}.{\w+}.name'); - $expected = array(array('pages' => 'page'), array('fruites' => 'fruit')); + $expected = [['pages' => 'page'], ['fruites' => 'fruit']]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{s}.{\d+}.name'); - $expected = array(array('jippi'), array('jippi')); + $expected = [['jippi'], ['jippi']]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{s}'); - $expected = array(array(array('name' => 'jippi')), array(array('name' => 'jippi'))); + $expected = [[['name' => 'jippi']], [['name' => 'jippi']]]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{[a-z]}'); - $expected = array( - 'test' => array(array('name' => 'jippi')), - 'dot.test' => array(array('name' => 'jippi')) - ); + $expected = [ + 'test' => [['name' => 'jippi']], + 'dot.test' => [['name' => 'jippi']] + ]; $this->assertEquals($expected, $result); $result = Set::extract($a, '{dot\.test}.{n}'); - $expected = array('dot.test' => array(array('name' => 'jippi'))); + $expected = ['dot.test' => [['name' => 'jippi']]]; $this->assertEquals($expected, $result); $a = new stdClass(); - $a->articles = array( - array('Article' => array('id' => 1, 'title' => 'Article 1')), - array('Article' => array('id' => 2, 'title' => 'Article 2')), - array('Article' => array('id' => 3, 'title' => 'Article 3')) - ); + $a->articles = [ + ['Article' => ['id' => 1, 'title' => 'Article 1']], + ['Article' => ['id' => 2, 'title' => 'Article 2']], + ['Article' => ['id' => 3, 'title' => 'Article 3']] + ]; $result = Set::extract($a, 'articles.{n}.Article.id'); - $expected = array(1, 2, 3); + $expected = [1, 2, 3]; $this->assertEquals($expected, $result); $result = Set::extract($a, 'articles.{n}.Article.title'); - $expected = array('Article 1', 'Article 2', 'Article 3'); + $expected = ['Article 1', 'Article 2', 'Article 3']; $this->assertEquals($expected, $result); $a = new ArrayObject(); - $a['articles'] = array( - array('Article' => array('id' => 1, 'title' => 'Article 1')), - array('Article' => array('id' => 2, 'title' => 'Article 2')), - array('Article' => array('id' => 3, 'title' => 'Article 3')) - ); + $a['articles'] = [ + ['Article' => ['id' => 1, 'title' => 'Article 1']], + ['Article' => ['id' => 2, 'title' => 'Article 2']], + ['Article' => ['id' => 3, 'title' => 'Article 3']] + ]; $result = Set::extract($a, 'articles.{n}.Article.id'); - $expected = array(1, 2, 3); + $expected = [1, 2, 3]; $this->assertEquals($expected, $result); $result = Set::extract($a, 'articles.{n}.Article.title'); - $expected = array('Article 1', 'Article 2', 'Article 3'); + $expected = ['Article 1', 'Article 2', 'Article 3']; $this->assertEquals($expected, $result); $result = Set::extract($a, 'articles.0.Article.title'); @@ -1655,11 +1655,11 @@ public function testClassicExtract() { * @return void */ public function testClassicExtractMaxInt() { - $data = array( - 'Data' => array( + $data = [ + 'Data' => [ '13376924712' => 'abc' - ) - ); + ] + ]; $this->assertEquals('abc', Set::classicExtract($data, 'Data.13376924712')); } @@ -1670,15 +1670,15 @@ public function testClassicExtractMaxInt() { * @return void */ public function testInsert() { - $a = array( - 'pages' => array('name' => 'page') - ); + $a = [ + 'pages' => ['name' => 'page'] + ]; - $result = Set::insert($a, 'files', array('name' => 'files')); - $expected = array( - 'pages' => array('name' => 'page'), - 'files' => array('name' => 'files') - ); + $result = Set::insert($a, 'files', ['name' => 'files']); + $expected = [ + 'pages' => ['name' => 'page'], + 'files' => ['name' => 'files'] + ]; $this->assertEquals($expected, $result); } @@ -1688,15 +1688,15 @@ public function testInsert() { * @return void */ public function testRemove() { - $a = array( - 'pages' => array('name' => 'page'), - 'files' => array('name' => 'files') - ); + $a = [ + 'pages' => ['name' => 'page'], + 'files' => ['name' => 'files'] + ]; $result = Set::remove($a, 'files'); - $expected = array( - 'pages' => array('name' => 'page') - ); + $expected = [ + 'pages' => ['name' => 'page'] + ]; $this->assertEquals($expected, $result); } @@ -1706,16 +1706,16 @@ public function testRemove() { * @return void */ public function testCheck() { - $set = array( - 'My Index 1' => array('First' => 'The first item') - ); + $set = [ + 'My Index 1' => ['First' => 'The first item'] + ]; $this->assertTrue(Set::check($set, 'My Index 1.First')); $this->assertTrue(Set::check($set, 'My Index 1')); - $this->assertEquals(Set::check($set, array()), $set); + $this->assertEquals(Set::check($set, []), $set); - $set = array( - 'My Index 1' => array('First' => array('Second' => array('Third' => array('Fourth' => 'Heavy. Nesting.')))) - ); + $set = [ + 'My Index 1' => ['First' => ['Second' => ['Third' => ['Fourth' => 'Heavy. Nesting.']]]] + ]; $this->assertTrue(Set::check($set, 'My Index 1.First.Second')); $this->assertTrue(Set::check($set, 'My Index 1.First.Second.Third')); $this->assertTrue(Set::check($set, 'My Index 1.First.Second.Third.Fourth')); @@ -1728,14 +1728,14 @@ public function testCheck() { * @return void */ public function testWritingWithFunkyKeys() { - $set = Set::insert(array(), 'Session Test', "test"); + $set = Set::insert([], 'Session Test', "test"); $this->assertEquals('test', Set::extract($set, 'Session Test')); $set = Set::remove($set, 'Session Test'); $this->assertFalse(Set::check($set, 'Session Test')); - $expected = array('Session Test' => array('Test Case' => 'test')); - $this->assertEquals($expected, Set::insert(array(), 'Session Test.Test Case', "test")); + $expected = ['Session Test' => ['Test Case' => 'test']]; + $this->assertEquals($expected, Set::insert([], 'Session Test.Test Case', "test")); $this->assertTrue(Set::check($expected, 'Session Test.Test Case')); } @@ -1745,77 +1745,77 @@ public function testWritingWithFunkyKeys() { * @return void */ public function testDiff() { - $a = array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about') - ); - $b = array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about'), - 2 => array('name' => 'contact') - ); + $a = [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'] + ]; + $b = [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'], + 2 => ['name' => 'contact'] + ]; $result = Set::diff($a, $b); - $expected = array( - 2 => array('name' => 'contact') - ); + $expected = [ + 2 => ['name' => 'contact'] + ]; $this->assertEquals($expected, $result); - $result = Set::diff($a, array()); + $result = Set::diff($a, []); $expected = $a; $this->assertEquals($expected, $result); - $result = Set::diff(array(), $b); + $result = Set::diff([], $b); $expected = $b; $this->assertEquals($expected, $result); - $b = array( - 0 => array('name' => 'me'), - 1 => array('name' => 'about') - ); + $b = [ + 0 => ['name' => 'me'], + 1 => ['name' => 'about'] + ]; $result = Set::diff($a, $b); - $expected = array( - 0 => array('name' => 'main') - ); + $expected = [ + 0 => ['name' => 'main'] + ]; $this->assertEquals($expected, $result); - $a = array(); - $b = array('name' => 'bob', 'address' => 'home'); + $a = []; + $b = ['name' => 'bob', 'address' => 'home']; $result = Set::diff($a, $b); $this->assertEquals($b, $result); - $a = array('name' => 'bob', 'address' => 'home'); - $b = array(); + $a = ['name' => 'bob', 'address' => 'home']; + $b = []; $result = Set::diff($a, $b); $this->assertEquals($a, $result); - $a = array('key' => true, 'another' => false, 'name' => 'me'); - $b = array('key' => 1, 'another' => 0); - $expected = array('name' => 'me'); + $a = ['key' => true, 'another' => false, 'name' => 'me']; + $b = ['key' => 1, 'another' => 0]; + $expected = ['name' => 'me']; $result = Set::diff($a, $b); $this->assertEquals($expected, $result); - $a = array('key' => 'value', 'another' => null, 'name' => 'me'); - $b = array('key' => 'differentValue', 'another' => null); - $expected = array('key' => 'value', 'name' => 'me'); + $a = ['key' => 'value', 'another' => null, 'name' => 'me']; + $b = ['key' => 'differentValue', 'another' => null]; + $expected = ['key' => 'value', 'name' => 'me']; $result = Set::diff($a, $b); $this->assertEquals($expected, $result); - $a = array('key' => 'value', 'another' => null, 'name' => 'me'); - $b = array('key' => 'differentValue', 'another' => 'value'); - $expected = array('key' => 'value', 'another' => null, 'name' => 'me'); + $a = ['key' => 'value', 'another' => null, 'name' => 'me']; + $b = ['key' => 'differentValue', 'another' => 'value']; + $expected = ['key' => 'value', 'another' => null, 'name' => 'me']; $result = Set::diff($a, $b); $this->assertEquals($expected, $result); - $a = array('key' => 'value', 'another' => null, 'name' => 'me'); - $b = array('key' => 'differentValue', 'another' => 'value'); - $expected = array('key' => 'differentValue', 'another' => 'value', 'name' => 'me'); + $a = ['key' => 'value', 'another' => null, 'name' => 'me']; + $b = ['key' => 'differentValue', 'another' => 'value']; + $expected = ['key' => 'differentValue', 'another' => 'value', 'name' => 'me']; $result = Set::diff($b, $a); $this->assertEquals($expected, $result); - $a = array('key' => 'value', 'another' => null, 'name' => 'me'); - $b = array(0 => 'differentValue', 1 => 'value'); + $a = ['key' => 'value', 'another' => null, 'name' => 'me']; + $b = [0 => 'differentValue', 1 => 'value']; $expected = $a + $b; $result = Set::diff($a, $b); $this->assertEquals($expected, $result); @@ -1827,16 +1827,16 @@ public function testDiff() { * @return void */ public function testContains() { - $a = array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about') - ); - $b = array( - 0 => array('name' => 'main'), - 1 => array('name' => 'about'), - 2 => array('name' => 'contact'), + $a = [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'] + ]; + $b = [ + 0 => ['name' => 'main'], + 1 => ['name' => 'about'], + 2 => ['name' => 'contact'], 'a' => 'b' - ); + ]; $this->assertTrue(Set::contains($a, $a)); $this->assertFalse(Set::contains($a, $b)); @@ -1849,133 +1849,133 @@ public function testContains() { * @return void */ public function testCombine() { - $result = Set::combine(array(), '{n}.User.id', '{n}.User.Data'); + $result = Set::combine([], '{n}.User.id', '{n}.User.Data'); $this->assertTrue(empty($result)); $result = Set::combine('', '{n}.User.id', '{n}.User.Data'); $this->assertTrue(empty($result)); - $a = array( - array('User' => array('id' => 2, 'group_id' => 1, - 'Data' => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'))), - array('User' => array('id' => 14, 'group_id' => 2, - 'Data' => array('user' => 'phpnut', 'name' => 'Larry E. Masters'))), - array('User' => array('id' => 25, 'group_id' => 1, - 'Data' => array('user' => 'gwoo', 'name' => 'The Gwoo')))); + $a = [ + ['User' => ['id' => 2, 'group_id' => 1, + 'Data' => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias']]], + ['User' => ['id' => 14, 'group_id' => 2, + 'Data' => ['user' => 'phpnut', 'name' => 'Larry E. Masters']]], + ['User' => ['id' => 25, 'group_id' => 1, + 'Data' => ['user' => 'gwoo', 'name' => 'The Gwoo']]]]; $result = Set::combine($a, '{n}.User.id'); - $expected = array(2 => null, 14 => null, 25 => null); + $expected = [2 => null, 14 => null, 25 => null]; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.non-existant'); - $expected = array(2 => null, 14 => null, 25 => null); + $expected = [2 => null, 14 => null, 25 => null]; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data'); - $expected = array( - 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), - 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'), - 25 => array('user' => 'gwoo', 'name' => 'The Gwoo')); + $expected = [ + 2 => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'], + 14 => ['user' => 'phpnut', 'name' => 'Larry E. Masters'], + 25 => ['user' => 'gwoo', 'name' => 'The Gwoo']]; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name'); - $expected = array( + $expected = [ 2 => 'Mariano Iglesias', 14 => 'Larry E. Masters', - 25 => 'The Gwoo'); + 25 => 'The Gwoo']; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); - $expected = array( - 1 => array( - 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), - 25 => array('user' => 'gwoo', 'name' => 'The Gwoo')), - 2 => array( - 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'))); + $expected = [ + 1 => [ + 2 => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'], + 25 => ['user' => 'gwoo', 'name' => 'The Gwoo']], + 2 => [ + 14 => ['user' => 'phpnut', 'name' => 'Larry E. Masters']]]; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name', '{n}.User.group_id'); - $expected = array( - 1 => array( + $expected = [ + 1 => [ 2 => 'Mariano Iglesias', - 25 => 'The Gwoo'), - 2 => array( - 14 => 'Larry E. Masters')); + 25 => 'The Gwoo'], + 2 => [ + 14 => 'Larry E. Masters']]; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id'); - $expected = array(2 => null, 14 => null, 25 => null); + $expected = [2 => null, 14 => null, 25 => null]; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data'); - $expected = array( - 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), - 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'), - 25 => array('user' => 'gwoo', 'name' => 'The Gwoo')); + $expected = [ + 2 => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'], + 14 => ['user' => 'phpnut', 'name' => 'Larry E. Masters'], + 25 => ['user' => 'gwoo', 'name' => 'The Gwoo']]; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name'); - $expected = array(2 => 'Mariano Iglesias', 14 => 'Larry E. Masters', 25 => 'The Gwoo'); + $expected = [2 => 'Mariano Iglesias', 14 => 'Larry E. Masters', 25 => 'The Gwoo']; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data', '{n}.User.group_id'); - $expected = array( - 1 => array( - 2 => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'), - 25 => array('user' => 'gwoo', 'name' => 'The Gwoo')), - 2 => array( - 14 => array('user' => 'phpnut', 'name' => 'Larry E. Masters'))); + $expected = [ + 1 => [ + 2 => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'], + 25 => ['user' => 'gwoo', 'name' => 'The Gwoo']], + 2 => [ + 14 => ['user' => 'phpnut', 'name' => 'Larry E. Masters']]]; $this->assertEquals($expected, $result); $result = Set::combine($a, '{n}.User.id', '{n}.User.Data.name', '{n}.User.group_id'); - $expected = array( - 1 => array( + $expected = [ + 1 => [ 2 => 'Mariano Iglesias', - 25 => 'The Gwoo'), - 2 => array( - 14 => 'Larry E. Masters')); + 25 => 'The Gwoo'], + 2 => [ + 14 => 'Larry E. Masters']]; $this->assertEquals($expected, $result); - $result = Set::combine($a, '{n}.User.id', array('{0}: {1}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.group_id'); - $expected = array( - 1 => array( + $result = Set::combine($a, '{n}.User.id', ['{0}: {1}', '{n}.User.Data.user', '{n}.User.Data.name'], '{n}.User.group_id'); + $expected = [ + 1 => [ 2 => 'mariano.iglesias: Mariano Iglesias', - 25 => 'gwoo: The Gwoo'), - 2 => array(14 => 'phpnut: Larry E. Masters')); + 25 => 'gwoo: The Gwoo'], + 2 => [14 => 'phpnut: Larry E. Masters']]; $this->assertEquals($expected, $result); - $result = Set::combine($a, array('{0}: {1}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.id'); - $expected = array('mariano.iglesias: Mariano Iglesias' => 2, 'phpnut: Larry E. Masters' => 14, 'gwoo: The Gwoo' => 25); + $result = Set::combine($a, ['{0}: {1}', '{n}.User.Data.user', '{n}.User.Data.name'], '{n}.User.id'); + $expected = ['mariano.iglesias: Mariano Iglesias' => 2, 'phpnut: Larry E. Masters' => 14, 'gwoo: The Gwoo' => 25]; $this->assertEquals($expected, $result); - $result = Set::combine($a, array('{1}: {0}', '{n}.User.Data.user', '{n}.User.Data.name'), '{n}.User.id'); - $expected = array('Mariano Iglesias: mariano.iglesias' => 2, 'Larry E. Masters: phpnut' => 14, 'The Gwoo: gwoo' => 25); + $result = Set::combine($a, ['{1}: {0}', '{n}.User.Data.user', '{n}.User.Data.name'], '{n}.User.id'); + $expected = ['Mariano Iglesias: mariano.iglesias' => 2, 'Larry E. Masters: phpnut' => 14, 'The Gwoo: gwoo' => 25]; $this->assertEquals($expected, $result); - $result = Set::combine($a, array('%1$s: %2$d', '{n}.User.Data.user', '{n}.User.id'), '{n}.User.Data.name'); - $expected = array('mariano.iglesias: 2' => 'Mariano Iglesias', 'phpnut: 14' => 'Larry E. Masters', 'gwoo: 25' => 'The Gwoo'); + $result = Set::combine($a, ['%1$s: %2$d', '{n}.User.Data.user', '{n}.User.id'], '{n}.User.Data.name'); + $expected = ['mariano.iglesias: 2' => 'Mariano Iglesias', 'phpnut: 14' => 'Larry E. Masters', 'gwoo: 25' => 'The Gwoo']; $this->assertEquals($expected, $result); - $result = Set::combine($a, array('%2$d: %1$s', '{n}.User.Data.user', '{n}.User.id'), '{n}.User.Data.name'); - $expected = array('2: mariano.iglesias' => 'Mariano Iglesias', '14: phpnut' => 'Larry E. Masters', '25: gwoo' => 'The Gwoo'); + $result = Set::combine($a, ['%2$d: %1$s', '{n}.User.Data.user', '{n}.User.id'], '{n}.User.Data.name'); + $expected = ['2: mariano.iglesias' => 'Mariano Iglesias', '14: phpnut' => 'Larry E. Masters', '25: gwoo' => 'The Gwoo']; $this->assertEquals($expected, $result); $b = new stdClass(); - $b->users = array( - array('User' => array('id' => 2, 'group_id' => 1, - 'Data' => array('user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias'))), - array('User' => array('id' => 14, 'group_id' => 2, - 'Data' => array('user' => 'phpnut', 'name' => 'Larry E. Masters'))), - array('User' => array('id' => 25, 'group_id' => 1, - 'Data' => array('user' => 'gwoo', 'name' => 'The Gwoo')))); + $b->users = [ + ['User' => ['id' => 2, 'group_id' => 1, + 'Data' => ['user' => 'mariano.iglesias', 'name' => 'Mariano Iglesias']]], + ['User' => ['id' => 14, 'group_id' => 2, + 'Data' => ['user' => 'phpnut', 'name' => 'Larry E. Masters']]], + ['User' => ['id' => 25, 'group_id' => 1, + 'Data' => ['user' => 'gwoo', 'name' => 'The Gwoo']]]]; $result = Set::combine($b, 'users.{n}.User.id'); - $expected = array(2 => null, 14 => null, 25 => null); + $expected = [2 => null, 14 => null, 25 => null]; $this->assertEquals($expected, $result); $result = Set::combine($b, 'users.{n}.User.id', 'users.{n}.User.non-existant'); - $expected = array(2 => null, 14 => null, 25 => null); + $expected = [2 => null, 14 => null, 25 => null]; $this->assertEquals($expected, $result); $result = Set::combine($a, 'fail', 'fail'); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -1990,21 +1990,21 @@ public function testMapReverse() { $result = Set::reverse(false); $this->assertEquals(false, $result); - $expected = array( - 'Array1' => array( - 'Array1Data1' => 'Array1Data1 value 1', 'Array1Data2' => 'Array1Data2 value 2'), - 'Array2' => array( - 0 => array('Array2Data1' => 1, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 1 => array('Array2Data1' => 2, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 2 => array('Array2Data1' => 3, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 3 => array('Array2Data1' => 4, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 4 => array('Array2Data1' => 5, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4')), - 'Array3' => array( - 0 => array('Array3Data1' => 1, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 1 => array('Array3Data1' => 2, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 2 => array('Array3Data1' => 3, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 3 => array('Array3Data1' => 4, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 4 => array('Array3Data1' => 5, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'))); + $expected = [ + 'Array1' => [ + 'Array1Data1' => 'Array1Data1 value 1', 'Array1Data2' => 'Array1Data2 value 2'], + 'Array2' => [ + 0 => ['Array2Data1' => 1, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 1 => ['Array2Data1' => 2, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 2 => ['Array2Data1' => 3, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 3 => ['Array2Data1' => 4, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 4 => ['Array2Data1' => 5, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4']], + 'Array3' => [ + 0 => ['Array3Data1' => 1, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 1 => ['Array3Data1' => 2, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 2 => ['Array3Data1' => 3, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 3 => ['Array3Data1' => 4, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 4 => ['Array3Data1' => 5, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4']]]; $map = Set::map($expected, true); $this->assertEquals($expected['Array1']['Array1Data1'], $map->Array1->Array1Data1); $this->assertEquals($expected['Array2'][0]['Array2Data1'], $map->Array2[0]->Array2Data1); @@ -2012,82 +2012,82 @@ public function testMapReverse() { $result = Set::reverse($map); $this->assertEquals($expected, $result); - $expected = array( - 'Post' => array('id' => 1, 'title' => 'First Post'), - 'Comment' => array( - array('id' => 1, 'title' => 'First Comment'), - array('id' => 2, 'title' => 'Second Comment') - ), - 'Tag' => array( - array('id' => 1, 'title' => 'First Tag'), - array('id' => 2, 'title' => 'Second Tag') - ), - ); + $expected = [ + 'Post' => ['id' => 1, 'title' => 'First Post'], + 'Comment' => [ + ['id' => 1, 'title' => 'First Comment'], + ['id' => 2, 'title' => 'Second Comment'] + ], + 'Tag' => [ + ['id' => 1, 'title' => 'First Tag'], + ['id' => 2, 'title' => 'Second Tag'] + ], + ]; $map = Set::map($expected); $this->assertEquals($expected['Post']['title'], $map->title); foreach ($map->Comment as $comment) { $ids[] = $comment->id; } - $this->assertEquals(array(1, 2), $ids); + $this->assertEquals([1, 2], $ids); - $expected = array( - 'Array1' => array( + $expected = [ + 'Array1' => [ 'Array1Data1' => 'Array1Data1 value 1', 'Array1Data2' => 'Array1Data2 value 2', 'Array1Data3' => 'Array1Data3 value 3', 'Array1Data4' => 'Array1Data4 value 4', - 'Array1Data5' => 'Array1Data5 value 5', 'Array1Data6' => 'Array1Data6 value 6', 'Array1Data7' => 'Array1Data7 value 7', 'Array1Data8' => 'Array1Data8 value 8'), + 'Array1Data5' => 'Array1Data5 value 5', 'Array1Data6' => 'Array1Data6 value 6', 'Array1Data7' => 'Array1Data7 value 7', 'Array1Data8' => 'Array1Data8 value 8'], 'string' => 1, 'another' => 'string', 'some' => 'thing else', - 'Array2' => array( - 0 => array('Array2Data1' => 1, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 1 => array('Array2Data1' => 2, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 2 => array('Array2Data1' => 3, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 3 => array('Array2Data1' => 4, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 4 => array('Array2Data1' => 5, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4')), - 'Array3' => array( - 0 => array('Array3Data1' => 1, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 1 => array('Array3Data1' => 2, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 2 => array('Array3Data1' => 3, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 3 => array('Array3Data1' => 4, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 4 => array('Array3Data1' => 5, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'))); + 'Array2' => [ + 0 => ['Array2Data1' => 1, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 1 => ['Array2Data1' => 2, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 2 => ['Array2Data1' => 3, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 3 => ['Array2Data1' => 4, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 4 => ['Array2Data1' => 5, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4']], + 'Array3' => [ + 0 => ['Array3Data1' => 1, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 1 => ['Array3Data1' => 2, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 2 => ['Array3Data1' => 3, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 3 => ['Array3Data1' => 4, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 4 => ['Array3Data1' => 5, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4']]]; $map = Set::map($expected, true); $result = Set::reverse($map); $this->assertEquals($expected, $result); - $expected = array( - 'Array1' => array( + $expected = [ + 'Array1' => [ 'Array1Data1' => 'Array1Data1 value 1', 'Array1Data2' => 'Array1Data2 value 2', 'Array1Data3' => 'Array1Data3 value 3', 'Array1Data4' => 'Array1Data4 value 4', - 'Array1Data5' => 'Array1Data5 value 5', 'Array1Data6' => 'Array1Data6 value 6', 'Array1Data7' => 'Array1Data7 value 7', 'Array1Data8' => 'Array1Data8 value 8'), + 'Array1Data5' => 'Array1Data5 value 5', 'Array1Data6' => 'Array1Data6 value 6', 'Array1Data7' => 'Array1Data7 value 7', 'Array1Data8' => 'Array1Data8 value 8'], 'string' => 1, 'another' => 'string', 'some' => 'thing else', - 'Array2' => array( - 0 => array('Array2Data1' => 1, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 1 => array('Array2Data1' => 2, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 2 => array('Array2Data1' => 3, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 3 => array('Array2Data1' => 4, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'), - 4 => array('Array2Data1' => 5, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4')), + 'Array2' => [ + 0 => ['Array2Data1' => 1, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 1 => ['Array2Data1' => 2, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 2 => ['Array2Data1' => 3, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 3 => ['Array2Data1' => 4, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4'], + 4 => ['Array2Data1' => 5, 'Array2Data2' => 'Array2Data2 value 2', 'Array2Data3' => 'Array2Data3 value 2', 'Array2Data4' => 'Array2Data4 value 4']], 'string2' => 1, 'another2' => 'string', 'some2' => 'thing else', - 'Array3' => array( - 0 => array('Array3Data1' => 1, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 1 => array('Array3Data1' => 2, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 2 => array('Array3Data1' => 3, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 3 => array('Array3Data1' => 4, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'), - 4 => array('Array3Data1' => 5, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4')), + 'Array3' => [ + 0 => ['Array3Data1' => 1, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 1 => ['Array3Data1' => 2, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 2 => ['Array3Data1' => 3, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 3 => ['Array3Data1' => 4, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4'], + 4 => ['Array3Data1' => 5, 'Array3Data2' => 'Array3Data2 value 2', 'Array3Data3' => 'Array3Data3 value 2', 'Array3Data4' => 'Array3Data4 value 4']], 'string3' => 1, 'another3' => 'string', - 'some3' => 'thing else'); + 'some3' => 'thing else']; $map = Set::map($expected, true); $result = Set::reverse($map); $this->assertEquals($expected, $result); - $expected = array('User' => array('psword' => 'whatever', 'Icon' => array('id' => 851))); + $expected = ['User' => ['psword' => 'whatever', 'Icon' => ['id' => 851]]]; $map = Set::map($expected); $result = Set::reverse($map); $this->assertEquals($expected, $result); - $expected = array('User' => array('psword' => 'whatever', 'Icon' => array('id' => 851))); + $expected = ['User' => ['psword' => 'whatever', 'Icon' => ['id' => 851]]]; $class = new stdClass; $class->User = new stdClass; $class->User->psword = 'whatever'; @@ -2096,7 +2096,7 @@ public function testMapReverse() { $result = Set::reverse($class); $this->assertEquals($expected, $result); - $expected = array('User' => array('psword' => 'whatever', 'Icon' => array('id' => 851), 'Profile' => array('name' => 'Some Name', 'address' => 'Some Address'))); + $expected = ['User' => ['psword' => 'whatever', 'Icon' => ['id' => 851], 'Profile' => ['name' => 'Some Name', 'address' => 'Some Address']]]; $class = new stdClass; $class->User = new stdClass; $class->User->psword = 'whatever'; @@ -2109,12 +2109,12 @@ public function testMapReverse() { $result = Set::reverse($class); $this->assertEquals($expected, $result); - $expected = array('User' => array('psword' => 'whatever', - 'Icon' => array('id' => 851), - 'Profile' => array('name' => 'Some Name', 'address' => 'Some Address'), - 'Comment' => array( - array('id' => 1, 'article_id' => 1, 'user_id' => 1, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'), - array('id' => 2, 'article_id' => 1, 'user_id' => 2, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31')))); + $expected = ['User' => ['psword' => 'whatever', + 'Icon' => ['id' => 851], + 'Profile' => ['name' => 'Some Name', 'address' => 'Some Address'], + 'Comment' => [ + ['id' => 1, 'article_id' => 1, 'user_id' => 1, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'], + ['id' => 2, 'article_id' => 1, 'user_id' => 2, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31']]]]; $class = new stdClass; $class->User = new stdClass; @@ -2145,12 +2145,12 @@ public function testMapReverse() { $result = Set::reverse($class); $this->assertEquals($expected, $result); - $expected = array('User' => array('psword' => 'whatever', - 'Icon' => array('id' => 851), - 'Profile' => array('name' => 'Some Name', 'address' => 'Some Address'), - 'Comment' => array( - array('id' => 1, 'article_id' => 1, 'user_id' => 1, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'), - array('id' => 2, 'article_id' => 1, 'user_id' => 2, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31')))); + $expected = ['User' => ['psword' => 'whatever', + 'Icon' => ['id' => 851], + 'Profile' => ['name' => 'Some Name', 'address' => 'Some Address'], + 'Comment' => [ + ['id' => 1, 'article_id' => 1, 'user_id' => 1, 'comment' => 'First Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'], + ['id' => 2, 'article_id' => 1, 'user_id' => 2, 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31']]]]; // @codingStandardsIgnoreStart $class = new stdClass; @@ -2161,7 +2161,7 @@ public function testMapReverse() { $class->User->Profile = new stdClass; $class->User->Profile->name = 'Some Name'; $class->User->Profile->address = 'Some Address'; - $class->User->Comment = array(); + $class->User->Comment = []; $comment = new stdClass; $comment->id = 1; $comment->article_id = 1; @@ -2179,7 +2179,7 @@ public function testMapReverse() { $comment2->created = '2007-03-18 10:47:23'; $comment2->updated = '2007-03-18 10:49:31'; // @codingStandardsIgnoreEnd - $class->User->Comment = array($comment, $comment2); + $class->User->Comment = [$comment, $comment2]; $result = Set::reverse($class); $this->assertEquals($expected, $result); @@ -2191,11 +2191,11 @@ public function testMapReverse() { $class->Profile->name = 'Joe Mamma'; $result = Set::reverse($class); - $expected = array( - 'User' => array('id' => '100'), + $expected = [ + 'User' => ['id' => '100'], 'someString' => 'this is some string', - 'Profile' => array('name' => 'Joe Mamma') - ); + 'Profile' => ['name' => 'Joe Mamma'] + ]; $this->assertEquals($expected, $result); // @codingStandardsIgnoreStart @@ -2209,7 +2209,7 @@ public function testMapReverse() { // @codingStandardsIgnoreEnd $result = Set::reverse($class); - $expected = array('User' => array('id' => '100'), 'Profile' => array('name' => 'Joe Mamma')); + $expected = ['User' => ['id' => '100'], 'Profile' => ['name' => 'Joe Mamma']]; $this->assertEquals($expected, $result); } @@ -2219,44 +2219,44 @@ public function testMapReverse() { * @return void */ public function testFormatting() { - $data = array( - array('Person' => array('first_name' => 'Nate', 'last_name' => 'Abele', 'city' => 'Boston', 'state' => 'MA', 'something' => '42')), - array('Person' => array('first_name' => 'Larry', 'last_name' => 'Masters', 'city' => 'Boondock', 'state' => 'TN', 'something' => '{0}')), - array('Person' => array('first_name' => 'Garrett', 'last_name' => 'Woodworth', 'city' => 'Venice Beach', 'state' => 'CA', 'something' => '{1}'))); + $data = [ + ['Person' => ['first_name' => 'Nate', 'last_name' => 'Abele', 'city' => 'Boston', 'state' => 'MA', 'something' => '42']], + ['Person' => ['first_name' => 'Larry', 'last_name' => 'Masters', 'city' => 'Boondock', 'state' => 'TN', 'something' => '{0}']], + ['Person' => ['first_name' => 'Garrett', 'last_name' => 'Woodworth', 'city' => 'Venice Beach', 'state' => 'CA', 'something' => '{1}']]]; - $result = Set::format($data, '{1}, {0}', array('{n}.Person.first_name', '{n}.Person.last_name')); - $expected = array('Abele, Nate', 'Masters, Larry', 'Woodworth, Garrett'); + $result = Set::format($data, '{1}, {0}', ['{n}.Person.first_name', '{n}.Person.last_name']); + $expected = ['Abele, Nate', 'Masters, Larry', 'Woodworth, Garrett']; $this->assertEquals($expected, $result); - $result = Set::format($data, '{0}, {1}', array('{n}.Person.last_name', '{n}.Person.first_name')); + $result = Set::format($data, '{0}, {1}', ['{n}.Person.last_name', '{n}.Person.first_name']); $this->assertEquals($expected, $result); - $result = Set::format($data, '{0}, {1}', array('{n}.Person.city', '{n}.Person.state')); - $expected = array('Boston, MA', 'Boondock, TN', 'Venice Beach, CA'); + $result = Set::format($data, '{0}, {1}', ['{n}.Person.city', '{n}.Person.state']); + $expected = ['Boston, MA', 'Boondock, TN', 'Venice Beach, CA']; $this->assertEquals($expected, $result); - $result = Set::format($data, '{{0}, {1}}', array('{n}.Person.city', '{n}.Person.state')); - $expected = array('{Boston, MA}', '{Boondock, TN}', '{Venice Beach, CA}'); + $result = Set::format($data, '{{0}, {1}}', ['{n}.Person.city', '{n}.Person.state']); + $expected = ['{Boston, MA}', '{Boondock, TN}', '{Venice Beach, CA}']; $this->assertEquals($expected, $result); - $result = Set::format($data, '{{0}, {1}}', array('{n}.Person.something', '{n}.Person.something')); - $expected = array('{42, 42}', '{{0}, {0}}', '{{1}, {1}}'); + $result = Set::format($data, '{{0}, {1}}', ['{n}.Person.something', '{n}.Person.something']); + $expected = ['{42, 42}', '{{0}, {0}}', '{{1}, {1}}']; $this->assertEquals($expected, $result); - $result = Set::format($data, '{%2$d, %1$s}', array('{n}.Person.something', '{n}.Person.something')); - $expected = array('{42, 42}', '{0, {0}}', '{0, {1}}'); + $result = Set::format($data, '{%2$d, %1$s}', ['{n}.Person.something', '{n}.Person.something']); + $expected = ['{42, 42}', '{0, {0}}', '{0, {1}}']; $this->assertEquals($expected, $result); - $result = Set::format($data, '{%1$s, %1$s}', array('{n}.Person.something', '{n}.Person.something')); - $expected = array('{42, 42}', '{{0}, {0}}', '{{1}, {1}}'); + $result = Set::format($data, '{%1$s, %1$s}', ['{n}.Person.something', '{n}.Person.something']); + $expected = ['{42, 42}', '{{0}, {0}}', '{{1}, {1}}']; $this->assertEquals($expected, $result); - $result = Set::format($data, '%2$d, %1$s', array('{n}.Person.first_name', '{n}.Person.something')); - $expected = array('42, Nate', '0, Larry', '0, Garrett'); + $result = Set::format($data, '%2$d, %1$s', ['{n}.Person.first_name', '{n}.Person.something']); + $expected = ['42, Nate', '0, Larry', '0, Garrett']; $this->assertEquals($expected, $result); - $result = Set::format($data, '%1$s, %2$d', array('{n}.Person.first_name', '{n}.Person.something')); - $expected = array('Nate, 42', 'Larry, 0', 'Garrett, 0'); + $result = Set::format($data, '%1$s, %2$d', ['{n}.Person.first_name', '{n}.Person.something']); + $expected = ['Nate, 42', 'Larry, 0', 'Garrett, 0']; $this->assertEquals($expected, $result); } @@ -2266,17 +2266,17 @@ public function testFormatting() { * @return void */ public function testFormattingNullValues() { - $data = array( - array('Person' => array('first_name' => 'Nate', 'last_name' => 'Abele', 'city' => 'Boston', 'state' => 'MA', 'something' => '42')), - array('Person' => array('first_name' => 'Larry', 'last_name' => 'Masters', 'city' => 'Boondock', 'state' => 'TN', 'something' => null)), - array('Person' => array('first_name' => 'Garrett', 'last_name' => 'Woodworth', 'city' => 'Venice Beach', 'state' => 'CA', 'something' => null))); + $data = [ + ['Person' => ['first_name' => 'Nate', 'last_name' => 'Abele', 'city' => 'Boston', 'state' => 'MA', 'something' => '42']], + ['Person' => ['first_name' => 'Larry', 'last_name' => 'Masters', 'city' => 'Boondock', 'state' => 'TN', 'something' => null]], + ['Person' => ['first_name' => 'Garrett', 'last_name' => 'Woodworth', 'city' => 'Venice Beach', 'state' => 'CA', 'something' => null]]]; - $result = Set::format($data, '%s', array('{n}.Person.something')); - $expected = array('42', '', ''); + $result = Set::format($data, '%s', ['{n}.Person.something']); + $expected = ['42', '', '']; $this->assertEquals($expected, $result); - $result = Set::format($data, '{0}, {1}', array('{n}.Person.city', '{n}.Person.something')); - $expected = array('Boston, 42', 'Boondock, ', 'Venice Beach, '); + $result = Set::format($data, '{0}, {1}', ['{n}.Person.city', '{n}.Person.something']); + $expected = ['Boston, 42', 'Boondock, ', 'Venice Beach, ']; $this->assertEquals($expected, $result); } @@ -2286,47 +2286,47 @@ public function testFormattingNullValues() { * @return void */ public function testCountDim() { - $data = array('one', '2', 'three'); + $data = ['one', '2', 'three']; $result = Set::countDim($data); $this->assertEquals(1, $result); - $data = array('1' => '1.1', '2', '3'); + $data = ['1' => '1.1', '2', '3']; $result = Set::countDim($data); $this->assertEquals(1, $result); - $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => '3.1.1')); + $data = ['1' => ['1.1' => '1.1.1'], '2', '3' => ['3.1' => '3.1.1']]; $result = Set::countDim($data); $this->assertEquals(2, $result); - $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1')); + $data = ['1' => '1.1', '2', '3' => ['3.1' => '3.1.1']]; $result = Set::countDim($data); $this->assertEquals(1, $result); - $data = array('1' => '1.1', '2', '3' => array('3.1' => '3.1.1')); + $data = ['1' => '1.1', '2', '3' => ['3.1' => '3.1.1']]; $result = Set::countDim($data, true); $this->assertEquals(2, $result); - $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); + $data = ['1' => ['1.1' => '1.1.1'], '2', '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Set::countDim($data); $this->assertEquals(2, $result); - $data = array('1' => array('1.1' => '1.1.1'), '2', '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); + $data = ['1' => ['1.1' => '1.1.1'], '2', '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Set::countDim($data, true); $this->assertEquals(3, $result); - $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => '2.1.1.1'))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); + $data = ['1' => ['1.1' => '1.1.1'], ['2' => ['2.1' => ['2.1.1' => '2.1.1.1']]], '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Set::countDim($data, true); $this->assertEquals(4, $result); - $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); + $data = ['1' => ['1.1' => '1.1.1'], ['2' => ['2.1' => ['2.1.1' => ['2.1.1.1']]]], '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Set::countDim($data, true); $this->assertEquals(5, $result); - $data = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1' => '2.1.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); + $data = ['1' => ['1.1' => '1.1.1'], ['2' => ['2.1' => ['2.1.1' => ['2.1.1.1' => '2.1.1.1.1']]]], '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Set::countDim($data, true); $this->assertEquals(5, $result); - $set = array('1' => array('1.1' => '1.1.1'), array('2' => array('2.1' => array('2.1.1' => array('2.1.1.1' => '2.1.1.1.1')))), '3' => array('3.1' => array('3.1.1' => '3.1.1.1'))); + $set = ['1' => ['1.1' => '1.1.1'], ['2' => ['2.1' => ['2.1.1' => ['2.1.1.1' => '2.1.1.1.1']]]], '3' => ['3.1' => ['3.1.1' => '3.1.1.1']]]; $result = Set::countDim($set, false, 0); $this->assertEquals(2, $result); @@ -2340,13 +2340,13 @@ public function testCountDim() { * @return void */ public function testMapNesting() { - $expected = array( - array( - "IndexedPage" => array( + $expected = [ + [ + "IndexedPage" => [ "id" => 1, "url" => 'http://blah.com/', 'hash' => '68a9f053b19526d08e36c6a9ad150737933816a5', - 'headers' => array( + 'headers' => [ 'Date' => "Wed, 14 Nov 2007 15:51:42 GMT", 'Server' => "Apache", 'Expires' => "Thu, 19 Nov 1981 08:52:00 GMT", @@ -2355,25 +2355,25 @@ public function testMapNesting() { 'Content-Type' => "text/html; charset=UTF-8", 'X-Original-Transfer-Encoding' => "chunked", 'Content-Length' => "50210", - ), - 'meta' => array( - 'keywords' => array('testing', 'tests'), + ], + 'meta' => [ + 'keywords' => ['testing', 'tests'], 'description' => 'describe me', - ), + ], 'get_vars' => '', - 'post_vars' => array(), - 'cookies' => array('PHPSESSID' => "dde9896ad24595998161ffaf9e0dbe2d"), + 'post_vars' => [], + 'cookies' => ['PHPSESSID' => "dde9896ad24595998161ffaf9e0dbe2d"], 'redirect' => '', 'created' => "1195055503", 'updated' => "1195055503", - ) - ), - array( - "IndexedPage" => array( + ] + ], + [ + "IndexedPage" => [ "id" => 2, "url" => 'http://blah.com/', 'hash' => '68a9f053b19526d08e36c6a9ad150737933816a5', - 'headers' => array( + 'headers' => [ 'Date' => "Wed, 14 Nov 2007 15:51:42 GMT", 'Server' => "Apache", 'Expires' => "Thu, 19 Nov 1981 08:52:00 GMT", @@ -2382,36 +2382,36 @@ public function testMapNesting() { 'Content-Type' => "text/html; charset=UTF-8", 'X-Original-Transfer-Encoding' => "chunked", 'Content-Length' => "50210", - ), - 'meta' => array( - 'keywords' => array('testing', 'tests'), + ], + 'meta' => [ + 'keywords' => ['testing', 'tests'], 'description' => 'describe me', - ), + ], 'get_vars' => '', - 'post_vars' => array(), - 'cookies' => array('PHPSESSID' => "dde9896ad24595998161ffaf9e0dbe2d"), + 'post_vars' => [], + 'cookies' => ['PHPSESSID' => "dde9896ad24595998161ffaf9e0dbe2d"], 'redirect' => '', 'created' => "1195055503", 'updated' => "1195055503", - ), - ) - ); + ], + ] + ]; $mapped = Set::map($expected); - $ids = array(); + $ids = []; foreach ($mapped as $object) { $ids[] = $object->id; } - $this->assertEquals(array(1, 2), $ids); + $this->assertEquals([1, 2], $ids); $this->assertEquals($expected[0]['IndexedPage']['headers'], get_object_vars($mapped[0]->headers)); $result = Set::reverse($mapped); $this->assertEquals($expected, $result); - $data = array( - array( - "IndexedPage" => array( + $data = [ + [ + "IndexedPage" => [ "id" => 1, "url" => 'http://blah.com/', 'hash' => '68a9f053b19526d08e36c6a9ad150737933816a5', @@ -2419,10 +2419,10 @@ public function testMapNesting() { 'redirect' => '', 'created' => "1195055503", 'updated' => "1195055503", - ) - ), - array( - "IndexedPage" => array( + ] + ], + [ + "IndexedPage" => [ "id" => 2, "url" => 'http://blah.com/', 'hash' => '68a9f053b19526d08e36c6a9ad150737933816a5', @@ -2430,9 +2430,9 @@ public function testMapNesting() { 'redirect' => '', 'created' => "1195055503", 'updated' => "1195055503", - ), - ) - ); + ], + ] + ]; $mapped = Set::map($data); // @codingStandardsIgnoreStart @@ -2448,12 +2448,12 @@ public function testMapNesting() { // @codingStandardsIgnoreEnd $this->assertEquals($expected, $mapped[1]); - $ids = array(); + $ids = []; foreach ($mapped as $object) { $ids[] = $object->id; } - $this->assertEquals(array(1, 2), $ids); + $this->assertEquals([1, 2], $ids); $result = Set::map(null); $expected = null; @@ -2466,16 +2466,16 @@ public function testMapNesting() { * @return void */ public function testNestedMappedData() { - $result = Set::map(array( - array( - 'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), - 'Author' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'), - ), - array( - 'Post' => array('id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'), - 'Author' => array('id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', 'test' => 'working'), - ) - )); + $result = Set::map([ + [ + 'Post' => ['id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'], + 'Author' => ['id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'], + ], + [ + 'Post' => ['id' => '2', 'author_id' => '3', 'title' => 'Second Post', 'body' => 'Second Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:41:23', 'updated' => '2007-03-18 10:43:31'], + 'Author' => ['id' => '3', 'user' => 'larry', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31', 'test' => 'working'], + ] + ]); // @codingStandardsIgnoreStart $expected = new stdClass; @@ -2517,17 +2517,17 @@ public function testNestedMappedData() { $expected2->Author->_name_ = 'Author'; // @codingStandardsIgnoreEnd - $test = array(); + $test = []; $test[0] = $expected; $test[1] = $expected2; $this->assertEquals($test, $result); $result = Set::map( - array( - 'Post' => array('id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'), - 'Author' => array('id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'), - ) + [ + 'Post' => ['id' => '1', 'author_id' => '1', 'title' => 'First Post', 'body' => 'First Post Body', 'published' => 'Y', 'created' => '2007-03-18 10:39:23', 'updated' => '2007-03-18 10:41:31'], + 'Author' => ['id' => '1', 'user' => 'mariano', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31', 'test' => 'working'], + ] ); // @codingStandardsIgnoreStart $expected = new stdClass; @@ -2552,40 +2552,40 @@ public function testNestedMappedData() { $this->assertEquals($expected, $result); //Case where extra HABTM fields come back in a result - $data = array( - 'User' => array( + $data = [ + 'User' => [ 'id' => 1, 'email' => 'user@example.com', 'first_name' => 'John', 'last_name' => 'Smith', - ), - 'Piece' => array( - array( + ], + 'Piece' => [ + [ 'id' => 1, 'title' => 'Moonlight Sonata', 'composer' => 'Ludwig van Beethoven', - 'PiecesUser' => array( + 'PiecesUser' => [ 'id' => 1, 'created' => '2008-01-01 00:00:00', 'modified' => '2008-01-01 00:00:00', 'piece_id' => 1, 'user_id' => 2, - ) - ), - array( + ] + ], + [ 'id' => 2, 'title' => 'Moonlight Sonata 2', 'composer' => 'Ludwig van Beethoven', - 'PiecesUser' => array( + 'PiecesUser' => [ 'id' => 2, 'created' => '2008-01-01 00:00:00', 'modified' => '2008-01-01 00:00:00', 'piece_id' => 2, 'user_id' => 2, - ) - ) - ) - ); + ] + ] + ] + ]; $result = Set::map($data); @@ -2628,50 +2628,50 @@ public function testNestedMappedData() { $piece2->_name_ = 'Piece'; // @codingStandardsIgnoreEnd - $expected->Piece = array($piece, $piece2); + $expected->Piece = [$piece, $piece2]; $this->assertEquals($expected, $result); //Same data, but should work if _name_ has been manually defined: - $data = array( - 'User' => array( + $data = [ + 'User' => [ 'id' => 1, 'email' => 'user@example.com', 'first_name' => 'John', 'last_name' => 'Smith', '_name_' => 'FooUser', - ), - 'Piece' => array( - array( + ], + 'Piece' => [ + [ 'id' => 1, 'title' => 'Moonlight Sonata', 'composer' => 'Ludwig van Beethoven', '_name_' => 'FooPiece', - 'PiecesUser' => array( + 'PiecesUser' => [ 'id' => 1, 'created' => '2008-01-01 00:00:00', 'modified' => '2008-01-01 00:00:00', 'piece_id' => 1, 'user_id' => 2, '_name_' => 'FooPiecesUser', - ) - ), - array( + ] + ], + [ 'id' => 2, 'title' => 'Moonlight Sonata 2', 'composer' => 'Ludwig van Beethoven', '_name_' => 'FooPiece', - 'PiecesUser' => array( + 'PiecesUser' => [ 'id' => 2, 'created' => '2008-01-01 00:00:00', 'modified' => '2008-01-01 00:00:00', 'piece_id' => 2, 'user_id' => 2, '_name_' => 'FooPiecesUser', - ) - ) - ) - ); + ] + ] + ] + ]; $result = Set::map($data); @@ -2710,7 +2710,7 @@ public function testNestedMappedData() { $piece2->PiecesUser->_name_ = 'FooPiecesUser'; // @codingStandardsIgnoreEnd - $expected->Piece = array($piece, $piece2); + $expected->Piece = [$piece, $piece2]; $this->assertEquals($expected, $result); } @@ -2721,36 +2721,36 @@ public function testNestedMappedData() { * @return void */ public function testPushDiff() { - $array1 = array('ModelOne' => array('id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2')); - $array2 = array('ModelTwo' => array('id' => 1002, 'field_one' => 'a2.m2.f1', 'field_two' => 'a2.m2.f2')); + $array1 = ['ModelOne' => ['id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2']]; + $array2 = ['ModelTwo' => ['id' => 1002, 'field_one' => 'a2.m2.f1', 'field_two' => 'a2.m2.f2']]; $result = Set::pushDiff($array1, $array2); $this->assertEquals($array1 + $array2, $result); - $array3 = array('ModelOne' => array('id' => 1003, 'field_one' => 'a3.m1.f1', 'field_two' => 'a3.m1.f2', 'field_three' => 'a3.m1.f3')); + $array3 = ['ModelOne' => ['id' => 1003, 'field_one' => 'a3.m1.f1', 'field_two' => 'a3.m1.f2', 'field_three' => 'a3.m1.f3']]; $result = Set::pushDiff($array1, $array3); - $expected = array('ModelOne' => array('id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2', 'field_three' => 'a3.m1.f3')); + $expected = ['ModelOne' => ['id' => 1001, 'field_one' => 'a1.m1.f1', 'field_two' => 'a1.m1.f2', 'field_three' => 'a3.m1.f3']]; $this->assertEquals($expected, $result); - $array1 = array( - 0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2')), - 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2'))); - $array2 = array( - 0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's2.0.m1.f1', 'field_two' => 's2.0.m1.f2')), - 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's2.1.m2.f2', 'field_two' => 's2.1.m2.f2'))); + $array1 = [ + 0 => ['ModelOne' => ['id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2']], + 1 => ['ModelTwo' => ['id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2']]]; + $array2 = [ + 0 => ['ModelOne' => ['id' => 1001, 'field_one' => 's2.0.m1.f1', 'field_two' => 's2.0.m1.f2']], + 1 => ['ModelTwo' => ['id' => 1002, 'field_one' => 's2.1.m2.f2', 'field_two' => 's2.1.m2.f2']]]; $result = Set::pushDiff($array1, $array2); $this->assertEquals($array1, $result); - $array3 = array(0 => array('ModelThree' => array('id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2'))); + $array3 = [0 => ['ModelThree' => ['id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2']]]; $result = Set::pushDiff($array1, $array3); - $expected = array( - 0 => array('ModelOne' => array('id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2'), - 'ModelThree' => array('id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2')), - 1 => array('ModelTwo' => array('id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2'))); + $expected = [ + 0 => ['ModelOne' => ['id' => 1001, 'field_one' => 's1.0.m1.f1', 'field_two' => 's1.0.m1.f2'], + 'ModelThree' => ['id' => 1003, 'field_one' => 's3.0.m3.f1', 'field_two' => 's3.0.m3.f2']], + 1 => ['ModelTwo' => ['id' => 1002, 'field_one' => 's1.1.m2.f2', 'field_two' => 's1.1.m2.f2']]]; $this->assertEquals($expected, $result); $result = Set::pushDiff($array1, null); @@ -2765,11 +2765,11 @@ public function testPushDiff() { * @return void */ public function testApply() { - $data = array( - array('Movie' => array('id' => 1, 'title' => 'movie 3', 'rating' => 5)), - array('Movie' => array('id' => 1, 'title' => 'movie 1', 'rating' => 1)), - array('Movie' => array('id' => 1, 'title' => 'movie 2', 'rating' => 3)) - ); + $data = [ + ['Movie' => ['id' => 1, 'title' => 'movie 3', 'rating' => 5]], + ['Movie' => ['id' => 1, 'title' => 'movie 1', 'rating' => 1]], + ['Movie' => ['id' => 1, 'title' => 'movie 2', 'rating' => 3]] + ]; $result = Set::apply('/Movie/rating', $data, 'array_sum'); $expected = 9; @@ -2779,19 +2779,19 @@ public function testApply() { $expected = 15; $this->assertEquals($expected, $result); - $result = Set::apply('/Movie/title', $data, 'ucfirst', array('type' => 'map')); - $expected = array('Movie 3', 'Movie 1', 'Movie 2'); + $result = Set::apply('/Movie/title', $data, 'ucfirst', ['type' => 'map']); + $expected = ['Movie 3', 'Movie 1', 'Movie 2']; $this->assertEquals($expected, $result); - $result = Set::apply('/Movie/title', $data, 'strtoupper', array('type' => 'map')); - $expected = array('MOVIE 3', 'MOVIE 1', 'MOVIE 2'); + $result = Set::apply('/Movie/title', $data, 'strtoupper', ['type' => 'map']); + $expected = ['MOVIE 3', 'MOVIE 1', 'MOVIE 2']; $this->assertEquals($expected, $result); - $result = Set::apply('/Movie/rating', $data, array('SetTest', 'method'), array('type' => 'reduce')); + $result = Set::apply('/Movie/rating', $data, ['SetTest', 'method'], ['type' => 'reduce']); $expected = 9; $this->assertEquals($expected, $result); - $result = Set::apply('/Movie/rating', $data, 'strtoupper', array('type' => 'non existing type')); + $result = Set::apply('/Movie/rating', $data, 'strtoupper', ['type' => 'non existing type']); $expected = null; $this->assertEquals($expected, $result); } @@ -2841,79 +2841,79 @@ public function testXmlSetReverse() { '; $xml = Xml::build($string); $result = Set::reverse($xml); - $expected = array('rss' => array( + $expected = ['rss' => [ '@version' => '2.0', - 'channel' => array( + 'channel' => [ 'title' => 'Cake PHP Google Group', 'link' => 'http://groups.google.com/group/cake-php', 'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.', 'language' => 'en', - 'item' => array( - array( + 'item' => [ + [ 'title' => 'constructng result array when using findall', 'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f', 'description' => "i'm using cakephp to construct a logical data model array that will be
passed to a flex app. I have the following model association:
ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what
the current output from my findall is something like this example:

Array(
[0] => Array(", - 'guid' => array('@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'), + 'guid' => ['@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'], 'author' => 'bmil...@gmail.com(bpscrugs)', 'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT', - ), - array( + ], + [ 'title' => 'Re: share views between actions?', 'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8', 'description' => 'Then perhaps you might do us all a favour and refrain from replying to
things you do not understand. That goes especially for asinine comments.
Indeed.
To sum up:
No comment.
In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any
further responses from you.
You (and I) were referring to the *online documentation*, not other', - 'guid' => array('@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'), + 'guid' => ['@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'], 'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)', 'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT' - ) - ) - ) - )); + ] + ] + ] + ]]; $this->assertEquals($expected, $result); $string = ''; $xml = Xml::build($string); $result = Set::reverse($xml); - $expected = array('data' => array('post' => array('@title' => 'Title of this post', '@description' => 'cool'))); + $expected = ['data' => ['post' => ['@title' => 'Title of this post', '@description' => 'cool']]]; $this->assertEquals($expected, $result); $xml = Xml::build('An example of a correctly reversed SimpleXMLElement'); $result = Set::reverse($xml); - $expected = array('example' => - array( - 'item' => array( + $expected = ['example' => + [ + 'item' => [ 'title' => 'An example of a correctly reversed SimpleXMLElement', 'desc' => '', - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $xml = Xml::build('title1title2'); $result = Set::reverse($xml); $expected = - array('example' => array( - 'item' => array( + ['example' => [ + 'item' => [ '@attr' => '123', - 'titles' => array( - 'title' => array('title1', 'title2') - ) - ) - ) - ); + 'titles' => [ + 'title' => ['title1', 'title2'] + ] + ] + ] + ]; $this->assertEquals($expected, $result); $xml = Xml::build('listtextforitems'); $result = Set::reverse($xml); $expected = - array('example' => array( + ['example' => [ '@attr' => 'ex_attr', - 'item' => array( + 'item' => [ '@attr' => '123', 'titles' => 'list', '@' => 'textforitems' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, $result); $string = ' @@ -2951,37 +2951,37 @@ public function testXmlSetReverse() { $xml = Xml::build($string); $result = Set::reverse($xml); - $expected = array('rss' => array( + $expected = ['rss' => [ '@version' => '2.0', - 'channel' => array( + 'channel' => [ 'title' => 'Cake PHP Google Group', 'link' => 'http://groups.google.com/group/cake-php', 'description' => 'Search this group before posting anything. There are over 20,000 posts and it's very likely your question was answered before. Visit the IRC channel #cakephp at irc.freenode.net for live chat with users and developers of Cake. If you post, tell us the version of Cake, PHP, and database.', 'language' => 'en', - 'item' => array( - array( + 'item' => [ + [ 'title' => 'constructng result array when using findall', 'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f', 'description' => "i'm using cakephp to construct a logical data model array that will be
passed to a flex app. I have the following model association:
ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what
the current output from my findall is something like this example:

Array(
[0] => Array(", 'dc:creator' => 'cakephp', - 'category' => array('cakephp', 'model'), - 'guid' => array('@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'), + 'category' => ['cakephp', 'model'], + 'guid' => ['@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'], 'author' => 'bmil...@gmail.com(bpscrugs)', 'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT', - ), - array( + ], + [ 'title' => 'Re: share views between actions?', 'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8', 'description' => 'Then perhaps you might do us all a favour and refrain from replying to
things you do not understand. That goes especially for asinine comments.
Indeed.
To sum up:
No comment.
In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any
further responses from you.
You (and I) were referring to the *online documentation*, not other', 'dc:creator' => 'cakephp', - 'category' => array('cakephp', 'model'), - 'guid' => array('@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'), + 'category' => ['cakephp', 'model'], + 'guid' => ['@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'], 'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)', 'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT' - ) - ) - ) - )); + ] + ] + ] + ]]; $this->assertEquals($expected, $result); $text = ' @@ -3009,42 +3009,42 @@ public function testXmlSetReverse() { $xml = Xml::build($text); $result = Set::reverse($xml); - $expected = array('XRDS' => array( - 'XRD' => array( - array( + $expected = ['XRDS' => [ + 'XRD' => [ + [ '@xml:id' => 'oauth', '@version' => '2.0', 'Type' => 'xri://$xrds*simple', 'Expires' => '2008-04-13T07:34:58Z', - 'Service' => array( - 'Type' => array( + 'Service' => [ + 'Type' => [ 'http://oauth.net/core/1.0/endpoint/authorize', 'http://oauth.net/core/1.0/parameters/auth-header', 'http://oauth.net/core/1.0/parameters/uri-query' - ), - 'URI' => array( - array( + ], + 'URI' => [ + [ '@' => 'https://ma.gnolia.com/oauth/authorize', '@priority' => '10', - ), - array( + ], + [ '@' => 'http://ma.gnolia.com/oauth/authorize', '@priority' => '20' - ) - ) - ) - ), - array( + ] + ] + ] + ], + [ '@version' => '2.0', 'Type' => 'xri://$xrds*simple', - 'Service' => array( + 'Service' => [ '@priority' => '10', 'Type' => 'http://oauth.net/discovery/1.0', 'URI' => '#oauth' - ) - ) - ) - )); + ] + ] + ] + ]]; $this->assertEquals($expected, $result); } @@ -3054,7 +3054,7 @@ public function testXmlSetReverse() { * @return void */ public function testStrictKeyCheck() { - $set = array('a' => 'hi'); + $set = ['a' => 'hi']; $this->assertFalse(Set::check($set, 'a.b')); } @@ -3065,7 +3065,7 @@ public function testStrictKeyCheck() { * @return void */ public function testFlatten() { - $data = array('Larry', 'Curly', 'Moe'); + $data = ['Larry', 'Curly', 'Moe']; $result = Set::flatten($data); $this->assertEquals($data, $result); @@ -3073,19 +3073,19 @@ public function testFlatten() { $result = Set::flatten($data); $this->assertEquals($data, $result); - $data = array( - array( - 'Post' => array('id' => '1', 'author_id' => null, 'title' => 'First Post'), - 'Author' => array(), - ) - ); + $data = [ + [ + 'Post' => ['id' => '1', 'author_id' => null, 'title' => 'First Post'], + 'Author' => [], + ] + ]; $result = Set::flatten($data); - $expected = array( + $expected = [ '0.Post.id' => '1', '0.Post.author_id' => null, '0.Post.title' => 'First Post', - '0.Author' => array() - ); + '0.Author' => [] + ]; $this->assertEquals($expected, $result); } @@ -3095,7 +3095,7 @@ public function testFlatten() { * @return void */ public function testExpand() { - $data = array('My', 'Array', 'To', 'Flatten'); + $data = ['My', 'Array', 'To', 'Flatten']; $flat = Set::flatten($data); $result = Set::expand($flat); $this->assertEquals($data, $result); @@ -3108,15 +3108,15 @@ public function testExpand() { */ public function testNormalizeStrings() { $result = Set::normalize('one,two,three'); - $expected = array('one' => null, 'two' => null, 'three' => null); + $expected = ['one' => null, 'two' => null, 'three' => null]; $this->assertEquals($expected, $result); $result = Set::normalize('one two three', true, ' '); - $expected = array('one' => null, 'two' => null, 'three' => null); + $expected = ['one' => null, 'two' => null, 'three' => null]; $this->assertEquals($expected, $result); $result = Set::normalize('one , two , three ', true, ',', true); - $expected = array('one' => null, 'two' => null, 'three' => null); + $expected = ['one' => null, 'two' => null, 'three' => null]; $this->assertEquals($expected, $result); } @@ -3126,24 +3126,24 @@ public function testNormalizeStrings() { * @return void */ public function testNormalizeArrays() { - $result = Set::normalize(array('one', 'two', 'three')); - $expected = array('one' => null, 'two' => null, 'three' => null); + $result = Set::normalize(['one', 'two', 'three']); + $expected = ['one' => null, 'two' => null, 'three' => null]; $this->assertEquals($expected, $result); - $result = Set::normalize(array('one', 'two', 'three'), false); - $expected = array('one', 'two', 'three'); + $result = Set::normalize(['one', 'two', 'three'], false); + $expected = ['one', 'two', 'three']; $this->assertEquals($expected, $result); - $result = Set::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four'), false); - $expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null); + $result = Set::normalize(['one' => 1, 'two' => 2, 'three' => 3, 'four'], false); + $expected = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => null]; $this->assertEquals($expected, $result); - $result = Set::normalize(array('one' => 1, 'two' => 2, 'three' => 3, 'four')); - $expected = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => null); + $result = Set::normalize(['one' => 1, 'two' => 2, 'three' => 3, 'four']); + $expected = ['one' => 1, 'two' => 2, 'three' => 3, 'four' => null]; $this->assertEquals($expected, $result); - $result = Set::normalize(array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three')); - $expected = array('one' => array('a', 'b', 'c' => 'cee'), 'two' => 2, 'three' => null); + $result = Set::normalize(['one' => ['a', 'b', 'c' => 'cee'], 'two' => 2, 'three']); + $expected = ['one' => ['a', 'b', 'c' => 'cee'], 'two' => 2, 'three' => null]; $this->assertEquals($expected, $result); } @@ -3154,143 +3154,143 @@ public function testNormalizeArrays() { * @return void */ public function testNestModel() { - $input = array( - array( - 'ModelName' => array( + $input = [ + [ + 'ModelName' => [ 'id' => 1, 'parent_id' => null - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 2, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 3, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 4, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 5, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 6, 'parent_id' => null - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 7, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 8, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 9, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 10, 'parent_id' => 6 - ) - ) - ); - $expected = array( - array( - 'ModelName' => array( + ] + ] + ]; + $expected = [ + [ + 'ModelName' => [ 'id' => 1, 'parent_id' => null - ), - 'children' => array( - array( - 'ModelName' => array( + ], + 'children' => [ + [ + 'ModelName' => [ 'id' => 2, 'parent_id' => 1 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 3, 'parent_id' => 1 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 4, 'parent_id' => 1 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 5, 'parent_id' => 1 - ), - 'children' => array() - ), - - ) - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + + ] + ], + [ + 'ModelName' => [ 'id' => 6, 'parent_id' => null - ), - 'children' => array( - array( - 'ModelName' => array( + ], + 'children' => [ + [ + 'ModelName' => [ 'id' => 7, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 8, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 9, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 10, 'parent_id' => 6 - ), - 'children' => array() - ) - ) - ) - ); + ], + 'children' => [] + ] + ] + ] + ]; $result = Set::nest($input); $this->assertEquals($expected, $result); } @@ -3301,107 +3301,107 @@ public function testNestModel() { * @return void */ public function testNestModelExplicitRoot() { - $input = array( - array( - 'ModelName' => array( + $input = [ + [ + 'ModelName' => [ 'id' => 1, 'parent_id' => null - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 2, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 3, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 4, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 5, 'parent_id' => 1 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 6, 'parent_id' => null - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 7, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 8, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 9, 'parent_id' => 6 - ), - ), - array( - 'ModelName' => array( + ], + ], + [ + 'ModelName' => [ 'id' => 10, 'parent_id' => 6 - ) - ) - ); - $expected = array( - array( - 'ModelName' => array( + ] + ] + ]; + $expected = [ + [ + 'ModelName' => [ 'id' => 6, 'parent_id' => null - ), - 'children' => array( - array( - 'ModelName' => array( + ], + 'children' => [ + [ + 'ModelName' => [ 'id' => 7, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 8, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 9, 'parent_id' => 6 - ), - 'children' => array() - ), - array( - 'ModelName' => array( + ], + 'children' => [] + ], + [ + 'ModelName' => [ 'id' => 10, 'parent_id' => 6 - ), - 'children' => array() - ) - ) - ) - ); - $result = Set::nest($input, array('root' => 6)); + ], + 'children' => [] + ] + ] + ] + ]; + $result = Set::nest($input, ['root' => 6]); $this->assertEquals($expected, $result); } @@ -3411,104 +3411,104 @@ public function testNestModelExplicitRoot() { * @return void */ public function testNest1Dimensional() { - $input = array( - array( + $input = [ + [ 'id' => 1, 'parent_id' => null - ), - array( + ], + [ 'id' => 2, 'parent_id' => 1 - ), - array( + ], + [ 'id' => 3, 'parent_id' => 1 - ), - array( + ], + [ 'id' => 4, 'parent_id' => 1 - ), - array( + ], + [ 'id' => 5, 'parent_id' => 1 - ), - array( + ], + [ 'id' => 6, 'parent_id' => null - ), - array( + ], + [ 'id' => 7, 'parent_id' => 6 - ), - array( + ], + [ 'id' => 8, 'parent_id' => 6 - ), - array( + ], + [ 'id' => 9, 'parent_id' => 6 - ), - array( + ], + [ 'id' => 10, 'parent_id' => 6 - ) - ); - $expected = array( - array( + ] + ]; + $expected = [ + [ 'id' => 1, 'parent_id' => null, - 'children' => array( - array( + 'children' => [ + [ 'id' => 2, 'parent_id' => 1, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 3, 'parent_id' => 1, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 4, 'parent_id' => 1, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 5, 'parent_id' => 1, - 'children' => array() - ), + 'children' => [] + ], - ) - ), - array( + ] + ], + [ 'id' => 6, 'parent_id' => null, - 'children' => array( - array( + 'children' => [ + [ 'id' => 7, 'parent_id' => 6, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 8, 'parent_id' => 6, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 9, 'parent_id' => 6, - 'children' => array() - ), - array( + 'children' => [] + ], + [ 'id' => 10, 'parent_id' => 6, - 'children' => array() - ) - ) - ) - ); - $result = Set::nest($input, array('idPath' => '/id', 'parentPath' => '/parent_id')); + 'children' => [] + ] + ] + ] + ]; + $result = Set::nest($input, ['idPath' => '/id', 'parentPath' => '/parent_id']); $this->assertEquals($expected, $result); } @@ -3521,40 +3521,40 @@ public function testNest1Dimensional() { * @return void */ public function testMissingParent() { - $input = array( - array( + $input = [ + [ 'id' => 1, - ), - array( + ], + [ 'id' => 2, - ), - array( + ], + [ 'id' => 3, - ), - array( + ], + [ 'id' => 4, - ), - array( + ], + [ 'id' => 5, - ), - array( + ], + [ 'id' => 6, - ), - array( + ], + [ 'id' => 7, - ), - array( + ], + [ 'id' => 8, - ), - array( + ], + [ 'id' => 9, - ), - array( + ], + [ 'id' => 10, - ) - ); + ] + ]; - $result = Set::nest($input, array('idPath' => '/id', 'parentPath' => '/parent_id')); + $result = Set::nest($input, ['idPath' => '/id', 'parentPath' => '/parent_id']); foreach ($result as &$row) { if (empty($row['children'])) { unset($row['children']); diff --git a/lib/Cake/Test/Case/Utility/ValidationTest.php b/lib/Cake/Test/Case/Utility/ValidationTest.php index 37339eff82..964534795f 100644 --- a/lib/Cake/Test/Case/Utility/ValidationTest.php +++ b/lib/Cake/Test/Case/Utility/ValidationTest.php @@ -122,8 +122,8 @@ class ValidationTest extends CakeTestCase { public function setUp() : void { parent::setUp(); $this->_appEncoding = Configure::read('App.encoding'); - $this->_appLocale = array(); - foreach (array(LC_MONETARY, LC_NUMERIC, LC_TIME) as $category) { + $this->_appLocale = []; + foreach ([LC_MONETARY, LC_NUMERIC, LC_TIME] as $category) { $this->_appLocale[$category] = setlocale($category, 0); setlocale($category, 'en_US'); } @@ -242,447 +242,447 @@ public function testBlank() { */ public function testCc() { //American Express - $this->assertTrue(Validation::cc('370482756063980', array('amex'))); - $this->assertTrue(Validation::cc('349106433773483', array('amex'))); - $this->assertTrue(Validation::cc('344671486204764', array('amex'))); - $this->assertTrue(Validation::cc('344042544509943', array('amex'))); - $this->assertTrue(Validation::cc('377147515754475', array('amex'))); - $this->assertTrue(Validation::cc('375239372816422', array('amex'))); - $this->assertTrue(Validation::cc('376294341957707', array('amex'))); - $this->assertTrue(Validation::cc('341779292230411', array('amex'))); - $this->assertTrue(Validation::cc('341646919853372', array('amex'))); - $this->assertTrue(Validation::cc('348498616319346', array('amex'))); + $this->assertTrue(Validation::cc('370482756063980', ['amex'])); + $this->assertTrue(Validation::cc('349106433773483', ['amex'])); + $this->assertTrue(Validation::cc('344671486204764', ['amex'])); + $this->assertTrue(Validation::cc('344042544509943', ['amex'])); + $this->assertTrue(Validation::cc('377147515754475', ['amex'])); + $this->assertTrue(Validation::cc('375239372816422', ['amex'])); + $this->assertTrue(Validation::cc('376294341957707', ['amex'])); + $this->assertTrue(Validation::cc('341779292230411', ['amex'])); + $this->assertTrue(Validation::cc('341646919853372', ['amex'])); + $this->assertTrue(Validation::cc('348498616319346', ['amex'])); //BankCard - $this->assertTrue(Validation::cc('5610745867413420', array('bankcard'))); - $this->assertTrue(Validation::cc('5610376649499352', array('bankcard'))); - $this->assertTrue(Validation::cc('5610091936000694', array('bankcard'))); - $this->assertTrue(Validation::cc('5602248780118788', array('bankcard'))); - $this->assertTrue(Validation::cc('5610631567676765', array('bankcard'))); - $this->assertTrue(Validation::cc('5602238211270795', array('bankcard'))); - $this->assertTrue(Validation::cc('5610173951215470', array('bankcard'))); - $this->assertTrue(Validation::cc('5610139705753702', array('bankcard'))); - $this->assertTrue(Validation::cc('5602226032150551', array('bankcard'))); - $this->assertTrue(Validation::cc('5602223993735777', array('bankcard'))); + $this->assertTrue(Validation::cc('5610745867413420', ['bankcard'])); + $this->assertTrue(Validation::cc('5610376649499352', ['bankcard'])); + $this->assertTrue(Validation::cc('5610091936000694', ['bankcard'])); + $this->assertTrue(Validation::cc('5602248780118788', ['bankcard'])); + $this->assertTrue(Validation::cc('5610631567676765', ['bankcard'])); + $this->assertTrue(Validation::cc('5602238211270795', ['bankcard'])); + $this->assertTrue(Validation::cc('5610173951215470', ['bankcard'])); + $this->assertTrue(Validation::cc('5610139705753702', ['bankcard'])); + $this->assertTrue(Validation::cc('5602226032150551', ['bankcard'])); + $this->assertTrue(Validation::cc('5602223993735777', ['bankcard'])); //Diners Club 14 - $this->assertTrue(Validation::cc('30155483651028', array('diners'))); - $this->assertTrue(Validation::cc('36371312803821', array('diners'))); - $this->assertTrue(Validation::cc('38801277489875', array('diners'))); - $this->assertTrue(Validation::cc('30348560464296', array('diners'))); - $this->assertTrue(Validation::cc('30349040317708', array('diners'))); - $this->assertTrue(Validation::cc('36567413559978', array('diners'))); - $this->assertTrue(Validation::cc('36051554732702', array('diners'))); - $this->assertTrue(Validation::cc('30391842198191', array('diners'))); - $this->assertTrue(Validation::cc('30172682197745', array('diners'))); - $this->assertTrue(Validation::cc('30162056566641', array('diners'))); - $this->assertTrue(Validation::cc('30085066927745', array('diners'))); - $this->assertTrue(Validation::cc('36519025221976', array('diners'))); - $this->assertTrue(Validation::cc('30372679371044', array('diners'))); - $this->assertTrue(Validation::cc('38913939150124', array('diners'))); - $this->assertTrue(Validation::cc('36852899094637', array('diners'))); - $this->assertTrue(Validation::cc('30138041971120', array('diners'))); - $this->assertTrue(Validation::cc('36184047836838', array('diners'))); - $this->assertTrue(Validation::cc('30057460264462', array('diners'))); - $this->assertTrue(Validation::cc('38980165212050', array('diners'))); - $this->assertTrue(Validation::cc('30356516881240', array('diners'))); - $this->assertTrue(Validation::cc('38744810033182', array('diners'))); - $this->assertTrue(Validation::cc('30173638706621', array('diners'))); - $this->assertTrue(Validation::cc('30158334709185', array('diners'))); - $this->assertTrue(Validation::cc('30195413721186', array('diners'))); - $this->assertTrue(Validation::cc('38863347694793', array('diners'))); - $this->assertTrue(Validation::cc('30275627009113', array('diners'))); - $this->assertTrue(Validation::cc('30242860404971', array('diners'))); - $this->assertTrue(Validation::cc('30081877595151', array('diners'))); - $this->assertTrue(Validation::cc('38053196067461', array('diners'))); - $this->assertTrue(Validation::cc('36520379984870', array('diners'))); + $this->assertTrue(Validation::cc('30155483651028', ['diners'])); + $this->assertTrue(Validation::cc('36371312803821', ['diners'])); + $this->assertTrue(Validation::cc('38801277489875', ['diners'])); + $this->assertTrue(Validation::cc('30348560464296', ['diners'])); + $this->assertTrue(Validation::cc('30349040317708', ['diners'])); + $this->assertTrue(Validation::cc('36567413559978', ['diners'])); + $this->assertTrue(Validation::cc('36051554732702', ['diners'])); + $this->assertTrue(Validation::cc('30391842198191', ['diners'])); + $this->assertTrue(Validation::cc('30172682197745', ['diners'])); + $this->assertTrue(Validation::cc('30162056566641', ['diners'])); + $this->assertTrue(Validation::cc('30085066927745', ['diners'])); + $this->assertTrue(Validation::cc('36519025221976', ['diners'])); + $this->assertTrue(Validation::cc('30372679371044', ['diners'])); + $this->assertTrue(Validation::cc('38913939150124', ['diners'])); + $this->assertTrue(Validation::cc('36852899094637', ['diners'])); + $this->assertTrue(Validation::cc('30138041971120', ['diners'])); + $this->assertTrue(Validation::cc('36184047836838', ['diners'])); + $this->assertTrue(Validation::cc('30057460264462', ['diners'])); + $this->assertTrue(Validation::cc('38980165212050', ['diners'])); + $this->assertTrue(Validation::cc('30356516881240', ['diners'])); + $this->assertTrue(Validation::cc('38744810033182', ['diners'])); + $this->assertTrue(Validation::cc('30173638706621', ['diners'])); + $this->assertTrue(Validation::cc('30158334709185', ['diners'])); + $this->assertTrue(Validation::cc('30195413721186', ['diners'])); + $this->assertTrue(Validation::cc('38863347694793', ['diners'])); + $this->assertTrue(Validation::cc('30275627009113', ['diners'])); + $this->assertTrue(Validation::cc('30242860404971', ['diners'])); + $this->assertTrue(Validation::cc('30081877595151', ['diners'])); + $this->assertTrue(Validation::cc('38053196067461', ['diners'])); + $this->assertTrue(Validation::cc('36520379984870', ['diners'])); //2004 MasterCard/Diners Club Alliance International 14 - $this->assertTrue(Validation::cc('36747701998969', array('diners'))); - $this->assertTrue(Validation::cc('36427861123159', array('diners'))); - $this->assertTrue(Validation::cc('36150537602386', array('diners'))); - $this->assertTrue(Validation::cc('36582388820610', array('diners'))); - $this->assertTrue(Validation::cc('36729045250216', array('diners'))); + $this->assertTrue(Validation::cc('36747701998969', ['diners'])); + $this->assertTrue(Validation::cc('36427861123159', ['diners'])); + $this->assertTrue(Validation::cc('36150537602386', ['diners'])); + $this->assertTrue(Validation::cc('36582388820610', ['diners'])); + $this->assertTrue(Validation::cc('36729045250216', ['diners'])); //2004 MasterCard/Diners Club Alliance US & Canada 16 - $this->assertTrue(Validation::cc('5597511346169950', array('diners'))); - $this->assertTrue(Validation::cc('5526443162217562', array('diners'))); - $this->assertTrue(Validation::cc('5577265786122391', array('diners'))); - $this->assertTrue(Validation::cc('5534061404676989', array('diners'))); - $this->assertTrue(Validation::cc('5545313588374502', array('diners'))); + $this->assertTrue(Validation::cc('5597511346169950', ['diners'])); + $this->assertTrue(Validation::cc('5526443162217562', ['diners'])); + $this->assertTrue(Validation::cc('5577265786122391', ['diners'])); + $this->assertTrue(Validation::cc('5534061404676989', ['diners'])); + $this->assertTrue(Validation::cc('5545313588374502', ['diners'])); //Discover - $this->assertTrue(Validation::cc('6011802876467237', array('disc'))); - $this->assertTrue(Validation::cc('6506432777720955', array('disc'))); - $this->assertTrue(Validation::cc('6011126265283942', array('disc'))); - $this->assertTrue(Validation::cc('6502187151579252', array('disc'))); - $this->assertTrue(Validation::cc('6506600836002298', array('disc'))); - $this->assertTrue(Validation::cc('6504376463615189', array('disc'))); - $this->assertTrue(Validation::cc('6011440907005377', array('disc'))); - $this->assertTrue(Validation::cc('6509735979634270', array('disc'))); - $this->assertTrue(Validation::cc('6011422366775856', array('disc'))); - $this->assertTrue(Validation::cc('6500976374623323', array('disc'))); + $this->assertTrue(Validation::cc('6011802876467237', ['disc'])); + $this->assertTrue(Validation::cc('6506432777720955', ['disc'])); + $this->assertTrue(Validation::cc('6011126265283942', ['disc'])); + $this->assertTrue(Validation::cc('6502187151579252', ['disc'])); + $this->assertTrue(Validation::cc('6506600836002298', ['disc'])); + $this->assertTrue(Validation::cc('6504376463615189', ['disc'])); + $this->assertTrue(Validation::cc('6011440907005377', ['disc'])); + $this->assertTrue(Validation::cc('6509735979634270', ['disc'])); + $this->assertTrue(Validation::cc('6011422366775856', ['disc'])); + $this->assertTrue(Validation::cc('6500976374623323', ['disc'])); //enRoute - $this->assertTrue(Validation::cc('201496944158937', array('enroute'))); - $this->assertTrue(Validation::cc('214945833739665', array('enroute'))); - $this->assertTrue(Validation::cc('214982692491187', array('enroute'))); - $this->assertTrue(Validation::cc('214901395949424', array('enroute'))); - $this->assertTrue(Validation::cc('201480676269187', array('enroute'))); - $this->assertTrue(Validation::cc('214911922887807', array('enroute'))); - $this->assertTrue(Validation::cc('201485025457250', array('enroute'))); - $this->assertTrue(Validation::cc('201402662758866', array('enroute'))); - $this->assertTrue(Validation::cc('214981579370225', array('enroute'))); - $this->assertTrue(Validation::cc('201447595859877', array('enroute'))); + $this->assertTrue(Validation::cc('201496944158937', ['enroute'])); + $this->assertTrue(Validation::cc('214945833739665', ['enroute'])); + $this->assertTrue(Validation::cc('214982692491187', ['enroute'])); + $this->assertTrue(Validation::cc('214901395949424', ['enroute'])); + $this->assertTrue(Validation::cc('201480676269187', ['enroute'])); + $this->assertTrue(Validation::cc('214911922887807', ['enroute'])); + $this->assertTrue(Validation::cc('201485025457250', ['enroute'])); + $this->assertTrue(Validation::cc('201402662758866', ['enroute'])); + $this->assertTrue(Validation::cc('214981579370225', ['enroute'])); + $this->assertTrue(Validation::cc('201447595859877', ['enroute'])); //JCB 15 digit - $this->assertTrue(Validation::cc('213134762247898', array('jcb'))); - $this->assertTrue(Validation::cc('180078671678892', array('jcb'))); - $this->assertTrue(Validation::cc('180010559353736', array('jcb'))); - $this->assertTrue(Validation::cc('213195474464253', array('jcb'))); - $this->assertTrue(Validation::cc('213106675562183', array('jcb'))); - $this->assertTrue(Validation::cc('213163299662667', array('jcb'))); - $this->assertTrue(Validation::cc('180032506857825', array('jcb'))); - $this->assertTrue(Validation::cc('213157919192733', array('jcb'))); - $this->assertTrue(Validation::cc('180031358949367', array('jcb'))); - $this->assertTrue(Validation::cc('180033802147846', array('jcb'))); + $this->assertTrue(Validation::cc('213134762247898', ['jcb'])); + $this->assertTrue(Validation::cc('180078671678892', ['jcb'])); + $this->assertTrue(Validation::cc('180010559353736', ['jcb'])); + $this->assertTrue(Validation::cc('213195474464253', ['jcb'])); + $this->assertTrue(Validation::cc('213106675562183', ['jcb'])); + $this->assertTrue(Validation::cc('213163299662667', ['jcb'])); + $this->assertTrue(Validation::cc('180032506857825', ['jcb'])); + $this->assertTrue(Validation::cc('213157919192733', ['jcb'])); + $this->assertTrue(Validation::cc('180031358949367', ['jcb'])); + $this->assertTrue(Validation::cc('180033802147846', ['jcb'])); //JCB 16 digit - $this->assertTrue(Validation::cc('3096806857839939', array('jcb'))); - $this->assertTrue(Validation::cc('3158699503187091', array('jcb'))); - $this->assertTrue(Validation::cc('3112549607186579', array('jcb'))); - $this->assertTrue(Validation::cc('3112332922425604', array('jcb'))); - $this->assertTrue(Validation::cc('3112001541159239', array('jcb'))); - $this->assertTrue(Validation::cc('3112162495317841', array('jcb'))); - $this->assertTrue(Validation::cc('3337562627732768', array('jcb'))); - $this->assertTrue(Validation::cc('3337107161330775', array('jcb'))); - $this->assertTrue(Validation::cc('3528053736003621', array('jcb'))); - $this->assertTrue(Validation::cc('3528915255020360', array('jcb'))); - $this->assertTrue(Validation::cc('3096786059660921', array('jcb'))); - $this->assertTrue(Validation::cc('3528264799292320', array('jcb'))); - $this->assertTrue(Validation::cc('3096469164130136', array('jcb'))); - $this->assertTrue(Validation::cc('3112127443822853', array('jcb'))); - $this->assertTrue(Validation::cc('3096849995802328', array('jcb'))); - $this->assertTrue(Validation::cc('3528090735127407', array('jcb'))); - $this->assertTrue(Validation::cc('3112101006819234', array('jcb'))); - $this->assertTrue(Validation::cc('3337444428040784', array('jcb'))); - $this->assertTrue(Validation::cc('3088043154151061', array('jcb'))); - $this->assertTrue(Validation::cc('3088295969414866', array('jcb'))); - $this->assertTrue(Validation::cc('3158748843158575', array('jcb'))); - $this->assertTrue(Validation::cc('3158709206148538', array('jcb'))); - $this->assertTrue(Validation::cc('3158365159575324', array('jcb'))); - $this->assertTrue(Validation::cc('3158671691305165', array('jcb'))); - $this->assertTrue(Validation::cc('3528523028771093', array('jcb'))); - $this->assertTrue(Validation::cc('3096057126267870', array('jcb'))); - $this->assertTrue(Validation::cc('3158514047166834', array('jcb'))); - $this->assertTrue(Validation::cc('3528274546125962', array('jcb'))); - $this->assertTrue(Validation::cc('3528890967705733', array('jcb'))); - $this->assertTrue(Validation::cc('3337198811307545', array('jcb'))); + $this->assertTrue(Validation::cc('3096806857839939', ['jcb'])); + $this->assertTrue(Validation::cc('3158699503187091', ['jcb'])); + $this->assertTrue(Validation::cc('3112549607186579', ['jcb'])); + $this->assertTrue(Validation::cc('3112332922425604', ['jcb'])); + $this->assertTrue(Validation::cc('3112001541159239', ['jcb'])); + $this->assertTrue(Validation::cc('3112162495317841', ['jcb'])); + $this->assertTrue(Validation::cc('3337562627732768', ['jcb'])); + $this->assertTrue(Validation::cc('3337107161330775', ['jcb'])); + $this->assertTrue(Validation::cc('3528053736003621', ['jcb'])); + $this->assertTrue(Validation::cc('3528915255020360', ['jcb'])); + $this->assertTrue(Validation::cc('3096786059660921', ['jcb'])); + $this->assertTrue(Validation::cc('3528264799292320', ['jcb'])); + $this->assertTrue(Validation::cc('3096469164130136', ['jcb'])); + $this->assertTrue(Validation::cc('3112127443822853', ['jcb'])); + $this->assertTrue(Validation::cc('3096849995802328', ['jcb'])); + $this->assertTrue(Validation::cc('3528090735127407', ['jcb'])); + $this->assertTrue(Validation::cc('3112101006819234', ['jcb'])); + $this->assertTrue(Validation::cc('3337444428040784', ['jcb'])); + $this->assertTrue(Validation::cc('3088043154151061', ['jcb'])); + $this->assertTrue(Validation::cc('3088295969414866', ['jcb'])); + $this->assertTrue(Validation::cc('3158748843158575', ['jcb'])); + $this->assertTrue(Validation::cc('3158709206148538', ['jcb'])); + $this->assertTrue(Validation::cc('3158365159575324', ['jcb'])); + $this->assertTrue(Validation::cc('3158671691305165', ['jcb'])); + $this->assertTrue(Validation::cc('3528523028771093', ['jcb'])); + $this->assertTrue(Validation::cc('3096057126267870', ['jcb'])); + $this->assertTrue(Validation::cc('3158514047166834', ['jcb'])); + $this->assertTrue(Validation::cc('3528274546125962', ['jcb'])); + $this->assertTrue(Validation::cc('3528890967705733', ['jcb'])); + $this->assertTrue(Validation::cc('3337198811307545', ['jcb'])); //Maestro (debit card) - $this->assertTrue(Validation::cc('5020147409985219', array('maestro'))); - $this->assertTrue(Validation::cc('5020931809905616', array('maestro'))); - $this->assertTrue(Validation::cc('5020412965470224', array('maestro'))); - $this->assertTrue(Validation::cc('5020129740944022', array('maestro'))); - $this->assertTrue(Validation::cc('5020024696747943', array('maestro'))); - $this->assertTrue(Validation::cc('5020581514636509', array('maestro'))); - $this->assertTrue(Validation::cc('5020695008411987', array('maestro'))); - $this->assertTrue(Validation::cc('5020565359718977', array('maestro'))); - $this->assertTrue(Validation::cc('6339931536544062', array('maestro'))); - $this->assertTrue(Validation::cc('6465028615704406', array('maestro'))); + $this->assertTrue(Validation::cc('5020147409985219', ['maestro'])); + $this->assertTrue(Validation::cc('5020931809905616', ['maestro'])); + $this->assertTrue(Validation::cc('5020412965470224', ['maestro'])); + $this->assertTrue(Validation::cc('5020129740944022', ['maestro'])); + $this->assertTrue(Validation::cc('5020024696747943', ['maestro'])); + $this->assertTrue(Validation::cc('5020581514636509', ['maestro'])); + $this->assertTrue(Validation::cc('5020695008411987', ['maestro'])); + $this->assertTrue(Validation::cc('5020565359718977', ['maestro'])); + $this->assertTrue(Validation::cc('6339931536544062', ['maestro'])); + $this->assertTrue(Validation::cc('6465028615704406', ['maestro'])); //Mastercard - $this->assertTrue(Validation::cc('5580424361774366', array('mc'))); - $this->assertTrue(Validation::cc('5589563059318282', array('mc'))); - $this->assertTrue(Validation::cc('5387558333690047', array('mc'))); - $this->assertTrue(Validation::cc('5163919215247175', array('mc'))); - $this->assertTrue(Validation::cc('5386742685055055', array('mc'))); - $this->assertTrue(Validation::cc('5102303335960674', array('mc'))); - $this->assertTrue(Validation::cc('5526543403964565', array('mc'))); - $this->assertTrue(Validation::cc('5538725892618432', array('mc'))); - $this->assertTrue(Validation::cc('5119543573129778', array('mc'))); - $this->assertTrue(Validation::cc('5391174753915767', array('mc'))); - $this->assertTrue(Validation::cc('5510994113980714', array('mc'))); - $this->assertTrue(Validation::cc('5183720260418091', array('mc'))); - $this->assertTrue(Validation::cc('5488082196086704', array('mc'))); - $this->assertTrue(Validation::cc('5484645164161834', array('mc'))); - $this->assertTrue(Validation::cc('5171254350337031', array('mc'))); - $this->assertTrue(Validation::cc('5526987528136452', array('mc'))); - $this->assertTrue(Validation::cc('5504148941409358', array('mc'))); - $this->assertTrue(Validation::cc('5240793507243615', array('mc'))); - $this->assertTrue(Validation::cc('5162114693017107', array('mc'))); - $this->assertTrue(Validation::cc('5163104807404753', array('mc'))); - $this->assertTrue(Validation::cc('5590136167248365', array('mc'))); - $this->assertTrue(Validation::cc('5565816281038948', array('mc'))); - $this->assertTrue(Validation::cc('5467639122779531', array('mc'))); - $this->assertTrue(Validation::cc('5297350261550024', array('mc'))); - $this->assertTrue(Validation::cc('5162739131368058', array('mc'))); + $this->assertTrue(Validation::cc('5580424361774366', ['mc'])); + $this->assertTrue(Validation::cc('5589563059318282', ['mc'])); + $this->assertTrue(Validation::cc('5387558333690047', ['mc'])); + $this->assertTrue(Validation::cc('5163919215247175', ['mc'])); + $this->assertTrue(Validation::cc('5386742685055055', ['mc'])); + $this->assertTrue(Validation::cc('5102303335960674', ['mc'])); + $this->assertTrue(Validation::cc('5526543403964565', ['mc'])); + $this->assertTrue(Validation::cc('5538725892618432', ['mc'])); + $this->assertTrue(Validation::cc('5119543573129778', ['mc'])); + $this->assertTrue(Validation::cc('5391174753915767', ['mc'])); + $this->assertTrue(Validation::cc('5510994113980714', ['mc'])); + $this->assertTrue(Validation::cc('5183720260418091', ['mc'])); + $this->assertTrue(Validation::cc('5488082196086704', ['mc'])); + $this->assertTrue(Validation::cc('5484645164161834', ['mc'])); + $this->assertTrue(Validation::cc('5171254350337031', ['mc'])); + $this->assertTrue(Validation::cc('5526987528136452', ['mc'])); + $this->assertTrue(Validation::cc('5504148941409358', ['mc'])); + $this->assertTrue(Validation::cc('5240793507243615', ['mc'])); + $this->assertTrue(Validation::cc('5162114693017107', ['mc'])); + $this->assertTrue(Validation::cc('5163104807404753', ['mc'])); + $this->assertTrue(Validation::cc('5590136167248365', ['mc'])); + $this->assertTrue(Validation::cc('5565816281038948', ['mc'])); + $this->assertTrue(Validation::cc('5467639122779531', ['mc'])); + $this->assertTrue(Validation::cc('5297350261550024', ['mc'])); + $this->assertTrue(Validation::cc('5162739131368058', ['mc'])); //Mastercard (additional 2016 BIN) - $this->assertTrue(Validation::cc('2221000000000009', array('mc'))); - $this->assertTrue(Validation::cc('2720999999999996', array('mc'))); - $this->assertTrue(Validation::cc('2223000010005798', array('mc'))); - $this->assertTrue(Validation::cc('2623430710235708', array('mc'))); - $this->assertTrue(Validation::cc('2420452519835723', array('mc'))); + $this->assertTrue(Validation::cc('2221000000000009', ['mc'])); + $this->assertTrue(Validation::cc('2720999999999996', ['mc'])); + $this->assertTrue(Validation::cc('2223000010005798', ['mc'])); + $this->assertTrue(Validation::cc('2623430710235708', ['mc'])); + $this->assertTrue(Validation::cc('2420452519835723', ['mc'])); //Solo 16 - $this->assertTrue(Validation::cc('6767432107064987', array('solo'))); - $this->assertTrue(Validation::cc('6334667758225411', array('solo'))); - $this->assertTrue(Validation::cc('6767037421954068', array('solo'))); - $this->assertTrue(Validation::cc('6767823306394854', array('solo'))); - $this->assertTrue(Validation::cc('6334768185398134', array('solo'))); - $this->assertTrue(Validation::cc('6767286729498589', array('solo'))); - $this->assertTrue(Validation::cc('6334972104431261', array('solo'))); - $this->assertTrue(Validation::cc('6334843427400616', array('solo'))); - $this->assertTrue(Validation::cc('6767493947881311', array('solo'))); - $this->assertTrue(Validation::cc('6767194235798817', array('solo'))); + $this->assertTrue(Validation::cc('6767432107064987', ['solo'])); + $this->assertTrue(Validation::cc('6334667758225411', ['solo'])); + $this->assertTrue(Validation::cc('6767037421954068', ['solo'])); + $this->assertTrue(Validation::cc('6767823306394854', ['solo'])); + $this->assertTrue(Validation::cc('6334768185398134', ['solo'])); + $this->assertTrue(Validation::cc('6767286729498589', ['solo'])); + $this->assertTrue(Validation::cc('6334972104431261', ['solo'])); + $this->assertTrue(Validation::cc('6334843427400616', ['solo'])); + $this->assertTrue(Validation::cc('6767493947881311', ['solo'])); + $this->assertTrue(Validation::cc('6767194235798817', ['solo'])); //Solo 18 - $this->assertTrue(Validation::cc('676714834398858593', array('solo'))); - $this->assertTrue(Validation::cc('676751666435130857', array('solo'))); - $this->assertTrue(Validation::cc('676781908573924236', array('solo'))); - $this->assertTrue(Validation::cc('633488724644003240', array('solo'))); - $this->assertTrue(Validation::cc('676732252338067316', array('solo'))); - $this->assertTrue(Validation::cc('676747520084495821', array('solo'))); - $this->assertTrue(Validation::cc('633465488901381957', array('solo'))); - $this->assertTrue(Validation::cc('633487484858610484', array('solo'))); - $this->assertTrue(Validation::cc('633453764680740694', array('solo'))); - $this->assertTrue(Validation::cc('676768613295414451', array('solo'))); + $this->assertTrue(Validation::cc('676714834398858593', ['solo'])); + $this->assertTrue(Validation::cc('676751666435130857', ['solo'])); + $this->assertTrue(Validation::cc('676781908573924236', ['solo'])); + $this->assertTrue(Validation::cc('633488724644003240', ['solo'])); + $this->assertTrue(Validation::cc('676732252338067316', ['solo'])); + $this->assertTrue(Validation::cc('676747520084495821', ['solo'])); + $this->assertTrue(Validation::cc('633465488901381957', ['solo'])); + $this->assertTrue(Validation::cc('633487484858610484', ['solo'])); + $this->assertTrue(Validation::cc('633453764680740694', ['solo'])); + $this->assertTrue(Validation::cc('676768613295414451', ['solo'])); //Solo 19 - $this->assertTrue(Validation::cc('6767838565218340113', array('solo'))); - $this->assertTrue(Validation::cc('6767760119829705181', array('solo'))); - $this->assertTrue(Validation::cc('6767265917091593668', array('solo'))); - $this->assertTrue(Validation::cc('6767938856947440111', array('solo'))); - $this->assertTrue(Validation::cc('6767501945697390076', array('solo'))); - $this->assertTrue(Validation::cc('6334902868716257379', array('solo'))); - $this->assertTrue(Validation::cc('6334922127686425532', array('solo'))); - $this->assertTrue(Validation::cc('6334933119080706440', array('solo'))); - $this->assertTrue(Validation::cc('6334647959628261714', array('solo'))); - $this->assertTrue(Validation::cc('6334527312384101382', array('solo'))); + $this->assertTrue(Validation::cc('6767838565218340113', ['solo'])); + $this->assertTrue(Validation::cc('6767760119829705181', ['solo'])); + $this->assertTrue(Validation::cc('6767265917091593668', ['solo'])); + $this->assertTrue(Validation::cc('6767938856947440111', ['solo'])); + $this->assertTrue(Validation::cc('6767501945697390076', ['solo'])); + $this->assertTrue(Validation::cc('6334902868716257379', ['solo'])); + $this->assertTrue(Validation::cc('6334922127686425532', ['solo'])); + $this->assertTrue(Validation::cc('6334933119080706440', ['solo'])); + $this->assertTrue(Validation::cc('6334647959628261714', ['solo'])); + $this->assertTrue(Validation::cc('6334527312384101382', ['solo'])); //Switch 16 - $this->assertTrue(Validation::cc('5641829171515733', array('switch'))); - $this->assertTrue(Validation::cc('5641824852820809', array('switch'))); - $this->assertTrue(Validation::cc('6759129648956909', array('switch'))); - $this->assertTrue(Validation::cc('6759626072268156', array('switch'))); - $this->assertTrue(Validation::cc('5641822698388957', array('switch'))); - $this->assertTrue(Validation::cc('5641827123105470', array('switch'))); - $this->assertTrue(Validation::cc('5641823755819553', array('switch'))); - $this->assertTrue(Validation::cc('5641821939587682', array('switch'))); - $this->assertTrue(Validation::cc('4936097148079186', array('switch'))); - $this->assertTrue(Validation::cc('5641829739125009', array('switch'))); - $this->assertTrue(Validation::cc('5641822860725507', array('switch'))); - $this->assertTrue(Validation::cc('4936717688865831', array('switch'))); - $this->assertTrue(Validation::cc('6759487613615441', array('switch'))); - $this->assertTrue(Validation::cc('5641821346840617', array('switch'))); - $this->assertTrue(Validation::cc('5641825793417126', array('switch'))); - $this->assertTrue(Validation::cc('5641821302759595', array('switch'))); - $this->assertTrue(Validation::cc('6759784969918837', array('switch'))); - $this->assertTrue(Validation::cc('5641824910667036', array('switch'))); - $this->assertTrue(Validation::cc('6759139909636173', array('switch'))); - $this->assertTrue(Validation::cc('6333425070638022', array('switch'))); - $this->assertTrue(Validation::cc('5641823910382067', array('switch'))); - $this->assertTrue(Validation::cc('4936295218139423', array('switch'))); - $this->assertTrue(Validation::cc('6333031811316199', array('switch'))); - $this->assertTrue(Validation::cc('4936912044763198', array('switch'))); - $this->assertTrue(Validation::cc('4936387053303824', array('switch'))); - $this->assertTrue(Validation::cc('6759535838760523', array('switch'))); - $this->assertTrue(Validation::cc('6333427174594051', array('switch'))); - $this->assertTrue(Validation::cc('5641829037102700', array('switch'))); - $this->assertTrue(Validation::cc('5641826495463046', array('switch'))); - $this->assertTrue(Validation::cc('6333480852979946', array('switch'))); - $this->assertTrue(Validation::cc('5641827761302876', array('switch'))); - $this->assertTrue(Validation::cc('5641825083505317', array('switch'))); - $this->assertTrue(Validation::cc('6759298096003991', array('switch'))); - $this->assertTrue(Validation::cc('4936119165483420', array('switch'))); - $this->assertTrue(Validation::cc('4936190990500993', array('switch'))); - $this->assertTrue(Validation::cc('4903356467384927', array('switch'))); - $this->assertTrue(Validation::cc('6333372765092554', array('switch'))); - $this->assertTrue(Validation::cc('5641821330950570', array('switch'))); - $this->assertTrue(Validation::cc('6759841558826118', array('switch'))); - $this->assertTrue(Validation::cc('4936164540922452', array('switch'))); + $this->assertTrue(Validation::cc('5641829171515733', ['switch'])); + $this->assertTrue(Validation::cc('5641824852820809', ['switch'])); + $this->assertTrue(Validation::cc('6759129648956909', ['switch'])); + $this->assertTrue(Validation::cc('6759626072268156', ['switch'])); + $this->assertTrue(Validation::cc('5641822698388957', ['switch'])); + $this->assertTrue(Validation::cc('5641827123105470', ['switch'])); + $this->assertTrue(Validation::cc('5641823755819553', ['switch'])); + $this->assertTrue(Validation::cc('5641821939587682', ['switch'])); + $this->assertTrue(Validation::cc('4936097148079186', ['switch'])); + $this->assertTrue(Validation::cc('5641829739125009', ['switch'])); + $this->assertTrue(Validation::cc('5641822860725507', ['switch'])); + $this->assertTrue(Validation::cc('4936717688865831', ['switch'])); + $this->assertTrue(Validation::cc('6759487613615441', ['switch'])); + $this->assertTrue(Validation::cc('5641821346840617', ['switch'])); + $this->assertTrue(Validation::cc('5641825793417126', ['switch'])); + $this->assertTrue(Validation::cc('5641821302759595', ['switch'])); + $this->assertTrue(Validation::cc('6759784969918837', ['switch'])); + $this->assertTrue(Validation::cc('5641824910667036', ['switch'])); + $this->assertTrue(Validation::cc('6759139909636173', ['switch'])); + $this->assertTrue(Validation::cc('6333425070638022', ['switch'])); + $this->assertTrue(Validation::cc('5641823910382067', ['switch'])); + $this->assertTrue(Validation::cc('4936295218139423', ['switch'])); + $this->assertTrue(Validation::cc('6333031811316199', ['switch'])); + $this->assertTrue(Validation::cc('4936912044763198', ['switch'])); + $this->assertTrue(Validation::cc('4936387053303824', ['switch'])); + $this->assertTrue(Validation::cc('6759535838760523', ['switch'])); + $this->assertTrue(Validation::cc('6333427174594051', ['switch'])); + $this->assertTrue(Validation::cc('5641829037102700', ['switch'])); + $this->assertTrue(Validation::cc('5641826495463046', ['switch'])); + $this->assertTrue(Validation::cc('6333480852979946', ['switch'])); + $this->assertTrue(Validation::cc('5641827761302876', ['switch'])); + $this->assertTrue(Validation::cc('5641825083505317', ['switch'])); + $this->assertTrue(Validation::cc('6759298096003991', ['switch'])); + $this->assertTrue(Validation::cc('4936119165483420', ['switch'])); + $this->assertTrue(Validation::cc('4936190990500993', ['switch'])); + $this->assertTrue(Validation::cc('4903356467384927', ['switch'])); + $this->assertTrue(Validation::cc('6333372765092554', ['switch'])); + $this->assertTrue(Validation::cc('5641821330950570', ['switch'])); + $this->assertTrue(Validation::cc('6759841558826118', ['switch'])); + $this->assertTrue(Validation::cc('4936164540922452', ['switch'])); //Switch 18 - $this->assertTrue(Validation::cc('493622764224625174', array('switch'))); - $this->assertTrue(Validation::cc('564182823396913535', array('switch'))); - $this->assertTrue(Validation::cc('675917308304801234', array('switch'))); - $this->assertTrue(Validation::cc('675919890024220298', array('switch'))); - $this->assertTrue(Validation::cc('633308376862556751', array('switch'))); - $this->assertTrue(Validation::cc('564182377633208779', array('switch'))); - $this->assertTrue(Validation::cc('564182870014926787', array('switch'))); - $this->assertTrue(Validation::cc('675979788553829819', array('switch'))); - $this->assertTrue(Validation::cc('493668394358130935', array('switch'))); - $this->assertTrue(Validation::cc('493637431790930965', array('switch'))); - $this->assertTrue(Validation::cc('633321438601941513', array('switch'))); - $this->assertTrue(Validation::cc('675913800898840986', array('switch'))); - $this->assertTrue(Validation::cc('564182592016841547', array('switch'))); - $this->assertTrue(Validation::cc('564182428380440899', array('switch'))); - $this->assertTrue(Validation::cc('493696376827623463', array('switch'))); - $this->assertTrue(Validation::cc('675977939286485757', array('switch'))); - $this->assertTrue(Validation::cc('490302699502091579', array('switch'))); - $this->assertTrue(Validation::cc('564182085013662230', array('switch'))); - $this->assertTrue(Validation::cc('493693054263310167', array('switch'))); - $this->assertTrue(Validation::cc('633321755966697525', array('switch'))); - $this->assertTrue(Validation::cc('675996851719732811', array('switch'))); - $this->assertTrue(Validation::cc('493699211208281028', array('switch'))); - $this->assertTrue(Validation::cc('493697817378356614', array('switch'))); - $this->assertTrue(Validation::cc('675968224161768150', array('switch'))); - $this->assertTrue(Validation::cc('493669416873337627', array('switch'))); - $this->assertTrue(Validation::cc('564182439172549714', array('switch'))); - $this->assertTrue(Validation::cc('675926914467673598', array('switch'))); - $this->assertTrue(Validation::cc('564182565231977809', array('switch'))); - $this->assertTrue(Validation::cc('675966282607849002', array('switch'))); - $this->assertTrue(Validation::cc('493691609704348548', array('switch'))); - $this->assertTrue(Validation::cc('675933118546065120', array('switch'))); - $this->assertTrue(Validation::cc('493631116677238592', array('switch'))); - $this->assertTrue(Validation::cc('675921142812825938', array('switch'))); - $this->assertTrue(Validation::cc('633338311815675113', array('switch'))); - $this->assertTrue(Validation::cc('633323539867338621', array('switch'))); - $this->assertTrue(Validation::cc('675964912740845663', array('switch'))); - $this->assertTrue(Validation::cc('633334008833727504', array('switch'))); - $this->assertTrue(Validation::cc('493631941273687169', array('switch'))); - $this->assertTrue(Validation::cc('564182971729706785', array('switch'))); - $this->assertTrue(Validation::cc('633303461188963496', array('switch'))); + $this->assertTrue(Validation::cc('493622764224625174', ['switch'])); + $this->assertTrue(Validation::cc('564182823396913535', ['switch'])); + $this->assertTrue(Validation::cc('675917308304801234', ['switch'])); + $this->assertTrue(Validation::cc('675919890024220298', ['switch'])); + $this->assertTrue(Validation::cc('633308376862556751', ['switch'])); + $this->assertTrue(Validation::cc('564182377633208779', ['switch'])); + $this->assertTrue(Validation::cc('564182870014926787', ['switch'])); + $this->assertTrue(Validation::cc('675979788553829819', ['switch'])); + $this->assertTrue(Validation::cc('493668394358130935', ['switch'])); + $this->assertTrue(Validation::cc('493637431790930965', ['switch'])); + $this->assertTrue(Validation::cc('633321438601941513', ['switch'])); + $this->assertTrue(Validation::cc('675913800898840986', ['switch'])); + $this->assertTrue(Validation::cc('564182592016841547', ['switch'])); + $this->assertTrue(Validation::cc('564182428380440899', ['switch'])); + $this->assertTrue(Validation::cc('493696376827623463', ['switch'])); + $this->assertTrue(Validation::cc('675977939286485757', ['switch'])); + $this->assertTrue(Validation::cc('490302699502091579', ['switch'])); + $this->assertTrue(Validation::cc('564182085013662230', ['switch'])); + $this->assertTrue(Validation::cc('493693054263310167', ['switch'])); + $this->assertTrue(Validation::cc('633321755966697525', ['switch'])); + $this->assertTrue(Validation::cc('675996851719732811', ['switch'])); + $this->assertTrue(Validation::cc('493699211208281028', ['switch'])); + $this->assertTrue(Validation::cc('493697817378356614', ['switch'])); + $this->assertTrue(Validation::cc('675968224161768150', ['switch'])); + $this->assertTrue(Validation::cc('493669416873337627', ['switch'])); + $this->assertTrue(Validation::cc('564182439172549714', ['switch'])); + $this->assertTrue(Validation::cc('675926914467673598', ['switch'])); + $this->assertTrue(Validation::cc('564182565231977809', ['switch'])); + $this->assertTrue(Validation::cc('675966282607849002', ['switch'])); + $this->assertTrue(Validation::cc('493691609704348548', ['switch'])); + $this->assertTrue(Validation::cc('675933118546065120', ['switch'])); + $this->assertTrue(Validation::cc('493631116677238592', ['switch'])); + $this->assertTrue(Validation::cc('675921142812825938', ['switch'])); + $this->assertTrue(Validation::cc('633338311815675113', ['switch'])); + $this->assertTrue(Validation::cc('633323539867338621', ['switch'])); + $this->assertTrue(Validation::cc('675964912740845663', ['switch'])); + $this->assertTrue(Validation::cc('633334008833727504', ['switch'])); + $this->assertTrue(Validation::cc('493631941273687169', ['switch'])); + $this->assertTrue(Validation::cc('564182971729706785', ['switch'])); + $this->assertTrue(Validation::cc('633303461188963496', ['switch'])); //Switch 19 - $this->assertTrue(Validation::cc('6759603460617628716', array('switch'))); - $this->assertTrue(Validation::cc('4936705825268647681', array('switch'))); - $this->assertTrue(Validation::cc('5641829846600479183', array('switch'))); - $this->assertTrue(Validation::cc('6759389846573792530', array('switch'))); - $this->assertTrue(Validation::cc('4936189558712637603', array('switch'))); - $this->assertTrue(Validation::cc('5641822217393868189', array('switch'))); - $this->assertTrue(Validation::cc('4903075563780057152', array('switch'))); - $this->assertTrue(Validation::cc('4936510653566569547', array('switch'))); - $this->assertTrue(Validation::cc('4936503083627303364', array('switch'))); - $this->assertTrue(Validation::cc('4936777334398116272', array('switch'))); - $this->assertTrue(Validation::cc('5641823876900554860', array('switch'))); - $this->assertTrue(Validation::cc('6759619236903407276', array('switch'))); - $this->assertTrue(Validation::cc('6759011470269978117', array('switch'))); - $this->assertTrue(Validation::cc('6333175833997062502', array('switch'))); - $this->assertTrue(Validation::cc('6759498728789080439', array('switch'))); - $this->assertTrue(Validation::cc('4903020404168157841', array('switch'))); - $this->assertTrue(Validation::cc('6759354334874804313', array('switch'))); - $this->assertTrue(Validation::cc('6759900856420875115', array('switch'))); - $this->assertTrue(Validation::cc('5641827269346868860', array('switch'))); - $this->assertTrue(Validation::cc('5641828995047453870', array('switch'))); - $this->assertTrue(Validation::cc('6333321884754806543', array('switch'))); - $this->assertTrue(Validation::cc('6333108246283715901', array('switch'))); - $this->assertTrue(Validation::cc('6759572372800700102', array('switch'))); - $this->assertTrue(Validation::cc('4903095096797974933', array('switch'))); - $this->assertTrue(Validation::cc('6333354315797920215', array('switch'))); - $this->assertTrue(Validation::cc('6759163746089433755', array('switch'))); - $this->assertTrue(Validation::cc('6759871666634807647', array('switch'))); - $this->assertTrue(Validation::cc('5641827883728575248', array('switch'))); - $this->assertTrue(Validation::cc('4936527975051407847', array('switch'))); - $this->assertTrue(Validation::cc('5641823318396882141', array('switch'))); - $this->assertTrue(Validation::cc('6759123772311123708', array('switch'))); - $this->assertTrue(Validation::cc('4903054736148271088', array('switch'))); - $this->assertTrue(Validation::cc('4936477526808883952', array('switch'))); - $this->assertTrue(Validation::cc('4936433964890967966', array('switch'))); - $this->assertTrue(Validation::cc('6333245128906049344', array('switch'))); - $this->assertTrue(Validation::cc('4936321036970553134', array('switch'))); - $this->assertTrue(Validation::cc('4936111816358702773', array('switch'))); - $this->assertTrue(Validation::cc('4936196077254804290', array('switch'))); - $this->assertTrue(Validation::cc('6759558831206830183', array('switch'))); - $this->assertTrue(Validation::cc('5641827998830403137', array('switch'))); + $this->assertTrue(Validation::cc('6759603460617628716', ['switch'])); + $this->assertTrue(Validation::cc('4936705825268647681', ['switch'])); + $this->assertTrue(Validation::cc('5641829846600479183', ['switch'])); + $this->assertTrue(Validation::cc('6759389846573792530', ['switch'])); + $this->assertTrue(Validation::cc('4936189558712637603', ['switch'])); + $this->assertTrue(Validation::cc('5641822217393868189', ['switch'])); + $this->assertTrue(Validation::cc('4903075563780057152', ['switch'])); + $this->assertTrue(Validation::cc('4936510653566569547', ['switch'])); + $this->assertTrue(Validation::cc('4936503083627303364', ['switch'])); + $this->assertTrue(Validation::cc('4936777334398116272', ['switch'])); + $this->assertTrue(Validation::cc('5641823876900554860', ['switch'])); + $this->assertTrue(Validation::cc('6759619236903407276', ['switch'])); + $this->assertTrue(Validation::cc('6759011470269978117', ['switch'])); + $this->assertTrue(Validation::cc('6333175833997062502', ['switch'])); + $this->assertTrue(Validation::cc('6759498728789080439', ['switch'])); + $this->assertTrue(Validation::cc('4903020404168157841', ['switch'])); + $this->assertTrue(Validation::cc('6759354334874804313', ['switch'])); + $this->assertTrue(Validation::cc('6759900856420875115', ['switch'])); + $this->assertTrue(Validation::cc('5641827269346868860', ['switch'])); + $this->assertTrue(Validation::cc('5641828995047453870', ['switch'])); + $this->assertTrue(Validation::cc('6333321884754806543', ['switch'])); + $this->assertTrue(Validation::cc('6333108246283715901', ['switch'])); + $this->assertTrue(Validation::cc('6759572372800700102', ['switch'])); + $this->assertTrue(Validation::cc('4903095096797974933', ['switch'])); + $this->assertTrue(Validation::cc('6333354315797920215', ['switch'])); + $this->assertTrue(Validation::cc('6759163746089433755', ['switch'])); + $this->assertTrue(Validation::cc('6759871666634807647', ['switch'])); + $this->assertTrue(Validation::cc('5641827883728575248', ['switch'])); + $this->assertTrue(Validation::cc('4936527975051407847', ['switch'])); + $this->assertTrue(Validation::cc('5641823318396882141', ['switch'])); + $this->assertTrue(Validation::cc('6759123772311123708', ['switch'])); + $this->assertTrue(Validation::cc('4903054736148271088', ['switch'])); + $this->assertTrue(Validation::cc('4936477526808883952', ['switch'])); + $this->assertTrue(Validation::cc('4936433964890967966', ['switch'])); + $this->assertTrue(Validation::cc('6333245128906049344', ['switch'])); + $this->assertTrue(Validation::cc('4936321036970553134', ['switch'])); + $this->assertTrue(Validation::cc('4936111816358702773', ['switch'])); + $this->assertTrue(Validation::cc('4936196077254804290', ['switch'])); + $this->assertTrue(Validation::cc('6759558831206830183', ['switch'])); + $this->assertTrue(Validation::cc('5641827998830403137', ['switch'])); //VISA 13 digit - $this->assertTrue(Validation::cc('4024007174754', array('visa'))); - $this->assertTrue(Validation::cc('4104816460717', array('visa'))); - $this->assertTrue(Validation::cc('4716229700437', array('visa'))); - $this->assertTrue(Validation::cc('4539305400213', array('visa'))); - $this->assertTrue(Validation::cc('4728260558665', array('visa'))); - $this->assertTrue(Validation::cc('4929100131792', array('visa'))); - $this->assertTrue(Validation::cc('4024007117308', array('visa'))); - $this->assertTrue(Validation::cc('4539915491024', array('visa'))); - $this->assertTrue(Validation::cc('4539790901139', array('visa'))); - $this->assertTrue(Validation::cc('4485284914909', array('visa'))); - $this->assertTrue(Validation::cc('4782793022350', array('visa'))); - $this->assertTrue(Validation::cc('4556899290685', array('visa'))); - $this->assertTrue(Validation::cc('4024007134774', array('visa'))); - $this->assertTrue(Validation::cc('4333412341316', array('visa'))); - $this->assertTrue(Validation::cc('4539534204543', array('visa'))); - $this->assertTrue(Validation::cc('4485640373626', array('visa'))); - $this->assertTrue(Validation::cc('4929911445746', array('visa'))); - $this->assertTrue(Validation::cc('4539292550806', array('visa'))); - $this->assertTrue(Validation::cc('4716523014030', array('visa'))); - $this->assertTrue(Validation::cc('4024007125152', array('visa'))); - $this->assertTrue(Validation::cc('4539758883311', array('visa'))); - $this->assertTrue(Validation::cc('4024007103258', array('visa'))); - $this->assertTrue(Validation::cc('4916933155767', array('visa'))); - $this->assertTrue(Validation::cc('4024007159672', array('visa'))); - $this->assertTrue(Validation::cc('4716935544871', array('visa'))); - $this->assertTrue(Validation::cc('4929415177779', array('visa'))); - $this->assertTrue(Validation::cc('4929748547896', array('visa'))); - $this->assertTrue(Validation::cc('4929153468612', array('visa'))); - $this->assertTrue(Validation::cc('4539397132104', array('visa'))); - $this->assertTrue(Validation::cc('4485293435540', array('visa'))); - $this->assertTrue(Validation::cc('4485799412720', array('visa'))); - $this->assertTrue(Validation::cc('4916744757686', array('visa'))); - $this->assertTrue(Validation::cc('4556475655426', array('visa'))); - $this->assertTrue(Validation::cc('4539400441625', array('visa'))); - $this->assertTrue(Validation::cc('4485437129173', array('visa'))); - $this->assertTrue(Validation::cc('4716253605320', array('visa'))); - $this->assertTrue(Validation::cc('4539366156589', array('visa'))); - $this->assertTrue(Validation::cc('4916498061392', array('visa'))); - $this->assertTrue(Validation::cc('4716127163779', array('visa'))); - $this->assertTrue(Validation::cc('4024007183078', array('visa'))); - $this->assertTrue(Validation::cc('4041553279654', array('visa'))); - $this->assertTrue(Validation::cc('4532380121960', array('visa'))); - $this->assertTrue(Validation::cc('4485906062491', array('visa'))); - $this->assertTrue(Validation::cc('4539365115149', array('visa'))); - $this->assertTrue(Validation::cc('4485146516702', array('visa'))); + $this->assertTrue(Validation::cc('4024007174754', ['visa'])); + $this->assertTrue(Validation::cc('4104816460717', ['visa'])); + $this->assertTrue(Validation::cc('4716229700437', ['visa'])); + $this->assertTrue(Validation::cc('4539305400213', ['visa'])); + $this->assertTrue(Validation::cc('4728260558665', ['visa'])); + $this->assertTrue(Validation::cc('4929100131792', ['visa'])); + $this->assertTrue(Validation::cc('4024007117308', ['visa'])); + $this->assertTrue(Validation::cc('4539915491024', ['visa'])); + $this->assertTrue(Validation::cc('4539790901139', ['visa'])); + $this->assertTrue(Validation::cc('4485284914909', ['visa'])); + $this->assertTrue(Validation::cc('4782793022350', ['visa'])); + $this->assertTrue(Validation::cc('4556899290685', ['visa'])); + $this->assertTrue(Validation::cc('4024007134774', ['visa'])); + $this->assertTrue(Validation::cc('4333412341316', ['visa'])); + $this->assertTrue(Validation::cc('4539534204543', ['visa'])); + $this->assertTrue(Validation::cc('4485640373626', ['visa'])); + $this->assertTrue(Validation::cc('4929911445746', ['visa'])); + $this->assertTrue(Validation::cc('4539292550806', ['visa'])); + $this->assertTrue(Validation::cc('4716523014030', ['visa'])); + $this->assertTrue(Validation::cc('4024007125152', ['visa'])); + $this->assertTrue(Validation::cc('4539758883311', ['visa'])); + $this->assertTrue(Validation::cc('4024007103258', ['visa'])); + $this->assertTrue(Validation::cc('4916933155767', ['visa'])); + $this->assertTrue(Validation::cc('4024007159672', ['visa'])); + $this->assertTrue(Validation::cc('4716935544871', ['visa'])); + $this->assertTrue(Validation::cc('4929415177779', ['visa'])); + $this->assertTrue(Validation::cc('4929748547896', ['visa'])); + $this->assertTrue(Validation::cc('4929153468612', ['visa'])); + $this->assertTrue(Validation::cc('4539397132104', ['visa'])); + $this->assertTrue(Validation::cc('4485293435540', ['visa'])); + $this->assertTrue(Validation::cc('4485799412720', ['visa'])); + $this->assertTrue(Validation::cc('4916744757686', ['visa'])); + $this->assertTrue(Validation::cc('4556475655426', ['visa'])); + $this->assertTrue(Validation::cc('4539400441625', ['visa'])); + $this->assertTrue(Validation::cc('4485437129173', ['visa'])); + $this->assertTrue(Validation::cc('4716253605320', ['visa'])); + $this->assertTrue(Validation::cc('4539366156589', ['visa'])); + $this->assertTrue(Validation::cc('4916498061392', ['visa'])); + $this->assertTrue(Validation::cc('4716127163779', ['visa'])); + $this->assertTrue(Validation::cc('4024007183078', ['visa'])); + $this->assertTrue(Validation::cc('4041553279654', ['visa'])); + $this->assertTrue(Validation::cc('4532380121960', ['visa'])); + $this->assertTrue(Validation::cc('4485906062491', ['visa'])); + $this->assertTrue(Validation::cc('4539365115149', ['visa'])); + $this->assertTrue(Validation::cc('4485146516702', ['visa'])); //VISA 16 digit - $this->assertTrue(Validation::cc('4916375389940009', array('visa'))); - $this->assertTrue(Validation::cc('4929167481032610', array('visa'))); - $this->assertTrue(Validation::cc('4485029969061519', array('visa'))); - $this->assertTrue(Validation::cc('4485573845281759', array('visa'))); - $this->assertTrue(Validation::cc('4485669810383529', array('visa'))); - $this->assertTrue(Validation::cc('4929615806560327', array('visa'))); - $this->assertTrue(Validation::cc('4556807505609535', array('visa'))); - $this->assertTrue(Validation::cc('4532611336232890', array('visa'))); - $this->assertTrue(Validation::cc('4532201952422387', array('visa'))); - $this->assertTrue(Validation::cc('4485073797976290', array('visa'))); - $this->assertTrue(Validation::cc('4024007157580969', array('visa'))); - $this->assertTrue(Validation::cc('4053740470212274', array('visa'))); - $this->assertTrue(Validation::cc('4716265831525676', array('visa'))); - $this->assertTrue(Validation::cc('4024007100222966', array('visa'))); - $this->assertTrue(Validation::cc('4539556148303244', array('visa'))); - $this->assertTrue(Validation::cc('4532449879689709', array('visa'))); - $this->assertTrue(Validation::cc('4916805467840986', array('visa'))); - $this->assertTrue(Validation::cc('4532155644440233', array('visa'))); - $this->assertTrue(Validation::cc('4467977802223781', array('visa'))); - $this->assertTrue(Validation::cc('4539224637000686', array('visa'))); - $this->assertTrue(Validation::cc('4556629187064965', array('visa'))); - $this->assertTrue(Validation::cc('4532970205932943', array('visa'))); - $this->assertTrue(Validation::cc('4821470132041850', array('visa'))); - $this->assertTrue(Validation::cc('4916214267894485', array('visa'))); - $this->assertTrue(Validation::cc('4024007169073284', array('visa'))); - $this->assertTrue(Validation::cc('4716783351296122', array('visa'))); - $this->assertTrue(Validation::cc('4556480171913795', array('visa'))); - $this->assertTrue(Validation::cc('4929678411034997', array('visa'))); - $this->assertTrue(Validation::cc('4682061913519392', array('visa'))); - $this->assertTrue(Validation::cc('4916495481746474', array('visa'))); - $this->assertTrue(Validation::cc('4929007108460499', array('visa'))); - $this->assertTrue(Validation::cc('4539951357838586', array('visa'))); - $this->assertTrue(Validation::cc('4716482691051558', array('visa'))); - $this->assertTrue(Validation::cc('4916385069917516', array('visa'))); - $this->assertTrue(Validation::cc('4929020289494641', array('visa'))); - $this->assertTrue(Validation::cc('4532176245263774', array('visa'))); - $this->assertTrue(Validation::cc('4556242273553949', array('visa'))); - $this->assertTrue(Validation::cc('4481007485188614', array('visa'))); - $this->assertTrue(Validation::cc('4716533372139623', array('visa'))); - $this->assertTrue(Validation::cc('4929152038152632', array('visa'))); - $this->assertTrue(Validation::cc('4539404037310550', array('visa'))); - $this->assertTrue(Validation::cc('4532800925229140', array('visa'))); - $this->assertTrue(Validation::cc('4916845885268360', array('visa'))); - $this->assertTrue(Validation::cc('4394514669078434', array('visa'))); - $this->assertTrue(Validation::cc('4485611378115042', array('visa'))); + $this->assertTrue(Validation::cc('4916375389940009', ['visa'])); + $this->assertTrue(Validation::cc('4929167481032610', ['visa'])); + $this->assertTrue(Validation::cc('4485029969061519', ['visa'])); + $this->assertTrue(Validation::cc('4485573845281759', ['visa'])); + $this->assertTrue(Validation::cc('4485669810383529', ['visa'])); + $this->assertTrue(Validation::cc('4929615806560327', ['visa'])); + $this->assertTrue(Validation::cc('4556807505609535', ['visa'])); + $this->assertTrue(Validation::cc('4532611336232890', ['visa'])); + $this->assertTrue(Validation::cc('4532201952422387', ['visa'])); + $this->assertTrue(Validation::cc('4485073797976290', ['visa'])); + $this->assertTrue(Validation::cc('4024007157580969', ['visa'])); + $this->assertTrue(Validation::cc('4053740470212274', ['visa'])); + $this->assertTrue(Validation::cc('4716265831525676', ['visa'])); + $this->assertTrue(Validation::cc('4024007100222966', ['visa'])); + $this->assertTrue(Validation::cc('4539556148303244', ['visa'])); + $this->assertTrue(Validation::cc('4532449879689709', ['visa'])); + $this->assertTrue(Validation::cc('4916805467840986', ['visa'])); + $this->assertTrue(Validation::cc('4532155644440233', ['visa'])); + $this->assertTrue(Validation::cc('4467977802223781', ['visa'])); + $this->assertTrue(Validation::cc('4539224637000686', ['visa'])); + $this->assertTrue(Validation::cc('4556629187064965', ['visa'])); + $this->assertTrue(Validation::cc('4532970205932943', ['visa'])); + $this->assertTrue(Validation::cc('4821470132041850', ['visa'])); + $this->assertTrue(Validation::cc('4916214267894485', ['visa'])); + $this->assertTrue(Validation::cc('4024007169073284', ['visa'])); + $this->assertTrue(Validation::cc('4716783351296122', ['visa'])); + $this->assertTrue(Validation::cc('4556480171913795', ['visa'])); + $this->assertTrue(Validation::cc('4929678411034997', ['visa'])); + $this->assertTrue(Validation::cc('4682061913519392', ['visa'])); + $this->assertTrue(Validation::cc('4916495481746474', ['visa'])); + $this->assertTrue(Validation::cc('4929007108460499', ['visa'])); + $this->assertTrue(Validation::cc('4539951357838586', ['visa'])); + $this->assertTrue(Validation::cc('4716482691051558', ['visa'])); + $this->assertTrue(Validation::cc('4916385069917516', ['visa'])); + $this->assertTrue(Validation::cc('4929020289494641', ['visa'])); + $this->assertTrue(Validation::cc('4532176245263774', ['visa'])); + $this->assertTrue(Validation::cc('4556242273553949', ['visa'])); + $this->assertTrue(Validation::cc('4481007485188614', ['visa'])); + $this->assertTrue(Validation::cc('4716533372139623', ['visa'])); + $this->assertTrue(Validation::cc('4929152038152632', ['visa'])); + $this->assertTrue(Validation::cc('4539404037310550', ['visa'])); + $this->assertTrue(Validation::cc('4532800925229140', ['visa'])); + $this->assertTrue(Validation::cc('4916845885268360', ['visa'])); + $this->assertTrue(Validation::cc('4394514669078434', ['visa'])); + $this->assertTrue(Validation::cc('4485611378115042', ['visa'])); //Visa Electron - $this->assertTrue(Validation::cc('4175003346287100', array('electron'))); - $this->assertTrue(Validation::cc('4913042516577228', array('electron'))); - $this->assertTrue(Validation::cc('4917592325659381', array('electron'))); - $this->assertTrue(Validation::cc('4917084924450511', array('electron'))); - $this->assertTrue(Validation::cc('4917994610643999', array('electron'))); - $this->assertTrue(Validation::cc('4175005933743585', array('electron'))); - $this->assertTrue(Validation::cc('4175008373425044', array('electron'))); - $this->assertTrue(Validation::cc('4913119763664154', array('electron'))); - $this->assertTrue(Validation::cc('4913189017481812', array('electron'))); - $this->assertTrue(Validation::cc('4913085104968622', array('electron'))); - $this->assertTrue(Validation::cc('4175008803122021', array('electron'))); - $this->assertTrue(Validation::cc('4913294453962489', array('electron'))); - $this->assertTrue(Validation::cc('4175009797419290', array('electron'))); - $this->assertTrue(Validation::cc('4175005028142917', array('electron'))); - $this->assertTrue(Validation::cc('4913940802385364', array('electron'))); + $this->assertTrue(Validation::cc('4175003346287100', ['electron'])); + $this->assertTrue(Validation::cc('4913042516577228', ['electron'])); + $this->assertTrue(Validation::cc('4917592325659381', ['electron'])); + $this->assertTrue(Validation::cc('4917084924450511', ['electron'])); + $this->assertTrue(Validation::cc('4917994610643999', ['electron'])); + $this->assertTrue(Validation::cc('4175005933743585', ['electron'])); + $this->assertTrue(Validation::cc('4175008373425044', ['electron'])); + $this->assertTrue(Validation::cc('4913119763664154', ['electron'])); + $this->assertTrue(Validation::cc('4913189017481812', ['electron'])); + $this->assertTrue(Validation::cc('4913085104968622', ['electron'])); + $this->assertTrue(Validation::cc('4175008803122021', ['electron'])); + $this->assertTrue(Validation::cc('4913294453962489', ['electron'])); + $this->assertTrue(Validation::cc('4175009797419290', ['electron'])); + $this->assertTrue(Validation::cc('4175005028142917', ['electron'])); + $this->assertTrue(Validation::cc('4913940802385364', ['electron'])); //Voyager - $this->assertTrue(Validation::cc('869940697287073', array('voyager'))); - $this->assertTrue(Validation::cc('869934523596112', array('voyager'))); - $this->assertTrue(Validation::cc('869958670174621', array('voyager'))); - $this->assertTrue(Validation::cc('869921250068209', array('voyager'))); - $this->assertTrue(Validation::cc('869972521242198', array('voyager'))); + $this->assertTrue(Validation::cc('869940697287073', ['voyager'])); + $this->assertTrue(Validation::cc('869934523596112', ['voyager'])); + $this->assertTrue(Validation::cc('869958670174621', ['voyager'])); + $this->assertTrue(Validation::cc('869921250068209', ['voyager'])); + $this->assertTrue(Validation::cc('869972521242198', ['voyager'])); } /** @@ -964,18 +964,18 @@ public function testCustom() { * @return void */ public function testDateDdmmyyyy() { - $this->assertTrue(Validation::date('27-12-2006', array('dmy'))); - $this->assertTrue(Validation::date('27.12.2006', array('dmy'))); - $this->assertTrue(Validation::date('27/12/2006', array('dmy'))); - $this->assertTrue(Validation::date('27 12 2006', array('dmy'))); - $this->assertFalse(Validation::date('00-00-0000', array('dmy'))); - $this->assertFalse(Validation::date('00.00.0000', array('dmy'))); - $this->assertFalse(Validation::date('00/00/0000', array('dmy'))); - $this->assertFalse(Validation::date('00 00 0000', array('dmy'))); - $this->assertFalse(Validation::date('31-11-2006', array('dmy'))); - $this->assertFalse(Validation::date('31.11.2006', array('dmy'))); - $this->assertFalse(Validation::date('31/11/2006', array('dmy'))); - $this->assertFalse(Validation::date('31 11 2006', array('dmy'))); + $this->assertTrue(Validation::date('27-12-2006', ['dmy'])); + $this->assertTrue(Validation::date('27.12.2006', ['dmy'])); + $this->assertTrue(Validation::date('27/12/2006', ['dmy'])); + $this->assertTrue(Validation::date('27 12 2006', ['dmy'])); + $this->assertFalse(Validation::date('00-00-0000', ['dmy'])); + $this->assertFalse(Validation::date('00.00.0000', ['dmy'])); + $this->assertFalse(Validation::date('00/00/0000', ['dmy'])); + $this->assertFalse(Validation::date('00 00 0000', ['dmy'])); + $this->assertFalse(Validation::date('31-11-2006', ['dmy'])); + $this->assertFalse(Validation::date('31.11.2006', ['dmy'])); + $this->assertFalse(Validation::date('31/11/2006', ['dmy'])); + $this->assertFalse(Validation::date('31 11 2006', ['dmy'])); } /** @@ -984,14 +984,14 @@ public function testDateDdmmyyyy() { * @return void */ public function testDateDdmmyyyyLeapYear() { - $this->assertTrue(Validation::date('29-02-2004', array('dmy'))); - $this->assertTrue(Validation::date('29.02.2004', array('dmy'))); - $this->assertTrue(Validation::date('29/02/2004', array('dmy'))); - $this->assertTrue(Validation::date('29 02 2004', array('dmy'))); - $this->assertFalse(Validation::date('29-02-2006', array('dmy'))); - $this->assertFalse(Validation::date('29.02.2006', array('dmy'))); - $this->assertFalse(Validation::date('29/02/2006', array('dmy'))); - $this->assertFalse(Validation::date('29 02 2006', array('dmy'))); + $this->assertTrue(Validation::date('29-02-2004', ['dmy'])); + $this->assertTrue(Validation::date('29.02.2004', ['dmy'])); + $this->assertTrue(Validation::date('29/02/2004', ['dmy'])); + $this->assertTrue(Validation::date('29 02 2004', ['dmy'])); + $this->assertFalse(Validation::date('29-02-2006', ['dmy'])); + $this->assertFalse(Validation::date('29.02.2006', ['dmy'])); + $this->assertFalse(Validation::date('29/02/2006', ['dmy'])); + $this->assertFalse(Validation::date('29 02 2006', ['dmy'])); } /** @@ -1000,18 +1000,18 @@ public function testDateDdmmyyyyLeapYear() { * @return void */ public function testDateDdmmyy() { - $this->assertTrue(Validation::date('27-12-06', array('dmy'))); - $this->assertTrue(Validation::date('27.12.06', array('dmy'))); - $this->assertTrue(Validation::date('27/12/06', array('dmy'))); - $this->assertTrue(Validation::date('27 12 06', array('dmy'))); - $this->assertFalse(Validation::date('00-00-00', array('dmy'))); - $this->assertFalse(Validation::date('00.00.00', array('dmy'))); - $this->assertFalse(Validation::date('00/00/00', array('dmy'))); - $this->assertFalse(Validation::date('00 00 00', array('dmy'))); - $this->assertFalse(Validation::date('31-11-06', array('dmy'))); - $this->assertFalse(Validation::date('31.11.06', array('dmy'))); - $this->assertFalse(Validation::date('31/11/06', array('dmy'))); - $this->assertFalse(Validation::date('31 11 06', array('dmy'))); + $this->assertTrue(Validation::date('27-12-06', ['dmy'])); + $this->assertTrue(Validation::date('27.12.06', ['dmy'])); + $this->assertTrue(Validation::date('27/12/06', ['dmy'])); + $this->assertTrue(Validation::date('27 12 06', ['dmy'])); + $this->assertFalse(Validation::date('00-00-00', ['dmy'])); + $this->assertFalse(Validation::date('00.00.00', ['dmy'])); + $this->assertFalse(Validation::date('00/00/00', ['dmy'])); + $this->assertFalse(Validation::date('00 00 00', ['dmy'])); + $this->assertFalse(Validation::date('31-11-06', ['dmy'])); + $this->assertFalse(Validation::date('31.11.06', ['dmy'])); + $this->assertFalse(Validation::date('31/11/06', ['dmy'])); + $this->assertFalse(Validation::date('31 11 06', ['dmy'])); } /** @@ -1020,14 +1020,14 @@ public function testDateDdmmyy() { * @return void */ public function testDateDdmmyyLeapYear() { - $this->assertTrue(Validation::date('29-02-04', array('dmy'))); - $this->assertTrue(Validation::date('29.02.04', array('dmy'))); - $this->assertTrue(Validation::date('29/02/04', array('dmy'))); - $this->assertTrue(Validation::date('29 02 04', array('dmy'))); - $this->assertFalse(Validation::date('29-02-06', array('dmy'))); - $this->assertFalse(Validation::date('29.02.06', array('dmy'))); - $this->assertFalse(Validation::date('29/02/06', array('dmy'))); - $this->assertFalse(Validation::date('29 02 06', array('dmy'))); + $this->assertTrue(Validation::date('29-02-04', ['dmy'])); + $this->assertTrue(Validation::date('29.02.04', ['dmy'])); + $this->assertTrue(Validation::date('29/02/04', ['dmy'])); + $this->assertTrue(Validation::date('29 02 04', ['dmy'])); + $this->assertFalse(Validation::date('29-02-06', ['dmy'])); + $this->assertFalse(Validation::date('29.02.06', ['dmy'])); + $this->assertFalse(Validation::date('29/02/06', ['dmy'])); + $this->assertFalse(Validation::date('29 02 06', ['dmy'])); } /** @@ -1036,18 +1036,18 @@ public function testDateDdmmyyLeapYear() { * @return void */ public function testDateDmyy() { - $this->assertTrue(Validation::date('7-2-06', array('dmy'))); - $this->assertTrue(Validation::date('7.2.06', array('dmy'))); - $this->assertTrue(Validation::date('7/2/06', array('dmy'))); - $this->assertTrue(Validation::date('7 2 06', array('dmy'))); - $this->assertFalse(Validation::date('0-0-00', array('dmy'))); - $this->assertFalse(Validation::date('0.0.00', array('dmy'))); - $this->assertFalse(Validation::date('0/0/00', array('dmy'))); - $this->assertFalse(Validation::date('0 0 00', array('dmy'))); - $this->assertFalse(Validation::date('32-2-06', array('dmy'))); - $this->assertFalse(Validation::date('32.2.06', array('dmy'))); - $this->assertFalse(Validation::date('32/2/06', array('dmy'))); - $this->assertFalse(Validation::date('32 2 06', array('dmy'))); + $this->assertTrue(Validation::date('7-2-06', ['dmy'])); + $this->assertTrue(Validation::date('7.2.06', ['dmy'])); + $this->assertTrue(Validation::date('7/2/06', ['dmy'])); + $this->assertTrue(Validation::date('7 2 06', ['dmy'])); + $this->assertFalse(Validation::date('0-0-00', ['dmy'])); + $this->assertFalse(Validation::date('0.0.00', ['dmy'])); + $this->assertFalse(Validation::date('0/0/00', ['dmy'])); + $this->assertFalse(Validation::date('0 0 00', ['dmy'])); + $this->assertFalse(Validation::date('32-2-06', ['dmy'])); + $this->assertFalse(Validation::date('32.2.06', ['dmy'])); + $this->assertFalse(Validation::date('32/2/06', ['dmy'])); + $this->assertFalse(Validation::date('32 2 06', ['dmy'])); } /** @@ -1056,14 +1056,14 @@ public function testDateDmyy() { * @return void */ public function testDateDmyyLeapYear() { - $this->assertTrue(Validation::date('29-2-04', array('dmy'))); - $this->assertTrue(Validation::date('29.2.04', array('dmy'))); - $this->assertTrue(Validation::date('29/2/04', array('dmy'))); - $this->assertTrue(Validation::date('29 2 04', array('dmy'))); - $this->assertFalse(Validation::date('29-2-06', array('dmy'))); - $this->assertFalse(Validation::date('29.2.06', array('dmy'))); - $this->assertFalse(Validation::date('29/2/06', array('dmy'))); - $this->assertFalse(Validation::date('29 2 06', array('dmy'))); + $this->assertTrue(Validation::date('29-2-04', ['dmy'])); + $this->assertTrue(Validation::date('29.2.04', ['dmy'])); + $this->assertTrue(Validation::date('29/2/04', ['dmy'])); + $this->assertTrue(Validation::date('29 2 04', ['dmy'])); + $this->assertFalse(Validation::date('29-2-06', ['dmy'])); + $this->assertFalse(Validation::date('29.2.06', ['dmy'])); + $this->assertFalse(Validation::date('29/2/06', ['dmy'])); + $this->assertFalse(Validation::date('29 2 06', ['dmy'])); } /** @@ -1072,18 +1072,18 @@ public function testDateDmyyLeapYear() { * @return void */ public function testDateDmyyyy() { - $this->assertTrue(Validation::date('7-2-2006', array('dmy'))); - $this->assertTrue(Validation::date('7.2.2006', array('dmy'))); - $this->assertTrue(Validation::date('7/2/2006', array('dmy'))); - $this->assertTrue(Validation::date('7 2 2006', array('dmy'))); - $this->assertFalse(Validation::date('0-0-0000', array('dmy'))); - $this->assertFalse(Validation::date('0.0.0000', array('dmy'))); - $this->assertFalse(Validation::date('0/0/0000', array('dmy'))); - $this->assertFalse(Validation::date('0 0 0000', array('dmy'))); - $this->assertFalse(Validation::date('32-2-2006', array('dmy'))); - $this->assertFalse(Validation::date('32.2.2006', array('dmy'))); - $this->assertFalse(Validation::date('32/2/2006', array('dmy'))); - $this->assertFalse(Validation::date('32 2 2006', array('dmy'))); + $this->assertTrue(Validation::date('7-2-2006', ['dmy'])); + $this->assertTrue(Validation::date('7.2.2006', ['dmy'])); + $this->assertTrue(Validation::date('7/2/2006', ['dmy'])); + $this->assertTrue(Validation::date('7 2 2006', ['dmy'])); + $this->assertFalse(Validation::date('0-0-0000', ['dmy'])); + $this->assertFalse(Validation::date('0.0.0000', ['dmy'])); + $this->assertFalse(Validation::date('0/0/0000', ['dmy'])); + $this->assertFalse(Validation::date('0 0 0000', ['dmy'])); + $this->assertFalse(Validation::date('32-2-2006', ['dmy'])); + $this->assertFalse(Validation::date('32.2.2006', ['dmy'])); + $this->assertFalse(Validation::date('32/2/2006', ['dmy'])); + $this->assertFalse(Validation::date('32 2 2006', ['dmy'])); } /** @@ -1092,14 +1092,14 @@ public function testDateDmyyyy() { * @return void */ public function testDateDmyyyyLeapYear() { - $this->assertTrue(Validation::date('29-2-2004', array('dmy'))); - $this->assertTrue(Validation::date('29.2.2004', array('dmy'))); - $this->assertTrue(Validation::date('29/2/2004', array('dmy'))); - $this->assertTrue(Validation::date('29 2 2004', array('dmy'))); - $this->assertFalse(Validation::date('29-2-2006', array('dmy'))); - $this->assertFalse(Validation::date('29.2.2006', array('dmy'))); - $this->assertFalse(Validation::date('29/2/2006', array('dmy'))); - $this->assertFalse(Validation::date('29 2 2006', array('dmy'))); + $this->assertTrue(Validation::date('29-2-2004', ['dmy'])); + $this->assertTrue(Validation::date('29.2.2004', ['dmy'])); + $this->assertTrue(Validation::date('29/2/2004', ['dmy'])); + $this->assertTrue(Validation::date('29 2 2004', ['dmy'])); + $this->assertFalse(Validation::date('29-2-2006', ['dmy'])); + $this->assertFalse(Validation::date('29.2.2006', ['dmy'])); + $this->assertFalse(Validation::date('29/2/2006', ['dmy'])); + $this->assertFalse(Validation::date('29 2 2006', ['dmy'])); } /** @@ -1108,18 +1108,18 @@ public function testDateDmyyyyLeapYear() { * @return void */ public function testDateMmddyyyy() { - $this->assertTrue(Validation::date('12-27-2006', array('mdy'))); - $this->assertTrue(Validation::date('12.27.2006', array('mdy'))); - $this->assertTrue(Validation::date('12/27/2006', array('mdy'))); - $this->assertTrue(Validation::date('12 27 2006', array('mdy'))); - $this->assertFalse(Validation::date('00-00-0000', array('mdy'))); - $this->assertFalse(Validation::date('00.00.0000', array('mdy'))); - $this->assertFalse(Validation::date('00/00/0000', array('mdy'))); - $this->assertFalse(Validation::date('00 00 0000', array('mdy'))); - $this->assertFalse(Validation::date('11-31-2006', array('mdy'))); - $this->assertFalse(Validation::date('11.31.2006', array('mdy'))); - $this->assertFalse(Validation::date('11/31/2006', array('mdy'))); - $this->assertFalse(Validation::date('11 31 2006', array('mdy'))); + $this->assertTrue(Validation::date('12-27-2006', ['mdy'])); + $this->assertTrue(Validation::date('12.27.2006', ['mdy'])); + $this->assertTrue(Validation::date('12/27/2006', ['mdy'])); + $this->assertTrue(Validation::date('12 27 2006', ['mdy'])); + $this->assertFalse(Validation::date('00-00-0000', ['mdy'])); + $this->assertFalse(Validation::date('00.00.0000', ['mdy'])); + $this->assertFalse(Validation::date('00/00/0000', ['mdy'])); + $this->assertFalse(Validation::date('00 00 0000', ['mdy'])); + $this->assertFalse(Validation::date('11-31-2006', ['mdy'])); + $this->assertFalse(Validation::date('11.31.2006', ['mdy'])); + $this->assertFalse(Validation::date('11/31/2006', ['mdy'])); + $this->assertFalse(Validation::date('11 31 2006', ['mdy'])); } /** @@ -1128,14 +1128,14 @@ public function testDateMmddyyyy() { * @return void */ public function testDateMmddyyyyLeapYear() { - $this->assertTrue(Validation::date('02-29-2004', array('mdy'))); - $this->assertTrue(Validation::date('02.29.2004', array('mdy'))); - $this->assertTrue(Validation::date('02/29/2004', array('mdy'))); - $this->assertTrue(Validation::date('02 29 2004', array('mdy'))); - $this->assertFalse(Validation::date('02-29-2006', array('mdy'))); - $this->assertFalse(Validation::date('02.29.2006', array('mdy'))); - $this->assertFalse(Validation::date('02/29/2006', array('mdy'))); - $this->assertFalse(Validation::date('02 29 2006', array('mdy'))); + $this->assertTrue(Validation::date('02-29-2004', ['mdy'])); + $this->assertTrue(Validation::date('02.29.2004', ['mdy'])); + $this->assertTrue(Validation::date('02/29/2004', ['mdy'])); + $this->assertTrue(Validation::date('02 29 2004', ['mdy'])); + $this->assertFalse(Validation::date('02-29-2006', ['mdy'])); + $this->assertFalse(Validation::date('02.29.2006', ['mdy'])); + $this->assertFalse(Validation::date('02/29/2006', ['mdy'])); + $this->assertFalse(Validation::date('02 29 2006', ['mdy'])); } /** @@ -1144,18 +1144,18 @@ public function testDateMmddyyyyLeapYear() { * @return void */ public function testDateMmddyy() { - $this->assertTrue(Validation::date('12-27-06', array('mdy'))); - $this->assertTrue(Validation::date('12.27.06', array('mdy'))); - $this->assertTrue(Validation::date('12/27/06', array('mdy'))); - $this->assertTrue(Validation::date('12 27 06', array('mdy'))); - $this->assertFalse(Validation::date('00-00-00', array('mdy'))); - $this->assertFalse(Validation::date('00.00.00', array('mdy'))); - $this->assertFalse(Validation::date('00/00/00', array('mdy'))); - $this->assertFalse(Validation::date('00 00 00', array('mdy'))); - $this->assertFalse(Validation::date('11-31-06', array('mdy'))); - $this->assertFalse(Validation::date('11.31.06', array('mdy'))); - $this->assertFalse(Validation::date('11/31/06', array('mdy'))); - $this->assertFalse(Validation::date('11 31 06', array('mdy'))); + $this->assertTrue(Validation::date('12-27-06', ['mdy'])); + $this->assertTrue(Validation::date('12.27.06', ['mdy'])); + $this->assertTrue(Validation::date('12/27/06', ['mdy'])); + $this->assertTrue(Validation::date('12 27 06', ['mdy'])); + $this->assertFalse(Validation::date('00-00-00', ['mdy'])); + $this->assertFalse(Validation::date('00.00.00', ['mdy'])); + $this->assertFalse(Validation::date('00/00/00', ['mdy'])); + $this->assertFalse(Validation::date('00 00 00', ['mdy'])); + $this->assertFalse(Validation::date('11-31-06', ['mdy'])); + $this->assertFalse(Validation::date('11.31.06', ['mdy'])); + $this->assertFalse(Validation::date('11/31/06', ['mdy'])); + $this->assertFalse(Validation::date('11 31 06', ['mdy'])); } /** @@ -1164,14 +1164,14 @@ public function testDateMmddyy() { * @return void */ public function testDateMmddyyLeapYear() { - $this->assertTrue(Validation::date('02-29-04', array('mdy'))); - $this->assertTrue(Validation::date('02.29.04', array('mdy'))); - $this->assertTrue(Validation::date('02/29/04', array('mdy'))); - $this->assertTrue(Validation::date('02 29 04', array('mdy'))); - $this->assertFalse(Validation::date('02-29-06', array('mdy'))); - $this->assertFalse(Validation::date('02.29.06', array('mdy'))); - $this->assertFalse(Validation::date('02/29/06', array('mdy'))); - $this->assertFalse(Validation::date('02 29 06', array('mdy'))); + $this->assertTrue(Validation::date('02-29-04', ['mdy'])); + $this->assertTrue(Validation::date('02.29.04', ['mdy'])); + $this->assertTrue(Validation::date('02/29/04', ['mdy'])); + $this->assertTrue(Validation::date('02 29 04', ['mdy'])); + $this->assertFalse(Validation::date('02-29-06', ['mdy'])); + $this->assertFalse(Validation::date('02.29.06', ['mdy'])); + $this->assertFalse(Validation::date('02/29/06', ['mdy'])); + $this->assertFalse(Validation::date('02 29 06', ['mdy'])); } /** @@ -1180,18 +1180,18 @@ public function testDateMmddyyLeapYear() { * @return void */ public function testDateMdyy() { - $this->assertTrue(Validation::date('2-7-06', array('mdy'))); - $this->assertTrue(Validation::date('2.7.06', array('mdy'))); - $this->assertTrue(Validation::date('2/7/06', array('mdy'))); - $this->assertTrue(Validation::date('2 7 06', array('mdy'))); - $this->assertFalse(Validation::date('0-0-00', array('mdy'))); - $this->assertFalse(Validation::date('0.0.00', array('mdy'))); - $this->assertFalse(Validation::date('0/0/00', array('mdy'))); - $this->assertFalse(Validation::date('0 0 00', array('mdy'))); - $this->assertFalse(Validation::date('2-32-06', array('mdy'))); - $this->assertFalse(Validation::date('2.32.06', array('mdy'))); - $this->assertFalse(Validation::date('2/32/06', array('mdy'))); - $this->assertFalse(Validation::date('2 32 06', array('mdy'))); + $this->assertTrue(Validation::date('2-7-06', ['mdy'])); + $this->assertTrue(Validation::date('2.7.06', ['mdy'])); + $this->assertTrue(Validation::date('2/7/06', ['mdy'])); + $this->assertTrue(Validation::date('2 7 06', ['mdy'])); + $this->assertFalse(Validation::date('0-0-00', ['mdy'])); + $this->assertFalse(Validation::date('0.0.00', ['mdy'])); + $this->assertFalse(Validation::date('0/0/00', ['mdy'])); + $this->assertFalse(Validation::date('0 0 00', ['mdy'])); + $this->assertFalse(Validation::date('2-32-06', ['mdy'])); + $this->assertFalse(Validation::date('2.32.06', ['mdy'])); + $this->assertFalse(Validation::date('2/32/06', ['mdy'])); + $this->assertFalse(Validation::date('2 32 06', ['mdy'])); } /** @@ -1200,14 +1200,14 @@ public function testDateMdyy() { * @return void */ public function testDateMdyyLeapYear() { - $this->assertTrue(Validation::date('2-29-04', array('mdy'))); - $this->assertTrue(Validation::date('2.29.04', array('mdy'))); - $this->assertTrue(Validation::date('2/29/04', array('mdy'))); - $this->assertTrue(Validation::date('2 29 04', array('mdy'))); - $this->assertFalse(Validation::date('2-29-06', array('mdy'))); - $this->assertFalse(Validation::date('2.29.06', array('mdy'))); - $this->assertFalse(Validation::date('2/29/06', array('mdy'))); - $this->assertFalse(Validation::date('2 29 06', array('mdy'))); + $this->assertTrue(Validation::date('2-29-04', ['mdy'])); + $this->assertTrue(Validation::date('2.29.04', ['mdy'])); + $this->assertTrue(Validation::date('2/29/04', ['mdy'])); + $this->assertTrue(Validation::date('2 29 04', ['mdy'])); + $this->assertFalse(Validation::date('2-29-06', ['mdy'])); + $this->assertFalse(Validation::date('2.29.06', ['mdy'])); + $this->assertFalse(Validation::date('2/29/06', ['mdy'])); + $this->assertFalse(Validation::date('2 29 06', ['mdy'])); } /** @@ -1216,18 +1216,18 @@ public function testDateMdyyLeapYear() { * @return void */ public function testDateMdyyyy() { - $this->assertTrue(Validation::date('2-7-2006', array('mdy'))); - $this->assertTrue(Validation::date('2.7.2006', array('mdy'))); - $this->assertTrue(Validation::date('2/7/2006', array('mdy'))); - $this->assertTrue(Validation::date('2 7 2006', array('mdy'))); - $this->assertFalse(Validation::date('0-0-0000', array('mdy'))); - $this->assertFalse(Validation::date('0.0.0000', array('mdy'))); - $this->assertFalse(Validation::date('0/0/0000', array('mdy'))); - $this->assertFalse(Validation::date('0 0 0000', array('mdy'))); - $this->assertFalse(Validation::date('2-32-2006', array('mdy'))); - $this->assertFalse(Validation::date('2.32.2006', array('mdy'))); - $this->assertFalse(Validation::date('2/32/2006', array('mdy'))); - $this->assertFalse(Validation::date('2 32 2006', array('mdy'))); + $this->assertTrue(Validation::date('2-7-2006', ['mdy'])); + $this->assertTrue(Validation::date('2.7.2006', ['mdy'])); + $this->assertTrue(Validation::date('2/7/2006', ['mdy'])); + $this->assertTrue(Validation::date('2 7 2006', ['mdy'])); + $this->assertFalse(Validation::date('0-0-0000', ['mdy'])); + $this->assertFalse(Validation::date('0.0.0000', ['mdy'])); + $this->assertFalse(Validation::date('0/0/0000', ['mdy'])); + $this->assertFalse(Validation::date('0 0 0000', ['mdy'])); + $this->assertFalse(Validation::date('2-32-2006', ['mdy'])); + $this->assertFalse(Validation::date('2.32.2006', ['mdy'])); + $this->assertFalse(Validation::date('2/32/2006', ['mdy'])); + $this->assertFalse(Validation::date('2 32 2006', ['mdy'])); } /** @@ -1236,14 +1236,14 @@ public function testDateMdyyyy() { * @return void */ public function testDateMdyyyyLeapYear() { - $this->assertTrue(Validation::date('2-29-2004', array('mdy'))); - $this->assertTrue(Validation::date('2.29.2004', array('mdy'))); - $this->assertTrue(Validation::date('2/29/2004', array('mdy'))); - $this->assertTrue(Validation::date('2 29 2004', array('mdy'))); - $this->assertFalse(Validation::date('2-29-2006', array('mdy'))); - $this->assertFalse(Validation::date('2.29.2006', array('mdy'))); - $this->assertFalse(Validation::date('2/29/2006', array('mdy'))); - $this->assertFalse(Validation::date('2 29 2006', array('mdy'))); + $this->assertTrue(Validation::date('2-29-2004', ['mdy'])); + $this->assertTrue(Validation::date('2.29.2004', ['mdy'])); + $this->assertTrue(Validation::date('2/29/2004', ['mdy'])); + $this->assertTrue(Validation::date('2 29 2004', ['mdy'])); + $this->assertFalse(Validation::date('2-29-2006', ['mdy'])); + $this->assertFalse(Validation::date('2.29.2006', ['mdy'])); + $this->assertFalse(Validation::date('2/29/2006', ['mdy'])); + $this->assertFalse(Validation::date('2 29 2006', ['mdy'])); } /** @@ -1252,14 +1252,14 @@ public function testDateMdyyyyLeapYear() { * @return void */ public function testDateYyyymmdd() { - $this->assertTrue(Validation::date('2006-12-27', array('ymd'))); - $this->assertTrue(Validation::date('2006.12.27', array('ymd'))); - $this->assertTrue(Validation::date('2006/12/27', array('ymd'))); - $this->assertTrue(Validation::date('2006 12 27', array('ymd'))); - $this->assertFalse(Validation::date('2006-11-31', array('ymd'))); - $this->assertFalse(Validation::date('2006.11.31', array('ymd'))); - $this->assertFalse(Validation::date('2006/11/31', array('ymd'))); - $this->assertFalse(Validation::date('2006 11 31', array('ymd'))); + $this->assertTrue(Validation::date('2006-12-27', ['ymd'])); + $this->assertTrue(Validation::date('2006.12.27', ['ymd'])); + $this->assertTrue(Validation::date('2006/12/27', ['ymd'])); + $this->assertTrue(Validation::date('2006 12 27', ['ymd'])); + $this->assertFalse(Validation::date('2006-11-31', ['ymd'])); + $this->assertFalse(Validation::date('2006.11.31', ['ymd'])); + $this->assertFalse(Validation::date('2006/11/31', ['ymd'])); + $this->assertFalse(Validation::date('2006 11 31', ['ymd'])); } /** @@ -1268,14 +1268,14 @@ public function testDateYyyymmdd() { * @return void */ public function testDateYyyymmddLeapYear() { - $this->assertTrue(Validation::date('2004-02-29', array('ymd'))); - $this->assertTrue(Validation::date('2004.02.29', array('ymd'))); - $this->assertTrue(Validation::date('2004/02/29', array('ymd'))); - $this->assertTrue(Validation::date('2004 02 29', array('ymd'))); - $this->assertFalse(Validation::date('2006-02-29', array('ymd'))); - $this->assertFalse(Validation::date('2006.02.29', array('ymd'))); - $this->assertFalse(Validation::date('2006/02/29', array('ymd'))); - $this->assertFalse(Validation::date('2006 02 29', array('ymd'))); + $this->assertTrue(Validation::date('2004-02-29', ['ymd'])); + $this->assertTrue(Validation::date('2004.02.29', ['ymd'])); + $this->assertTrue(Validation::date('2004/02/29', ['ymd'])); + $this->assertTrue(Validation::date('2004 02 29', ['ymd'])); + $this->assertFalse(Validation::date('2006-02-29', ['ymd'])); + $this->assertFalse(Validation::date('2006.02.29', ['ymd'])); + $this->assertFalse(Validation::date('2006/02/29', ['ymd'])); + $this->assertFalse(Validation::date('2006 02 29', ['ymd'])); } /** @@ -1284,18 +1284,18 @@ public function testDateYyyymmddLeapYear() { * @return void */ public function testDateYymmdd() { - $this->assertTrue(Validation::date('06-12-27', array('ymd'))); - $this->assertTrue(Validation::date('06.12.27', array('ymd'))); - $this->assertTrue(Validation::date('06/12/27', array('ymd'))); - $this->assertTrue(Validation::date('06 12 27', array('ymd'))); - $this->assertFalse(Validation::date('12/27/2600', array('ymd'))); - $this->assertFalse(Validation::date('12.27.2600', array('ymd'))); - $this->assertFalse(Validation::date('12/27/2600', array('ymd'))); - $this->assertFalse(Validation::date('12 27 2600', array('ymd'))); - $this->assertFalse(Validation::date('06-11-31', array('ymd'))); - $this->assertFalse(Validation::date('06.11.31', array('ymd'))); - $this->assertFalse(Validation::date('06/11/31', array('ymd'))); - $this->assertFalse(Validation::date('06 11 31', array('ymd'))); + $this->assertTrue(Validation::date('06-12-27', ['ymd'])); + $this->assertTrue(Validation::date('06.12.27', ['ymd'])); + $this->assertTrue(Validation::date('06/12/27', ['ymd'])); + $this->assertTrue(Validation::date('06 12 27', ['ymd'])); + $this->assertFalse(Validation::date('12/27/2600', ['ymd'])); + $this->assertFalse(Validation::date('12.27.2600', ['ymd'])); + $this->assertFalse(Validation::date('12/27/2600', ['ymd'])); + $this->assertFalse(Validation::date('12 27 2600', ['ymd'])); + $this->assertFalse(Validation::date('06-11-31', ['ymd'])); + $this->assertFalse(Validation::date('06.11.31', ['ymd'])); + $this->assertFalse(Validation::date('06/11/31', ['ymd'])); + $this->assertFalse(Validation::date('06 11 31', ['ymd'])); } /** @@ -1304,14 +1304,14 @@ public function testDateYymmdd() { * @return void */ public function testDateYymmddLeapYear() { - $this->assertTrue(Validation::date('2004-02-29', array('ymd'))); - $this->assertTrue(Validation::date('2004.02.29', array('ymd'))); - $this->assertTrue(Validation::date('2004/02/29', array('ymd'))); - $this->assertTrue(Validation::date('2004 02 29', array('ymd'))); - $this->assertFalse(Validation::date('2006-02-29', array('ymd'))); - $this->assertFalse(Validation::date('2006.02.29', array('ymd'))); - $this->assertFalse(Validation::date('2006/02/29', array('ymd'))); - $this->assertFalse(Validation::date('2006 02 29', array('ymd'))); + $this->assertTrue(Validation::date('2004-02-29', ['ymd'])); + $this->assertTrue(Validation::date('2004.02.29', ['ymd'])); + $this->assertTrue(Validation::date('2004/02/29', ['ymd'])); + $this->assertTrue(Validation::date('2004 02 29', ['ymd'])); + $this->assertFalse(Validation::date('2006-02-29', ['ymd'])); + $this->assertFalse(Validation::date('2006.02.29', ['ymd'])); + $this->assertFalse(Validation::date('2006/02/29', ['ymd'])); + $this->assertFalse(Validation::date('2006 02 29', ['ymd'])); } /** @@ -1320,10 +1320,10 @@ public function testDateYymmddLeapYear() { * @return void */ public function testDateDdMMMMyyyy() { - $this->assertTrue(Validation::date('27 December 2006', array('dMy'))); - $this->assertTrue(Validation::date('27 Dec 2006', array('dMy'))); - $this->assertFalse(Validation::date('2006 Dec 27', array('dMy'))); - $this->assertFalse(Validation::date('2006 December 27', array('dMy'))); + $this->assertTrue(Validation::date('27 December 2006', ['dMy'])); + $this->assertTrue(Validation::date('27 Dec 2006', ['dMy'])); + $this->assertFalse(Validation::date('2006 Dec 27', ['dMy'])); + $this->assertFalse(Validation::date('2006 December 27', ['dMy'])); } /** @@ -1332,8 +1332,8 @@ public function testDateDdMMMMyyyy() { * @return void */ public function testDateDdMMMMyyyyLeapYear() { - $this->assertTrue(Validation::date('29 February 2004', array('dMy'))); - $this->assertFalse(Validation::date('29 February 2006', array('dMy'))); + $this->assertTrue(Validation::date('29 February 2004', ['dMy'])); + $this->assertFalse(Validation::date('29 February 2006', ['dMy'])); } /** @@ -1342,13 +1342,13 @@ public function testDateDdMMMMyyyyLeapYear() { * @return void */ public function testDateMmmmDdyyyy() { - $this->assertTrue(Validation::date('December 27, 2006', array('Mdy'))); - $this->assertTrue(Validation::date('Dec 27, 2006', array('Mdy'))); - $this->assertTrue(Validation::date('December 27 2006', array('Mdy'))); - $this->assertTrue(Validation::date('Dec 27 2006', array('Mdy'))); - $this->assertFalse(Validation::date('27 Dec 2006', array('Mdy'))); - $this->assertFalse(Validation::date('2006 December 27', array('Mdy'))); - $this->assertTrue(Validation::date('Sep 12, 2011', array('Mdy'))); + $this->assertTrue(Validation::date('December 27, 2006', ['Mdy'])); + $this->assertTrue(Validation::date('Dec 27, 2006', ['Mdy'])); + $this->assertTrue(Validation::date('December 27 2006', ['Mdy'])); + $this->assertTrue(Validation::date('Dec 27 2006', ['Mdy'])); + $this->assertFalse(Validation::date('27 Dec 2006', ['Mdy'])); + $this->assertFalse(Validation::date('2006 December 27', ['Mdy'])); + $this->assertTrue(Validation::date('Sep 12, 2011', ['Mdy'])); } /** @@ -1357,11 +1357,11 @@ public function testDateMmmmDdyyyy() { * @return void */ public function testDateMmmmDdyyyyLeapYear() { - $this->assertTrue(Validation::date('February 29, 2004', array('Mdy'))); - $this->assertTrue(Validation::date('Feb 29, 2004', array('Mdy'))); - $this->assertTrue(Validation::date('February 29 2004', array('Mdy'))); - $this->assertTrue(Validation::date('Feb 29 2004', array('Mdy'))); - $this->assertFalse(Validation::date('February 29, 2006', array('Mdy'))); + $this->assertTrue(Validation::date('February 29, 2004', ['Mdy'])); + $this->assertTrue(Validation::date('Feb 29, 2004', ['Mdy'])); + $this->assertTrue(Validation::date('February 29 2004', ['Mdy'])); + $this->assertTrue(Validation::date('Feb 29 2004', ['Mdy'])); + $this->assertFalse(Validation::date('February 29, 2006', ['Mdy'])); } /** @@ -1370,10 +1370,10 @@ public function testDateMmmmDdyyyyLeapYear() { * @return void */ public function testDateMy() { - $this->assertTrue(Validation::date('December 2006', array('My'))); - $this->assertTrue(Validation::date('Dec 2006', array('My'))); - $this->assertTrue(Validation::date('December/2006', array('My'))); - $this->assertTrue(Validation::date('Dec/2006', array('My'))); + $this->assertTrue(Validation::date('December 2006', ['My'])); + $this->assertTrue(Validation::date('Dec 2006', ['My'])); + $this->assertTrue(Validation::date('December/2006', ['My'])); + $this->assertTrue(Validation::date('Dec/2006', ['My'])); } /** @@ -1382,16 +1382,16 @@ public function testDateMy() { * @return void */ public function testDateMyNumeric() { - $this->assertTrue(Validation::date('01/2006', array('my'))); - $this->assertTrue(Validation::date('12-2006', array('my'))); - $this->assertTrue(Validation::date('12.2006', array('my'))); - $this->assertTrue(Validation::date('12 2006', array('my'))); - $this->assertTrue(Validation::date('01/06', array('my'))); - $this->assertTrue(Validation::date('12-06', array('my'))); - $this->assertTrue(Validation::date('12.06', array('my'))); - $this->assertTrue(Validation::date('12 06', array('my'))); - $this->assertFalse(Validation::date('13 06', array('my'))); - $this->assertFalse(Validation::date('13 2006', array('my'))); + $this->assertTrue(Validation::date('01/2006', ['my'])); + $this->assertTrue(Validation::date('12-2006', ['my'])); + $this->assertTrue(Validation::date('12.2006', ['my'])); + $this->assertTrue(Validation::date('12 2006', ['my'])); + $this->assertTrue(Validation::date('01/06', ['my'])); + $this->assertTrue(Validation::date('12-06', ['my'])); + $this->assertTrue(Validation::date('12.06', ['my'])); + $this->assertTrue(Validation::date('12 06', ['my'])); + $this->assertFalse(Validation::date('13 06', ['my'])); + $this->assertFalse(Validation::date('13 2006', ['my'])); } /** @@ -1400,21 +1400,21 @@ public function testDateMyNumeric() { * @return void */ public function testDateYmNumeric() { - $this->assertTrue(Validation::date('2006/12', array('ym'))); - $this->assertTrue(Validation::date('2006-12', array('ym'))); - $this->assertTrue(Validation::date('2006-12', array('ym'))); - $this->assertTrue(Validation::date('2006 12', array('ym'))); - $this->assertTrue(Validation::date('2006 12', array('ym'))); - $this->assertTrue(Validation::date('1900-01', array('ym'))); - $this->assertTrue(Validation::date('2153-01', array('ym'))); - $this->assertTrue(Validation::date('06/12', array('ym'))); - $this->assertTrue(Validation::date('06-12', array('ym'))); - $this->assertTrue(Validation::date('06-12', array('ym'))); - $this->assertTrue(Validation::date('06 12', array('ym'))); - $this->assertFalse(Validation::date('2006/12 ', array('ym'))); - $this->assertFalse(Validation::date('2006/12/', array('ym'))); - $this->assertFalse(Validation::date('06/12 ', array('ym'))); - $this->assertFalse(Validation::date('06/13 ', array('ym'))); + $this->assertTrue(Validation::date('2006/12', ['ym'])); + $this->assertTrue(Validation::date('2006-12', ['ym'])); + $this->assertTrue(Validation::date('2006-12', ['ym'])); + $this->assertTrue(Validation::date('2006 12', ['ym'])); + $this->assertTrue(Validation::date('2006 12', ['ym'])); + $this->assertTrue(Validation::date('1900-01', ['ym'])); + $this->assertTrue(Validation::date('2153-01', ['ym'])); + $this->assertTrue(Validation::date('06/12', ['ym'])); + $this->assertTrue(Validation::date('06-12', ['ym'])); + $this->assertTrue(Validation::date('06-12', ['ym'])); + $this->assertTrue(Validation::date('06 12', ['ym'])); + $this->assertFalse(Validation::date('2006/12 ', ['ym'])); + $this->assertFalse(Validation::date('2006/12/', ['ym'])); + $this->assertFalse(Validation::date('06/12 ', ['ym'])); + $this->assertFalse(Validation::date('06/13 ', ['ym'])); } /** @@ -1423,17 +1423,17 @@ public function testDateYmNumeric() { * @return void */ public function testDateY() { - $this->assertTrue(Validation::date('1900', array('y'))); - $this->assertTrue(Validation::date('1984', array('y'))); - $this->assertTrue(Validation::date('2006', array('y'))); - $this->assertTrue(Validation::date('2008', array('y'))); - $this->assertTrue(Validation::date('2013', array('y'))); - $this->assertTrue(Validation::date('2104', array('y'))); - $this->assertTrue(Validation::date('1899', array('y'))); - $this->assertFalse(Validation::date('20009', array('y'))); - $this->assertFalse(Validation::date(' 2012', array('y'))); - $this->assertFalse(Validation::date('3000', array('y'))); - $this->assertFalse(Validation::date('1799', array('y'))); + $this->assertTrue(Validation::date('1900', ['y'])); + $this->assertTrue(Validation::date('1984', ['y'])); + $this->assertTrue(Validation::date('2006', ['y'])); + $this->assertTrue(Validation::date('2008', ['y'])); + $this->assertTrue(Validation::date('2013', ['y'])); + $this->assertTrue(Validation::date('2104', ['y'])); + $this->assertTrue(Validation::date('1899', ['y'])); + $this->assertFalse(Validation::date('20009', ['y'])); + $this->assertFalse(Validation::date(' 2012', ['y'])); + $this->assertFalse(Validation::date('3000', ['y'])); + $this->assertFalse(Validation::date('1799', ['y'])); } /** @@ -1442,8 +1442,8 @@ public function testDateY() { * @return void */ public function testDateMultiple() { - $this->assertTrue(Validation::date('2011-12-31', array('ymd', 'dmy'))); - $this->assertTrue(Validation::date('31-12-2011', array('ymd', 'dmy'))); + $this->assertTrue(Validation::date('2011-12-31', ['ymd', 'dmy'])); + $this->assertTrue(Validation::date('31-12-2011', ['ymd', 'dmy'])); } /** @@ -1964,24 +1964,24 @@ public function testUuid() { * @return void */ public function testInList() { - $this->assertTrue(Validation::inList('one', array('one', 'two'))); - $this->assertTrue(Validation::inList('two', array('one', 'two'))); - $this->assertFalse(Validation::inList('three', array('one', 'two'))); - $this->assertFalse(Validation::inList('1one', array(0, 1, 2, 3))); - $this->assertFalse(Validation::inList('one', array(0, 1, 2, 3))); - $this->assertTrue(Validation::inList('2', array(1, 2, 3))); - $this->assertFalse(Validation::inList('2x', array(1, 2, 3))); - $this->assertFalse(Validation::inList(2, array('1', '2x', '3'))); - $this->assertFalse(Validation::inList('One', array('one', 'two'))); + $this->assertTrue(Validation::inList('one', ['one', 'two'])); + $this->assertTrue(Validation::inList('two', ['one', 'two'])); + $this->assertFalse(Validation::inList('three', ['one', 'two'])); + $this->assertFalse(Validation::inList('1one', [0, 1, 2, 3])); + $this->assertFalse(Validation::inList('one', [0, 1, 2, 3])); + $this->assertTrue(Validation::inList('2', [1, 2, 3])); + $this->assertFalse(Validation::inList('2x', [1, 2, 3])); + $this->assertFalse(Validation::inList(2, ['1', '2x', '3'])); + $this->assertFalse(Validation::inList('One', ['one', 'two'])); // No hexadecimal for numbers. - $this->assertFalse(Validation::inList('0x7B', array('ABC', '123'))); - $this->assertFalse(Validation::inList('0x7B', array('ABC', 123))); + $this->assertFalse(Validation::inList('0x7B', ['ABC', '123'])); + $this->assertFalse(Validation::inList('0x7B', ['ABC', 123])); // case insensitive - $this->assertTrue(Validation::inList('one', array('One', 'Two'), true)); - $this->assertTrue(Validation::inList('Two', array('one', 'two'), true)); - $this->assertFalse(Validation::inList('three', array('one', 'two'), true)); + $this->assertTrue(Validation::inList('one', ['One', 'Two'], true)); + $this->assertTrue(Validation::inList('Two', ['one', 'two'], true)); + $this->assertFalse(Validation::inList('three', ['one', 'two'], true)); } /** @@ -2029,19 +2029,19 @@ public function testExtension() { $this->assertTrue(Validation::extension('extension.jpg')); $this->assertTrue(Validation::extension('extension.JPG')); $this->assertFalse(Validation::extension('noextension')); - $this->assertTrue(Validation::extension('extension.pdf', array('PDF'))); - $this->assertFalse(Validation::extension('extension.jpg', array('GIF'))); - $this->assertTrue(Validation::extension(array('extension.JPG', 'extension.gif', 'extension.png'))); - $this->assertTrue(Validation::extension(array('file' => array('name' => 'file.jpg')))); - $this->assertTrue(Validation::extension(array('file1' => array('name' => 'file.jpg'), - 'file2' => array('name' => 'file.jpg'), - 'file3' => array('name' => 'file.jpg')))); - $this->assertFalse(Validation::extension(array('file1' => array('name' => 'file.jpg'), - 'file2' => array('name' => 'file.jpg'), - 'file3' => array('name' => 'file.jpg')), array('gif'))); + $this->assertTrue(Validation::extension('extension.pdf', ['PDF'])); + $this->assertFalse(Validation::extension('extension.jpg', ['GIF'])); + $this->assertTrue(Validation::extension(['extension.JPG', 'extension.gif', 'extension.png'])); + $this->assertTrue(Validation::extension(['file' => ['name' => 'file.jpg']])); + $this->assertTrue(Validation::extension(['file1' => ['name' => 'file.jpg'], + 'file2' => ['name' => 'file.jpg'], + 'file3' => ['name' => 'file.jpg']])); + $this->assertFalse(Validation::extension(['file1' => ['name' => 'file.jpg'], + 'file2' => ['name' => 'file.jpg'], + 'file3' => ['name' => 'file.jpg']], ['gif'])); - $this->assertFalse(Validation::extension(array('noextension', 'extension.JPG', 'extension.gif', 'extension.png'))); - $this->assertFalse(Validation::extension(array('extension.pdf', 'extension.JPG', 'extension.gif', 'extension.png'))); + $this->assertFalse(Validation::extension(['noextension', 'extension.JPG', 'extension.gif', 'extension.png'])); + $this->assertFalse(Validation::extension(['extension.pdf', 'extension.JPG', 'extension.gif', 'extension.png'])); } /** @@ -2090,52 +2090,52 @@ public function testMoney() { * @return void */ public function testMultiple() { - $this->assertTrue(Validation::multiple(array(0, 1, 2, 3))); - $this->assertTrue(Validation::multiple(array(50, 32, 22, 0))); - $this->assertTrue(Validation::multiple(array('str', 'var', 'enum', 0))); + $this->assertTrue(Validation::multiple([0, 1, 2, 3])); + $this->assertTrue(Validation::multiple([50, 32, 22, 0])); + $this->assertTrue(Validation::multiple(['str', 'var', 'enum', 0])); $this->assertFalse(Validation::multiple('')); $this->assertFalse(Validation::multiple(null)); - $this->assertFalse(Validation::multiple(array())); - $this->assertTrue(Validation::multiple(array(0))); - $this->assertTrue(Validation::multiple(array('0'))); - $this->assertFalse(Validation::multiple(array(''))); - - $this->assertTrue(Validation::multiple(array(0, 3, 4, 5), array('in' => range(0, 10)))); - $this->assertFalse(Validation::multiple(array(0, 15, 20, 5), array('in' => range(0, 10)))); - $this->assertFalse(Validation::multiple(array(0, 5, 10, 11), array('in' => range(0, 10)))); - $this->assertFalse(Validation::multiple(array('boo', 'foo', 'bar'), array('in' => array('foo', 'bar', 'baz')))); - $this->assertFalse(Validation::multiple(array('foo', '1bar'), array('in' => range(0, 10)))); - - $this->assertFalse(Validation::multiple(array(1, 5, 10, 11), array('max' => 3))); - $this->assertTrue(Validation::multiple(array(0, 5, 10, 11), array('max' => 4))); - $this->assertFalse(Validation::multiple(array(0, 5, 10, 11, 55), array('max' => 4))); - $this->assertTrue(Validation::multiple(array('foo', 'bar', 'baz'), array('max' => 3))); - $this->assertFalse(Validation::multiple(array('foo', 'bar', 'baz', 'squirrel'), array('max' => 3))); - - $this->assertTrue(Validation::multiple(array(0, 5, 10, 11), array('min' => 3))); - $this->assertTrue(Validation::multiple(array(0, 5, 10, 11, 55), array('min' => 3))); - $this->assertFalse(Validation::multiple(array('foo', 'bar', 'baz'), array('min' => 5))); - $this->assertFalse(Validation::multiple(array('foo', 'bar', 'baz', 'squirrel'), array('min' => 10))); - - $this->assertTrue(Validation::multiple(array(0, 5, 9), array('in' => range(0, 10), 'max' => 5))); - $this->assertTrue(Validation::multiple(array('0', '5', '9'), array('in' => range(0, 10), 'max' => 5))); - - $this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 6, 2, 1), array('in' => range(0, 10), 'max' => 5))); - $this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 11), array('in' => range(0, 10), 'max' => 5))); - - $this->assertFalse(Validation::multiple(array(-1, 5, 9), array('in' => range(0, 10), 'max' => 5, 'min' => 3))); - $this->assertFalse(Validation::multiple(array(-1, 5, 9, 8, 6, 2, 1), array('in' => range(0, 10), 'max' => 5, 'min' => 2))); - $this->assertFalse(Validation::multiple(array(0, 5, 9, 8, 11), array('in' => range(0, 10), 'max' => 5, 'min' => 2))); - - $this->assertFalse(Validation::multiple(array('2x', '3x'), array('in' => array(1, 2, 3, 4, 5)))); - $this->assertFalse(Validation::multiple(array(2, 3), array('in' => array('1x', '2x', '3x', '4x')))); - $this->assertFalse(Validation::multiple(array('one'), array('in' => array('One', 'Two')))); - $this->assertFalse(Validation::multiple(array('Two'), array('in' => array('one', 'two')))); + $this->assertFalse(Validation::multiple([])); + $this->assertTrue(Validation::multiple([0])); + $this->assertTrue(Validation::multiple(['0'])); + $this->assertFalse(Validation::multiple([''])); + + $this->assertTrue(Validation::multiple([0, 3, 4, 5], ['in' => range(0, 10)])); + $this->assertFalse(Validation::multiple([0, 15, 20, 5], ['in' => range(0, 10)])); + $this->assertFalse(Validation::multiple([0, 5, 10, 11], ['in' => range(0, 10)])); + $this->assertFalse(Validation::multiple(['boo', 'foo', 'bar'], ['in' => ['foo', 'bar', 'baz']])); + $this->assertFalse(Validation::multiple(['foo', '1bar'], ['in' => range(0, 10)])); + + $this->assertFalse(Validation::multiple([1, 5, 10, 11], ['max' => 3])); + $this->assertTrue(Validation::multiple([0, 5, 10, 11], ['max' => 4])); + $this->assertFalse(Validation::multiple([0, 5, 10, 11, 55], ['max' => 4])); + $this->assertTrue(Validation::multiple(['foo', 'bar', 'baz'], ['max' => 3])); + $this->assertFalse(Validation::multiple(['foo', 'bar', 'baz', 'squirrel'], ['max' => 3])); + + $this->assertTrue(Validation::multiple([0, 5, 10, 11], ['min' => 3])); + $this->assertTrue(Validation::multiple([0, 5, 10, 11, 55], ['min' => 3])); + $this->assertFalse(Validation::multiple(['foo', 'bar', 'baz'], ['min' => 5])); + $this->assertFalse(Validation::multiple(['foo', 'bar', 'baz', 'squirrel'], ['min' => 10])); + + $this->assertTrue(Validation::multiple([0, 5, 9], ['in' => range(0, 10), 'max' => 5])); + $this->assertTrue(Validation::multiple(['0', '5', '9'], ['in' => range(0, 10), 'max' => 5])); + + $this->assertFalse(Validation::multiple([0, 5, 9, 8, 6, 2, 1], ['in' => range(0, 10), 'max' => 5])); + $this->assertFalse(Validation::multiple([0, 5, 9, 8, 11], ['in' => range(0, 10), 'max' => 5])); + + $this->assertFalse(Validation::multiple([-1, 5, 9], ['in' => range(0, 10), 'max' => 5, 'min' => 3])); + $this->assertFalse(Validation::multiple([-1, 5, 9, 8, 6, 2, 1], ['in' => range(0, 10), 'max' => 5, 'min' => 2])); + $this->assertFalse(Validation::multiple([0, 5, 9, 8, 11], ['in' => range(0, 10), 'max' => 5, 'min' => 2])); + + $this->assertFalse(Validation::multiple(['2x', '3x'], ['in' => [1, 2, 3, 4, 5]])); + $this->assertFalse(Validation::multiple([2, 3], ['in' => ['1x', '2x', '3x', '4x']])); + $this->assertFalse(Validation::multiple(['one'], ['in' => ['One', 'Two']])); + $this->assertFalse(Validation::multiple(['Two'], ['in' => ['one', 'two']])); // case insensitive - $this->assertTrue(Validation::multiple(array('one'), array('in' => array('One', 'Two')), true)); - $this->assertTrue(Validation::multiple(array('Two'), array('in' => array('one', 'two')), true)); - $this->assertFalse(Validation::multiple(array('three'), array('in' => array('one', 'two')), true)); + $this->assertTrue(Validation::multiple(['one'], ['in' => ['One', 'Two']], true)); + $this->assertTrue(Validation::multiple(['Two'], ['in' => ['one', 'two']], true)); + $this->assertFalse(Validation::multiple(['three'], ['in' => ['one', 'two']], true)); } /** @@ -2360,7 +2360,7 @@ public function testUserDefined() { */ public function testDatetime() { $this->assertTrue(Validation::datetime('27-12-2006 01:00', 'dmy')); - $this->assertTrue(Validation::datetime('27-12-2006 01:00', array('dmy'))); + $this->assertTrue(Validation::datetime('27-12-2006 01:00', ['dmy'])); $this->assertFalse(Validation::datetime('27-12-2006 1:00', 'dmy')); $this->assertTrue(Validation::datetime('27.12.2006 1:00pm', 'dmy')); @@ -2393,13 +2393,13 @@ public function testMimeType() { $this->skipIf(!$File->mime(), 'Cannot determine mimeType'); - $this->assertTrue(Validation::mimeType($image, array('image/gif'))); - $this->assertTrue(Validation::mimeType(array('tmp_name' => $image), array('image/gif'))); - $this->assertTrue(Validation::mimeType(array('tmp_name' => $image), '#image/.+#')); - $this->assertTrue(Validation::mimeType($image, array('image/GIF'))); + $this->assertTrue(Validation::mimeType($image, ['image/gif'])); + $this->assertTrue(Validation::mimeType(['tmp_name' => $image], ['image/gif'])); + $this->assertTrue(Validation::mimeType(['tmp_name' => $image], '#image/.+#')); + $this->assertTrue(Validation::mimeType($image, ['image/GIF'])); - $this->assertFalse(Validation::mimeType($image, array('image/png'))); - $this->assertFalse(Validation::mimeType(array('tmp_name' => $image), array('image/png'))); + $this->assertFalse(Validation::mimeType($image, ['image/png'])); + $this->assertFalse(Validation::mimeType(['tmp_name' => $image], ['image/png'])); } /** @@ -2412,7 +2412,7 @@ public function testMimeTypeFalse() { $image = CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif'; $File = new File($image, false); $this->skipIf($File->mime(), 'mimeType can be determined, no Exception will be thrown'); - Validation::mimeType($image, array('image/gif')); + Validation::mimeType($image, ['image/gif']); } /** @@ -2422,12 +2422,12 @@ public function testMimeTypeFalse() { */ public function testUploadError() { $this->assertTrue(Validation::uploadError(0)); - $this->assertTrue(Validation::uploadError(array('error' => 0))); - $this->assertTrue(Validation::uploadError(array('error' => '0'))); + $this->assertTrue(Validation::uploadError(['error' => 0])); + $this->assertTrue(Validation::uploadError(['error' => '0'])); $this->assertFalse(Validation::uploadError(2)); - $this->assertFalse(Validation::uploadError(array('error' => 2))); - $this->assertFalse(Validation::uploadError(array('error' => '2'))); + $this->assertFalse(Validation::uploadError(['error' => 2])); + $this->assertFalse(Validation::uploadError(['error' => '2'])); $this->assertFalse(Validation::uploadError(UPLOAD_ERR_NO_FILE)); $this->assertFalse(Validation::uploadError(UPLOAD_ERR_FORM_SIZE, true)); @@ -2444,14 +2444,14 @@ public function testUploadError() { public function testFileSize() { $image = CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif'; $this->assertTrue(Validation::fileSize($image, '<', 1024)); - $this->assertTrue(Validation::fileSize(array('tmp_name' => $image), 'isless', 1024)); + $this->assertTrue(Validation::fileSize(['tmp_name' => $image], 'isless', 1024)); $this->assertTrue(Validation::fileSize($image, '<', '1KB')); $this->assertTrue(Validation::fileSize($image, '>=', 200)); $this->assertTrue(Validation::fileSize($image, '==', 201)); $this->assertTrue(Validation::fileSize($image, '==', '201B')); $this->assertFalse(Validation::fileSize($image, 'isgreater', 1024)); - $this->assertFalse(Validation::fileSize(array('tmp_name' => $image), '>', '1KB')); + $this->assertFalse(Validation::fileSize(['tmp_name' => $image], '>', '1KB')); } /** @@ -2461,17 +2461,17 @@ public function testFileSize() { */ public function testUploadedFileErrorCode() { $this->assertFalse(ValidationStub::uploadedFile('derp')); - $invalid = array( + $invalid = [ 'name' => 'testing' - ); + ]; $this->assertFalse(ValidationStub::uploadedFile($invalid)); - $file = array( + $file = [ 'name' => 'cake.power.gif', 'tmp_name' => CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot/img/cake.power.gif', 'error' => UPLOAD_ERR_OK, 'type' => 'image/gif', 'size' => 201 - ); + ]; $this->assertTrue(ValidationStub::uploadedFile($file)); $file['error'] = UPLOAD_ERR_NO_FILE; $this->assertFalse(ValidationStub::uploadedFile($file), 'Error upload should fail.'); @@ -2483,20 +2483,20 @@ public function testUploadedFileErrorCode() { * @return void */ public function testUploadedFileMimeType() { - $file = array( + $file = [ 'name' => 'cake.power.gif', 'tmp_name' => CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot/img/cake.power.gif', 'error' => UPLOAD_ERR_OK, 'type' => 'text/plain', 'size' => 201 - ); - $options = array( - 'types' => array('text/plain') - ); + ]; + $options = [ + 'types' => ['text/plain'] + ]; $this->assertFalse(ValidationStub::uploadedFile($file, $options), 'Incorrect mimetype.'); - $options = array( - 'types' => array('image/gif', 'image/png') - ); + $options = [ + 'types' => ['image/gif', 'image/png'] + ]; $this->assertTrue(ValidationStub::uploadedFile($file, $options)); } @@ -2506,33 +2506,33 @@ public function testUploadedFileMimeType() { * @return void */ public function testUploadedFileSize() { - $file = array( + $file = [ 'name' => 'cake.power.gif', 'tmp_name' => CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot/img/cake.power.gif', 'error' => UPLOAD_ERR_OK, 'type' => 'text/plain', 'size' => 201 - ); - $options = array( + ]; + $options = [ 'minSize' => 500 - ); + ]; $this->assertFalse(ValidationStub::uploadedFile($file, $options), 'Too small'); - $options = array( + $options = [ 'maxSize' => 100 - ); + ]; $this->assertFalse(ValidationStub::uploadedFile($file, $options), 'Too big'); - $options = array( + $options = [ 'minSize' => 100, - ); + ]; $this->assertTrue(ValidationStub::uploadedFile($file, $options)); - $options = array( + $options = [ 'maxSize' => 500, - ); + ]; $this->assertTrue(ValidationStub::uploadedFile($file, $options)); - $options = array( + $options = [ 'minSize' => 100, 'maxSize' => 500 - ); + ]; $this->assertTrue(ValidationStub::uploadedFile($file, $options)); } @@ -2542,22 +2542,22 @@ public function testUploadedFileSize() { * @return void */ public function testUploadedFileNoFile() { - $file = array( + $file = [ 'name' => '', 'tmp_name' => CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot/img/cake.power.gif', 'error' => UPLOAD_ERR_NO_FILE, 'type' => '', 'size' => 0 - ); - $options = array( + ]; + $options = [ 'optional' => true, 'minSize' => 500, - 'types' => array('image/gif', 'image/png') - ); + 'types' => ['image/gif', 'image/png'] + ]; $this->assertTrue(Validation::uploadedFile($file, $options), 'No file should be ok.'); - $options = array( + $options = [ 'optional' => false - ); + ]; $this->assertFalse(Validation::uploadedFile($file, $options), 'File is required.'); } /** @@ -2566,14 +2566,14 @@ public function testUploadedFileNoFile() { * @return void */ public function testUploadedFileWithDifferentFileParametersOrder() { - $file = array( + $file = [ 'name' => 'cake.power.gif', 'error' => UPLOAD_ERR_OK, 'tmp_name' => CORE_PATH . 'Cake' . DS . 'Test' . DS . 'test_app' . DS . 'webroot/img/cake.power.gif', 'type' => 'text/plain', 'size' => 201 - ); - $options = array(); + ]; + $options = []; $this->assertTrue(ValidationStub::uploadedFile($file, $options), 'Wrong order'); } } diff --git a/lib/Cake/Test/Case/Utility/XmlTest.php b/lib/Cake/Test/Case/Utility/XmlTest.php index 8fa7fd9ef5..f93e5479ca 100644 --- a/lib/Cake/Test/Case/Utility/XmlTest.php +++ b/lib/Cake/Test/Case/Utility/XmlTest.php @@ -38,12 +38,12 @@ class XmlArticle extends CakeTestModel { * * @var array */ - public $belongsTo = array( - 'User' => array( + public $belongsTo = [ + 'User' => [ 'className' => 'XmlUser', 'foreignKey' => 'user_id' - ) - ); + ] + ]; } /** @@ -65,11 +65,11 @@ class XmlUser extends CakeTestModel { * * @var array */ - public $hasMany = array( - 'Article' => array( + public $hasMany = [ + 'Article' => [ 'className' => 'XmlArticle' - ) - ); + ] + ]; } /** @@ -90,9 +90,9 @@ class XmlTest extends CakeTestCase { * fixtures property * @var array */ - public $fixtures = array( + public $fixtures = [ 'core.article', 'core.user' - ); + ]; /** * setUp method @@ -130,7 +130,7 @@ public function testBuild() { $xml = 'value'; $this->assertEquals($obj, Xml::build($xml)); - $obj = Xml::build($xml, array('return' => 'domdocument')); + $obj = Xml::build($xml, ['return' => 'domdocument']); $this->assertTrue($obj instanceof DOMDocument); $this->assertEquals('tag', $obj->firstChild->nodeName); $this->assertEquals('value', $obj->firstChild->nodeValue); @@ -142,28 +142,28 @@ public function testBuild() { $this->assertEquals(Xml::build($xml), Xml::build(file_get_contents($xml))); - $obj = Xml::build($xml, array('return' => 'domdocument')); + $obj = Xml::build($xml, ['return' => 'domdocument']); $this->assertEquals('tags', $obj->firstChild->nodeName); $this->assertEquals( - Xml::build($xml, array('return' => 'domdocument')), - Xml::build(file_get_contents($xml), array('return' => 'domdocument')) + Xml::build($xml, ['return' => 'domdocument']), + Xml::build(file_get_contents($xml), ['return' => 'domdocument']) ); $this->assertEquals( - Xml::build($xml, array('return' => 'simplexml')), + Xml::build($xml, ['return' => 'simplexml']), Xml::build($xml, 'simplexml') ); - $xml = array('tag' => 'value'); + $xml = ['tag' => 'value']; $obj = Xml::build($xml); $this->assertEquals('tag', $obj->getName()); $this->assertEquals('value', (string)$obj); - $obj = Xml::build($xml, array('return' => 'domdocument')); + $obj = Xml::build($xml, ['return' => 'domdocument']); $this->assertEquals('tag', $obj->firstChild->nodeName); $this->assertEquals('value', $obj->firstChild->nodeValue); - $obj = Xml::build($xml, array('return' => 'domdocument', 'encoding' => null)); + $obj = Xml::build($xml, ['return' => 'domdocument', 'encoding' => null]); $this->assertDoesNotMatchRegularExpression('/encoding/', $obj->saveXML()); } @@ -174,7 +174,7 @@ public function testBuild() { */ public function testBuildHuge() { $xml = 'value'; - $obj = Xml::build($xml, array('parseHuge' => true)); + $obj = Xml::build($xml, ['parseHuge' => true]); $this->assertEquals('tag', $obj->getName()); $this->assertEquals('value', (string)$obj); } @@ -187,7 +187,7 @@ public function testBuildHuge() { public function testBuildFromFileWhenDisabled() { $this->expectException(XmlException::class); $xml = CAKE . 'Test' . DS . 'Fixture' . DS . 'sample.xml'; - Xml::build($xml, array('readFile' => false)); + Xml::build($xml, ['readFile' => false]); } /** @@ -198,7 +198,7 @@ public function testBuildFromFileWhenDisabled() { public function testBuildFromUrlWhenDisabled() { $this->expectException(XmlException::class); $xml = 'http://www.google.com'; - Xml::build($xml, array('readFile' => false)); + Xml::build($xml, ['readFile' => false]); } /** @@ -207,12 +207,12 @@ public function testBuildFromUrlWhenDisabled() { * @return array */ public static function invalidDataProvider() { - return array( - array(null), - array(false), - array(''), - array('http://localhost/notthere.xml'), - ); + return [ + [null], + [false], + [''], + ['http://localhost/notthere.xml'], + ]; } /** @@ -234,7 +234,7 @@ public function testBuildInvalidData($value) { public function testBuildInvalidDataSimpleXml() { $this->expectException(XmlException::class); $input = ' 'simplexml')); + Xml::build($input, ['return' => 'simplexml']); } /** @@ -246,7 +246,7 @@ public function testBuildEmptyTag() { try { Xml::build(''); $this->fail('No exception'); - } catch (Exception $e) { + } catch (Exception) { $this->assertTrue(true, 'An exception was raised'); } } @@ -257,35 +257,35 @@ public function testBuildEmptyTag() { * @return void */ public function testFromArray() { - $xml = array('tag' => 'value'); + $xml = ['tag' => 'value']; $obj = Xml::fromArray($xml); $this->assertEquals('tag', $obj->getName()); $this->assertEquals('value', (string)$obj); - $xml = array('tag' => null); + $xml = ['tag' => null]; $obj = Xml::fromArray($xml); $this->assertEquals('tag', $obj->getName()); $this->assertEquals('', (string)$obj); - $xml = array('tag' => array('@' => 'value')); + $xml = ['tag' => ['@' => 'value']]; $obj = Xml::fromArray($xml); $this->assertEquals('tag', $obj->getName()); $this->assertEquals('value', (string)$obj); - $xml = array( - 'tags' => array( - 'tag' => array( - array( + $xml = [ + 'tags' => [ + 'tag' => [ + [ 'id' => '1', 'name' => 'defect' - ), - array( + ], + [ 'id' => '2', 'name' => 'enhancement' - ) - ) - ) - ); + ] + ] + ] + ]; $obj = Xml::fromArray($xml, 'attributes'); $this->assertTrue($obj instanceof SimpleXMLElement); $this->assertEquals('tags', $obj->getName()); @@ -318,24 +318,24 @@ public function testFromArray() { XML; $this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML()); - $xml = array( - 'tags' => array( - ) - ); + $xml = [ + 'tags' => [ + ] + ]; $obj = Xml::fromArray($xml); $this->assertEquals('tags', $obj->getName()); $this->assertEquals('', (string)$obj); - $xml = array( - 'tags' => array( + $xml = [ + 'tags' => [ 'bool' => true, 'int' => 1, 'float' => 10.2, 'string' => 'ok', 'null' => null, - 'array' => array() - ) - ); + 'array' => [] + ] + ]; $obj = Xml::fromArray($xml, 'tags'); $this->assertEquals(6, count($obj)); $this->assertSame((string)$obj->bool, '1'); @@ -345,20 +345,20 @@ public function testFromArray() { $this->assertSame((string)$obj->null, ''); $this->assertSame((string)$obj->array, ''); - $xml = array( - 'tags' => array( - 'tag' => array( - array( + $xml = [ + 'tags' => [ + 'tag' => [ + [ '@id' => '1', 'name' => 'defect' - ), - array( + ], + [ '@id' => '2', 'name' => 'enhancement' - ) - ) - ) - ); + ] + ] + ] + ]; $obj = Xml::fromArray($xml, 'tags'); $xmlText = << @@ -373,22 +373,22 @@ public function testFromArray() { XML; $this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML()); - $xml = array( - 'tags' => array( - 'tag' => array( - array( + $xml = [ + 'tags' => [ + 'tag' => [ + [ '@id' => '1', 'name' => 'defect', '@' => 'Tag 1' - ), - array( + ], + [ '@id' => '2', 'name' => 'enhancement' - ), - ), + ], + ], '@' => 'All tags' - ) - ); + ] + ]; $obj = Xml::fromArray($xml, 'tags'); $xmlText = << @@ -396,14 +396,14 @@ public function testFromArray() { XML; $this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML()); - $xml = array( - 'tags' => array( - 'tag' => array( + $xml = [ + 'tags' => [ + 'tag' => [ 'id' => 1, '@' => 'defect' - ) - ) - ); + ] + ] + ]; $obj = Xml::fromArray($xml, 'attributes'); $xmlText = '<' . '?xml version="1.0" encoding="UTF-8"?>defect'; $this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML()); @@ -415,12 +415,12 @@ public function testFromArray() { * @return void */ public function testFromArrayZeroValue() { - $xml = array( - 'tag' => array( + $xml = [ + 'tag' => [ '@' => 0, '@test' => 'A test' - ) - ); + ] + ]; $obj = Xml::fromArray($xml); $xmlText = << @@ -428,9 +428,9 @@ public function testFromArrayZeroValue() { XML; $this->assertXmlStringEqualsXmlString($xmlText, $obj->asXML()); - $xml = array( - 'tag' => array('0') - ); + $xml = [ + 'tag' => ['0'] + ]; $obj = Xml::fromArray($xml); $xmlText = << @@ -445,21 +445,21 @@ public function testFromArrayZeroValue() { * @return void */ public function testFromArrayNonSequentialKeys() { - $xmlArray = array( - 'Event' => array( - array( + $xmlArray = [ + 'Event' => [ + [ 'id' => '235', - 'Attribute' => array( - 0 => array( + 'Attribute' => [ + 0 => [ 'id' => '9646', - ), - 2 => array( + ], + 2 => [ 'id' => '9647', - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $obj = Xml::fromArray($xmlArray); $expected = << @@ -482,27 +482,27 @@ public function testFromArrayNonSequentialKeys() { * @return void */ public function testFromArrayPretty() { - $xml = array( - 'tags' => array( - 'tag' => array( - array( + $xml = [ + 'tags' => [ + 'tag' => [ + [ 'id' => '1', 'name' => 'defect' - ), - array( + ], + [ 'id' => '2', 'name' => 'enhancement' - ) - ) - ) - ); + ] + ] + ] + ]; $expected = << 1defect2enhancement XML; - $xmlResponse = Xml::fromArray($xml, array('pretty' => false)); + $xmlResponse = Xml::fromArray($xml, ['pretty' => false]); $this->assertTextEquals($expected, $xmlResponse->asXML()); $expected = << XML; - $xmlResponse = Xml::fromArray($xml, array('pretty' => true)); + $xmlResponse = Xml::fromArray($xml, ['pretty' => true]); $this->assertTextEquals($expected, $xmlResponse->asXML()); - $xml = array( - 'tags' => array( - 'tag' => array( - array( + $xml = [ + 'tags' => [ + 'tag' => [ + [ 'id' => '1', 'name' => 'defect' - ), - array( + ], + [ 'id' => '2', 'name' => 'enhancement' - ) - ) - ) - ); + ] + ] + ] + ]; $expected = << XML; - $xmlResponse = Xml::fromArray($xml, array('pretty' => false, 'format' => 'attributes')); + $xmlResponse = Xml::fromArray($xml, ['pretty' => false, 'format' => 'attributes']); $this->assertTextEquals($expected, $xmlResponse->asXML()); $expected = << XML; - $xmlResponse = Xml::fromArray($xml, array('pretty' => true, 'format' => 'attributes')); + $xmlResponse = Xml::fromArray($xml, ['pretty' => true, 'format' => 'attributes']); $this->assertTextEquals($expected, $xmlResponse->asXML()); } @@ -563,41 +563,41 @@ public function testFromArrayPretty() { * @return array */ public static function invalidArrayDataProvider() { - return array( - array(''), - array(null), - array(false), - array(array()), - array(array('numeric key as root')), - array(array('item1' => '', 'item2' => '')), - array(array('items' => array('item1', 'item2'))), - array(array( - 'tags' => array( - 'tag' => array( - array( - array( + return [ + [''], + [null], + [false], + [[]], + [['numeric key as root']], + [['item1' => '', 'item2' => '']], + [['items' => ['item1', 'item2']]], + [[ + 'tags' => [ + 'tag' => [ + [ + [ 'string' - ) - ) - ) - ) - )), - array(array( - 'tags' => array( - '@tag' => array( - array( + ] + ] + ] + ] + ]], + [[ + 'tags' => [ + '@tag' => [ + [ '@id' => '1', 'name' => 'defect' - ), - array( + ], + [ '@id' => '2', 'name' => 'enhancement' - ) - ) - ) - )), - array(new DateTime()) - ); + ] + ] + ] + ]], + [new DateTime()] + ]; } /** @@ -610,7 +610,7 @@ public function testFromArrayFail($value) { try { Xml::fromArray($value); $this->fail('No exception.'); - } catch (Exception $e) { + } catch (Exception) { $this->assertTrue(true, 'Caught exception.'); } } @@ -621,18 +621,18 @@ public function testFromArrayFail($value) { * @return void */ public function testFromArrayUnterminatedError() { - $data = array( + $data = [ 'product_ID' => 'GENERT-DL', 'deeplink' => 'http://example.com/deep', 'image_URL' => 'http://example.com/image', 'thumbnail_image_URL' => 'http://example.com/thumb', 'brand' => 'Malte Lange & Co', 'availability' => 'in stock', - 'authors' => array( - 'author' => array('Malte Lange & Co') - ) - ); - $xml = Xml::fromArray(array('products' => $data), 'tags'); + 'authors' => [ + 'author' => ['Malte Lange & Co'] + ] + ]; + $xml = Xml::fromArray(['products' => $data], 'tags'); $expected = << @@ -658,95 +658,95 @@ public function testFromArrayUnterminatedError() { public function testToArray() { $xml = 'name'; $obj = Xml::build($xml); - $this->assertEquals(array('tag' => 'name'), Xml::toArray($obj)); + $this->assertEquals(['tag' => 'name'], Xml::toArray($obj)); $xml = CAKE . 'Test' . DS . 'Fixture' . DS . 'sample.xml'; $obj = Xml::build($xml); - $expected = array( - 'tags' => array( - 'tag' => array( - array( + $expected = [ + 'tags' => [ + 'tag' => [ + [ '@id' => '1', 'name' => 'defect' - ), - array( + ], + [ '@id' => '2', 'name' => 'enhancement' - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, Xml::toArray($obj)); - $array = array( - 'tags' => array( - 'tag' => array( - array( + $array = [ + 'tags' => [ + 'tag' => [ + [ 'id' => '1', 'name' => 'defect' - ), - array( + ], + [ 'id' => '2', 'name' => 'enhancement' - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals(Xml::toArray(Xml::fromArray($array, 'tags')), $array); - $expected = array( - 'tags' => array( - 'tag' => array( - array( + $expected = [ + 'tags' => [ + 'tag' => [ + [ '@id' => '1', '@name' => 'defect' - ), - array( + ], + [ '@id' => '2', '@name' => 'enhancement' - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, 'attributes'))); - $this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, array('return' => 'domdocument', 'format' => 'attributes')))); + $this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, ['return' => 'domdocument', 'format' => 'attributes']))); $this->assertEquals(Xml::toArray(Xml::fromArray($array)), $array); - $this->assertEquals(Xml::toArray(Xml::fromArray($array, array('return' => 'domdocument'))), $array); + $this->assertEquals(Xml::toArray(Xml::fromArray($array, ['return' => 'domdocument'])), $array); - $array = array( - 'tags' => array( - 'tag' => array( + $array = [ + 'tags' => [ + 'tag' => [ 'id' => '1', - 'posts' => array( - array('id' => '1'), - array('id' => '2') - ) - ), - 'tagOther' => array( - 'subtag' => array( + 'posts' => [ + ['id' => '1'], + ['id' => '2'] + ] + ], + 'tagOther' => [ + 'subtag' => [ 'id' => '1' - ) - ) - ) - ); - $expected = array( - 'tags' => array( - 'tag' => array( + ] + ] + ] + ]; + $expected = [ + 'tags' => [ + 'tag' => [ '@id' => '1', - 'posts' => array( - array('@id' => '1'), - array('@id' => '2') - ) - ), - 'tagOther' => array( - 'subtag' => array( + 'posts' => [ + ['@id' => '1'], + ['@id' => '2'] + ] + ], + 'tagOther' => [ + 'subtag' => [ '@id' => '1' - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, 'attributes'))); - $this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, array('format' => 'attributes', 'return' => 'domdocument')))); + $this->assertEquals($expected, Xml::toArray(Xml::fromArray($array, ['format' => 'attributes', 'return' => 'domdocument']))); $xml = << @@ -755,14 +755,14 @@ public function testToArray() { XML; $obj = Xml::build($xml); - $expected = array( - 'root' => array( - 'tag' => array( + $expected = [ + 'root' => [ + 'tag' => [ '@id' => 1, '@' => 'defect' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, Xml::toArray($obj)); $xml = << array( - 'table' => array( - array('tr' => array('td' => array('Apples', 'Bananas'))), - array('name' => 'CakePHP', 'license' => 'MIT'), + $expected = [ + 'root' => [ + 'table' => [ + ['tr' => ['td' => ['Apples', 'Bananas']]], + ['name' => 'CakePHP', 'license' => 'MIT'], 'The book is on the table.' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, Xml::toArray($obj)); $xml = << array( + $expected = [ + 'root' => [ 'tag' => 'defect', 'cake:bug' => 1 - ) - ); + ] + ]; $this->assertEquals($expected, Xml::toArray($obj)); $xml = '0'; $obj = Xml::build($xml); - $expected = array( - 'tag' => array( + $expected = [ + 'tag' => [ '@type' => 'myType', '@' => 0 - ) - ); + ] + ]; $this->assertEquals($expected, Xml::toArray($obj)); } @@ -823,46 +823,46 @@ public function testRss() { $this->assertEquals('2.0', $rssAsArray['rss']['@version']); $this->assertEquals(2, count($rssAsArray['rss']['channel']['item'])); - $atomLink = array('@href' => 'https://bakery.cakephp.org/articles/rss', '@rel' => 'self', '@type' => 'application/rss+xml'); + $atomLink = ['@href' => 'https://bakery.cakephp.org/articles/rss', '@rel' => 'self', '@type' => 'application/rss+xml']; $this->assertEquals($rssAsArray['rss']['channel']['atom:link'], $atomLink); $this->assertEquals('https://bakery.cakephp.org/', $rssAsArray['rss']['channel']['link']); - $expected = array( + $expected = [ 'title' => 'Alertpay automated sales via IPN', 'link' => 'https://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn', 'description' => 'I\'m going to show you how I implemented a payment module via the Alertpay payment processor.', 'pubDate' => 'Tue, 31 Aug 2010 01:42:00 -0500', 'guid' => 'https://bakery.cakephp.org/articles/view/alertpay-automated-sales-via-ipn' - ); + ]; $this->assertSame($expected, $rssAsArray['rss']['channel']['item'][1]); - $rss = array( - 'rss' => array( + $rss = [ + 'rss' => [ 'xmlns:atom' => 'http://www.w3.org/2005/Atom', '@version' => '2.0', - 'channel' => array( - 'atom:link' => array( + 'channel' => [ + 'atom:link' => [ '@href' => 'https://bakery.cakephp.org/articles/rss', '@rel' => 'self', '@type' => 'application/rss+xml' - ), + ], 'title' => 'The Bakery: ', 'link' => 'https://bakery.cakephp.org/', 'description' => 'Recent Articles at The Bakery.', 'pubDate' => 'Sun, 12 Sep 2010 04:18:26 -0500', - 'item' => array( - array( + 'item' => [ + [ 'title' => 'CakePHP 1.3.4 released', 'link' => 'https://bakery.cakephp.org/articles/view/cakephp-1-3-4-released' - ), - array( + ], + [ 'title' => 'Wizard Component 1.2 Tutorial', 'link' => 'https://bakery.cakephp.org/articles/view/wizard-component-1-2-tutorial' - ) - ) - ) - ) - ); + ] + ] + ] + ] + ]; $rssAsSimpleXML = Xml::fromArray($rss); $xmlText = << @@ -894,36 +894,36 @@ public function testRss() { */ public function testXmlRpc() { $xml = Xml::build('test'); - $expected = array( - 'methodCall' => array( + $expected = [ + 'methodCall' => [ 'methodName' => 'test', 'params' => '' - ) - ); + ] + ]; $this->assertSame($expected, Xml::toArray($xml)); $xml = Xml::build('test12Egypt0-31'); - $expected = array( - 'methodCall' => array( + $expected = [ + 'methodCall' => [ 'methodName' => 'test', - 'params' => array( - 'param' => array( - 'value' => array( - 'array' => array( - 'data' => array( - 'value' => array( - array('int' => '12'), - array('string' => 'Egypt'), - array('boolean' => '0'), - array('int' => '-31') - ) - ) - ) - ) - ) - ) - ) - ); + 'params' => [ + 'param' => [ + 'value' => [ + 'array' => [ + 'data' => [ + 'value' => [ + ['int' => '12'], + ['string' => 'Egypt'], + ['boolean' => '0'], + ['int' => '-31'] + ] + ] + ] + ] + ] + ] + ] + ]; $this->assertSame($expected, Xml::toArray($xml)); $xmlText = << XML; $xml = Xml::build($xmlText); - $expected = array( - 'methodResponse' => array( - 'params' => array( - 'param' => array( - 'value' => array( - 'array' => array( - 'data' => array( - 'value' => array( - array('int' => '1'), - array('string' => 'testing') - ) - ) - ) - ) - ) - ) - ) - ); + $expected = [ + 'methodResponse' => [ + 'params' => [ + 'param' => [ + 'value' => [ + 'array' => [ + 'data' => [ + 'value' => [ + ['int' => '1'], + ['string' => 'testing'] + ] + ] + ] + ] + ] + ] + ] + ]; $this->assertSame($expected, Xml::toArray($xml)); $xml = Xml::fromArray($expected, 'tags'); @@ -979,44 +979,44 @@ public function testXmlRpc() { */ public function testSoap() { $xmlRequest = Xml::build(CAKE . 'Test' . DS . 'Fixture' . DS . 'soap_request.xml'); - $expected = array( - 'Envelope' => array( + $expected = [ + 'Envelope' => [ '@soap:encodingStyle' => 'http://www.w3.org/2001/12/soap-encoding', - 'soap:Body' => array( - 'm:GetStockPrice' => array( + 'soap:Body' => [ + 'm:GetStockPrice' => [ 'm:StockName' => 'IBM' - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, Xml::toArray($xmlRequest)); $xmlResponse = Xml::build(CAKE . 'Test' . DS . 'Fixture' . DS . 'soap_response.xml'); - $expected = array( - 'Envelope' => array( + $expected = [ + 'Envelope' => [ '@soap:encodingStyle' => 'http://www.w3.org/2001/12/soap-encoding', - 'soap:Body' => array( - 'm:GetStockPriceResponse' => array( + 'soap:Body' => [ + 'm:GetStockPriceResponse' => [ 'm:Price' => '34.5' - ) - ) - ) - ); + ] + ] + ] + ]; $this->assertEquals($expected, Xml::toArray($xmlResponse)); - $xml = array( - 'soap:Envelope' => array( + $xml = [ + 'soap:Envelope' => [ 'xmlns:soap' => 'http://www.w3.org/2001/12/soap-envelope', '@soap:encodingStyle' => 'http://www.w3.org/2001/12/soap-encoding', - 'soap:Body' => array( + 'soap:Body' => [ 'xmlns:m' => 'http://www.example.org/stock', - 'm:GetStockPrice' => array( + 'm:GetStockPrice' => [ 'm:StockName' => 'IBM' - ) - ) - ) - ); - $xmlRequest = Xml::fromArray($xml, array('encoding' => null)); + ] + ] + ] + ]; + $xmlRequest = Xml::fromArray($xml, ['encoding' => null]); $xmlText = << @@ -1044,65 +1044,65 @@ public function testNamespace() { XML; $xmlResponse = Xml::build($xml); - $expected = array( - 'root' => array( - 'ns:tag' => array( + $expected = [ + 'root' => [ + 'ns:tag' => [ '@id' => '1', 'child' => 'good', 'otherchild' => 'bad' - ), + ], 'tag' => 'Tag without ns' - ) - ); + ] + ]; $this->assertEquals($expected, Xml::toArray($xmlResponse)); $xmlResponse = Xml::build('1'); - $expected = array( - 'root' => array( - 'ns:tag' => array( + $expected = [ + 'root' => [ + 'ns:tag' => [ '@id' => '1' - ), - 'tag' => array( + ], + 'tag' => [ 'id' => '1' - ) - ) - ); + ] + ] + ]; $this->assertEquals($expected, Xml::toArray($xmlResponse)); $xmlResponse = Xml::build('1'); - $expected = array( - 'root' => array( + $expected = [ + 'root' => [ 'ns:attr' => '1' - ) - ); + ] + ]; $this->assertEquals($expected, Xml::toArray($xmlResponse)); $xmlResponse = Xml::build('1'); $this->assertEquals($expected, Xml::toArray($xmlResponse)); - $xml = array( - 'root' => array( - 'ns:attr' => array( + $xml = [ + 'root' => [ + 'ns:attr' => [ 'xmlns:ns' => 'https://cakephp.org', '@' => 1 - ) - ) - ); + ] + ] + ]; $expected = '<' . '?xml version="1.0" encoding="UTF-8"?>1'; $xmlResponse = Xml::fromArray($xml); - $this->assertEquals($expected, str_replace(array("\r", "\n"), '', $xmlResponse->asXML())); + $this->assertEquals($expected, str_replace(["\r", "\n"], '', $xmlResponse->asXML())); - $xml = array( - 'root' => array( - 'tag' => array( + $xml = [ + 'root' => [ + 'tag' => [ 'xmlns:pref' => 'https://cakephp.org', - 'pref:item' => array( + 'pref:item' => [ 'item 1', 'item 2' - ) - ) - ) - ); + ] + ] + ] + ]; $expected = << @@ -1115,31 +1115,31 @@ public function testNamespace() { $xmlResponse = Xml::fromArray($xml); $this->assertXmlStringEqualsXmlString($expected, $xmlResponse->asXML()); - $xml = array( - 'root' => array( - 'tag' => array( + $xml = [ + 'root' => [ + 'tag' => [ 'xmlns:' => 'https://cakephp.org' - ) - ) - ); + ] + ] + ]; $expected = '<' . '?xml version="1.0" encoding="UTF-8"?>'; $xmlResponse = Xml::fromArray($xml); $this->assertXmlStringEqualsXmlString($expected, $xmlResponse->asXML()); - $xml = array( - 'root' => array( + $xml = [ + 'root' => [ 'xmlns:' => 'https://cakephp.org' - ) - ); + ] + ]; $expected = '<' . '?xml version="1.0" encoding="UTF-8"?>'; $xmlResponse = Xml::fromArray($xml); $this->assertXmlStringEqualsXmlString($expected, $xmlResponse->asXML()); - $xml = array( - 'root' => array( + $xml = [ + 'root' => [ 'xmlns:ns' => 'https://cakephp.org' - ) - ); + ] + ]; $expected = '<' . '?xml version="1.0" encoding="UTF-8"?>'; $xmlResponse = Xml::fromArray($xml); $this->assertXmlStringEqualsXmlString($expected, $xmlResponse->asXML()); @@ -1164,10 +1164,10 @@ public function testCdata() { * @return array */ public static function invalidToArrayDataProvider() { - return array( - array(new DateTime()), - array(array()) - ); + return [ + [new DateTime()], + [[]] + ]; } /** @@ -1206,8 +1206,8 @@ public function testWithModel() { $this->assertXmlStringEqualsXmlString($expected, $obj->asXML()); //multiple model results - without a records key it would fatal error - $data = $user->find('all', array('limit' => 2)); - $data = array('records' => $data); + $data = $user->find('all', ['limit' => 2]); + $data = ['records' => $data]; $obj = Xml::build(compact('data')); $expected = << @@ -1233,11 +1233,11 @@ public function testWithModel() { * @return void */ public function testAmpInText() { - $data = array( - 'outer' => array( - 'inner' => array('name' => 'mark & mark') - ) - ); + $data = [ + 'outer' => [ + 'inner' => ['name' => 'mark & mark'] + ] + ]; $obj = Xml::build($data); $result = $obj->asXml(); $this->assertStringContainsString('mark & mark', $result); @@ -1260,7 +1260,7 @@ public function testNoEntityLoading() { try { $result = Xml::build($xml); $this->assertEquals('', (string)$result->xxe); - } catch (Exception $e) { + } catch (Exception) { $this->assertTrue(true, 'A warning was raised meaning external entities were not loaded'); } } diff --git a/lib/Cake/Test/Case/View/Helper/CacheHelperTest.php b/lib/Cake/Test/Case/View/Helper/CacheHelperTest.php index 1d276f8be1..eb5de0cea8 100644 --- a/lib/Cake/Test/Case/View/Helper/CacheHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/CacheHelperTest.php @@ -34,7 +34,7 @@ class CacheTestController extends Controller { * * @var array */ - public $helpers = array('Html', 'Cache'); + public $helpers = ['Html', 'Cache']; /** * cache_parsing method @@ -77,16 +77,16 @@ public function skip() { */ public function setUp() : void { parent::setUp(); - $_GET = array(); + $_GET = []; $request = new CakeRequest(); $this->Controller = new CacheTestController($request); $View = new View($this->Controller); $this->Cache = new CacheHelper($View); Configure::write('Cache.check', true); Configure::write('Cache.disable', false); - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - ), App::RESET); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ], App::RESET); } /** @@ -107,12 +107,12 @@ public function tearDown() : void { */ public function testLayoutCacheParsingNoTagsInView() { $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); + 'pass' => [], + 'named' => [] + ]); $this->Controller->cacheAction = 21600; $this->Controller->request->here = '/cacheTest/cache_parsing'; $this->Controller->request->action = 'cache_parsing'; @@ -140,12 +140,12 @@ public function testLayoutCacheParsingNoTagsInView() { */ public function testLayoutCacheParsingNoTagsInViewWithRelativeDuration() { $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); + 'pass' => [], + 'named' => [] + ]); $this->Controller->cacheAction = '+2 hours'; $this->Controller->request->here = '/cacheTest/cache_parsing'; $this->Controller->request->action = 'cache_parsing'; @@ -173,12 +173,12 @@ public function testLayoutCacheParsingNoTagsInViewWithRelativeDuration() { */ public function testCacheNonLatinCharactersInRoute() { $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array('風街ろまん'), - 'named' => array() - )); + 'pass' => ['風街ろまん'], + 'named' => [] + ]); $this->Controller->cacheAction = 21600; $this->Controller->request->here = '/posts/view/風街ろまん'; $this->Controller->action = 'view'; @@ -199,12 +199,12 @@ public function testCacheNonLatinCharactersInRoute() { */ public function testLayoutCacheParsingWithTagsInView() { $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); + 'pass' => [], + 'named' => [] + ]); $this->Controller->cacheAction = 21600; $this->Controller->request->here = '/cacheTest/cache_parsing'; $this->Controller->action = 'cache_parsing'; @@ -233,12 +233,12 @@ public function testLayoutCacheParsingWithTagsInView() { */ public function testMultipleNoCacheTagsInViewfile() { $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); + 'pass' => [], + 'named' => [] + ]); $this->Controller->cacheAction = 21600; $this->Controller->request->here = '/cacheTest/cache_parsing'; $this->Controller->action = 'cache_parsing'; @@ -264,13 +264,13 @@ public function testMultipleNoCacheTagsInViewfile() { */ public function testComplexNoCache() { $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_complex', - 'pass' => array(), - 'named' => array() - )); - $this->Controller->cacheAction = array('cache_complex' => 21600); + 'pass' => [], + 'named' => [] + ]); + $this->Controller->cacheAction = ['cache_complex' => 21600]; $this->Controller->request->here = '/cacheTest/cache_complex'; $this->Controller->action = 'cache_complex'; $this->Controller->layout = 'multi_cache'; @@ -324,12 +324,12 @@ public function testComplexNoCache() { */ public function testCacheViewVars() { $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); + 'pass' => [], + 'named' => [] + ]); $this->Controller->request->here = '/cacheTest/cache_parsing'; $this->Controller->cacheAction = 21600; @@ -355,18 +355,18 @@ public function testCacheViewVars() { * @return void */ public function testCacheCallbacks() { - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); - $this->Controller->cacheAction = array( - 'cache_parsing' => array( + 'pass' => [], + 'named' => [] + ]); + $this->Controller->cacheAction = [ + 'cache_parsing' => [ 'duration' => 21600, 'callbacks' => true - ) - ); + ] + ]; $this->Controller->request->here = '/cacheTest/cache_parsing'; $this->Controller->cache_parsing(); @@ -389,16 +389,16 @@ public function testCacheCallbacks() { * @return void */ public function testCacheActionArray() { - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); + 'pass' => [], + 'named' => [] + ]); $this->Controller->request->here = '/cache_test/cache_parsing'; - $this->Controller->cacheAction = array( + $this->Controller->cacheAction = [ 'cache_parsing' => 21600 - ); + ]; $this->Controller->cache_parsing(); @@ -419,15 +419,15 @@ public function testCacheActionArray() { * @return void */ public function testCacheActionArrayCamelCase() { - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); - $this->Controller->cacheAction = array( + 'pass' => [], + 'named' => [] + ]); + $this->Controller->cacheAction = [ 'cache_parsing' => 21600 - ); + ]; $this->Controller->request->here = '/cacheTest/cache_parsing'; $this->Controller->cache_parsing(); @@ -451,18 +451,18 @@ public function testCacheWithNamedAndPassedArgs() { Router::reload(); $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(1, 2), - 'named' => array( + 'pass' => [1, 2], + 'named' => [ 'name' => 'mark', 'ice' => 'cream' - ) - )); - $this->Controller->cacheAction = array( + ] + ]); + $this->Controller->cacheAction = [ 'cache_parsing' => 21600 - ); + ]; $this->Controller->request->here = '/cache_test/cache_parsing/1/2/name:mark/ice:cream'; $View = new View($this->Controller); @@ -485,16 +485,16 @@ public function testCacheWithQueryStringParams() { Router::reload(); $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); - $this->Controller->request->query = array('q' => 'cakephp'); - $this->Controller->cacheAction = array( + 'pass' => [], + 'named' => [] + ]); + $this->Controller->request->query = ['q' => 'cakephp']; + $this->Controller->cacheAction = [ 'cache_parsing' => 21600 - ); + ]; $this->Controller->request->here = '/cache_test/cache_parsing'; $View = new View($this->Controller); @@ -515,19 +515,19 @@ public function testCacheWithQueryStringParams() { */ public function testCacheWithCustomRoutes() { Router::reload(); - Router::connect('/:lang/:controller/:action/*', array(), array('lang' => '[a-z]{3}')); + Router::connect('/:lang/:controller/:action/*', [], ['lang' => '[a-z]{3}']); $this->Controller->cache_parsing(); - $this->Controller->request->addParams(array( + $this->Controller->request->addParams([ 'lang' => 'en', 'controller' => 'cache_test', 'action' => 'cache_parsing', - 'pass' => array(), - 'named' => array() - )); - $this->Controller->cacheAction = array( + 'pass' => [], + 'named' => [] + ]); + $this->Controller->cacheAction = [ 'cache_parsing' => 21600 - ); + ]; $this->Controller->request->here = '/en/cache_test/cache_parsing'; $this->Controller->action = 'cache_parsing'; @@ -553,15 +553,15 @@ public function testCacheWithCustomRoutes() { */ public function testCacheBaseNameControllerName() { $this->Controller->cache_parsing(); - $this->Controller->cacheAction = array( + $this->Controller->cacheAction = [ 'cache_name' => 21600 - ); - $this->Controller->params = array( + ]; + $this->Controller->params = [ 'controller' => 'cacheTest', 'action' => 'cache_name', - 'pass' => array(), - 'named' => array() - ); + 'pass' => [], + 'named' => [] + ]; $this->Controller->here = '/cache/cacheTest/cache_name'; $this->Controller->action = 'cache_name'; $this->Controller->base = '/cache'; @@ -588,7 +588,7 @@ public function testAfterRenderConditions() { $View->cacheAction = '+1 day'; $View->output = 'test'; - $Cache = $this->getMock('CacheHelper', array('_parseContent'), array($View)); + $Cache = $this->getMock('CacheHelper', ['_parseContent'], [$View]); $Cache->expects($this->once()) ->method('_parseContent') ->with('posts/index', 'content') @@ -615,7 +615,7 @@ public function testAfterLayoutConditions() { $View->cacheAction = '+1 day'; $View->output = 'test'; - $Cache = $this->getMock('CacheHelper', array('cache'), array($View)); + $Cache = $this->getMock('CacheHelper', ['cache'], [$View]); $Cache->expects($this->once()) ->method('cache') ->with('posts/index', $View->output) @@ -640,13 +640,13 @@ public function testAfterLayoutConditions() { */ public function testCacheEmptySections() { $this->Controller->cache_parsing(); - $this->Controller->params = array( + $this->Controller->params = [ 'controller' => 'cacheTest', 'action' => 'cache_empty_sections', - 'pass' => array(), - 'named' => array() - ); - $this->Controller->cacheAction = array('cache_empty_sections' => 21600); + 'pass' => [], + 'named' => [] + ]; + $this->Controller->cacheAction = ['cache_empty_sections' => 21600]; $this->Controller->here = '/cacheTest/cache_empty_sections'; $this->Controller->action = 'cache_empty_sections'; $this->Controller->layout = 'cache_empty_sections'; diff --git a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php index f01d69f760..cf666fe119 100644 --- a/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FlashHelperTest.php @@ -35,9 +35,9 @@ class FlashHelperTest extends CakeTestCase { * @return void */ public static function setupBeforeClass() : void { - App::build(array( - 'View' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS) - )); + App::build([ + 'View' => [CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS] + ]); } /** @@ -54,51 +54,51 @@ public function setUp() : void { if (!CakeSession::started()) { CakeSession::start(); } - CakeSession::write(array( - 'Message' => array( - 'flash' => array( - array( + CakeSession::write([ + 'Message' => [ + 'flash' => [ + [ 'key' => 'flash', 'message' => 'This is the first Message', 'element' => 'Flash/default', - 'params' => array() - ), - array( + 'params' => [] + ], + [ 'key' => 'flash', 'message' => 'This is the second Message', 'element' => 'Flash/default', - 'params' => array() - ) - ), - 'notification' => array( - array( + 'params' => [] + ] + ], + 'notification' => [ + [ 'key' => 'notification', 'message' => 'Broadcast message testing', 'element' => 'flash_helper', - 'params' => array( + 'params' => [ 'title' => 'Notice!', 'name' => 'Alert!' - ) - ) - ), - 'classy' => array( - array( + ] + ] + ], + 'classy' => [ + [ 'key' => 'classy', 'message' => 'Recorded', 'element' => 'flash_classy', - 'params' => array() - ) - ), - 'default' => array( - array( + 'params' => [] + ] + ], + 'default' => [ + [ 'key' => 'default', 'message' => 'Default', 'element' => 'default', - 'params' => array() - ) - ) - ) - )); + 'params' => [] + ] + ] + ] + ]); } /** @@ -149,10 +149,10 @@ public function testFlashThrowsException() { * @return void */ public function testFlashElementInAttrs() { - $result = $this->Flash->render('notification', array( + $result = $this->Flash->render('notification', [ 'element' => 'flash_helper', - 'params' => array('title' => 'Alert!', 'name' => 'Notice!') - )); + 'params' => ['title' => 'Alert!', 'name' => 'Notice!'] + ]); $expected = "

\n\t

Notice!

\n\t

Alert!

\n\t

Broadcast message testing

\n
"; @@ -165,12 +165,12 @@ public function testFlashElementInAttrs() { * @return void */ public function testFlashWithPluginElement() { - App::build(array( - 'Plugin' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS) - )); + App::build([ + 'Plugin' => [CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS] + ]); CakePlugin::load('TestPlugin'); - $result = $this->Flash->render('flash', array('element' => 'TestPlugin.plugin_element')); + $result = $this->Flash->render('flash', ['element' => 'TestPlugin.plugin_element']); $expected = 'this is the plugin element'; $this->assertStringContainsString($expected, $result); } diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 6024e39fed..60b80ebb42 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -60,55 +60,55 @@ class Contact extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'phone' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'password' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'lap_time' => array('type' => 'time', 'null' => '', 'default' => '', 'length' => '2'), - 'last_seen' => array('type' => 'datetime', 'null' => '', 'default' => '', 'length' => '3'), - 'published' => array('type' => 'date', 'null' => true, 'default' => null, 'length' => null), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null), - 'age' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'phone' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'password' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'lap_time' => ['type' => 'time', 'null' => '', 'default' => '', 'length' => '2'], + 'last_seen' => ['type' => 'datetime', 'null' => '', 'default' => '', 'length' => '3'], + 'published' => ['type' => 'date', 'null' => true, 'default' => null, 'length' => null], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null], + 'age' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => null] + ]; /** * validate property * * @var array */ - public $validate = array( - 'non_existing' => array(), - 'idontexist' => array(), - 'imrequired' => array('rule' => array('between', 5, 30), 'allowEmpty' => false), - 'imrequiredonupdate' => array('notBlank' => array('rule' => 'alphaNumeric', 'on' => 'update')), - 'imrequiredoncreate' => array('required' => array('rule' => 'alphaNumeric', 'on' => 'create')), - 'imrequiredonboth' => array( - 'required' => array('rule' => 'alphaNumeric'), - ), + public $validate = [ + 'non_existing' => [], + 'idontexist' => [], + 'imrequired' => ['rule' => ['between', 5, 30], 'allowEmpty' => false], + 'imrequiredonupdate' => ['notBlank' => ['rule' => 'alphaNumeric', 'on' => 'update']], + 'imrequiredoncreate' => ['required' => ['rule' => 'alphaNumeric', 'on' => 'create']], + 'imrequiredonboth' => [ + 'required' => ['rule' => 'alphaNumeric'], + ], 'string_required' => 'notBlank', - 'imalsorequired' => array('rule' => 'alphaNumeric', 'allowEmpty' => false), - 'imrequiredtoo' => array('rule' => 'notBlank'), - 'required_one' => array('required' => array('rule' => array('notBlank'))), - 'imnotrequired' => array('required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true), - 'imalsonotrequired' => array( - 'alpha' => array('rule' => 'alphaNumeric', 'allowEmpty' => true), - 'between' => array('rule' => array('between', 5, 30)), - ), - 'imalsonotrequired2' => array( - 'alpha' => array('rule' => 'alphaNumeric', 'allowEmpty' => true), - 'between' => array('rule' => array('between', 5, 30), 'allowEmpty' => true), - ), - 'imnotrequiredeither' => array('required' => true, 'rule' => array('between', 5, 30), 'allowEmpty' => true), - 'iamrequiredalways' => array( - 'email' => array('rule' => 'email'), - 'rule_on_create' => array('rule' => array('maxLength', 50), 'on' => 'create'), - 'rule_on_update' => array('rule' => array('between', 1, 50), 'on' => 'update'), - ), - 'boolean_field' => array('rule' => 'boolean') - ); + 'imalsorequired' => ['rule' => 'alphaNumeric', 'allowEmpty' => false], + 'imrequiredtoo' => ['rule' => 'notBlank'], + 'required_one' => ['required' => ['rule' => ['notBlank']]], + 'imnotrequired' => ['required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true], + 'imalsonotrequired' => [ + 'alpha' => ['rule' => 'alphaNumeric', 'allowEmpty' => true], + 'between' => ['rule' => ['between', 5, 30]], + ], + 'imalsonotrequired2' => [ + 'alpha' => ['rule' => 'alphaNumeric', 'allowEmpty' => true], + 'between' => ['rule' => ['between', 5, 30], 'allowEmpty' => true], + ], + 'imnotrequiredeither' => ['required' => true, 'rule' => ['between', 5, 30], 'allowEmpty' => true], + 'iamrequiredalways' => [ + 'email' => ['rule' => 'email'], + 'rule_on_create' => ['rule' => ['maxLength', 50], 'on' => 'create'], + 'rule_on_update' => ['rule' => ['between', 1, 50], 'on' => 'update'], + ], + 'boolean_field' => ['rule' => 'boolean'] + ]; /** * schema method @@ -124,14 +124,14 @@ public function setSchema($schema) { * * @var array */ - public $hasAndBelongsToMany = array('ContactTag' => array('with' => 'ContactTagsContact')); + public $hasAndBelongsToMany = ['ContactTag' => ['with' => 'ContactTagsContact']]; /** * hasAndBelongsToMany property * * @var array */ - public $belongsTo = array('User' => array('className' => 'UserForm')); + public $belongsTo = ['User' => ['className' => 'UserForm']]; } /** @@ -153,12 +153,12 @@ class ContactTagsContact extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'contact_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'contact_tag_id' => array( + protected $_schema = [ + 'contact_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'contact_tag_id' => [ 'type' => 'integer', 'null' => '', 'default' => '', 'length' => '8' - ) - ); + ] + ]; /** * schema method @@ -218,12 +218,12 @@ class ContactTag extends Model { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => false, 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => true, 'default' => '', 'length' => ''), - 'modified' => array('type' => 'datetime', 'null' => true, 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => false, 'default' => '', 'length' => '8'], + 'name' => ['type' => 'string', 'null' => false, 'default' => '', 'length' => '255'], + 'created' => ['type' => 'date', 'null' => true, 'default' => '', 'length' => ''], + 'modified' => ['type' => 'datetime', 'null' => true, 'default' => '', 'length' => null] + ]; } /** @@ -245,25 +245,25 @@ class UserForm extends CakeTestModel { * * @var array */ - public $hasMany = array( - 'OpenidUrl' => array('className' => 'OpenidUrl', 'foreignKey' => 'user_form_id' - )); + public $hasMany = [ + 'OpenidUrl' => ['className' => 'OpenidUrl', 'foreignKey' => 'user_form_id' + ]]; /** * schema definition * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'published' => array('type' => 'date', 'null' => true, 'default' => null, 'length' => null), - 'other' => array('type' => 'text', 'null' => true, 'default' => null, 'length' => null), - 'stuff' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 10), - 'something' => array('type' => 'string', 'null' => true, 'default' => null, 'length' => 255), - 'active' => array('type' => 'boolean', 'null' => false, 'default' => false), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'published' => ['type' => 'date', 'null' => true, 'default' => null, 'length' => null], + 'other' => ['type' => 'text', 'null' => true, 'default' => null, 'length' => null], + 'stuff' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 10], + 'something' => ['type' => 'string', 'null' => true, 'default' => null, 'length' => 255], + 'active' => ['type' => 'boolean', 'null' => false, 'default' => false], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; } /** @@ -285,36 +285,36 @@ class OpenidUrl extends CakeTestModel { * * @var array */ - public $belongsTo = array('UserForm' => array( + public $belongsTo = ['UserForm' => [ 'className' => 'UserForm', 'foreignKey' => 'user_form_id' - )); + ]]; /** * validate property * * @var array */ - public $validate = array('openid_not_registered' => array()); + public $validate = ['openid_not_registered' => []]; /** * schema method * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'user_form_id' => array( + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'user_form_id' => [ 'type' => 'user_form_id', 'null' => '', 'default' => '', 'length' => '8' - ), - 'url' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - ); + ], + 'url' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + ]; /** * beforeValidate method * * @return void */ - public function beforeValidate($options = array()) { + public function beforeValidate($options = []) { $this->invalidate('openid_not_registered'); return true; } @@ -340,34 +340,34 @@ class ValidateUser extends CakeTestModel { * * @var array */ - public $hasOne = array('ValidateProfile' => array( + public $hasOne = ['ValidateProfile' => [ 'className' => 'ValidateProfile', 'foreignKey' => 'user_id' - )); + ]]; /** * schema method * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'email' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'balance' => array('type' => 'float', 'null' => false, 'length' => '5,2'), - 'cost_decimal' => array('type' => 'decimal', 'null' => false, 'length' => '6,3'), - 'null_decimal' => array('type' => 'decimal', 'null' => false, 'length' => null), - 'ratio' => array('type' => 'decimal', 'null' => false, 'length' => '10,6'), - 'population' => array('type' => 'decimal', 'null' => false, 'length' => '15,0'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'email' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'balance' => ['type' => 'float', 'null' => false, 'length' => '5,2'], + 'cost_decimal' => ['type' => 'decimal', 'null' => false, 'length' => '6,3'], + 'null_decimal' => ['type' => 'decimal', 'null' => false, 'length' => null], + 'ratio' => ['type' => 'decimal', 'null' => false, 'length' => '10,6'], + 'population' => ['type' => 'decimal', 'null' => false, 'length' => '15,0'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; /** * beforeValidate method * * @return void */ - public function beforeValidate($options = array()) { + public function beforeValidate($options = []) { $this->invalidate('email'); return false; } @@ -393,39 +393,39 @@ class ValidateProfile extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'user_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'full_name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'city' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'user_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'full_name' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'city' => ['type' => 'string', 'null' => '', 'default' => '', 'length' => '255'], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; /** * hasOne property * * @var array */ - public $hasOne = array('ValidateItem' => array( + public $hasOne = ['ValidateItem' => [ 'className' => 'ValidateItem', 'foreignKey' => 'profile_id' - )); + ]]; /** * belongsTo property * * @var array */ - public $belongsTo = array('ValidateUser' => array( + public $belongsTo = ['ValidateUser' => [ 'className' => 'ValidateUser', 'foreignKey' => 'user_id' - )); + ]]; /** * beforeValidate method * * @return void */ - public function beforeValidate($options = array()) { + public function beforeValidate($options = []) { $this->invalidate('full_name'); $this->invalidate('city'); return false; @@ -452,30 +452,30 @@ class ValidateItem extends CakeTestModel { * * @var array */ - protected $_schema = array( - 'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'profile_id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'), - 'name' => array('type' => 'text', 'null' => '', 'default' => '', 'length' => '255'), - 'description' => array( + protected $_schema = [ + 'id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'profile_id' => ['type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'], + 'name' => ['type' => 'text', 'null' => '', 'default' => '', 'length' => '255'], + 'description' => [ 'type' => 'string', 'null' => '', 'default' => '', 'length' => '255' - ), - 'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''), - 'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null) - ); + ], + 'created' => ['type' => 'date', 'null' => '1', 'default' => '', 'length' => ''], + 'updated' => ['type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null] + ]; /** * belongsTo property * * @var array */ - public $belongsTo = array('ValidateProfile' => array('foreignKey' => 'profile_id')); + public $belongsTo = ['ValidateProfile' => ['foreignKey' => 'profile_id']]; /** * beforeValidate method * * @return void */ - public function beforeValidate($options = array()) { + public function beforeValidate($options = []) { $this->invalidate('description'); return false; } @@ -511,7 +511,7 @@ class FormHelperTest extends CakeTestCase { * * @var array */ - public $fixtures = array('core.post'); + public $fixtures = ['core.post']; /** * Do not load the fixtures by default @@ -553,14 +553,14 @@ public function setUp() : void { $this->oldSalt = Configure::read('Security.salt'); - $this->dateRegex = array( + $this->dateRegex = [ 'daysRegex' => 'preg:/(?: