Permalink
Browse files

Adhering to coding standards

  • Loading branch information...
1 parent 32a3737 commit 5876744709999157b23617a46be7d3293e1268f1 @shama shama committed Nov 30, 2011
Showing with 51 additions and 52 deletions.
  1. +1 −1 lib/Cake/Console/Command/Task/BakeTask.php
  2. +2 −2 lib/Cake/Console/Command/Task/PluginTask.php
  3. +5 −5 lib/Cake/Console/Command/UpgradeShell.php
  4. +1 −1 lib/Cake/Console/HelpFormatter.php
  5. +1 −1 lib/Cake/Controller/CakeErrorController.php
  6. +1 −1 lib/Cake/Model/Datasource/Database/Mysql.php
  7. +2 −2 lib/Cake/Model/Datasource/Database/Postgres.php
  8. +2 −2 lib/Cake/Model/Datasource/Database/Sqlite.php
  9. +3 −3 lib/Cake/Model/Datasource/DboSource.php
  10. +2 −2 lib/Cake/Model/Datasource/Session/DatabaseSession.php
  11. +1 −1 lib/Cake/Model/Model.php
  12. +1 −1 lib/Cake/Routing/Route/CakeRoute.php
  13. +1 −1 lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php
  14. +1 −1 lib/Cake/Test/Case/I18n/I18nTest.php
  15. +7 −7 lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php
  16. +2 −2 lib/Cake/Test/Case/Model/ModelReadTest.php
  17. +1 −1 lib/Cake/Test/Case/Model/models.php
  18. +1 −1 lib/Cake/Test/Case/Routing/DispatcherTest.php
  19. +2 −2 lib/Cake/Test/Case/Utility/SetTest.php
  20. +1 −1 lib/Cake/Test/Case/Utility/StringTest.php
  21. +1 −1 lib/Cake/Test/Case/Utility/XmlTest.php
  22. +1 −1 lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
  23. +2 −2 lib/Cake/Test/Case/View/Helper/TimeHelperTest.php
  24. +1 −1 lib/Cake/TestSuite/CakeTestSuiteDispatcher.php
  25. +2 −2 lib/Cake/TestSuite/Fixture/CakeTestFixture.php
  26. +1 −1 lib/Cake/TestSuite/Fixture/CakeTestModel.php
  27. +1 −1 lib/Cake/TestSuite/templates/menu.php
  28. +1 −1 lib/Cake/View/Helper/FormHelper.php
  29. +1 −1 lib/Cake/View/Helper/JqueryEngineHelper.php
  30. +2 −2 lib/Cake/View/Helper/TimeHelper.php
  31. +0 −1 lib/Cake/basics.php
