Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix most of the coding standards issues in Console/

  • Loading branch information...
commit db8c6b5c788893de6704907228e3714c5baf3ffd 1 parent 2a7bee0
Mark Story markstory authored
Showing with 146 additions and 158 deletions.
  1. +9 −6 lib/Cake/Console/Command/AclShell.php
  2. +11 −10 lib/Cake/Console/Command/ApiShell.php
  3. +3 −3 lib/Cake/Console/Command/BakeShell.php
  4. +2 −5 lib/Cake/Console/Command/CommandListShell.php
  5. +2 −5 lib/Cake/Console/Command/ConsoleShell.php
  6. +1 −0  lib/Cake/Console/Command/I18nShell.php
  7. +5 −4 lib/Cake/Console/Command/SchemaShell.php
  8. +4 −49 lib/Cake/Console/Command/Task/ControllerTask.php
  9. +2 −1  lib/Cake/Console/Command/Task/DbConfigTask.php
  10. +6 −3 lib/Cake/Console/Command/Task/ExtractTask.php
  11. +2 −2 lib/Cake/Console/Command/Task/FixtureTask.php
  12. +20 −10 lib/Cake/Console/Command/Task/ModelTask.php
  13. +2 −3 lib/Cake/Console/Command/Task/PluginTask.php
  14. +4 −5 lib/Cake/Console/Command/Task/ProjectTask.php
  15. +3 −2 lib/Cake/Console/Command/Task/TemplateTask.php
  16. +7 −5 lib/Cake/Console/Command/Task/TestTask.php
  17. +3 −2 lib/Cake/Console/Command/Task/ViewTask.php
  18. +3 −3 lib/Cake/Console/Command/TestShell.php
  19. +1 −0  lib/Cake/Console/Command/TestsuiteShell.php
  20. +7 −6 lib/Cake/Console/Command/UpgradeShell.php
  21. +3 −1 lib/Cake/Console/ConsoleInput.php
  22. +3 −1 lib/Cake/Console/ConsoleInputArgument.php
  23. +3 −1 lib/Cake/Console/ConsoleInputOption.php
  24. +1 −0  lib/Cake/Console/ConsoleInputSubcommand.php
  25. +1 −1  lib/Cake/Console/ConsoleOptionParser.php
  26. +1 −0  lib/Cake/Console/ConsoleOutput.php
  27. +2 −0  lib/Cake/Console/HelpFormatter.php
  28. +2 −1  lib/Cake/Console/Shell.php
  29. +1 −0  lib/Cake/Console/ShellDispatcher.php
  30. +1 −0  lib/Cake/Console/TaskCollection.php
  31. +11 −11 lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php
  32. +8 −8 lib/Cake/Console/Templates/skel/Config/Schema/i18n.php
  33. +5 −5 lib/Cake/Console/Templates/skel/Config/Schema/sessions.php
  34. +1 −1  lib/Cake/Console/Templates/skel/Console/cake.php
  35. +5 −3 lib/Cake/Console/Templates/skel/Controller/PagesController.php
  36. +1 −1  lib/Cake/Console/cake.php
