diff --git a/lib/Cake/Console/Command/AclShell.php b/lib/Cake/Console/Command/AclShell.php index 8bde81592..4e58ef874 100644 --- a/lib/Cake/Console/Command/AclShell.php +++ b/lib/Cake/Console/Command/AclShell.php @@ -200,7 +200,7 @@ class AclShell extends AppShell { } $this->out(__d('cake_console', 'Path:')); $this->hr(); - for ($i = 0; $i < count($nodes); $i++) { + for ($i = 0, $len = count($nodes); $i < $len; $i++) { $this->_outputNode($class, $nodes[$i], $i); } } @@ -218,7 +218,7 @@ class AclShell extends AppShell { $data = $node[$class]; if ($data['alias']) { $this->out($indent . "[" . $data['id'] . "] " . $data['alias']); - } else { + } else { $this->out($indent . "[" . $data['id'] . "] " . $data['model'] . '.' . $data['foreign_key']); } } @@ -366,8 +366,9 @@ class AclShell extends AppShell { 'help' => __d('cake_console', 'Type of node to create.') ); - $parser->description(__d('cake_console', 'A console tool for managing the DbAcl')) - ->addSubcommand('create', array( + $parser->description( + __d('cake_console', 'A console tool for managing the DbAcl') + )->addSubcommand('create', array( 'help' => __d('cake_console', 'Create a new ACL node'), 'parser' => array( 'description' => __d('cake_console', 'Creates a new ACL object under the parent'), @@ -514,8 +515,9 @@ class AclShell extends AppShell { if (!isset($this->args[0]) || !isset($this->args[1])) { return false; } - extract($this->_dataVars($this->args[0])); - $key = is_numeric($this->args[1]) ? $secondary_id : 'alias'; + $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]); $possibility = $this->Acl->{$class}->find('all', compact('conditions')); if (empty($possibility)) { @@ -602,4 +604,5 @@ class AclShell extends AppShell { $vars['class'] = $class; return $vars; } + } diff --git a/lib/Cake/Console/Command/ApiShell.php b/lib/Cake/Console/Command/ApiShell.php index 18c44b09e..b2d730688 100644 --- a/lib/Cake/Console/Command/ApiShell.php +++ b/lib/Cake/Console/Command/ApiShell.php @@ -92,7 +92,7 @@ class ApiShell extends AppShell { $this->error(__d('cake_console', '%s not found', $class)); } - $parsed = $this->_parseClass($path . $class .'.php', $class); + $parsed = $this->_parseClass($path . $class . '.php', $class); if (!empty($parsed)) { if (isset($this->params['method'])) { @@ -166,14 +166,14 @@ class ApiShell extends AppShell { $commands = array( 'path' => "\t\n" . - "\t\tEither a full path or type of class (model, behavior, controller, component, view, helper).\n". - "\t\tAvailable values:\n\n". - "\t\tbehavior\tLook for class in CakePHP behavior path\n". - "\t\tcache\tLook for class in CakePHP cache path\n". - "\t\tcontroller\tLook for class in CakePHP controller path\n". - "\t\tcomponent\tLook for class in CakePHP component path\n". - "\t\thelper\tLook for class in CakePHP helper path\n". - "\t\tmodel\tLook for class in CakePHP model path\n". + "\t\tEither a full path or type of class (model, behavior, controller, component, view, helper).\n" . + "\t\tAvailable values:\n\n" . + "\t\tbehavior\tLook for class in CakePHP behavior path\n" . + "\t\tcache\tLook for class in CakePHP cache path\n" . + "\t\tcontroller\tLook for class in CakePHP controller path\n" . + "\t\tcomponent\tLook for class in CakePHP component path\n" . + "\t\thelper\tLook for class in CakePHP helper path\n" . + "\t\tmodel\tLook for class in CakePHP model path\n" . "\t\tview\tLook for class in CakePHP view path\n", 'className' => "\t\n" . "\t\tA CakePHP core class name (e.g: Component, HtmlHelper).\n" @@ -203,7 +203,7 @@ class ApiShell extends AppShell { $parsed = array(); if (!class_exists($class)) { - if (!include_once($path)) { + if (!include_once $path) { $this->err(__d('cake_console', '%s could not be found', $path)); } } @@ -234,4 +234,5 @@ class ApiShell extends AppShell { ksort($parsed); return $parsed; } + } diff --git a/lib/Cake/Console/Command/BakeShell.php b/lib/Cake/Console/Command/BakeShell.php index 77d4fe610..71b8dd957 100644 --- a/lib/Cake/Console/Command/BakeShell.php +++ b/lib/Cake/Console/Command/BakeShell.php @@ -209,9 +209,9 @@ class BakeShell extends AppShell { public function getOptionParser() { $parser = parent::getOptionParser(); return $parser->description(__d('cake_console', - 'The Bake script generates controllers, views and models for your application.' - . ' If run with no command line arguments, Bake guides the user through the class creation process.' - . ' You can customize the generation process by telling Bake where different parts of your application are using command line arguments.' + '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( 'help' => __d('cake_console', 'Bake a complete MVC. optional of a Model'), ))->addSubcommand('project', array( diff --git a/lib/Cake/Console/Command/CommandListShell.php b/lib/Cake/Console/Command/CommandListShell.php index b69d9696a..7d2494c75 100644 --- a/lib/Cake/Console/Command/CommandListShell.php +++ b/lib/Cake/Console/Command/CommandListShell.php @@ -1,9 +1,5 @@ params['xml'])) { $this->out(__d('cake_console', "Current Paths:"), 2); - $this->out(" -app: ". APP_DIR); + $this->out(" -app: " . APP_DIR); $this->out(" -working: " . rtrim(APP, DS)); $this->out(" -root: " . rtrim(ROOT, DS)); $this->out(" -core: " . rtrim(CORE_PATH, DS)); @@ -234,4 +230,5 @@ class CommandListShell extends AppShell { 'boolean' => true )); } + } diff --git a/lib/Cake/Console/Command/ConsoleShell.php b/lib/Cake/Console/Command/ConsoleShell.php index 1f0981d3c..e077ca3fb 100644 --- a/lib/Cake/Console/Command/ConsoleShell.php +++ b/lib/Cake/Console/Command/ConsoleShell.php @@ -1,9 +1,5 @@ $this->Extract->getOptionParser() )); } + } diff --git a/lib/Cake/Console/Command/SchemaShell.php b/lib/Cake/Console/Command/SchemaShell.php index 87200e662..d9d2bfd06 100644 --- a/lib/Cake/Console/Command/SchemaShell.php +++ b/lib/Cake/Console/Command/SchemaShell.php @@ -58,7 +58,7 @@ class SchemaShell extends AppShell { $this->_welcome(); $this->out('Cake Schema Shell'); $this->hr(); - + $name = $path = $connection = $plugin = null; if (!empty($this->params['name'])) { $name = $this->params['name']; @@ -168,7 +168,7 @@ class SchemaShell extends AppShell { $count = 0; if (!empty($result[1])) { foreach ($result[1] as $file) { - if (preg_match('/'.preg_quote($fileName).'(?:[_\d]*)?\.php$/', $file)) { + if (preg_match('/' . preg_quote($fileName) . '(?:[_\d]*)?\.php$/', $file)) { $count++; } } @@ -216,7 +216,7 @@ class SchemaShell extends AppShell { } } $db = ConnectionManager::getDataSource($this->Schema->connection); - $contents = "\n\n" . $db->dropSchema($Schema) . "\n\n". $db->createSchema($Schema); + $contents = "\n\n" . $db->dropSchema($Schema) . "\n\n" . $db->createSchema($Schema); if ($write) { if (strpos($write, '.sql') === false) { @@ -419,7 +419,7 @@ class SchemaShell extends AppShell { try { $db->execute($sql); } catch (PDOException $e) { - $error = $table . ': ' . $e->getMessage(); + $error = $table . ': ' . $e->getMessage(); } $Schema->after(array($event => $table, 'errors' => $error)); @@ -529,4 +529,5 @@ class SchemaShell extends AppShell { )); return $parser; } + } diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index c1178dcec..834aa5919 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -145,17 +145,16 @@ class ControllerTask extends BakeTask { $useDynamicScaffold = 'n'; $wannaBakeCrud = 'y'; - $question[] = __d('cake_console', "Would you like to build your controller interactively?"); - if (file_exists($this->path . $controllerName .'Controller.php')) { + 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), array('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?"), array('y', 'n'), 'n' ); if (strtolower($useDynamicScaffold) == 'y') { @@ -233,7 +232,7 @@ class ControllerTask extends BakeTask { $output = ''; $length = count($$var); foreach ($$var as $i => $propElement) { - if ($i != $length -1) { + if ($i != $length - 1) { $output .= ucfirst($propElement) . ', '; } else { $output .= ucfirst($propElement); @@ -468,48 +467,4 @@ class ControllerTask extends BakeTask { ))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } -/** - * Displays help contents - * - * @return void - */ - public function help() { - $this->hr(); - $this->out("Usage: cake bake controller ..."); - $this->hr(); - $this->out('Arguments:'); - $this->out(); - $this->out(""); - $this->out("\tName of the controller to bake. Can use Plugin.name"); - $this->out("\tas a shortcut for plugin baking."); - $this->out(); - $this->out('Params:'); - $this->out(); - $this->out('-connection '); - $this->out("\tset db config . uses 'default' if none is specified"); - $this->out(); - $this->out('Commands:'); - $this->out(); - $this->out("controller "); - $this->out("\tbakes controller with var \$scaffold"); - $this->out(); - $this->out("controller public"); - $this->out("\tbakes controller with basic crud actions"); - $this->out("\t(index, view, add, edit, delete)"); - $this->out(); - $this->out("controller admin"); - $this->out("\tbakes a controller with basic crud actions for one of the"); - $this->out("\tConfigure::read('Routing.prefixes') methods."); - $this->out(); - $this->out("controller public admin"); - $this->out("\tbakes a controller with basic crud actions for one"); - $this->out("\tConfigure::read('Routing.prefixes') and non admin methods."); - $this->out("\t(index, view, add, edit, delete,"); - $this->out("\tadmin_index, admin_view, admin_edit, admin_add, admin_delete)"); - $this->out(); - $this->out("controller all"); - $this->out("\tbakes all controllers with CRUD methods."); - $this->out(); - $this->_stop(); - } } diff --git a/lib/Cake/Console/Command/Task/DbConfigTask.php b/lib/Cake/Console/Command/Task/DbConfigTask.php index 45367f16d..9602c0573 100644 --- a/lib/Cake/Console/Command/Task/DbConfigTask.php +++ b/lib/Cake/Console/Command/Task/DbConfigTask.php @@ -364,7 +364,7 @@ class DbConfigTask extends AppShell { $connections = array_keys($configs); if (count($connections) > 1) { - $useDbConfig = $this->in(__d('cake_console', 'Use Database Config') .':', $connections, $useDbConfig); + $useDbConfig = $this->in(__d('cake_console', 'Use Database Config') . ':', $connections, $useDbConfig); } return $useDbConfig; } @@ -380,4 +380,5 @@ class DbConfigTask extends AppShell { __d('cake_console', 'Bake new database configuration settings.') ); } + } diff --git a/lib/Cake/Console/Command/Task/ExtractTask.php b/lib/Cake/Console/Command/Task/ExtractTask.php index bf7547f07..f9c733e54 100644 --- a/lib/Cake/Console/Command/Task/ExtractTask.php +++ b/lib/Cake/Console/Command/Task/ExtractTask.php @@ -584,8 +584,10 @@ class ExtractTask extends AppShell { */ protected function _getStrings(&$position, $target) { $strings = array(); - while (count($strings) < $target && ($this->_tokens[$position] == ',' || $this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING)) { - if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING && $this->_tokens[$position+1] == '.') { + $count = count($strings); + while ($count < $target && ($this->_tokens[$position] == ',' || $this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING)) { + $count = count($strings); + if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING && $this->_tokens[$position + 1] == '.') { $string = ''; while ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING || $this->_tokens[$position] == '.') { if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) { @@ -668,7 +670,7 @@ class ExtractTask extends AppShell { } $exclude[] = preg_quote($e, '/'); } - $pattern = '/' . implode('|', $exclude) . '/'; + $pattern = '/' . implode('|', $exclude) . '/'; } foreach ($this->_paths as $path) { $Folder = new Folder($path); @@ -694,4 +696,5 @@ class ExtractTask extends AppShell { protected function _isExtractingApp() { return $this->_paths === array(APP); } + } diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index bf58cd4a7..6f2a22c58 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -86,7 +86,7 @@ class FixtureTask extends BakeTask { '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.')); } /** @@ -388,7 +388,7 @@ class FixtureTask extends BakeTask { $condition = $this->in($prompt, null, 'WHERE 1=1'); } $prompt = __d('cake_console', "How many records do you want to import?"); - $recordCount = $this->in($prompt, null, 10); + $recordCount = $this->in($prompt, null, 10); } else { $condition = 'WHERE 1=1'; $recordCount = (isset($this->params['count']) ? $this->params['count'] : 10); diff --git a/lib/Cake/Console/Command/Task/ModelTask.php b/lib/Cake/Console/Command/Task/ModelTask.php index 82a92188b..199c50d06 100644 --- a/lib/Cake/Console/Command/Task/ModelTask.php +++ b/lib/Cake/Console/Command/Task/ModelTask.php @@ -170,7 +170,7 @@ class ModelTask extends BakeTask { $max = count($options); while (!$valid) { foreach ($options as $i => $option) { - $this->out($i + 1 .'. ' . $option); + $this->out($i + 1 . '. ' . $option); } if (empty($prompt)) { $prompt = __d('cake_console', 'Make a selection from the choices above'); @@ -297,7 +297,7 @@ class ModelTask extends BakeTask { */ protected function _printAssociation($modelName, $type, $associations) { if (!empty($associations[$type])) { - for ($i = 0; $i < count($associations[$type]); $i++) { + for ($i = 0, $len = count($associations[$type]); $i < $len; $i++) { $out = "\t" . $modelName . ' ' . $type . ' ' . $associations[$type][$i]['alias']; $this->out($out); } @@ -414,7 +414,7 @@ class ModelTask extends BakeTask { for ($i = 1; $i < $defaultChoice; $i++) { $prompt .= $i . ' - ' . $this->_validations[$i] . "\n"; } - $prompt .= __d('cake_console', "%s - Do not do any validation on this field.\n", $defaultChoice); + $prompt .= __d('cake_console', "%s - Do not do any validation on this field.\n", $defaultChoice); $prompt .= __d('cake_console', "... or enter in a valid regex validation string.\n"); $methods = array_flip($this->_validations); @@ -498,11 +498,14 @@ class ModelTask extends BakeTask { } if (empty($this->_tables)) { - $this->_tables = (array) $this->getAllTables(); + $this->_tables = (array)$this->getAllTables(); } $associations = array( - 'belongsTo' => array(), 'hasMany' => array(), 'hasOne' => array(), 'hasAndBelongsToMany' => array() + 'belongsTo' => array(), + 'hasMany' => array(), + 'hasOne' => array(), + 'hasAndBelongsToMany' => array() ); $associations = $this->findBelongsTo($model, $associations); @@ -780,13 +783,19 @@ class ModelTask extends BakeTask { } else { $data['name'] = $name; } - $defaults = array('associations' => array(), 'validate' => array(), 'primaryKey' => 'id', - 'useTable' => null, 'useDbConfig' => 'default', 'displayField' => null); + $defaults = array( + 'associations' => array(), + 'validate' => array(), + 'primaryKey' => 'id', + 'useTable' => null, + 'useDbConfig' => 'default', + 'displayField' => null + ); $data = array_merge($defaults, $data); $pluginPath = ''; if ($this->plugin) { - $pluginPath = $this->plugin . '.'; + $pluginPath = $this->plugin . '.'; } $this->Template->set($data); @@ -824,7 +833,7 @@ class ModelTask extends BakeTask { * @return array */ public function listAll($useDbConfig = null) { - $this->_tables = (array) $this->getAllTables($useDbConfig); + $this->_tables = (array)$this->getAllTables($useDbConfig); $this->_modelNames = array(); $count = count($this->_tables); @@ -926,7 +935,7 @@ class ModelTask extends BakeTask { } if ($enteredModel == '' || intval($enteredModel) > count($this->_modelNames)) { - $this->err(__d('cake_console', "The model name you supplied was empty,\n" . + $this->err(__d('cake_console', "The model name you supplied was empty,\n" . "or the number you selected was not an option. Please try again.")); $enteredModel = ''; } @@ -975,4 +984,5 @@ class ModelTask extends BakeTask { $this->Fixture->plugin = $this->plugin; $this->Fixture->bake($className, $useTable); } + } diff --git a/lib/Cake/Console/Command/Task/PluginTask.php b/lib/Cake/Console/Command/Task/PluginTask.php index 056780dd1..aff2fc5b3 100644 --- a/lib/Cake/Console/Command/Task/PluginTask.php +++ b/lib/Cake/Console/Command/Task/PluginTask.php @@ -135,7 +135,7 @@ class PluginTask extends AppShell { $out = "createFile($this->path . $plugin. DS . 'Controller' . DS . $controllerFileName, $out); + $this->createFile($this->path . $plugin . DS . 'Controller' . DS . $controllerFileName, $out); $modelFileName = $plugin . 'AppModel.php'; @@ -167,7 +167,7 @@ class PluginTask extends AppShell { $max = count($pathOptions); while (!$valid) { foreach ($pathOptions as $i => $option) { - $this->out($i + 1 .'. ' . $option); + $this->out($i + 1 . '. ' . $option); } $prompt = __d('cake_console', 'Choose a plugin path from the paths above.'); $choice = $this->in($prompt); @@ -191,7 +191,6 @@ class PluginTask extends AppShell { ))->addArgument('name', array( 'help' => __d('cake_console', 'CamelCased name of the plugin to create.') )); - } } diff --git a/lib/Cake/Console/Command/Task/ProjectTask.php b/lib/Cake/Console/Command/Task/ProjectTask.php index 07548b6c4..f5454fb54 100644 --- a/lib/Cake/Console/Command/Task/ProjectTask.php +++ b/lib/Cake/Console/Command/Task/ProjectTask.php @@ -54,7 +54,6 @@ class ProjectTask extends AppShell { $project = $this->in($prompt, null, APP . 'myapp'); } - if ($project && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) { $project = $_SERVER['PWD'] . DS . $project; } @@ -112,7 +111,7 @@ class ProjectTask extends AppShell { $this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/index.php', CAKE_CORE_INCLUDE_PATH)); $this->out(__d('cake_console', ' * CAKE_CORE_INCLUDE_PATH set to %s in webroot/test.php', CAKE_CORE_INCLUDE_PATH)); } else { - $this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' .DS .'index.php')); + $this->err(__d('cake_console', 'Unable to set CAKE_CORE_INCLUDE_PATH, you should change it in %s', $path . 'webroot' . DS .'index.php')); $success = false; } if ($success && $hardCode) { @@ -231,8 +230,8 @@ class ProjectTask extends AppShell { $app = basename($dir); $path = $dir . 'View' . DS . 'Pages' . DS; $source = CAKE . 'Console' . DS . 'Templates' . DS .'default' . DS . 'views' . DS . 'home.ctp'; - include($source); - return $this->createFile($path.'home.ctp', $output); + include $source; + return $this->createFile($path . 'home.ctp', $output); } /** @@ -282,7 +281,7 @@ class ProjectTask extends AppShell { * * @param string $path Project path * @return boolean Success - */ + */ public function securityCipherSeed($path) { $File = new File($path . 'Config' . DS . 'core.php'); $contents = $File->read(); diff --git a/lib/Cake/Console/Command/Task/TemplateTask.php b/lib/Cake/Console/Command/Task/TemplateTask.php index 6cfd1e7a0..1f7d3c34e 100644 --- a/lib/Cake/Console/Command/Task/TemplateTask.php +++ b/lib/Cake/Console/Command/Task/TemplateTask.php @@ -74,7 +74,7 @@ class TemplateTask extends AppShell { foreach ($plugins as $plugin) { $paths[] = $this->_pluginPath($plugin) . 'Console' . DS; } - + $paths = array_merge($paths, App::path('Console')); // TEMPORARY TODO remove when all paths are DS terminated @@ -149,7 +149,7 @@ class TemplateTask extends AppShell { extract($this->templateVars); ob_start(); ob_implicit_flush(0); - include($templateFile); + include $templateFile; $content = ob_get_clean(); return $content; } @@ -214,4 +214,5 @@ class TemplateTask extends AppShell { $this->err(__d('cake_console', 'Could not find template for %s', $filename)); return false; } + } diff --git a/lib/Cake/Console/Command/Task/TestTask.php b/lib/Cake/Console/Command/Task/TestTask.php index bf3b4263f..857a717d4 100644 --- a/lib/Cake/Console/Command/Task/TestTask.php +++ b/lib/Cake/Console/Command/Task/TestTask.php @@ -46,7 +46,7 @@ class TestTask extends BakeTask { * * @var array */ - public $classTypes = array( + public $classTypes = array( 'Model' => 'Model', 'Controller' => 'Controller', 'Component' => 'Controller/Component', @@ -276,9 +276,9 @@ class TestTask extends BakeTask { if (strtolower($type) == 'model' || empty($this->classTypes[$type])) { return $class; } - + $position = strpos($class, $type); - + if ($position !== false && strlen($class) - $position == strlen($type)) { return $class; } @@ -291,6 +291,7 @@ class TestTask extends BakeTask { * @param string $type The type of thing having a test generated. * @param string $plugin The plugin name. * @return string + * @throws CakeException When invalid object types are requested. */ public function mapType($type, $plugin) { $type = ucfirst($type); @@ -397,8 +398,8 @@ class TestTask extends BakeTask { protected function _addFixture($name) { $parent = get_parent_class($name); $prefix = 'app.'; - if (strtolower($parent) != 'appmodel' && strtolower(substr($parent, -8)) == 'appmodel') { - $pluginName = substr($parent, 0, strlen($parent) -8); + if (strtolower($parent) != 'appmodel' && strtolower(substr($parent, - 8)) == 'appmodel') { + $pluginName = substr($parent, 0, strlen($parent) - 8); $prefix = 'plugin.' . Inflector::underscore($pluginName) . '.'; } $fixture = $prefix . Inflector::underscore($name); @@ -530,4 +531,5 @@ class TestTask extends BakeTask { 'help' => __d('cake_console', 'CamelCased name of the plugin to bake tests for.') ))->epilog(__d('cake_console', 'Omitting all arguments and options will enter into an interactive mode.')); } + } diff --git a/lib/Cake/Console/Command/Task/ViewTask.php b/lib/Cake/Console/Command/Task/ViewTask.php index 62160dee7..6595e03a4 100644 --- a/lib/Cake/Console/Command/Task/ViewTask.php +++ b/lib/Cake/Console/Command/Task/ViewTask.php @@ -133,7 +133,7 @@ class ViewTask extends BakeTask { * @return array Array of action names that should be baked */ protected function _methodsToBake() { - $methods = array_diff( + $methods = array_diff( array_map('strtolower', get_class_methods($this->controllerName . 'Controller')), array_map('strtolower', get_class_methods('AppController')) ); @@ -459,9 +459,10 @@ class ViewTask extends BakeTask { $associations[$type][$assocKey]['displayField'] = $model->{$assocKey}->displayField; $associations[$type][$assocKey]['foreignKey'] = $assocData['foreignKey']; $associations[$type][$assocKey]['controller'] = Inflector::pluralize(Inflector::underscore($modelClass)); - $associations[$type][$assocKey]['fields'] = array_keys($model->{$assocKey}->schema(true)); + $associations[$type][$assocKey]['fields'] = array_keys($model->{$assocKey}->schema(true)); } } return $associations; } + } diff --git a/lib/Cake/Console/Command/TestShell.php b/lib/Cake/Console/Command/TestShell.php index 9e8467c79..2f93695d3 100644 --- a/lib/Cake/Console/Command/TestShell.php +++ b/lib/Cake/Console/Command/TestShell.php @@ -192,7 +192,6 @@ class TestShell extends Shell { 'output' => 'text', ); - if (strpos($this->args[0], '.php')) { $category = $this->_mapFileToCategory($this->args[0]); $params['case'] = $this->_mapFileToCase($this->args[0], $category); @@ -312,7 +311,7 @@ class TestShell extends Shell { } while ($choice = $this->in(__d('cake_console', 'What test case would you like to run?'), null, 'q')) { - if (is_numeric($choice) && isset($cases[$choice])) { + if (is_numeric($choice) && isset($cases[$choice])) { $this->args[0] = $category; $this->args[1] = $cases[$choice]; $this->_run($this->_parseArgs(), $this->_runnerOptions()); @@ -385,7 +384,7 @@ class TestShell extends Shell { if (!file_exists($testFile) && $throwOnMissingFile) { throw new Exception(__d('cake_dev', 'Test case %s not found', $testFile)); } - + return $testCase; } @@ -431,4 +430,5 @@ class TestShell extends Shell { } return 'app'; } + } diff --git a/lib/Cake/Console/Command/TestsuiteShell.php b/lib/Cake/Console/Command/TestsuiteShell.php index 1d1514f6f..a9b2394b3 100644 --- a/lib/Cake/Console/Command/TestsuiteShell.php +++ b/lib/Cake/Console/Command/TestsuiteShell.php @@ -207,4 +207,5 @@ class TestsuiteShell extends TestShell { $this->_run($args, $this->_runnerOptions()); } + } diff --git a/lib/Cake/Console/Command/UpgradeShell.php b/lib/Cake/Console/Command/UpgradeShell.php index 36b6578a8..297032224 100644 --- a/lib/Cake/Console/Command/UpgradeShell.php +++ b/lib/Cake/Console/Command/UpgradeShell.php @@ -169,7 +169,7 @@ class UpgradeShell extends AppShell { } } } - + $this->_moveViewFiles(); $this->_moveAppClasses(); @@ -234,7 +234,7 @@ class UpgradeShell extends AppShell { $helpers = array_merge($pluginHelpers, $helpers); foreach ($helpers as $helper) { $helper = preg_replace('/Helper$/', '', $helper); - $oldHelper = strtolower(substr($helper, 0, 1)).substr($helper, 1); + $oldHelper = strtolower(substr($helper, 0, 1)) . substr($helper, 1); $patterns[] = array( "\${$oldHelper} to \$this->{$helper}", "/\\\${$oldHelper}->/", @@ -355,7 +355,7 @@ class UpgradeShell extends AppShell { $pluginPath = App::pluginPath($this->params['plugin']); $this->_paths = array( $pluginPath . 'controllers' . DS, - $pluginPath . 'controllers' . DS . 'components' .DS, + $pluginPath . 'controllers' . DS . 'components' . DS, $pluginPath . 'views' . DS, ); } @@ -536,7 +536,7 @@ class UpgradeShell extends AppShell { $pluginPath = App::pluginPath($this->params['plugin']); $this->_paths = array( $pluginPath . 'controllers' . DS, - $pluginPath . 'controllers' . DS . 'components' .DS, + $pluginPath . 'controllers' . DS . 'components' . DS, ); } $patterns = array( @@ -604,7 +604,7 @@ class UpgradeShell extends AppShell { protected function _moveAppClasses() { $files = array( APP . 'app_controller.php' => APP . 'Controller' . DS . 'AppController.php', - APP . 'controllers' . DS .'app_controller.php' => APP . 'Controller' . DS . 'AppController.php', + APP . 'controllers' . DS . 'app_controller.php' => APP . 'Controller' . DS . 'AppController.php', APP . 'app_model.php' => APP . 'Model' . DS . 'AppModel.php', APP . 'models' . DS . 'app_model.php' => APP . 'Model' . DS . 'AppModel.php', ); @@ -706,7 +706,7 @@ class UpgradeShell extends AppShell { if (!$this->params['dry-run']) { if ($this->params['git']) { exec('git mv -f ' . escapeshellarg($file) . ' ' . escapeshellarg($file . '__')); - exec('git mv -f ' . escapeshellarg($file. '__') . ' ' . escapeshellarg($new)); + exec('git mv -f ' . escapeshellarg($file . '__') . ' ' . escapeshellarg($new)); } else { rename($file, $new); } @@ -854,4 +854,5 @@ class UpgradeShell extends AppShell { 'parser' => $subcommandParser )); } + } diff --git a/lib/Cake/Console/ConsoleInput.php b/lib/Cake/Console/ConsoleInput.php index f6d52a9b0..d8334cf80 100644 --- a/lib/Cake/Console/ConsoleInput.php +++ b/lib/Cake/Console/ConsoleInput.php @@ -22,6 +22,7 @@ * @package Cake.Console */ class ConsoleInput { + /** * Input value. * @@ -46,4 +47,5 @@ class ConsoleInput { public function read() { return fgets($this->_input); } -} \ No newline at end of file + +} diff --git a/lib/Cake/Console/ConsoleInputArgument.php b/lib/Cake/Console/ConsoleInputArgument.php index b44579894..2e0eb5bd0 100644 --- a/lib/Cake/Console/ConsoleInputArgument.php +++ b/lib/Cake/Console/ConsoleInputArgument.php @@ -23,6 +23,7 @@ * @package Cake.Console */ class ConsoleInputArgument { + /** * Name of the argument. * @@ -125,7 +126,7 @@ class ConsoleInputArgument { * @return boolean */ public function isRequired() { - return (bool) $this->_required; + return (bool)$this->_required; } /** @@ -165,4 +166,5 @@ class ConsoleInputArgument { } return $parent; } + } diff --git a/lib/Cake/Console/ConsoleInputOption.php b/lib/Cake/Console/ConsoleInputOption.php index d52e3cb6e..0be938119 100644 --- a/lib/Cake/Console/ConsoleInputOption.php +++ b/lib/Cake/Console/ConsoleInputOption.php @@ -24,6 +24,7 @@ * @package Cake.Console */ class ConsoleInputOption { + /** * Name of the option * @@ -171,7 +172,7 @@ class ConsoleInputOption { * @return boolean */ public function isBoolean() { - return (bool) $this->_boolean; + return (bool)$this->_boolean; } /** @@ -216,4 +217,5 @@ class ConsoleInputOption { } return $parent; } + } diff --git a/lib/Cake/Console/ConsoleInputSubcommand.php b/lib/Cake/Console/ConsoleInputSubcommand.php index 4cac34244..c63138963 100644 --- a/lib/Cake/Console/ConsoleInputSubcommand.php +++ b/lib/Cake/Console/ConsoleInputSubcommand.php @@ -117,4 +117,5 @@ class ConsoleInputSubcommand { $command->addAttribute('help', $this->_help); return $parent; } + } diff --git a/lib/Cake/Console/ConsoleOptionParser.php b/lib/Cake/Console/ConsoleOptionParser.php index 1e2bff8c8..22721b882 100644 --- a/lib/Cake/Console/ConsoleOptionParser.php +++ b/lib/Cake/Console/ConsoleOptionParser.php @@ -551,6 +551,7 @@ class ConsoleOptionParser { * @param string $option The option to parse. * @param array $params The params to append the parsed value into * @return array Params with $option added in. + * @throws ConsoleException When unknown short options are encountered. */ protected function _parseShortOption($option, $params) { $key = substr($option, 1); @@ -597,7 +598,6 @@ class ConsoleOptionParser { } } - /** * Check to see if $name has an option (short/long) defined for it. * diff --git a/lib/Cake/Console/ConsoleOutput.php b/lib/Cake/Console/ConsoleOutput.php index a6cfd7d1f..56ca32987 100644 --- a/lib/Cake/Console/ConsoleOutput.php +++ b/lib/Cake/Console/ConsoleOutput.php @@ -284,4 +284,5 @@ class ConsoleOutput { public function __destruct() { fclose($this->_output); } + } diff --git a/lib/Cake/Console/HelpFormatter.php b/lib/Cake/Console/HelpFormatter.php index bfb9ee6a7..b7dbc5ac1 100644 --- a/lib/Cake/Console/HelpFormatter.php +++ b/lib/Cake/Console/HelpFormatter.php @@ -29,6 +29,7 @@ App::uses('String', 'Utility'); * @since CakePHP(tm) v 2.0 */ class HelpFormatter { + /** * The maximum number of arguments shown when generating usage. * @@ -196,4 +197,5 @@ class HelpFormatter { } return $string ? $xml->asXml() : $xml; } + } diff --git a/lib/Cake/Console/Shell.php b/lib/Cake/Console/Shell.php index 83404b371..bb4315496 100644 --- a/lib/Cake/Console/Shell.php +++ b/lib/Cake/Console/Shell.php @@ -400,7 +400,7 @@ class Shell extends Object { */ protected function _displayHelp($command) { $format = 'text'; - if (!empty($this->args[0]) && $this->args[0] == 'xml') { + if (!empty($this->args[0]) && $this->args[0] == 'xml') { $format = 'xml'; $this->stdout->outputAs(ConsoleOutput::RAW); } else { @@ -812,4 +812,5 @@ class Shell extends Object { } return current(App::path('plugins')) . $pluginName . DS; } + } diff --git a/lib/Cake/Console/ShellDispatcher.php b/lib/Cake/Console/ShellDispatcher.php index 3d01c8256..9dca3f97c 100644 --- a/lib/Cake/Console/ShellDispatcher.php +++ b/lib/Cake/Console/ShellDispatcher.php @@ -328,4 +328,5 @@ class ShellDispatcher { protected function _stop($status = 0) { exit($status); } + } diff --git a/lib/Cake/Console/TaskCollection.php b/lib/Cake/Console/TaskCollection.php index 5b2d371af..0205f4946 100644 --- a/lib/Cake/Console/TaskCollection.php +++ b/lib/Cake/Console/TaskCollection.php @@ -24,6 +24,7 @@ App::uses('ObjectCollection', 'Utility'); * @package Cake.Console */ class TaskCollection extends ObjectCollection { + /** * Shell to use to set params to tasks. * diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php b/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php index 176999dfe..405ce4d9a 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php @@ -39,29 +39,29 @@ class DbAclSchema extends CakeSchema { } public $acos = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'), - 'parent_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10), + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), + 'parent_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), 'model' => array('type' => 'string', 'null' => true), - 'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10), + 'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), 'alias' => array('type' => 'string', 'null' => true), - 'lft' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10), - 'rght' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10), + 'lft' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), + 'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)) ); public $aros = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'), - 'parent_id' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10), + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), + 'parent_id' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), 'model' => array('type' => 'string', 'null' => true), - 'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10), + 'foreign_key' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), 'alias' => array('type' => 'string', 'null' => true), - 'lft' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10), - 'rght' => array('type' => 'integer', 'null' => true, 'default' => NULL, 'length' => 10), + 'lft' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), + 'rght' => array('type' => 'integer', 'null' => true, 'default' => null, 'length' => 10), 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)) ); public $aros_acos = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'), + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), 'aro_id' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'), 'aco_id' => array('type' => 'integer', 'null' => false, 'length' => 10), '_create' => array('type' => 'string', 'null' => false, 'default' => '0', 'length' => 2), diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php b/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php index d5b542a9c..b8287c2d5 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/i18n.php @@ -39,13 +39,13 @@ class i18nSchema extends CakeSchema { } public $i18n = array( - 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'), - 'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'), - 'model' => array('type' => 'string', 'null' => false, 'key' => 'index'), - 'foreign_key' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'), - 'field' => array('type' => 'string', 'null' => false, 'key' => 'index'), - 'content' => array('type' => 'text', 'null' => true, 'default' => NULL), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0)) - ); + 'id' => array('type' => 'integer', 'null' => false, 'default' => null, 'length' => 10, 'key' => 'primary'), + 'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'), + 'model' => array('type' => 'string', 'null' => false, 'key' => 'index'), + 'foreign_key' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'), + 'field' => array('type' => 'string', 'null' => false, 'key' => 'index'), + 'content' => array('type' => 'text', 'null' => true, 'default' => null), + 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0)) + ); } diff --git a/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php b/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php index bd54edcfc..9a927d95e 100644 --- a/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php +++ b/lib/Cake/Console/Templates/skel/Config/Schema/sessions.php @@ -39,10 +39,10 @@ class SessionsSchema extends CakeSchema { } public $cake_sessions = array( - 'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'), - 'data' => array('type' => 'text', 'null' => true, 'default' => NULL), - 'expires' => array('type' => 'integer', 'null' => true, 'default' => NULL), - 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)) - ); + 'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'), + 'data' => array('type' => 'text', 'null' => true, 'default' => null), + 'expires' => array('type' => 'integer', 'null' => true, 'default' => null), + 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)) + ); } diff --git a/lib/Cake/Console/Templates/skel/Console/cake.php b/lib/Cake/Console/Templates/skel/Console/cake.php index 8ae23ff9f..a0ba7d897 100644 --- a/lib/Cake/Console/Templates/skel/Console/cake.php +++ b/lib/Cake/Console/Templates/skel/Console/cake.php @@ -25,7 +25,7 @@ if (function_exists('ini_set')) { ini_set('include_path', $root . PATH_SEPARATOR . __CAKE_PATH__ . PATH_SEPARATOR . ini_get('include_path')); } -if (!include($dispatcher)) { +if (!include $dispatcher) { trigger_error('Could not locate CakePHP core files.', E_USER_ERROR); } unset($paths, $path, $dispatcher, $root, $ds); diff --git a/lib/Cake/Console/Templates/skel/Controller/PagesController.php b/lib/Cake/Console/Templates/skel/Controller/PagesController.php index dd4f6308b..b0a5313d5 100644 --- a/lib/Cake/Console/Templates/skel/Controller/PagesController.php +++ b/lib/Cake/Console/Templates/skel/Controller/PagesController.php @@ -55,7 +55,7 @@ class PagesController extends AppController { if (!$count) { $this->redirect('/'); } - $page = $subpage = $title_for_layout = null; + $page = $subpage = $title = null; if (!empty($path[0])) { $page = $path[0]; @@ -64,9 +64,11 @@ class PagesController extends AppController { $subpage = $path[1]; } if (!empty($path[$count - 1])) { - $title_for_layout = Inflector::humanize($path[$count - 1]); + $title = Inflector::humanize($path[$count - 1]); } - $this->set(compact('page', 'subpage', 'title_for_layout')); + $this->set(compact('page', 'subpage')); + $this->set('title_for_layout', $title); $this->render(implode('/', $path)); } + } diff --git a/lib/Cake/Console/cake.php b/lib/Cake/Console/cake.php index dccd7b463..ddbb981c7 100644 --- a/lib/Cake/Console/cake.php +++ b/lib/Cake/Console/cake.php @@ -33,7 +33,7 @@ if (!$found && function_exists('ini_set')) { ini_set('include_path', $root . $ds . PATH_SEPARATOR . ini_get('include_path')); } -if (!include($dispatcher)) { +if (!include $dispatcher) { trigger_error('Could not locate CakePHP core files.', E_USER_ERROR); } unset($paths, $path, $found, $dispatcher, $root, $ds);