Browse Source

Adhering to coding standards

Kyle Robinson Young 14 years ago
parent
commit
5876744709
31 changed files 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

+ 1 - 1
lib/Cake/Console/Command/Task/BakeTask.php

@@ -79,7 +79,7 @@ class BakeTask extends AppShell {
  * @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;

+ 2 - 2
lib/Cake/Console/Command/Task/PluginTask.php

@@ -159,8 +159,8 @@ class PluginTask extends AppShell {
  */
 	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);
 			}
 		}

+ 5 - 5
lib/Cake/Console/Command/UpgradeShell.php

@@ -83,7 +83,7 @@ class UpgradeShell extends AppShell {
  * @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 @@ class UpgradeShell extends AppShell {
 		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 @@ class UpgradeShell extends AppShell {
 			'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 @@ class UpgradeShell extends AppShell {
 			'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 @@ class UpgradeShell extends AppShell {
 			$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]);
 				}

+ 1 - 1
lib/Cake/Console/HelpFormatter.php

@@ -140,7 +140,7 @@ class HelpFormatter {
 		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);

+ 1 - 1
lib/Cake/Controller/CakeErrorController.php

@@ -55,7 +55,7 @@ class CakeErrorController extends AppController {
 	public function beforeRender() {
 		parent::beforeRender();
 		foreach ($this->viewVars as $key => $value) {
-			if (!is_object($value)){
+			if (!is_object($value)) {
 				$this->viewVars[$key] = h($value);
 			}
 		}

+ 1 - 1
lib/Cake/Model/Datasource/Database/Mysql.php

@@ -567,7 +567,7 @@ class Mysql extends DboSource {
 	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';

+ 2 - 2
lib/Cake/Model/Datasource/Database/Postgres.php

@@ -409,7 +409,7 @@ class Postgres extends DboSource {
 
 		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 @@ class Postgres extends DboSource {
 	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;

+ 2 - 2
lib/Cake/Model/Datasource/Database/Sqlite.php

@@ -286,9 +286,9 @@ class Sqlite extends DboSource {
 			}
 		} 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) {

+ 3 - 3
lib/Cake/Model/Datasource/DboSource.php

@@ -1947,7 +1947,7 @@ class DboSource extends DataSource {
 				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 @@ class DboSource extends DataSource {
 				}
 				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 @@ class DboSource extends DataSource {
 			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) . ')';
 				}

+ 2 - 2
lib/Cake/Model/Datasource/Session/DatabaseSession.php

@@ -47,13 +47,13 @@ class DatabaseSession implements CakeSessionHandlerInterface {
 
 		if (empty($modelName)) {
 			$settings = array(
-				'class' =>'Session',
+				'class' => 'Session',
 				'alias' => 'Session',
 				'table' => 'cake_sessions',
 			);
 		} else {
 			$settings = array(
-				'class' =>$modelName,
+				'class' => $modelName,
 				'alias' => 'Session',
 			);
 		}

+ 1 - 1
lib/Cake/Model/Model.php

@@ -2136,7 +2136,7 @@ class Model extends Object {
 				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;
 				}

+ 1 - 1
lib/Cake/Routing/Route/CakeRoute.php

@@ -229,7 +229,7 @@ class CakeRoute {
 		// 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]]);
 				}

+ 1 - 1
lib/Cake/Test/Case/Cache/Engine/MemcacheEngineTest.php

@@ -102,7 +102,7 @@ class MemcacheEngineTest extends CakeTestCase {
 		$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;

+ 1 - 1
lib/Cake/Test/Case/I18n/I18nTest.php

@@ -2603,7 +2603,7 @@ class I18nTest extends CakeTestCase {
 		$this->assertEquals($expected, $result);
 	}
 
-	public function testTimeDefinitionJapanese(){
+	public function testTimeDefinitionJapanese() {
 		Configure::write('Config.language', 'ja_jp');
 		$result = __c('d_fmt', 5);
 

+ 7 - 7
lib/Cake/Test/Case/Model/Behavior/ContainableBehaviorTest.php

@@ -2921,8 +2921,8 @@ class ContainableBehaviorTest extends CakeTestCase {
 			'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 @@ class ContainableBehaviorTest extends CakeTestCase {
 			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 @@ class ContainableBehaviorTest extends CakeTestCase {
 	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 @@ class ContainableBehaviorTest extends CakeTestCase {
 
 		$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) . '}';

+ 2 - 2
lib/Cake/Test/Case/Model/ModelReadTest.php

@@ -131,7 +131,7 @@ class ModelReadTest extends BaseModelTest {
 			'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 @@ class ModelReadTest extends BaseModelTest {
 			'order'=> 'Thread.project_id'
 		));
 		$result = array();
-		foreach($rows as $row) {
+		foreach ($rows as $row) {
 			$result[$row['Thread']['project_id']] = $row[0]['total'];
 		}
 		$expected = array(

+ 1 - 1
lib/Cake/Test/Case/Model/models.php

@@ -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;

+ 1 - 1
lib/Cake/Test/Case/Routing/DispatcherTest.php

@@ -20,7 +20,7 @@ App::uses('Dispatcher', 'Routing');
 
 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);
 }
 

+ 2 - 2
lib/Cake/Test/Case/Utility/SetTest.php

@@ -2403,7 +2403,7 @@ class SetTest extends CakeTestCase {
 		$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 @@ class SetTest extends CakeTestCase {
 
 		$ids = array();
 
-		foreach($mapped as $object)	 {
+		foreach ($mapped as $object) {
 			$ids[] = $object->id;
 		}
 		$this->assertEquals($ids, array(1, 2));

+ 1 - 1
lib/Cake/Test/Case/Utility/StringTest.php

@@ -47,7 +47,7 @@ class StringTest extends CakeTestCase {
 		$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);

+ 1 - 1
lib/Cake/Test/Case/Utility/XmlTest.php

@@ -868,7 +868,7 @@ class XmlTest extends CakeTestCase {
 		
 		//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>';

+ 1 - 1
lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php

@@ -279,7 +279,7 @@ class PaginatorHelperTest extends CakeTestCase {
  *
  * @return void
  */
-	public function testSortLinksUsingDirectionOption(){
+	public function testSortLinksUsingDirectionOption() {
 		Router::reload();
 		Router::parse('/');
 		Router::setRequestInfo(array(

+ 2 - 2
lib/Cake/Test/Case/View/Helper/TimeHelperTest.php

@@ -116,7 +116,7 @@ class TimeHelperTest extends CakeTestCase {
 		$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 @@ class TimeHelperTest extends CakeTestCase {
 
 		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;

+ 1 - 1
lib/Cake/TestSuite/CakeTestSuiteDispatcher.php

@@ -228,7 +228,7 @@ class CakeTestSuiteDispatcher {
 	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'],

+ 2 - 2
lib/Cake/TestSuite/Fixture/CakeTestFixture.php

@@ -144,7 +144,7 @@ class CakeTestFixture {
 
 		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 @@ class CakeTestFixture {
 			$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);

+ 1 - 1
lib/Cake/TestSuite/Fixture/CakeTestModel.php

@@ -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'):

+ 1 - 1
lib/Cake/TestSuite/templates/menu.php

@@ -30,7 +30,7 @@ if (!empty($plugins)):
 ?>
 	<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>

+ 1 - 1
lib/Cake/View/Helper/FormHelper.php

@@ -1208,7 +1208,7 @@ class FormHelper extends AppHelper {
  */
 	public function checkbox($fieldName, $options = array()) {
 		$valueOptions = array();
-		if(isset($options['default'])){
+		if (isset($options['default'])) {
 			$valueOptions['default'] = $options['default'];
 			unset($options['default']);
 		}

+ 1 - 1
lib/Cake/View/Helper/JqueryEngineHelper.php

@@ -247,7 +247,7 @@ class JqueryEngineHelper extends JsBaseEngineHelper {
 		if (isset($options['update'])) {
 			$wrapCallbacks = isset($options['wrapCallbacks']) ? $options['wrapCallbacks'] : true;
 			$success = '';
-			if(isset($options['success']) AND !empty($options['success'])) {
+			if (isset($options['success']) AND !empty($options['success'])) {
 				$success .= $options['success'];
 			}
 			$success .= $this->jQueryObject . '("' . $options['update'] . '").html(data);';

+ 2 - 2
lib/Cake/View/Helper/TimeHelper.php

@@ -459,8 +459,8 @@ class TimeHelper extends AppHelper {
 	public function toRSS($dateString, $userOffset = null) {
 		$date = $this->fromString($dateString, $userOffset);
 
-		if(!is_null($userOffset)) {
-			if($userOffset == 0) {
+		if (!is_null($userOffset)) {
+			if ($userOffset == 0) {
 				$timezone = '+0000';
 			} else {
 				$hours = (int) floor(abs($userOffset));

+ 0 - 1
lib/Cake/basics.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Basic Cake functionality.
  *