15 lib/Cake/Console/Command/AclShell.php
View
@@ -200,7 +200,7 @@ public function getPath() {
}
$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 @@ protected function _outputNode($class, $node, $indent) {
$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 @@ public function getOptionParser() {
'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 <node> under the parent'),
@@ -514,8 +515,9 @@ public function nodeExists() {
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 @@ protected function _dataVars($type = null) {
$vars['class'] = $class;
return $vars;
}
+
}
21 lib/Cake/Console/Command/ApiShell.php
View
@@ -92,7 +92,7 @@ public function main() {
$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 @@ public function help() {
$commands = array(
'path' => "\t<type>\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<className>\n" .
"\t\tA CakePHP core class name (e.g: Component, HtmlHelper).\n"
@@ -203,7 +203,7 @@ protected function _parseClass($path, $class) {
$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 @@ protected function _parseClass($path, $class) {
ksort($parsed);
return $parsed;
}
+
}
6 lib/Cake/Console/Command/BakeShell.php
View
@@ -209,9 +209,9 @@ public function all() {
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 <name> of a Model'),
))->addSubcommand('project', array(
7 lib/Cake/Console/Command/CommandListShell.php
View
@@ -1,9 +1,5 @@
<?php
/**
- * Command list Shell
- *
- * PHP 5
- *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -46,7 +42,7 @@ public function startup() {
public function main() {
if (empty($this->params['xml'])) {
$this->out(__d('cake_console', "<info>Current Paths:</info>"), 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 @@ public function getOptionParser() {
'boolean' => true
));
}
+
}
7 lib/Cake/Console/Command/ConsoleShell.php
View
@@ -1,9 +1,5 @@
<?php
/**
- * CakePHP Console Shell
- *
- * PHP 5
- *
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
*
@@ -343,7 +339,7 @@ protected function _loadRoutes() {
Router::reload();
extract(Router::getNamedExpressions());
- if (!@include(APP . 'Config' . DS . 'routes.php')) {
+ if (!@include APP . 'Config' . DS . 'routes.php') {
return false;
}
CakePlugin::routes();
@@ -359,4 +355,5 @@ protected function _loadRoutes() {
}
return true;
}
+
}
1  lib/Cake/Console/Command/I18nShell.php
View
@@ -117,4 +117,5 @@ public function getOptionParser() {
'parser' => $this->Extract->getOptionParser()
));
}
+
}
9 lib/Cake/Console/Command/SchemaShell.php
View
@@ -58,7 +58,7 @@ public function startup() {
$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 @@ public function generate() {
$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 @@ public function dump() {
}
}
$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 @@ protected function _run($contents, $event, &$Schema) {
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 @@ public function getOptionParser() {
));
return $parser;
}
+
}
53 lib/Cake/Console/Command/Task/ControllerTask.php
View
@@ -145,17 +145,16 @@ protected function _interactive() {
$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 @@ public function confirmController($controllerName, $useDynamicScaffold, $helpers
$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 @@ public function getOptionParser() {
))->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 <arg1> <arg2>...");
- $this->hr();
- $this->out('Arguments:');
- $this->out();
- $this->out("<name>");
- $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 <config>');
- $this->out("\tset db config <config>. uses 'default' if none is specified");
- $this->out();
- $this->out('Commands:');
- $this->out();
- $this->out("controller <name>");
- $this->out("\tbakes controller with var \$scaffold");
- $this->out();
- $this->out("controller <name> public");
- $this->out("\tbakes controller with basic crud actions");
- $this->out("\t(index, view, add, edit, delete)");
- $this->out();
- $this->out("controller <name> 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 <name> 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();
- }
}
3  lib/Cake/Console/Command/Task/DbConfigTask.php
View
@@ -364,7 +364,7 @@ public function getConfig() {
$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 @@ public function getOptionParser() {
__d('cake_console', 'Bake new database configuration settings.')
);
}
+
}
9 lib/Cake/Console/Command/Task/ExtractTask.php
View
@@ -584,8 +584,10 @@ protected function _writeHeader() {
*/
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 @@ protected function _searchFiles() {
}
$exclude[] = preg_quote($e, '/');
}
- $pattern = '/' . implode('|', $exclude) . '/';
+ $pattern = '/' . implode('|', $exclude) . '/';
}
foreach ($this->_paths as $path) {
$Folder = new Folder($path);
@@ -694,4 +696,5 @@ protected function _searchFiles() {
protected function _isExtractingApp() {
return $this->_paths === array(APP);
}
+
}
4 lib/Cake/Console/Command/Task/FixtureTask.php
View
@@ -86,7 +86,7 @@ public function getOptionParser() {
'help' => __d('cake_console', 'Used with --count and <name>/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 @@ protected function _getRecordsFromTable($modelName, $useTable = null) {
$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);
30 lib/Cake/Console/Command/Task/ModelTask.php
View
@@ -170,7 +170,7 @@ public function inOptions($options, $prompt = null, $default = null) {
$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 @@ protected function _interactive() {
*/
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 @@ public function fieldValidation($fieldName, $metaData, $primaryKey = 'id') {
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 @@ public function doAssociations($model) {
}
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 @@ public function bake($name, $data = array()) {
} 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 @@ public function bakeTest($className) {
* @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 @@ public function getName($useDbConfig = null) {
}
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 @@ public function bakeFixture($className, $useTable = null) {
$this->Fixture->plugin = $this->plugin;
$this->Fixture->bake($className, $useTable);
}
+
}
5 lib/Cake/Console/Command/Task/PluginTask.php
View
@@ -135,7 +135,7 @@ public function bake($plugin) {
$out = "<?php\n\n";
$out .= "class {$plugin}AppController extends AppController {\n\n";
$out .= "}\n\n";
- $this->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 @@ public function findPath($pathOptions) {
$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 @@ public function getOptionParser() {
))->addArgument('name', array(
'help' => __d('cake_console', 'CamelCased name of the plugin to create.')
));
-
}
}
9 lib/Cake/Console/Command/Task/ProjectTask.php
View
@@ -54,7 +54,6 @@ public function execute() {
$project = $this->in($prompt, null, APP . 'myapp');
}
-
if ($project && !Folder::isAbsolute($project) && isset($_SERVER['PWD'])) {
$project = $_SERVER['PWD'] . DS . $project;
}
@@ -112,7 +111,7 @@ public function execute() {
$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 @@ public function createHome($dir) {
$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 @@ public function securitySalt($path) {
*
* @param string $path Project path
* @return boolean Success
- */
+ */
public function securityCipherSeed($path) {
$File = new File($path . 'Config' . DS . 'core.php');
$contents = $File->read();
5 lib/Cake/Console/Command/Task/TemplateTask.php
View
@@ -74,7 +74,7 @@ protected function _findThemes() {
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 @@ public function generate($directory, $filename, $vars = null) {
extract($this->templateVars);
ob_start();
ob_implicit_flush(0);
- include($templateFile);
+ include $templateFile;
$content = ob_get_clean();
return $content;
}
@@ -214,4 +214,5 @@ protected function _findTemplate($path, $directory, $filename) {
$this->err(__d('cake_console', 'Could not find template for %s', $filename));
return false;
}
+
}
12 lib/Cake/Console/Command/Task/TestTask.php
View
@@ -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 @@ public function getRealClassName($type, $class) {
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 @@ public function getRealClassName($type, $class) {
* @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 @@ protected function _processController($subject) {
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 @@ public function getOptionParser() {
'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.'));
}
+
}
5 lib/Cake/Console/Command/Task/ViewTask.php
View
@@ -133,7 +133,7 @@ public function execute() {
* @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 @@ protected function _associations(Model $model) {
$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;
}
+
}
6 lib/Cake/Console/Command/TestShell.php
View
@@ -192,7 +192,6 @@ protected function _parseArgs() {
'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 @@ public function available() {
}
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 @@ protected function _mapFileToCase($file, $category, $throwOnMissingFile = true)
if (!file_exists($testFile) && $throwOnMissingFile) {
throw new Exception(__d('cake_dev', 'Test case %s not found', $testFile));
}
-
+
return $testCase;
}
@@ -431,4 +430,5 @@ protected function _mapFileToCategory($file) {
}
return 'app';
}
+
}
1  lib/Cake/Console/Command/TestsuiteShell.php
View
@@ -207,4 +207,5 @@ public function main() {
$this->_run($args, $this->_runnerOptions());
}
+
}
13 lib/Cake/Console/Command/UpgradeShell.php
View
@@ -169,7 +169,7 @@ public function locations() {
}
}
}
-
+
$this->_moveViewFiles();
$this->_moveAppClasses();
@@ -234,7 +234,7 @@ public function helpers() {
$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 @@ public function request() {
$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 @@ public function exceptions() {
$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 @@ protected function _moveViewFiles() {
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 @@ protected function _movePhpFiles($path, $options) {
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 @@ public function getOptionParser() {
'parser' => $subcommandParser
));
}
+
}
4 lib/Cake/Console/ConsoleInput.php
View
@@ -22,6 +22,7 @@
* @package Cake.Console
*/
class ConsoleInput {
+
/**
* Input value.
*
@@ -46,4 +47,5 @@ public function __construct($handle = 'php://stdin') {
public function read() {
return fgets($this->_input);
}
-}
+
+}
4 lib/Cake/Console/ConsoleInputArgument.php
View
@@ -23,6 +23,7 @@
* @package Cake.Console
*/
class ConsoleInputArgument {
+
/**
* Name of the argument.
*
@@ -125,7 +126,7 @@ public function usage() {
* @return boolean
*/
public function isRequired() {
- return (bool) $this->_required;
+ return (bool)$this->_required;
}
/**
@@ -165,4 +166,5 @@ public function xml(SimpleXmlElement $parent) {
}
return $parent;
}
+
}
4 lib/Cake/Console/ConsoleInputOption.php
View
@@ -24,6 +24,7 @@
* @package Cake.Console
*/
class ConsoleInputOption {
+
/**
* Name of the option
*
@@ -171,7 +172,7 @@ public function defaultValue() {
* @return boolean
*/
public function isBoolean() {
- return (bool) $this->_boolean;
+ return (bool)$this->_boolean;
}
/**
@@ -216,4 +217,5 @@ public function xml(SimpleXmlElement $parent) {
}
return $parent;
}
+
}
1  lib/Cake/Console/ConsoleInputSubcommand.php
View
@@ -117,4 +117,5 @@ public function xml(SimpleXmlElement $parent) {
$command->addAttribute('help', $this->_help);
return $parent;
}
+
}
2  lib/Cake/Console/ConsoleOptionParser.php
View
@@ -551,6 +551,7 @@ protected function _parseLongOption($option, $params) {
* @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 @@ protected function _parseOption($name, $params) {
}
}
-
/**
* Check to see if $name has an option (short/long) defined for it.
*
1  lib/Cake/Console/ConsoleOutput.php
View
@@ -284,4 +284,5 @@ public function outputAs($type = null) {
public function __destruct() {
fclose($this->_output);
}
+
}
2  lib/Cake/Console/HelpFormatter.php
View
@@ -29,6 +29,7 @@
* @since CakePHP(tm) v 2.0
*/
class HelpFormatter {
+
/**
* The maximum number of arguments shown when generating usage.
*
@@ -196,4 +197,5 @@ public function xml($string = true) {
}
return $string ? $xml->asXml() : $xml;
}
+
}
3  lib/Cake/Console/Shell.php
View
@@ -400,7 +400,7 @@ public function runCommand($command, $argv) {
*/
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 @@ protected function _pluginPath($pluginName) {
}
return current(App::path('plugins')) . $pluginName . DS;
}
+
}
1  lib/Cake/Console/ShellDispatcher.php
View
@@ -328,4 +328,5 @@ public function help() {
protected function _stop($status = 0) {
exit($status);
}
+
}
1  lib/Cake/Console/TaskCollection.php
View
@@ -24,6 +24,7 @@
* @package Cake.Console
*/
class TaskCollection extends ObjectCollection {
+
/**
* Shell to use to set params to tasks.
*
22 lib/Cake/Console/Templates/skel/Config/Schema/db_acl.php
View
@@ -39,29 +39,29 @@ public function after($event = array()) {
}
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),
16 lib/Cake/Console/Templates/skel/Config/Schema/i18n.php
View
@@ -39,13 +39,13 @@ public function after($event = array()) {
}
public $i18n = array(
- 'id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 10, 'key' => 'primary'),
- 'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'),
- 'model' => array('type' => 'string', 'null' => false, 'key' => 'index'),
- 'foreign_key' => array('type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'),
- 'field' => array('type' => 'string', 'null' => false, 'key' => 'index'),
- 'content' => array('type' => 'text', 'null' => true, 'default' => NULL),
- 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1), 'locale' => array('column' => 'locale', 'unique' => 0), 'model' => array('column' => 'model', 'unique' => 0), 'row_id' => array('column' => 'foreign_key', 'unique' => 0), 'field' => array('column' => 'field', 'unique' => 0))
- );
+ '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))
+ );
}
10 lib/Cake/Console/Templates/skel/Config/Schema/sessions.php
View
@@ -39,10 +39,10 @@ public function after($event = array()) {
}
public $cake_sessions = array(
- 'id' => array('type' => 'string', 'null' => false, 'key' => 'primary'),
- 'data' => array('type' => 'text', 'null' => true, 'default' => NULL),
- 'expires' => array('type' => 'integer', 'null' => true, 'default' => NULL),
- 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1))
- );
+ '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))
+ );
}
2  lib/Cake/Console/Templates/skel/Console/cake.php
View
@@ -25,7 +25,7 @@
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);
8 lib/Cake/Console/Templates/skel/Controller/PagesController.php
View
@@ -55,7 +55,7 @@ public function display() {
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 @@ public function display() {
$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));
}
+
}
2  lib/Cake/Console/cake.php
View
@@ -33,7 +33,7 @@
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);
Please sign in to comment.
Something went wrong with that request. Please try again.