@@ -79,7 +79,7 @@ public function getPath() {
* @return void
*/
public function execute() {
- foreach($this->args as $i => $arg) {
+ foreach ($this->args as $i => $arg) {
if (strpos($arg, '.')) {
list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg);
break;
@@ -159,8 +159,8 @@ public function bake($plugin) {
*/
public function findPath($pathOptions) {
$valid = false;
- foreach ($pathOptions as $i =>$path) {
- if(!is_dir($path)) {
+ foreach ($pathOptions as $i => $path) {
+ if (!is_dir($path)) {
array_splice($pathOptions, $i, 1);
}
}
@@ -83,7 +83,7 @@ public function startup() {
* @return void
*/
public function all() {
- foreach($this->OptionParser->subcommands() as $command) {
+ foreach ($this->OptionParser->subcommands() as $command) {
$name = $command->name();
if ($name === 'all') {
continue;
@@ -135,7 +135,7 @@ public function locations() {
if (is_dir('plugins')) {
$Folder = new Folder('plugins');
list($plugins) = $Folder->read();
- foreach($plugins as $plugin) {
+ foreach ($plugins as $plugin) {
chdir($cwd . DS . 'plugins' . DS . $plugin);
$this->locations();
}
@@ -155,7 +155,7 @@ public function locations() {
'Test' . DS . 'fixtures' => 'Test' . DS . 'Fixture',
'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates',
);
- foreach($moves as $old => $new) {
+ foreach ($moves as $old => $new) {
if (is_dir($old)) {
$this->out(__d('cake_console', 'Moving %s to %s', $old, $new));
if (!$this->params['dry-run']) {
@@ -190,7 +190,7 @@ public function locations() {
'checkFolder' => true,
'regex' => '@class (\S*) .*{@i'
);
- foreach($sourceDirs as $dir => $options) {
+ foreach ($sourceDirs as $dir => $options) {
if (is_numeric($dir)) {
$dir = $options;
$options = array();
@@ -614,7 +614,7 @@ protected function _movePhpFiles($path, $options) {
$this->_findFiles('php');
} else {
$this->_files = scandir($path);
- foreach($this->_files as $i => $file) {
+ foreach ($this->_files as $i => $file) {
if (strlen($file) < 5 || substr($file, -4) !== '.php') {
unset($this->_files[$i]);
}
@@ -140,7 +140,7 @@ protected function _generateUsage() {
foreach ($this->_parser->options() as $option) {
$options[] = $option->usage();
}
- if (count($options) > $this->_maxOptions){
+ if (count($options) > $this->_maxOptions) {
$options = array('[options]');
}
$usage = array_merge($usage, $options);
@@ -55,7 +55,7 @@ public function __construct($request = null, $response = null) {
public function beforeRender() {
parent::beforeRender();
foreach ($this->viewVars as $key => $value) {
- if (!is_object($value)){
+ if (!is_object($value)) {
$this->viewVars[$key] = h($value);
}
}
@@ -567,7 +567,7 @@ protected function _alterTableParameters($table, $parameters) {
protected function _alterIndexes($table, $indexes) {
$alter = array();
if (isset($indexes['drop'])) {
- foreach($indexes['drop'] as $name => $value) {
+ foreach ($indexes['drop'] as $name => $value) {
$out = 'DROP ';
if ($name == 'PRIMARY') {
$out .= 'PRIMARY KEY';
@@ -409,7 +409,7 @@ protected function _quoteFunctionField($match) {
if (!$constant && strpos($match[1], '.') === false) {
$match[1] = $this->name($match[1]);
- } elseif (!$constant){
+ } elseif (!$constant) {
$parts = explode('.', $match[1]);
if (!Set::numeric($parts)) {
$match[1] = $this->name($match[1]);
@@ -550,7 +550,7 @@ public function alterSchema($compare, $table = null) {
protected function _alterIndexes($table, $indexes) {
$alter = array();
if (isset($indexes['drop'])) {
- foreach($indexes['drop'] as $name => $value) {
+ foreach ($indexes['drop'] as $name => $value) {
$out = 'DROP ';
if ($name == 'PRIMARY') {
continue;
@@ -286,9 +286,9 @@ public function resultSet($results) {
}
} elseif (strpos($querystring, 'PRAGMA table_info') === 0) {
$selects = array('cid', 'name', 'type', 'notnull', 'dflt_value', 'pk');
- } elseif(strpos($querystring, 'PRAGMA index_list') === 0) {
+ } elseif (strpos($querystring, 'PRAGMA index_list') === 0) {
$selects = array('seq', 'name', 'unique');
- } elseif(strpos($querystring, 'PRAGMA index_info') === 0) {
+ } elseif (strpos($querystring, 'PRAGMA index_info') === 0) {
$selects = array('seqno', 'cid', 'name');
}
while ($j < $num_fields) {
@@ -1947,7 +1947,7 @@ public function calculate($model, $func, $params = array()) {
if (!isset($params[1])) {
$params[1] = 'count';
}
- if (is_object($model) && $model->isVirtualField($params[0])){
+ if (is_object($model) && $model->isVirtualField($params[0])) {
$arg = $this->_quoteFields($model->getVirtualField($params[0]));
} else {
$arg = $this->name($params[0]);
@@ -2191,7 +2191,7 @@ public function fields($model, $alias = null, $fields = array(), $quote = true)
}
if (is_object($fields[$i]) && isset($fields[$i]->type) && $fields[$i]->type === 'expression') {
$fields[$i] = $fields[$i]->value;
- } elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])){
+ } elseif (preg_match('/^\(.*\)\s' . $this->alias . '.*/i', $fields[$i])) {
continue;
} elseif (!preg_match('/^.+\\(.*\\)/', $fields[$i])) {
$prepend = '';
@@ -2622,7 +2622,7 @@ public function group($group, $model = null) {
if (!is_array($group)) {
$group = array($group);
}
- foreach($group as $index => $key) {
+ foreach ($group as $index => $key) {
if (is_object($model) && $model->isVirtualField($key)) {
$group[$index] = '(' . $model->getVirtualField($key) . ')';
}
@@ -47,13 +47,13 @@ public function __construct() {
if (empty($modelName)) {
$settings = array(
- 'class' =>'Session',
+ 'class' => 'Session',
'alias' => 'Session',
'table' => 'cake_sessions',
);
} else {
$settings = array(
- 'class' =>$modelName,
+ 'class' => $modelName,
'alias' => 'Session',
);
}
View
@@ -2136,7 +2136,7 @@ public function validateAssociated($data, $options = array()) {
if (in_array($associations[$association], array('belongsTo', 'hasOne'))) {
$validates = $this->{$association}->create($values) && $this->{$association}->validates($options);
$return[$association][] = $validates;
- } elseif($associations[$association] === 'hasMany') {
+ } elseif ($associations[$association] === 'hasMany') {
$validates = $this->{$association}->validateMany($values, $options);
$return[$association] = $validates;
}
@@ -229,7 +229,7 @@ public function parse($url) {
// restructure 'pass' key route params
if (isset($this->options['pass'])) {
$j = count($this->options['pass']);
- while($j--) {
+ while ($j--) {
if (isset($route[$this->options['pass'][$j]])) {
array_unshift($route['pass'], $route[$this->options['pass'][$j]]);
}
@@ -102,7 +102,7 @@ public function testMultipleServers() {
$available = true;
$Memcache = new Memcache();
- foreach($servers as $server) {
+ foreach ($servers as $server) {
list($host, $port) = explode(':', $server);
if (!@$Memcache->connect($host, $port)) {
$available = false;
@@ -2603,7 +2603,7 @@ public function testTimeDefinition() {
$this->assertEquals($expected, $result);
}
- public function testTimeDefinitionJapanese(){
+ public function testTimeDefinitionJapanese() {
Configure::write('Config.language', 'ja_jp');
$result = __c('d_fmt', 5);
@@ -2921,8 +2921,8 @@ public function testEmbeddedFindFields() {
'order' => array('Article.id' => 'ASC')
));
if (!empty($result)) {
- foreach($result as $i=>$article) {
- foreach($article['Comment'] as $j=>$comment) {
+ foreach ($result as $i => $article) {
+ foreach ($article['Comment'] as $j => $comment) {
$result[$i]['Comment'][$j] = array_diff_key($comment, array('id'=>true));
}
}
@@ -3628,7 +3628,7 @@ function __containments(&$Model, $contain = array()) {
return $this->__containments($result['models']);
} else {
$result = $Model;
- foreach($result as $i => $containment) {
+ foreach ($result as $i => $containment) {
$result[$i] = array_diff_key($containment, array('instance' => true));
}
}
@@ -3646,7 +3646,7 @@ function __containments(&$Model, $contain = array()) {
function __assertBindings(&$Model, $expected = array()) {
$expected = array_merge(array('belongsTo' => array(), 'hasOne' => array(), 'hasMany' => array(), 'hasAndBelongsToMany' => array()), $expected);
- foreach($expected as $binding => $expect) {
+ foreach ($expected as $binding => $expect) {
$this->assertEquals(array_keys($Model->$binding), $expect);
}
}
@@ -3664,14 +3664,14 @@ function __bindings(&$Model, $extra = array(), $output = true) {
$debug = '[';
$lines = array();
- foreach($relationTypes as $binding) {
+ foreach ($relationTypes as $binding) {
if (!empty($Model->$binding)) {
$models = array_keys($Model->$binding);
- foreach($models as $linkedModel) {
+ foreach ($models as $linkedModel) {
$line = $linkedModel;
if (!empty($extra) && !empty($Model->{$binding}[$linkedModel])) {
$extraData = array();
- foreach(array_intersect_key($Model->{$binding}[$linkedModel], array_flip($extra)) as $key => $value) {
+ foreach (array_intersect_key($Model->{$binding}[$linkedModel], array_flip($extra)) as $key => $value) {
$extraData[] = $key . ': ' . (is_array($value) ? '(' . implode(', ', $value) . ')' : $value);
}
$line .= ' {' . implode(' - ', $extraData) . '}';
@@ -131,7 +131,7 @@ public function testGroupBy() {
'fields' => array('Thread.project_id', 'COUNT(*) AS total')
));
$result = array();
- foreach($rows as $row) {
+ foreach ($rows as $row) {
$result[$row['Thread']['project_id']] = $row[0]['total'];
}
$expected = array(
@@ -146,7 +146,7 @@ public function testGroupBy() {
'order'=> 'Thread.project_id'
));
$result = array();
- foreach($rows as $row) {
+ foreach ($rows as $row) {
$result[$row['Thread']['project_id']] = $row[0]['total'];
}
$expected = array(
@@ -899,7 +899,7 @@ class ModifiedAuthor extends Author {
* @return void
*/
public function afterFind($results, $primary = false) {
- foreach($results as $index => $result) {
+ foreach ($results as $index => $result) {
$results[$index]['Author']['user'] .= ' (CakePHP)';
}
return $results;
@@ -20,7 +20,7 @@
if (!class_exists('AppController', false)) {
require_once CAKE . 'Controller' . DS . 'AppController.php';
-} elseif (!defined('APP_CONTROLLER_EXISTS')){
+} elseif (!defined('APP_CONTROLLER_EXISTS')) {
define('APP_CONTROLLER_EXISTS', true);
}
@@ -2403,7 +2403,7 @@ public function testMapNesting() {
$mapped = Set::map($expected);
$ids = array();
- foreach($mapped as $object) {
+ foreach ($mapped as $object) {
$ids[] = $object->id;
}
$this->assertEquals($ids, array(1, 2));
@@ -2451,7 +2451,7 @@ public function testMapNesting() {
$ids = array();
- foreach($mapped as $object) {
+ foreach ($mapped as $object) {
$ids[] = $object->id;
}
$this->assertEquals($ids, array(1, 2));
@@ -47,7 +47,7 @@ public function testMultipleUuidGeneration() {
$count = mt_rand(10, 1000);
$pattern = "/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/";
- for($i = 0; $i < $count; $i++) {
+ for ($i = 0; $i < $count; $i++) {
$result = String::uuid();
$match = (bool) preg_match($pattern, $result);
$this->assertTrue($match);
@@ -868,7 +868,7 @@ public function testWithModel() {
//multiple model results - without a records key it would fatal error
$data = $user->find('all', array('limit'=>2));
- $data = array('records'=>$data);
+ $data = array('records' => $data);
$obj = Xml::build(compact('data'));
$expected = '<' . '?xml version="1.0" encoding="UTF-8"?><data>';
$expected .= '<records>';
@@ -279,7 +279,7 @@ public function testSortLinkWithVirtualField() {
*
* @return void
*/
- public function testSortLinksUsingDirectionOption(){
+ public function testSortLinksUsingDirectionOption() {
Router::reload();
Router::parse('/');
Router::setRequestInfo(array(
@@ -116,7 +116,7 @@ public function testTimeAgoInWords() {
$result = $this->Time->timeAgoInWords(strtotime('+1 month +1 week +6 days'), array('end' => '8 years'), true);
$this->assertEquals($result, '1 month, 1 week, 6 days');
- for($i = 0; $i < 200; $i ++) {
+ for ($i = 0; $i < 200; $i ++) {
$years = mt_rand(0, 3);
$months = mt_rand(0, 11);
$weeks = mt_rand(0, 3);
@@ -411,7 +411,7 @@ public function testToRss() {
if (!$this->skipIf(!class_exists('DateTimeZone'), '%s DateTimeZone class not available.')) {
$timezones = array('Europe/London', 'Europe/Brussels', 'UTC', 'America/Denver', 'America/Caracas', 'Asia/Kathmandu');
- foreach($timezones as $timezone) {
+ foreach ($timezones as $timezone) {
$yourTimezone = new DateTimeZone($timezone);
$yourTime = new DateTime('now', $yourTimezone);
$userOffset = $yourTimezone->getOffset($yourTime) / HOUR;
@@ -228,7 +228,7 @@ function _parseParams() {
function _runTestCase() {
$commandArgs = array(
'case' => $this->params['case'],
- 'core' =>$this->params['core'],
+ 'core' => $this->params['core'],
'app' => $this->params['app'],
'plugin' => $this->params['plugin'],
'codeCoverage' => $this->params['codeCoverage'],
@@ -144,7 +144,7 @@ public function create($db) {
if (empty($this->fields['tableParameters']['engine'])) {
$canUseMemory = true;
- foreach($this->fields as $field => $args) {
+ foreach ($this->fields as $field => $args) {
if (is_string($args)) {
$type = $args;
@@ -205,7 +205,7 @@ public function insert($db) {
$values = array();
if (isset($this->records) && !empty($this->records)) {
$fields = array();
- foreach($this->records as $record) {
+ foreach ($this->records as $record) {
$fields = array_merge($fields, array_keys(array_intersect_key($record, $this->fields)));
}
$fields = array_unique($fields);
@@ -39,7 +39,7 @@ class CakeTestModel extends Model {
public function beforeFind($queryData) {
$pk = $this->primaryKey;
$aliasedPk = $this->alias . '.' . $this->primaryKey;
- switch(true) {
+ switch (true) {
case !$pk:
case !$this->useTable:
case !$this->schema('id'):
@@ -30,7 +30,7 @@
?>
<li style="padding-top: 10px">
<span style="font-size: 18px">Plugins</span>
- <?php foreach($plugins as $plugin): ?>
+ <?php foreach ($plugins as $plugin): ?>
<ul>
<li style="padding-top: 10px">
<span style="font-size: 18px"><?php echo $plugin;?></span>
Oops, something went wrong.

0 comments on commit 5876744

Please sign in to comment.