diff --git a/Cake/Cache/Cache.php b/Cake/Cache/Cache.php index d65ebd44ce4..edeee3d21cb 100644 --- a/Cake/Cache/Cache.php +++ b/Cake/Cache/Cache.php @@ -32,10 +32,10 @@ * A sample configuration would be: * * {{{ - * Cache::config('shared', array( + * Cache::config('shared', [ * 'engine' => 'Cake\Cache\Engine\ApcEngine', * 'prefix' => 'my_app_' - * )); + * ]); * }}} * * This would configure an APC cache engine to the 'shared' alias. You could then read and write @@ -77,7 +77,7 @@ * @see app/Config/core.php for configuration settings * @param string $name Name of the configuration * @param array $settings Optional associative array of settings passed to the engine - * @return array array(engine, settings) on success, false on failure + * @return array [engine, settings] on success, false on failure * @throws Cake\Error\Exception */ class Cache { @@ -99,14 +99,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(); @@ -416,7 +416,7 @@ public static function groupConfigs($group = null) { } if (isset(self::$_groups[$group])) { - return array($group => self::$_groups[$group]); + return [$group => self::$_groups[$group]]; } throw new Error\Exception(__d('cake_dev', 'Invalid cache group %s', $group)); diff --git a/Cake/Cache/CacheEngine.php b/Cake/Cache/CacheEngine.php index 0fef9b7492f..c5e71636be5 100644 --- a/Cake/Cache/CacheEngine.php +++ b/Cake/Cache/CacheEngine.php @@ -27,7 +27,7 @@ abstract class CacheEngine { * * @var array */ - public $settings = array(); + public $settings = []; /** * Contains the compiled string with all groups @@ -45,13 +45,13 @@ abstract class CacheEngine { * @param array $settings Associative array of parameters for the engine * @return boolean 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']); @@ -174,7 +174,7 @@ public function key($key) { $prefix = vsprintf($this->_groupPrefix, $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/Cake/Config/routes.php b/Cake/Config/routes.php index 2bc88477e32..4fc5facf6a2 100644 --- a/Cake/Config/routes.php +++ b/Cake/Config/routes.php @@ -51,32 +51,32 @@ $plugins[$key] = Inflector::underscore($value); } $pluginPattern = implode('|', $plugins); - $match = array('plugin' => $pluginPattern); - $shortParams = array( + $match = ['plugin' => $pluginPattern]; + $shortParams = [ 'routeClass' => 'Cake\Routing\Route\PluginShortRoute', 'plugin' => $pluginPattern, '_name' => '_plugin._controller:index', - ); + ]; foreach ($prefixes as $prefix) { - $params = array('prefix' => $prefix); - $indexParams = $params + array('action' => 'index'); + $params = ['prefix' => $prefix]; + $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); - $indexParams = $params + array('action' => 'index'); + $params = ['prefix' => $prefix]; + $indexParams = $params + ['action' => 'index']; Router::connect("/{$prefix}/:controller", $indexParams); Router::connect("/{$prefix}/:controller/:action/*", $params); } -Router::connect('/:controller', array('action' => 'index')); +Router::connect('/:controller', ['action' => 'index']); Router::connect('/:controller/:action/*'); unset($params, $indexParams, $prefix, $prefixes, $shortParams, $match, diff --git a/Cake/Configure/Engine/IniConfig.php b/Cake/Configure/Engine/IniConfig.php index 96cc0d50d11..abba3ad54b0 100644 --- a/Cake/Configure/Engine/IniConfig.php +++ b/Cake/Configure/Engine/IniConfig.php @@ -29,7 +29,7 @@ * to create nested array structures through usage of `.` delimited names. This allows * you to create nested arrays structures in an ini config file. For example: * - * `db.password = secret` would turn into `array('db' => array('password' => 'secret'))` + * `db.password = secret` would turn into `['db' => ['password' => 'secret']]` * * You can nest properties as deeply as needed using `.`'s. In addition to using `.` you * can use standard ini section notation to create nested structures: diff --git a/Cake/Console/Command/AclShell.php b/Cake/Console/Command/AclShell.php index c2a4db7ecd3..a14b3b9b6ab 100644 --- a/Cake/Console/Command/AclShell.php +++ b/Cake/Console/Command/AclShell.php @@ -59,7 +59,7 @@ class AclShell extends Shell { * * @var array */ - public $tasks = array('DbConfig'); + public $tasks = ['DbConfig']; /** * Override startup of the Shell @@ -95,7 +95,7 @@ public function startup() { return $this->DbConfig->execute(); } - if (!in_array($this->command, array('initdb'))) { + if (!in_array($this->command, ['initdb'])) { $registry = new ComponentRegistry(); $this->Acl = new AclComponent($registry); $controller = new Controller(); @@ -132,7 +132,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")); } @@ -173,12 +173,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.')); @@ -301,19 +301,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)) { @@ -326,7 +326,7 @@ public function view() { $this->out($class . ' tree:'); $this->hr(); - $stack = array(); + $stack = []; $last = null; foreach ($nodes as $n) { @@ -367,139 +367,139 @@ 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') + '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', array( + ))->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.')) + 'node' => ['help' => __d('cake_console', 'The optional node to view the subtree of.')) ) ) - ))->addSubcommand('initdb', array( + ))->addSubcommand('initdb', [ 'help' => __d('cake_console', 'Initialize the DbAcl tables. Uses this command : cake schema create DbAcl') ))->epilog( - array( + [ '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.', @@ -526,7 +526,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.')); @@ -543,10 +543,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; } @@ -589,7 +589,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'); @@ -605,7 +605,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/Cake/Console/Command/BakeShell.php b/Cake/Console/Command/BakeShell.php index 74599a9cb14..d4846543a7f 100644 --- a/Cake/Console/Command/BakeShell.php +++ b/Cake/Console/Command/BakeShell.php @@ -38,7 +38,7 @@ class BakeShell extends Shell { * * @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. @@ -58,7 +58,7 @@ public function startup() { Cache::disable(); $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; } @@ -167,7 +167,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); @@ -189,7 +189,7 @@ public function all() { } $controller = App::classname($controller, 'Controller', 'Controller'); if ($controller) { - $this->View->args = array($name); + $this->View->args = [$name]; $this->View->execute(); } $this->out('', 1, Shell::QUIET); @@ -212,40 +212,40 @@ public function getOptionParser() { '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 datasources.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.') - )); + ]); } } diff --git a/Cake/Console/Command/CommandListShell.php b/Cake/Console/Command/CommandListShell.php index 5facd37c514..36daed24dfa 100644 --- a/Cake/Console/Command/CommandListShell.php +++ b/Cake/Console/Command/CommandListShell.php @@ -31,7 +31,7 @@ class CommandListShell extends Shell { * * @var array */ - public $tasks = array('Command'); + public $tasks = ['Command']; /** * startup @@ -129,14 +129,13 @@ protected function _asXml($shellList) { public function getOptionParser() { $parser = parent::getOptionParser(); return $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 - )); + ]); } } diff --git a/Cake/Console/Command/CompletionShell.php b/Cake/Console/Command/CompletionShell.php index 878c9169392..0603974b4f1 100644 --- a/Cake/Console/Command/CompletionShell.php +++ b/Cake/Console/Command/CompletionShell.php @@ -26,7 +26,7 @@ class CompletionShell extends Shell { * * @var array */ - public $tasks = array('Command'); + public $tasks = ['Command']; /** * Echo no header by overriding the startup method @@ -102,39 +102,39 @@ public function getOptionParser() { $parser = parent::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( - array( + ] + ] + ] + ])->epilog( + [ __d('cake_console', 'This command is not intended to be called manually'), - ) + ] ); return $parser; } @@ -145,7 +145,7 @@ public function getOptionParser() { * @param array $options * @return void */ - protected function _output($options = array()) { + protected function _output($options = []) { if ($options) { return $this->out(implode($options, ' ')); } diff --git a/Cake/Console/Command/I18nShell.php b/Cake/Console/Command/I18nShell.php index 32ce795b11c..469dce1cd5f 100644 --- a/Cake/Console/Command/I18nShell.php +++ b/Cake/Console/Command/I18nShell.php @@ -38,7 +38,7 @@ class I18nShell extends Shell { * * @var array */ - public $tasks = array('DbConfig', 'Extract'); + public $tasks = ['DbConfig', 'Extract']; /** * Override startup of the Shell @@ -51,7 +51,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(); @@ -72,7 +72,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(); @@ -110,12 +110,12 @@ public function getOptionParser() { $parser = parent::getOptionParser(); return $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() - )); + ]); } } diff --git a/Cake/Console/Command/ServerShell.php b/Cake/Console/Command/ServerShell.php index 63e0f53808e..496cba5edb8 100644 --- a/Cake/Console/Command/ServerShell.php +++ b/Cake/Console/Command/ServerShell.php @@ -143,23 +143,23 @@ public function main() { public function getOptionParser() { $parser = parent::getOptionParser(); - $parser->addOption('host', array( + $parser->addOption('host', [ 'short' => 'H', 'help' => __d('cake_console', 'ServerHost') - )); - $parser->addOption('port', array( + ]); + $parser->addOption('port', [ 'short' => 'p', 'help' => __d('cake_console', 'ListenPort') - )); - $parser->addOption('document_root', array( + ]); + $parser->addOption('document_root', [ 'short' => 'd', 'help' => __d('cake_console', 'DocumentRoot') - )); + ]); - $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'), - )); + ]); return $parser; } diff --git a/Cake/Console/Command/Task/CommandTask.php b/Cake/Console/Command/Task/CommandTask.php index 1c8a5042224..86f53d51d35 100644 --- a/Cake/Console/Command/Task/CommandTask.php +++ b/Cake/Console/Command/Task/CommandTask.php @@ -34,10 +34,10 @@ class CommandTask extends Shell { * @return array */ public function getShellList() { - $skipFiles = array('AppShell'); + $skipFiles = ['AppShell']; $plugins = Plugin::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]); @@ -78,10 +78,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 . '.'; } @@ -103,20 +103,20 @@ public function subCommands($commandName) { $Shell = $this->getShell($commandName); if (!$Shell) { - return array(); + return []; } $taskMap = $this->Tasks->normalizeArray((array)$Shell->tasks); $return = array_keys($taskMap); $return = array_map('Cake\Utility\Inflector::underscore', $return); - $shellMethodNames = array('main', 'help'); + $shellMethodNames = ['main', 'help']; $baseClasses = ['Object', 'Shell', 'AppShell']; $Reflection = new ReflectionClass($Shell); $methods = $Reflection->getMethods(ReflectionMethod::IS_PUBLIC); - $methodNames = array(); + $methodNames = []; foreach ($methods as $method) { $declaringClass = $method->getDeclaringClass()->getShortName(); if (!in_array($declaringClass, $baseClasses)) { @@ -139,7 +139,7 @@ public function subCommands($commandName) { public function getShell($commandName) { list($pluginDot, $name) = pluginSplit($commandName, true); - if (in_array(strtolower($pluginDot), array('app.', 'core.'))) { + if (in_array(strtolower($pluginDot), ['app.', 'core.'])) { $commandName = $name; $pluginDot = ''; } @@ -176,7 +176,7 @@ public function options($commandName) { $parser = $Shell->getOptionParser(); } - $options = array(); + $options = []; $array = $parser->options(); foreach ($array as $name => $obj) { $options[] = "--$name"; diff --git a/Cake/Console/Command/Task/ControllerTask.php b/Cake/Console/Command/Task/ControllerTask.php index 9d3b951a022..c763f03e90d 100644 --- a/Cake/Console/Command/Task/ControllerTask.php +++ b/Cake/Console/Command/Task/ControllerTask.php @@ -34,7 +34,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 @@ -105,7 +105,7 @@ public function execute() { public function all() { $this->interactive = false; $this->listAll($this->connection, false); - ClassRegistry::config('Model', array('ds' => $this->connection)); + ClassRegistry::config('Model', ['ds' => $this->connection]); $unitTestExists = $this->_checkUnitTest(); $admin = false; @@ -150,7 +150,7 @@ protected function _interactive() { $this->out(__d('cake_console', 'Baking %sController', $controllerName)); $this->hr(); - $helpers = $components = array(); + $helpers = $components = []; $actions = ''; $wannaUseSession = 'y'; $wannaBakeAdminCrud = 'n'; @@ -161,12 +161,12 @@ 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') { @@ -179,7 +179,7 @@ protected function _interactive() { $components = $this->doComponents(); $wannaUseSession = $this->in( - __d('cake_console', "Would you like to use Session flash messages?"), array('y', 'n'), 'y' + __d('cake_console', "Would you like to use Session flash messages?"), ['y', 'n'], 'y' ); } } else { @@ -197,7 +197,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); @@ -234,10 +234,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)) { @@ -264,13 +264,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]; } /** @@ -325,10 +325,10 @@ public function bake($controllerName, $actions = '', $helpers = null, $component $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'; @@ -376,7 +376,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'") @@ -391,8 +391,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); @@ -416,7 +416,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])); @@ -467,29 +467,29 @@ public function getOptionParser() { $parser = parent::getOptionParser(); return $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(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); + ])->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } } diff --git a/Cake/Console/Command/Task/DbConfigTask.php b/Cake/Console/Command/Task/DbConfigTask.php index 6d6571b444a..5707b0706de 100644 --- a/Cake/Console/Command/Task/DbConfigTask.php +++ b/Cake/Console/Command/Task/DbConfigTask.php @@ -40,7 +40,7 @@ class DbConfigTask extends Shell { * * @var array */ - protected $_defaultConfig = array( + protected $_defaultConfig = [ 'name' => 'default', 'datasource' => 'Database/Mysql', 'persistent' => 'false', @@ -52,7 +52,7 @@ class DbConfigTask extends Shell { 'prefix' => null, 'encoding' => null, 'port' => null - ); + ]; /** * initialization callback @@ -85,7 +85,7 @@ protected function _interactive() { $this->out(__d('cake_console', 'Database Configuration:')); $this->hr(); $done = false; - $dbConfigs = array(); + $dbConfigs = []; while (!$done) { $name = ''; @@ -101,9 +101,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 { @@ -135,7 +135,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; } @@ -231,7 +231,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; @@ -271,7 +271,7 @@ public function bake($configs) { $info['persistent'] = var_export((bool)$info['persistent'], true); - $oldConfigs[$configName] = array( + $oldConfigs[$configName] = [ 'name' => $configName, 'datasource' => $info['datasource'], 'persistent' => $info['persistent'], @@ -283,7 +283,7 @@ public function bake($configs) { 'prefix' => $info['prefix'], 'schema' => $info['schema'], 'encoding' => $info['encoding'] - ); + ]; } } diff --git a/Cake/Console/Command/Task/ExtractTask.php b/Cake/Console/Command/Task/ExtractTask.php index b21b4a995ea..3da0d302ad9 100644 --- a/Cake/Console/Command/Task/ExtractTask.php +++ b/Cake/Console/Command/Task/ExtractTask.php @@ -37,14 +37,14 @@ class ExtractTask extends Shell { * * @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 @@ -65,21 +65,21 @@ class ExtractTask extends Shell { * * @var string */ - protected $_storage = array(); + protected $_storage = []; /** * Extracted tokens * * @var array */ - protected $_tokens = array(); + protected $_tokens = []; /** * Extracted strings indexed by category and domain. * * @var array */ - protected $_translations = array(); + protected $_translations = []; /** * Destination path @@ -93,7 +93,7 @@ class ExtractTask extends Shell { * * @var array */ - protected $_exclude = array(); + protected $_exclude = []; /** * Holds whether this call should extract model validation messages @@ -124,7 +124,7 @@ class ExtractTask extends Shell { 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", @@ -168,7 +168,7 @@ public function execute() { if (!Plugin::loaded($plugin)) { Plugin::load($plugin); } - $this->_paths = array(Plugin::path($plugin)); + $this->_paths = [Plugin::path($plugin)]; $this->params['plugin'] = $plugin; } else { $this->_getPaths(); @@ -177,7 +177,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'; } @@ -194,10 +194,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'])) { @@ -225,7 +225,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'; } @@ -253,11 +253,11 @@ public function execute() { * @param array $details * @return void */ - protected function _addTranslation($category, $domain, $msgid, $details = array()) { + protected function _addTranslation($category, $domain, $msgid, $details = []) { if (empty($this->_translations[$category][$domain][$msgid])) { - $this->_translations[$category][$domain][$msgid] = array( + $this->_translations[$category][$domain][$msgid] = [ 'msgid_plural' => false - ); + ]; } if (isset($details['msgid_plural'])) { @@ -293,8 +293,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.')); @@ -308,45 +308,45 @@ protected function _extract() { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description(__d('cake_console', 'CakePHP Language String Extraction:')) - ->addOption('app', array('help' => __d('cake_console', 'Directory where your application is located.'))) - ->addOption('paths', array('help' => __d('cake_console', 'Comma separated list of paths.'))) - ->addOption('merge', array( + ->addOption('app', ['help' => __d('cake_console', 'Directory where your application is located.')]) + ->addOption('paths', ['help' => __d('cake_console', 'Comma separated list of paths.')]) + ->addOption('merge', [ 'help' => __d('cake_console', 'Merge all domain and category strings into the default.po file.'), - 'choices' => array('yes', 'no') - )) - ->addOption('output', array('help' => __d('cake_console', 'Full path to output directory.'))) - ->addOption('files', array('help' => __d('cake_console', 'Comma separated list of files.'))) - ->addOption('exclude-plugins', array( + 'choices' => ['yes', 'no'] + ]) + ->addOption('output', ['help' => __d('cake_console', 'Full path to output directory.')]) + ->addOption('files', ['help' => __d('cake_console', 'Comma separated list of files.')]) + ->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'] + ]); } /** @@ -362,20 +362,20 @@ 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('__', ['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']); } } @@ -388,7 +388,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) { @@ -422,10 +422,10 @@ protected function _parse($functionName, $map) { $category = intval($category); $categoryName = $categories[$category]; $domain = isset($domain) ? $domain : 'default'; - $details = array( + $details = [ 'file' => $this->_file, 'line' => $line, - ); + ]; if (isset($plural)) { $details['msgid_plural'] = $plural; } @@ -449,7 +449,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)); } @@ -513,7 +513,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) { @@ -528,10 +528,10 @@ protected function _processValidationRules($field, $rules, $file, $domain, $cate $msgid = $rule; } if ($msgid) { - $details = array( + $details = [ 'file' => $file, 'line' => 'validation for field ' . $field - ); + ]; $this->_addTranslation($category, $domain, $msgid, $details); } } @@ -550,7 +550,7 @@ protected function _buildFiles() { foreach ($translations as $msgid => $details) { $plural = $details['msgid_plural']; $files = $details['references']; - $occurrences = array(); + $occurrences = []; foreach ($files as $file => $lines) { $lines = array_unique($lines); $occurrences[] = $file . ':' . implode(';', $lines); @@ -588,10 +588,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; @@ -629,7 +629,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') { @@ -681,7 +681,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); @@ -716,7 +716,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\\\""); @@ -763,7 +763,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; @@ -794,7 +794,7 @@ protected function _searchFiles() { * @return boolean */ protected function _isExtractingApp() { - return $this->_paths === array(APP); + return $this->_paths === [APP]; } /** diff --git a/Cake/Console/Command/Task/FixtureTask.php b/Cake/Console/Command/Task/FixtureTask.php index 36689a9a864..4fbdf6f9dd9 100644 --- a/Cake/Console/Command/Task/FixtureTask.php +++ b/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 @@ -68,34 +68,34 @@ public function getOptionParser() { $parser = parent::getOptionParser(); return $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' => 10 - ))->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(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); + ])->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } /** @@ -135,7 +135,7 @@ public function all() { foreach ($tables as $table) { $model = $this->_modelName($table); - $importOptions = array(); + $importOptions = []; if (!empty($this->params['schema'])) { $importOptions['schema'] = $model; } @@ -170,12 +170,12 @@ protected function _interactive() { * @return array Array of import options. */ public function importOptions($modelName) { - $options = array(); + $options = []; if (!empty($this->params['schema'])) { $options['schema'] = $modelName; } else { - $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; } @@ -183,14 +183,14 @@ public function importOptions($modelName) { if (!empty($this->params['records'])) { $doRecords = 'y'; } else { - $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 ($doRecords === 'n') { $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; } @@ -206,9 +206,9 @@ public function importOptions($modelName) { * @param array $importOptions Options for public $import * @return string Baked fixture content */ - public function bake($model, $useTable = false, $importOptions = array()) { + public function bake($model, $useTable = false, $importOptions = []) { $table = $schema = $records = $import = $modelImport = null; - $importBits = array(); + $importBits = []; if (!$useTable) { $useTable = Inflector::tableize($model); @@ -228,12 +228,12 @@ public function bake($model, $useTable = false, $importOptions = array()) { $importBits[] .= "'connection' => '{$this->connection}'"; } if (!empty($importBits)) { - $import = sprintf("array(%s)", implode(', ', $importBits)); + $import = sprintf("[%s]", implode(', ', $importBits)); } } $this->_Schema = new Schema(); - $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->error('Could not find your selected table ' . $useTable); return false; @@ -323,9 +323,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; @@ -390,9 +390,9 @@ protected function _generateRecords($tableInfo, $recordCount = 1) { * @return string A string value of the $records array. */ protected function _makeRecordString($records) { - $out = "array(\n"; + $out = "[\n"; foreach ($records as $record) { - $values = array(); + $values = []; foreach ($record as $field => $value) { $val = var_export($value, true); if ($val === 'NULL') { @@ -400,11 +400,11 @@ protected function _makeRecordString($records) { } $values[] = "\t\t\t'$field' => $val"; } - $out .= "\t\tarray(\n"; + $out .= "\t\t[\n"; $out .= implode(",\n", $values); - $out .= "\n\t\t),\n"; + $out .= "\n\t\t],\n"; } - $out .= "\t)"; + $out .= "\t]"; return $out; } @@ -429,17 +429,17 @@ protected function _getRecordsFromTable($modelName, $useTable = null) { $condition = 'WHERE 1=1'; $recordCount = (isset($this->params['count']) ? $this->params['count'] : 10); } - $modelObject = new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection)); - $records = $modelObject->find('all', array( + $modelObject = new Model(['name' => $modelName, 'table' => $useTable, 'ds' => $this->connection]); + $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/Cake/Console/Command/Task/ModelTask.php b/Cake/Console/Command/Task/ModelTask.php index 376eb97b4f3..7fee33c4a5e 100644 --- a/Cake/Console/Command/Task/ModelTask.php +++ b/Cake/Console/Command/Task/ModelTask.php @@ -43,35 +43,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 @@ -148,7 +148,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') { @@ -198,7 +198,7 @@ protected function _interactive() { $this->interactive = true; $primaryKey = 'id'; - $validate = $associations = array(); + $validate = $associations = []; if (empty($this->connection)) { $this->connection = $this->DbConfig->getConfig(); @@ -209,39 +209,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); + $fields = [$tempModel->primaryKey]; } if (!array_key_exists('id', $fields)) { $primaryKey = $this->findPrimaryKey($fields); } 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); } @@ -267,14 +267,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'); @@ -332,7 +332,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; } @@ -356,7 +356,7 @@ public function doValidation($model) { if (empty($fields)) { return false; } - $validate = array(); + $validate = []; $this->initValidations(); foreach ($fields as $fieldName => $field) { $validation = $this->fieldValidation($fieldName, $field, $model->primaryKey); @@ -373,7 +373,7 @@ public function doValidation($model) { * @return void */ public function initValidations() { - $options = $choices = array(); + $options = $choices = []; if (class_exists('Validation')) { $options = get_class_methods('Validation'); } @@ -400,7 +400,7 @@ public function initValidations() { */ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { $defaultChoice = count($this->_validations); - $validate = $alreadyChosen = array(); + $validate = $alreadyChosen = []; $anotherValidator = 'y'; while ($anotherValidator === 'y') { @@ -428,7 +428,7 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') { $prompt = __d('cake_console', "... or enter in a valid regex validation string.\n"); $methods = array_flip($this->_validations); $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) { @@ -481,7 +481,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?'), array('y', 'n'), 'n'); + $anotherValidator = $this->in(__d('cake_console', 'Would you like to add another validation rule?'), ['y', 'n'], 'n'); } } return $validate; @@ -503,19 +503,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); @@ -549,10 +549,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' && @@ -576,17 +576,17 @@ public function findBelongsTo(Model $model, $associations) { $offset = strpos($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; @@ -613,17 +613,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; @@ -656,13 +656,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; @@ -680,7 +680,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]); @@ -703,10 +703,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 = intval($this->inOptions($assocs, __d('cake_console', 'Enter a number'))); @@ -764,7 +764,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; } @@ -775,9 +775,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') { @@ -795,10 +795,10 @@ protected function _generatePossibleKeys() { * @param array|boolean $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); @@ -811,15 +811,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 = ''; @@ -828,10 +828,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(); @@ -864,7 +864,7 @@ public function bakeTest($className) { public function listAll($useDbConfig = null) { $this->_tables = (array)$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]); @@ -903,7 +903,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?')); @@ -924,7 +924,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']; @@ -986,23 +986,23 @@ public function getOptionParser() { $parser = parent::getOptionParser(); return $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(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); + ])->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } /** diff --git a/Cake/Console/Command/Task/PluginTask.php b/Cake/Console/Command/Task/PluginTask.php index 545fdeb8955..127d4f9eb65 100644 --- a/Cake/Console/Command/Task/PluginTask.php +++ b/Cake/Console/Command/Task/PluginTask.php @@ -105,11 +105,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/Schema', 'Model/Behavior', 'Model/Datasource', @@ -123,7 +123,7 @@ public function bake($plugin) { 'Test/Fixture', 'vendor', 'webroot' - ); + ]; foreach ($directories as $directory) { $dirPath = $this->path . $plugin . DS . $directory; @@ -178,7 +178,7 @@ protected function _modifyBootstrap($plugin) { $bootstrap = new File($this->bootstrap, false); $contents = $bootstrap->read(); if (!preg_match("@\n\s*Plugin::loadAll@", $contents)) { - $bootstrap->append("\nPlugin::load('$plugin', array('bootstrap' => false, 'routes' => false));\n"); + $bootstrap->append("\nPlugin::load('$plugin', ['bootstrap' => false, 'routes' => false]);\n"); $this->out(''); $this->out(__d('cake_dev', '%s modified', $this->bootstrap)); } @@ -221,9 +221,9 @@ public function getOptionParser() { return $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.') - )); + ]); } } diff --git a/Cake/Console/Command/Task/ProjectTask.php b/Cake/Console/Command/Task/ProjectTask.php index 3db077a02da..ffdb38b7cda 100644 --- a/Cake/Console/Command/Task/ProjectTask.php +++ b/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 { @@ -62,7 +62,7 @@ public function execute() { $namespace = basename($project); if (!preg_match('/^\w[\w\d_]+$/', $namespace)) { $this->err(__d('cake_console', 'Project Name/Namespace needs to start with a letter and can only contain letters, digits and underscore')); - $this->args = array(); + $this->args = []; return $this->execute(); } @@ -73,7 +73,7 @@ public function execute() { $response = false; while (!$response && is_dir($project) === true && file_exists($project . 'Config' . 'boostrap.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; } @@ -106,11 +106,11 @@ public function bake($path) { $command = 'php ' . escapeshellarg($composer) . ' create-project --dev cakephp/app ' . escapeshellarg($path); - $descriptorSpec = array( - 0 => array('pipe', 'r'), - 1 => array('pipe', 'w'), - 2 => array('pipe', 'w') - ); + $descriptorSpec = [ + 0 => ['pipe', 'r'], + 1 => ['pipe', 'w'], + 2 => ['pipe', 'w'] + ]; $process = proc_open( $command, $descriptorSpec, @@ -149,10 +149,10 @@ public function cakeAdmin($name) { $path .= 'Config/'; $File = new File($path . 'routes.php'); $contents = $File->read(); - 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 (preg_match('%(\s*[/]*Configure::write\(\'Routing.prefixes\',[\s\'a-z,\)\(\]\[]*\);)%', $contents, $match)) { + $result = str_replace($match[0], "\n" . 'Configure::write(\'Routing.prefixes\', [\'' . $name . '\']);', $contents); if ($File->write($result)) { - Configure::write('Routing.prefixes', array($name)); + Configure::write('Routing.prefixes', [$name]); return true; } } @@ -175,7 +175,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) { @@ -188,7 +188,7 @@ public function getPrefix() { if ($this->interactive) { $this->hr(); $this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.', - 'Configure::write(\'Routing.prefixes\', array(\'admin\'))', + 'Configure::write(\'Routing.prefixes\', [\'admin\'])', '/app/Config/routes.php')); $this->out(__d('cake_console', 'What would you like the prefix route to be?')); $this->out(__d('cake_console', 'Example: %s', 'www.example.com/admin/controller')); @@ -198,7 +198,7 @@ public function getPrefix() { if ($this->cakeAdmin($admin) !== true) { $this->out(__d('cake_console', 'Unable to write to %s.', '/app/Config/routes.php')); $this->out(__d('cake_console', 'You need to enable %s in %s to use prefix routing.', - 'Configure::write(\'Routing.prefixes\', array(\'admin\'))', + 'Configure::write(\'Routing.prefixes\', [\'admin\'])', '/app/Config/routes.php')); return $this->_stop(); } @@ -216,18 +216,18 @@ public function getOptionParser() { $parser = parent::getOptionParser(); return $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('composer', array( + ])->addOption('composer', [ 'default' => ROOT . '/composer.phar', 'help' => __d('cake_console', 'The path to the composer executable.') - )); + ]); } } diff --git a/Cake/Console/Command/Task/TemplateTask.php b/Cake/Console/Command/Task/TemplateTask.php index 8b5ebe455da..33b55b9e0cf 100644 --- a/Cake/Console/Command/Task/TemplateTask.php +++ b/Cake/Console/Command/Task/TemplateTask.php @@ -38,7 +38,7 @@ class TemplateTask extends Shell { * * @var array */ - public $templatePaths = array(); + public $templatePaths = []; /** * Initialize callback. Setup paths for the template task. @@ -80,7 +80,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(); @@ -152,7 +152,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/Cake/Console/Command/Task/TestTask.php b/Cake/Console/Command/Task/TestTask.php index 01bb5a65e83..ea467be9111 100644 --- a/Cake/Console/Command/Task/TestTask.php +++ b/Cake/Console/Command/Task/TestTask.php @@ -44,33 +44,33 @@ 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 type names and their namespaces * * @var array */ - public $classNamespaces = array( + public $classNamespaces = [ 'Model' => 'Model', 'Controller' => 'Controller', 'Component' => 'Controller\Component', 'Behavior' => 'Model\Behavior', 'Helper' => 'View\Helper' - ); + ]; /** * Mapping between packages, and their baseclass @@ -78,20 +78,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 @@ -166,7 +166,7 @@ public function bake($type, $className) { $this->getUserFixtures(); } - $methods = array(); + $methods = []; if (class_exists($fullClassName)) { $methods = $this->getTestableMethods($fullClassName); } @@ -207,7 +207,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); @@ -239,7 +239,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; @@ -265,7 +265,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']); } /** @@ -379,7 +379,7 @@ 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)) { $out[] = $method; @@ -396,7 +396,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) { @@ -442,7 +442,7 @@ 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; } @@ -475,8 +475,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); @@ -524,7 +524,7 @@ public function generateConstructor($type, $fullClassName, $plugin) { $pre = "\$registry = new ComponentRegistry();\n"; $construct = "new {$className}(\$registry);\n"; } - return array($pre, $construct, $post); + return [$pre, $construct, $post]; } /** @@ -536,7 +536,7 @@ public function generateConstructor($type, $fullClassName, $plugin) { * @return array An array containing used classes */ public function generateUses($type, $realType, $fullClassName) { - $uses = array(); + $uses = []; $type = strtolower($type); if ($type == 'component') { $uses[] = 'Cake\Controller\ComponentRegistry'; @@ -574,27 +574,27 @@ public function testCaseFileName($type, $className) { public function getOptionParser() { $parser = parent::getOptionParser(); return $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(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); + ])->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } } diff --git a/Cake/Console/Command/Task/ViewTask.php b/Cake/Console/Command/Task/ViewTask.php index 7e10d0cc2f4..b75da86eee6 100644 --- a/Cake/Console/Command/Task/ViewTask.php +++ b/Cake/Console/Command/Task/ViewTask.php @@ -34,7 +34,7 @@ class ViewTask extends BakeTask { * * @var array */ - public $tasks = array('Project', 'Controller', 'DbConfig', 'Template'); + public $tasks = ['Project', 'Controller', 'DbConfig', 'Template']; /** * path to View directory @@ -62,7 +62,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 @@ -70,7 +70,7 @@ class ViewTask extends BakeTask { * * @var array */ - public $noTemplateActions = array('delete'); + public $noTemplateActions = ['delete']; /** * Override initialize @@ -172,7 +172,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) { @@ -209,16 +209,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 it 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(); @@ -229,7 +229,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; } @@ -288,7 +288,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); @@ -332,7 +332,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(); @@ -406,10 +406,10 @@ public function getTemplate($action) { $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; } @@ -423,30 +423,30 @@ public function getOptionParser() { $parser = parent::getOptionParser(); return $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(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); + ])->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } /** @@ -456,8 +456,8 @@ 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) { diff --git a/Cake/Console/Command/TestShell.php b/Cake/Console/Command/TestShell.php index 66ec2d90dab..637794f21b3 100644 --- a/Cake/Console/Command/TestShell.php +++ b/Cake/Console/Command/TestShell.php @@ -48,119 +48,119 @@ class TestShell extends Shell { */ public function getOptionParser() { $parser = new ConsoleOptionParser($this->name); - $parser->description(array( + $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('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.'), '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; } @@ -188,12 +188,12 @@ protected function _parseArgs() { if (empty($this->args)) { return; } - $params = array( + $params = [ 'core' => false, 'app' => false, 'plugin' => null, 'output' => 'text', - ); + ]; if (strpos($this->args[0], '.php')) { $category = $this->_mapFileToCategory($this->args[0]); @@ -222,7 +222,7 @@ protected function _parseArgs() { * @return array Array of params for Cake\TestSuite\TestDispatcher */ protected function _runnerOptions() { - $options = array(); + $options = []; $params = $this->params; unset($params['help']); @@ -269,7 +269,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(); @@ -305,7 +305,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"); @@ -340,7 +340,7 @@ public function available() { * @param string $file * @param string $category * @param boolean $throwOnMissingFile - * @return array array(type, case) + * @return array [type, case] * @throws Exception */ protected function _mapFileToCase($file, $category, $throwOnMissingFile = true) { diff --git a/Cake/Console/Command/UpgradeShell.php b/Cake/Console/Command/UpgradeShell.php index 40ae2da0b54..6df643b7559 100644 --- a/Cake/Console/Command/UpgradeShell.php +++ b/Cake/Console/Command/UpgradeShell.php @@ -76,7 +76,7 @@ public function all() { public function locations() { $path = $this->_getPath(); - $moves = array( + $moves = [ 'Test' . DS . 'Case' => 'Test' . DS . 'TestCase', 'View' . DS . 'Elements' => 'View' . DS . 'Element', 'View' . DS . 'Emails' => 'View' . DS . 'Email', @@ -84,7 +84,7 @@ public function locations() { 'View' . DS . 'Layout' . DS . 'Emails' => 'View' . DS . 'Layout' . DS . 'Email', 'View' . DS . 'Scaffolds' => 'View' . DS . 'Scaffold', 'View' . DS . 'Errors' => 'View' . DS . 'Error', - ); + ]; $dry = $this->params['dryRun']; foreach ($moves as $old => $new) { @@ -606,7 +606,7 @@ protected function _filesRegexpUpdate($patterns) { * @return void */ protected function _findFiles($extensions = '', $exclude = []) { - $this->_files = array(); + $this->_files = []; foreach ($this->_paths as $path) { if (!is_dir($path)) { continue; diff --git a/Cake/Console/ConsoleInputArgument.php b/Cake/Console/ConsoleInputArgument.php index fcee4f446ee..4024f9a78f0 100644 --- a/Cake/Console/ConsoleInputArgument.php +++ b/Cake/Console/ConsoleInputArgument.php @@ -64,7 +64,7 @@ class ConsoleInputArgument { * @param boolean $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/Cake/Console/ConsoleInputOption.php b/Cake/Console/ConsoleInputOption.php index e54c7eb0e0a..dae861c7b7b 100644 --- a/Cake/Console/ConsoleInputOption.php +++ b/Cake/Console/ConsoleInputOption.php @@ -81,7 +81,7 @@ class ConsoleInputOption { * @param array $choices Valid choices for this option. * @throws Cake\Error\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/Cake/Console/ConsoleInputSubcommand.php b/Cake/Console/ConsoleInputSubcommand.php index 837c9ed20ac..f092f8239a4 100644 --- a/Cake/Console/ConsoleInputSubcommand.php +++ b/Cake/Console/ConsoleInputSubcommand.php @@ -53,7 +53,7 @@ class ConsoleInputSubcommand { * @param string|array $name The long name of the subcommand, or an array with all the properties. * @param string $help The help text for this option * @param ConsoleOptionParser|array $parser A parser for this subcommand. Either a ConsoleOptionParser, or an array that can be - * used with ConsoleOptionParser::buildFromArray() + * used with ConsoleOptionParser::buildFrom[] */ public function __construct($name, $help = '', $parser = null) { if (is_array($name) && isset($name['name'])) { diff --git a/Cake/Console/ConsoleOptionParser.php b/Cake/Console/ConsoleOptionParser.php index 761c640ebcf..0e26f9a9934 100644 --- a/Cake/Console/ConsoleOptionParser.php +++ b/Cake/Console/ConsoleOptionParser.php @@ -64,7 +64,7 @@ * arguments any arguments greater than those defined will cause exceptions. Additionally you can * declare arguments as optional, by setting the required param to false. * - * `$parser->addArgument('model', array('required' => false));` + * `$parser->addArgument('model', ['required' => false]);` * * ### Providing Help text * @@ -96,14 +96,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. @@ -111,7 +111,7 @@ class ConsoleOptionParser { * @see ConsoleOptionParser::addArgument() * @var array */ - protected $_args = array(); + protected $_args = []; /** * Subcommands for this Shell. @@ -119,7 +119,7 @@ class ConsoleOptionParser { * @see ConsoleOptionParser::addSubcommand() * @var array */ - protected $_subcommands = array(); + protected $_subcommands = []; /** * Command name. @@ -138,22 +138,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 - )); + ]); } } @@ -172,19 +172,19 @@ public static function create($command, $defaultOptions = true) { * Build a parser from an array. Uses an array like * * {{{ - * $spec = array( + * $spec = [ * 'description' => 'text', * 'epilog' => 'text', - * 'arguments' => array( + * 'arguments' => [ * // list of arguments compatible with addArguments. - * ), - * 'options' => array( + * ], + * 'options' => [ * // list of options compatible with addOptions - * ), - * 'subcommands' => array( + * ], + * 'subcommands' => [ * // list of subcommands to add. - * ) - * ); + * ] + * ]; * }}} * * @param array $spec The spec to build the OptionParser with. @@ -282,19 +282,19 @@ public function epilog($text = null) { * @param array $options An array of parameters that define the behavior of the option * @return ConsoleOptionParser $this. */ - 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 = array_merge($defaults, $options); $option = new ConsoleInputOption($options); } @@ -322,18 +322,18 @@ public function addOption($name, $options = array()) { * @param array $params Parameters for the argument, see above. * @return ConsoleOptionParser $this. */ - 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 = array_merge($defaults, $params); $index = $options['index']; unset($options['index']); @@ -389,16 +389,16 @@ public function addOptions(array $options) { * @param array $options Array of params, see above. * @return ConsoleOptionParser $this. */ - 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 = array_merge($defaults, $options); $command = new ConsoleInputSubcommand($options); } @@ -454,14 +454,14 @@ public function subcommands() { * @param array $argv Array of args (argv) to parse. * @param string $command The subcommand to use. If this parameter is a subcommand, that has a parser, * That parser will be used to parse $argv instead. - * @return Array array($params, $args) + * @return Array [$params, $args] * @throws Cake\Error\ConsoleException When an invalid parameter is encountered. */ 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) === '--') { @@ -491,7 +491,7 @@ public function parse($argv, $command = null) { $params[$name] = false; } } - return array($params, $args); + return [$params, $args]; } /** diff --git a/Cake/Console/ConsoleOutput.php b/Cake/Console/ConsoleOutput.php index dad98a5ffce..2a775ebc34a 100644 --- a/Cake/Console/ConsoleOutput.php +++ b/Cake/Console/ConsoleOutput.php @@ -85,7 +85,7 @@ class ConsoleOutput { * * @var array */ - protected static $_foregroundColors = array( + protected static $_foregroundColors = [ 'black' => 30, 'red' => 31, 'green' => 32, @@ -94,14 +94,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, @@ -110,19 +110,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. @@ -130,19 +130,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. @@ -190,7 +190,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 ); } @@ -206,7 +206,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']]; } @@ -245,7 +245,7 @@ protected function _write($message) { * * ### Create or modify an existing style * - * `$this->output->styles('annoy', array('text' => 'purple', 'background' => 'yellow', 'blink' => true));` + * `$this->output->styles('annoy', ['text' => 'purple', 'background' => 'yellow', 'blink' => true]);` * * ### Remove a style * diff --git a/Cake/Console/HelpFormatter.php b/Cake/Console/HelpFormatter.php index f59ae94ba52..39dc9a607ca 100644 --- a/Cake/Console/HelpFormatter.php +++ b/Cake/Console/HelpFormatter.php @@ -63,7 +63,7 @@ public function __construct(ConsoleOptionParser $parser) { */ public function text($width = 72) { $parser = $this->_parser; - $out = array(); + $out = []; $description = $parser->description(); if (!empty($description)) { $out[] = String::wrap($description, $width); @@ -78,11 +78,11 @@ public function text($width = 72) { $out[] = ''; $max = $this->_getMaxLength($subcommands) + 2; foreach ($subcommands as $command) { - $out[] = String::wrap($command->help($max), array( + $out[] = String::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()); @@ -95,11 +95,11 @@ public function text($width = 72) { $out[] = __d('cake_console', 'Options:'); $out[] = ''; foreach ($options as $option) { - $out[] = String::wrap($option->help($max), array( + $out[] = String::wrap($option->help($max), [ 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 - )); + ]); } $out[] = ''; } @@ -110,11 +110,11 @@ public function text($width = 72) { $out[] = __d('cake_console', 'Arguments:'); $out[] = ''; foreach ($arguments as $argument) { - $out[] = String::wrap($argument->help($max), array( + $out[] = String::wrap($argument->help($max), [ 'width' => $width, 'indent' => str_repeat(' ', $max), 'indentAt' => 1 - )); + ]); } $out[] = ''; } @@ -134,25 +134,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/Cake/Console/Shell.php b/Cake/Console/Shell.php index cd0a4fc1485..b47c3937bf8 100644 --- a/Cake/Console/Shell.php +++ b/Cake/Console/Shell.php @@ -72,7 +72,7 @@ class Shell extends Object { * * @var array */ - public $params = array(); + public $params = []; /** * The command (method/task) that is being run. @@ -86,7 +86,7 @@ class Shell extends Object { * * @var array */ - public $args = array(); + public $args = []; /** * The name of the shell in camelized. @@ -109,14 +109,14 @@ class Shell extends Object { * @var array * @link http://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 @@ -124,7 +124,7 @@ class Shell extends Object { * @var array * @link http://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 @@ -145,7 +145,7 @@ class Shell extends Object { * * @var string */ - protected $_taskMap = array(); + protected $_taskMap = []; /** * stdout object. @@ -179,7 +179,7 @@ class Shell extends Object { public function __construct($stdout = null, $stderr = null, $stdin = null) { if (!$this->name) { list(, $class) = namespaceSplit(get_class($this)); - $this->name = str_replace(array('Shell', 'Task'), '', $class); + $this->name = str_replace(['Shell', 'Task'], '', $class); } $this->Tasks = new TaskRegistry($this); @@ -294,11 +294,11 @@ public function loadModel($modelClass = null, $id = null) { $this->modelClass = $modelClass; } - $this->{$modelClass} = ClassRegistry::init(array( + $this->{$modelClass} = ClassRegistry::init([ 'class' => $plugin . $modelClass, 'alias' => $modelClass, 'id' => $id - )); + ]); if (!$this->{$modelClass}) { throw new Error\MissingModelException($modelClass); } @@ -518,7 +518,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)) { @@ -583,7 +583,7 @@ protected function _getInput($prompt, $options, $default) { * @see String::wrap() * @link http://book.cakephp.org/2.0/en/console-and-shells.html#Shell::wrapText */ - public function wrapText($text, $options = array()) { + public function wrapText($text, $options = []) { return String::wrap($text, $options); } @@ -705,7 +705,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); @@ -745,7 +745,7 @@ protected function _checkUnitTest() { } $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) { diff --git a/Cake/Console/ShellDispatcher.php b/Cake/Console/ShellDispatcher.php index 0c71faab3af..9825b0ad175 100644 --- a/Cake/Console/ShellDispatcher.php +++ b/Cake/Console/ShellDispatcher.php @@ -29,14 +29,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 @@ -47,7 +47,7 @@ class ShellDispatcher { * @param array $args the argv from PHP * @param boolean $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); @@ -139,7 +139,7 @@ protected 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; } @@ -172,7 +172,7 @@ protected function _dispatch() { } } - throw new Error\MissingShellMethodException(array('shell' => $shell, 'method' => $command)); + throw new Error\MissingShellMethodException(['shell' => $shell, 'method' => $command]); } /** @@ -195,9 +195,9 @@ protected function _getShell($shell) { $class = App::classname($class, 'Console/Command', 'Shell'); if (!class_exists($class)) { - throw new Error\MissingShellException(array( + throw new Error\MissingShellException([ 'class' => $shell, - )); + ]); } $Shell = new $class(); $Shell->plugin = trim($plugin, '.'); @@ -213,12 +213,12 @@ protected function _getShell($shell) { public function parseParams($args) { $this->_parsePaths($args); - $defaults = array( + $defaults = [ 'app' => 'App', 'root' => dirname(dirname(dirname(__DIR__))), 'working' => null, 'webroot' => 'webroot' - ); + ]; $params = array_merge($defaults, array_intersect_key($this->params, $defaults)); $isWin = false; foreach ($defaults as $default => $value) { @@ -271,8 +271,8 @@ public function parseParams($args) { * @return void */ protected function _parsePaths($args) { - $parsed = array(); - $keys = array('-working', '--working', '-app', '--app', '-root', '--root'); + $parsed = []; + $keys = ['-working', '--working', '-app', '--app', '-root', '--root']; foreach ($keys as $key) { while (($index = array_search($key, $args)) !== false) { $keyname = str_replace('-', '', $key); @@ -300,7 +300,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/Cake/Console/Templates/default/actions/controller_actions.ctp b/Cake/Console/Templates/default/actions/controller_actions.ctp index 9696139c128..73ef968d76d 100644 --- a/Cake/Console/Templates/default/actions/controller_actions.ctp +++ b/Cake/Console/Templates/default/actions/controller_actions.ctp @@ -39,11 +39,11 @@ if (!$this->->exists($id)) { throw new NotFoundException(__('Invalid ')); } - $options = array('conditions' => array('.' . $this->->primaryKey => $id)); + $options = ['conditions' => ['.' . $this->->primaryKey => $id]]; $this->set('', $this->->find('first', $options)); } - + /** * add method * @@ -55,16 +55,16 @@ if ($this->->save($this->request->data)) { $this->Session->setFlash(__('The has been saved.')); - return $this->redirect(array('action' => 'index')); + return $this->redirect(['action' => 'index']); } else { $this->Session->setFlash(__('The could not be saved. Please, try again.')); - return $this->flash(__('The has been saved.'), array('action' => 'index')); + return $this->flash(__('The has been saved.'), ['action' => 'index']); } } {$assoc} as $associationName => $relation): if (!empty($associationName)): $otherModelName = $this->_modelName($associationName); @@ -80,7 +80,7 @@ ?> } - + /** * edit method * @@ -92,23 +92,23 @@ if (!$this->->exists($id)) { throw new NotFoundException(__('Invalid ')); } - if ($this->request->is(array('post', 'put'))) { + if ($this->request->is(['post', 'put'])) { if ($this->->save($this->request->data)) { $this->Session->setFlash(__('The has been saved.')); - return $this->redirect(array('action' => 'index')); + return $this->redirect(['action' => 'index']); } else { $this->Session->setFlash(__('The could not be saved. Please, try again.')); - return $this->flash(__('The has been saved.'), array('action' => 'index')); + return $this->flash(__('The has been saved.'), ['action' => 'index']); } } else { - $options = array('conditions' => array('.' . $this->->primaryKey => $id)); + $options = ['conditions' => ['.' . $this->->primaryKey => $id]]; $this->request->data = $this->->find('first', $options); } {$assoc} as $associationName => $relation): if (!empty($associationName)): $otherModelName = $this->_modelName($associationName); @@ -143,11 +143,11 @@ } else { $this->Session->setFlash(__('The could not be deleted. Please, try again.')); } - return $this->redirect(array('action' => 'index')); + return $this->redirect(['action' => 'index']); - return $this->flash(__('The has been deleted.'), array('action' => 'index')); + return $this->flash(__('The has been deleted.'), ['action' => 'index']); } else { - return $this->flash(__('The could not be deleted. Please, try again.'), array('action' => 'index')); + return $this->flash(__('The could not be deleted. Please, try again.'), ['action' => 'index']); } } diff --git a/Cake/Console/Templates/default/classes/controller.ctp b/Cake/Console/Templates/default/classes/controller.ctp index 7815e93e16b..c8808408940 100644 --- a/Cake/Console/Templates/default/classes/controller.ctp +++ b/Cake/Console/Templates/default/classes/controller.ctp @@ -52,7 +52,7 @@ class Controller extends App if (count($helpers)): echo "/**\n * Helpers\n *\n * @var array\n */\n"; - echo "\tpublic \$helpers = array("; + echo "\tpublic \$helpers = ["; for ($i = 0, $len = count($helpers); $i < $len; $i++): if ($i != $len - 1): echo "'" . Inflector::camelize($helpers[$i]) . "', "; @@ -60,12 +60,12 @@ class Controller extends App echo "'" . Inflector::camelize($helpers[$i]) . "'"; endif; endfor; - echo ");\n\n"; + echo "];\n\n"; endif; if (count($components)): echo "/**\n * Components\n *\n * @var array\n */\n"; - echo "\tpublic \$components = array("; + echo "\tpublic \$components = ["; for ($i = 0, $len = count($components); $i < $len; $i++): if ($i != $len - 1): echo "'" . Inflector::camelize($components[$i]) . "', "; @@ -73,7 +73,7 @@ class Controller extends App echo "'" . Inflector::camelize($components[$i]) . "'"; endif; endfor; - echo ");\n\n"; + echo "];\n\n"; endif; echo trim($actions); diff --git a/Cake/Console/Templates/default/classes/model.ctp b/Cake/Console/Templates/default/classes/model.ctp index fe432fd9b14..57b671e1719 100644 --- a/Cake/Console/Templates/default/classes/model.ctp +++ b/Cake/Console/Templates/default/classes/model.ctp @@ -27,7 +27,7 @@ echo "App::uses('{$plugin}AppModel', '{$pluginPath}Model');\n"; * Model * * * @var array */ - public $actsAs = array(); + public $actsAs = []; $validations): - echo "\t\t'$field' => array(\n"; + echo "\t\t'$field' => [\n"; foreach ($validations as $key => $validator): - echo "\t\t\t'$key' => array(\n"; - echo "\t\t\t\t'rule' => array('$validator'),\n"; + echo "\t\t\t'$key' => [\n"; + echo "\t\t\t\t'rule' => ['$validator'],\n"; echo "\t\t\t\t//'message' => 'Your custom message here',\n"; echo "\t\t\t\t//'allowEmpty' => false,\n"; echo "\t\t\t\t//'required' => false,\n"; echo "\t\t\t\t//'last' => false, // Stop validation after this rule\n"; echo "\t\t\t\t//'on' => 'create', // Limit validation to 'create' or 'update' operations\n"; - echo "\t\t\t),\n"; + echo "\t\t\t],\n"; endforeach; - echo "\t\t),\n"; + echo "\t\t],\n"; endforeach; - echo "\t);\n"; + echo "\t];\n"; endif; foreach ($associations as $assoc): @@ -114,19 +114,19 @@ foreach ($associations as $assoc): endif; endforeach; -foreach (array('hasOne', 'belongsTo') as $assocType): +foreach (['hasOne', 'belongsTo'] as $assocType): if (!empty($associations[$assocType])): $typeCount = count($associations[$assocType]); echo "\n/**\n * $assocType associations\n *\n * @var array\n */"; - echo "\n\tpublic \$$assocType = array("; + echo "\n\tpublic \$$assocType = ["; foreach ($associations[$assocType] as $i => $relation): - $out = "\n\t\t'{$relation['alias']}' => array(\n"; + $out = "\n\t\t'{$relation['alias']}' => [\n"; $out .= "\t\t\t'className' => '{$relation['className']}',\n"; $out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n"; $out .= "\t\t\t'conditions' => '',\n"; $out .= "\t\t\t'fields' => '',\n"; $out .= "\t\t\t'order' => ''\n"; - $out .= "\t\t)"; + $out .= "\t\t]"; if ($i + 1 < $typeCount) { $out .= ","; } @@ -139,9 +139,9 @@ endforeach; if (!empty($associations['hasMany'])): $belongsToCount = count($associations['hasMany']); echo "\n/**\n * hasMany associations\n *\n * @var array\n */"; - echo "\n\tpublic \$hasMany = array("; + echo "\n\tpublic \$hasMany = ["; foreach ($associations['hasMany'] as $i => $relation): - $out = "\n\t\t'{$relation['alias']}' => array(\n"; + $out = "\n\t\t'{$relation['alias']}' => [\n"; $out .= "\t\t\t'className' => '{$relation['className']}',\n"; $out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n"; $out .= "\t\t\t'dependent' => false,\n"; @@ -153,21 +153,21 @@ if (!empty($associations['hasMany'])): $out .= "\t\t\t'exclusive' => '',\n"; $out .= "\t\t\t'finderQuery' => '',\n"; $out .= "\t\t\t'counterQuery' => ''\n"; - $out .= "\t\t)"; + $out .= "\t\t]"; if ($i + 1 < $belongsToCount) { $out .= ","; } echo $out; endforeach; - echo "\n\t);\n\n"; + echo "\n\t];\n\n"; endif; if (!empty($associations['hasAndBelongsToMany'])): $habtmCount = count($associations['hasAndBelongsToMany']); echo "\n/**\n * hasAndBelongsToMany associations\n *\n * @var array\n */"; - echo "\n\tpublic \$hasAndBelongsToMany = array("; + echo "\n\tpublic \$hasAndBelongsToMany = ["; foreach ($associations['hasAndBelongsToMany'] as $i => $relation): - $out = "\n\t\t'{$relation['alias']}' => array(\n"; + $out = "\n\t\t'{$relation['alias']}' => [\n"; $out .= "\t\t\t'className' => '{$relation['className']}',\n"; $out .= "\t\t\t'joinTable' => '{$relation['joinTable']}',\n"; $out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n"; @@ -179,13 +179,13 @@ if (!empty($associations['hasAndBelongsToMany'])): $out .= "\t\t\t'limit' => '',\n"; $out .= "\t\t\t'offset' => '',\n"; $out .= "\t\t\t'finderQuery' => '',\n"; - $out .= "\t\t)"; + $out .= "\t\t]"; if ($i + 1 < $habtmCount) { $out .= ","; } echo $out; endforeach; - echo "\n\t);\n\n"; + echo "\n\t];\n\n"; endif; ?> } diff --git a/Cake/Console/Templates/default/classes/test.ctp b/Cake/Console/Templates/default/classes/test.ctp index 97974dfbe03..635a5f7e1bb 100644 --- a/Cake/Console/Templates/default/classes/test.ctp +++ b/Cake/Console/Templates/default/classes/test.ctp @@ -42,9 +42,9 @@ class Test extends TestCase { * * @var array */ - public $fixtures = array( + public $fixtures = [ '' - ); + ]; diff --git a/Cake/Console/Templates/default/views/form.ctp b/Cake/Console/Templates/default/views/form.ctp index 18f8f02ff32..f5d62758f00 100644 --- a/Cake/Console/Templates/default/views/form.ctp +++ b/Cake/Console/Templates/default/views/form.ctp @@ -26,7 +26,7 @@ use Cake\Utility\Inflector; foreach ($fields as $field) { if (strpos($action, 'add') !== false && $field == $primaryKey) { continue; - } elseif (!in_array($field, array('created', 'modified', 'updated'))) { + } elseif (!in_array($field, ['created', 'modified', 'updated'])) { echo "\t\techo \$this->Form->input('{$field}');\n"; } } @@ -47,16 +47,16 @@ use Cake\Utility\Inflector;
    -
  • Form->postLink(__('Delete'), array('action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')), null, __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>"; ?>
  • +
  • Form->postLink(__('Delete'), ['action' => 'delete', \$this->Form->value('{$modelClass}.{$primaryKey}')], null, __('Are you sure you want to delete # %s?', \$this->Form->value('{$modelClass}.{$primaryKey}'))); ?>"; ?>
  • -
  • Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>"; ?>
  • +
  • Html->link(__('List " . $pluralHumanName . "'), ['action' => 'index']); ?>"; ?>
  • $data) { foreach ($data as $alias => $details) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { - echo "\t\t
  • Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
  • \n"; - echo "\t\t
  • Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
  • \n"; + echo "\t\t
  • Html->link(__('List " . Inflector::humanize($details['controller']) . "'), ['controller' => '{$details['controller']}', 'action' => 'index']); ?>
  • \n"; + echo "\t\t
  • Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), ['controller' => '{$details['controller']}', 'action' => 'add']); ?>
  • \n"; $done[] = $details['controller']; } } diff --git a/Cake/Console/Templates/default/views/index.ctp b/Cake/Console/Templates/default/views/index.ctp index c7825af5d6f..183d0c6bd35 100644 --- a/Cake/Console/Templates/default/views/index.ctp +++ b/Cake/Console/Templates/default/views/index.ctp @@ -35,7 +35,7 @@ use Cake\Utility\Inflector; foreach ($associations['belongsTo'] as $alias => $details) { if ($field === $details['foreignKey']) { $isKey = true; - echo "\t\t\n\t\t\tHtml->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\n"; + echo "\t\t\n\t\t\tHtml->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], ['controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}']]); ?>\n\t\t\n"; break; } } @@ -46,9 +46,9 @@ use Cake\Utility\Inflector; } echo "\t\t\n"; - echo "\t\t\tHtml->link(__('View'), array('action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; - echo "\t\t\tHtml->link(__('Edit'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; - echo "\t\t\tForm->postLink(__('Delete'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; + echo "\t\t\tHtml->link(__('View'), ['action' => 'view', \${$singularVar}['{$modelClass}']['{$primaryKey}']]); ?>\n"; + echo "\t\t\tHtml->link(__('Edit'), ['action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}']]); ?>\n"; + echo "\t\t\tForm->postLink(__('Delete'), ['action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']], null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>\n"; echo "\t\t\n"; echo "\t\n"; @@ -57,17 +57,17 @@ use Cake\Utility\Inflector;

    Paginator->counter(array( + echo \$this->Paginator->counter([ 'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}') - )); + ]); ?>"; ?>

    Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));\n"; - echo "\t\techo \$this->Paginator->numbers(array('separator' => ''));\n"; - echo "\t\techo \$this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));\n"; + echo "\t\techo \$this->Paginator->prev('< ' . __('previous'), [], null, ['class' => 'prev disabled']);\n"; + echo "\t\techo \$this->Paginator->numbers(['separator' => '']);\n"; + echo "\t\techo \$this->Paginator->next(__('next') . ' >', [], null, ['class' => 'next disabled']);\n"; echo "\t?>\n"; ?>
    @@ -75,14 +75,14 @@ use Cake\Utility\Inflector;

    "; ?>

      -
    • Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?>"; ?>
    • +
    • Html->link(__('New " . $singularHumanName . "'), ['action' => 'add']); ?>"; ?>
    • $data) { foreach ($data as $alias => $details) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { - echo "\t\t
    • Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
    • \n"; - echo "\t\t
    • Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
    • \n"; + echo "\t\t
    • Html->link(__('List " . Inflector::humanize($details['controller']) . "'), ['controller' => '{$details['controller']}', 'action' => 'index']); ?>
    • \n"; + echo "\t\t
    • Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), ['controller' => '{$details['controller']}', 'action' => 'add']); ?>
    • \n"; $done[] = $details['controller']; } } diff --git a/Cake/Console/Templates/default/views/view.ctp b/Cake/Console/Templates/default/views/view.ctp index 7471df92749..28759fc9693 100644 --- a/Cake/Console/Templates/default/views/view.ctp +++ b/Cake/Console/Templates/default/views/view.ctp @@ -28,7 +28,7 @@ foreach ($fields as $field) { if ($field === $details['foreignKey']) { $isKey = true; echo "\t\t
      \n"; - echo "\t\t
      \n\t\t\tHtml->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], array('controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>\n\t\t\t \n\t\t
      \n"; + echo "\t\t
      \n\t\t\tHtml->link(\${$singularVar}['{$alias}']['{$details['displayField']}'], ['controller' => '{$details['controller']}', 'action' => 'view', \${$singularVar}['{$alias}']['{$details['primaryKey']}']]); ?>\n\t\t\t \n\t\t
      \n"; break; } } @@ -45,17 +45,17 @@ foreach ($fields as $field) {

      "; ?>

        Html->link(__('Edit " . $singularHumanName ."'), array('action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?> \n"; - echo "\t\t
      • Form->postLink(__('Delete " . $singularHumanName . "'), array('action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']), null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>
      • \n"; - echo "\t\t
      • Html->link(__('List " . $pluralHumanName . "'), array('action' => 'index')); ?>
      • \n"; - echo "\t\t
      • Html->link(__('New " . $singularHumanName . "'), array('action' => 'add')); ?>
      • \n"; + echo "\t\t
      • Html->link(__('Edit " . $singularHumanName ."'), ['action' => 'edit', \${$singularVar}['{$modelClass}']['{$primaryKey}']]); ?>
      • \n"; + echo "\t\t
      • Form->postLink(__('Delete " . $singularHumanName . "'), ['action' => 'delete', \${$singularVar}['{$modelClass}']['{$primaryKey}']], null, __('Are you sure you want to delete # %s?', \${$singularVar}['{$modelClass}']['{$primaryKey}'])); ?>
      • \n"; + echo "\t\t
      • Html->link(__('List " . $pluralHumanName . "'), ['action' => 'index']); ?>
      • \n"; + echo "\t\t
      • Html->link(__('New " . $singularHumanName . "'), ['action' => 'add']); ?>
      • \n"; - $done = array(); + $done = []; foreach ($associations as $type => $data) { foreach ($data as $alias => $details) { if ($details['controller'] != $this->name && !in_array($details['controller'], $done)) { - echo "\t\t
      • Html->link(__('List " . Inflector::humanize($details['controller']) . "'), array('controller' => '{$details['controller']}', 'action' => 'index')); ?>
      • \n"; - echo "\t\t
      • Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>
      • \n"; + echo "\t\t
      • Html->link(__('List " . Inflector::humanize($details['controller']) . "'), ['controller' => '{$details['controller']}', 'action' => 'index']); ?>
      • \n"; + echo "\t\t
      • Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), ['controller' => '{$details['controller']}', 'action' => 'add']); ?>
      • \n"; $done[] = $details['controller']; } } @@ -80,7 +80,7 @@ if (!empty($associations['hasOne'])) : \n"; ?>
          -
        • Html->link(__('Edit " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}'])); ?>
        • \n"; ?> +
        • Html->link(__('Edit " . Inflector::humanize(Inflector::underscore($alias)) . "'), ['controller' => '{$details['controller']}', 'action' => 'edit', \${$singularVar}['{$alias}']['{$details['primaryKey']}']]); ?>
        • \n"; ?>
    @@ -88,10 +88,10 @@ if (!empty($associations['hasOne'])) : endforeach; endif; if (empty($associations['hasMany'])) { - $associations['hasMany'] = array(); + $associations['hasMany'] = []; } if (empty($associations['hasAndBelongsToMany'])) { - $associations['hasAndBelongsToMany'] = array(); + $associations['hasAndBelongsToMany'] = []; } $relations = array_merge($associations['hasMany'], $associations['hasAndBelongsToMany']); foreach ($relations as $alias => $details): @@ -118,9 +118,9 @@ echo "\t\n"; - echo "\t\t\t\tHtml->link(__('View'), array('controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; - echo "\t\t\t\tHtml->link(__('Edit'), array('controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; - echo "\t\t\t\tForm->postLink(__('Delete'), array('controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']), null, __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; + echo "\t\t\t\tHtml->link(__('View'), ['controller' => '{$details['controller']}', 'action' => 'view', \${$otherSingularVar}['{$details['primaryKey']}']]); ?>\n"; + echo "\t\t\t\tHtml->link(__('Edit'), ['controller' => '{$details['controller']}', 'action' => 'edit', \${$otherSingularVar}['{$details['primaryKey']}']]); ?>\n"; + echo "\t\t\t\tForm->postLink(__('Delete'), ['controller' => '{$details['controller']}', 'action' => 'delete', \${$otherSingularVar}['{$details['primaryKey']}']], null, __('Are you sure you want to delete # %s?', \${$otherSingularVar}['{$details['primaryKey']}'])); ?>\n"; echo "\t\t\t\n"; echo "\t\t\n"; @@ -130,7 +130,7 @@ echo "\t\n"; \n\n"; ?>
      -
    • Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), array('controller' => '{$details['controller']}', 'action' => 'add')); ?>"; ?>
    • +
    • Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "'), ['controller' => '{$details['controller']}', 'action' => 'add']); ?>"; ?>