Skip to content

Commit

Permalink
code conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark authored and markstory committed Feb 26, 2012
1 parent ed22c17 commit e94d307
Show file tree
Hide file tree
Showing 36 changed files with 63 additions and 65 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Cache/Engine/XcacheEngine.php
Expand Up @@ -165,7 +165,7 @@ protected function _auth($reverse = false) {
}
if (!empty($this->settings[$setting])) {
$_SERVER[$key] = $this->settings[$setting];
} else if (!empty($this->settings[$key])) {
} elseif (!empty($this->settings[$key])) {
$_SERVER[$key] = $this->settings[$key];
} else {
$_SERVER[$key] = $value;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/DbConfigTask.php
Expand Up @@ -100,7 +100,7 @@ protected function _interactive() {
if (preg_match('/[^a-z0-9_]/i', $name)) {
$name = '';
$this->out(__d('cake_console', 'The name may only contain unaccented latin characters, numbers or underscores'));
} else if (preg_match('/^[^a-z_]/i', $name)) {
} elseif (preg_match('/^[^a-z_]/i', $name)) {
$name = '';
$this->out(__d('cake_console', 'The name must start with an unaccented latin character or an underscore'));
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Console/Command/Task/ExtractTask.php
Expand Up @@ -118,7 +118,7 @@ public function execute() {
}
if (isset($this->params['paths'])) {
$this->_paths = explode(',', $this->params['paths']);
} else if (isset($this->params['plugin'])) {
} elseif (isset($this->params['plugin'])) {
$plugin = Inflector::camelize($this->params['plugin']);
if (!CakePlugin::loaded($plugin)) {
CakePlugin::load($plugin);
Expand Down Expand Up @@ -159,7 +159,7 @@ public function execute() {

if (isset($this->params['output'])) {
$this->_output = $this->params['output'];
} else if (isset($this->params['plugin'])) {
} elseif (isset($this->params['plugin'])) {
$this->_output = $this->_paths[0] . DS . 'Locale';
} else {
$message = __d('cake_console', "What is the path you would like to output?\n[Q]uit", $this->_paths[0] . DS . 'Locale');
Expand Down Expand Up @@ -594,7 +594,7 @@ protected function _getStrings(&$position, $target) {
$position++;
}
$strings[] = $string;
} else if ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
} elseif ($this->_tokens[$position][0] == T_CONSTANT_ENCAPSED_STRING) {
$strings[] = $this->_formatString($this->_tokens[$position][1]);
}
$position++;
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Core/App.php
Expand Up @@ -652,7 +652,7 @@ public static function import($type = null, $name = null, $parent = true, $searc
protected static function _loadClass($name, $plugin, $type, $originalType, $parent) {
if ($type == 'Console/Command' && $name == 'Shell') {
$type = 'Console';
} else if (isset(self::$types[$originalType]['suffix'])) {
} elseif (isset(self::$types[$originalType]['suffix'])) {
$suffix = self::$types[$originalType]['suffix'];
$name .= ($suffix == $name) ? '' : $suffix;
}
Expand Down Expand Up @@ -691,7 +691,7 @@ protected static function _loadFile($name, $plugin, $search, $file, $return) {
$mapped = self::_mapped($name, $plugin);
if ($mapped) {
$file = $mapped;
} else if (!empty($search)) {
} elseif (!empty($search)) {
foreach ($search as $path) {
$found = false;
if (file_exists($path . $file)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Event/CakeEventManager.php
Expand Up @@ -126,7 +126,7 @@ protected function _attachSubscriber(CakeEventListener $subscriber) {
$method = $function;
if (is_array($function) && isset($function['callable'])) {
list($method, $options) = $this->_extractCallable($function, $subscriber);
} else if (is_array($function) && is_numeric(key($function))) {
} elseif (is_array($function) && is_numeric(key($function))) {
foreach ($function as $f) {
list($method, $options) = $this->_extractCallable($f, $subscriber);
$this->attach($method, $eventKey, $options);
Expand Down Expand Up @@ -198,7 +198,7 @@ protected function _detachSubscriber(CakeEventListener $subscriber, $eventKey =
$events = $subscriber->implementedEvents();
if (!empty($eventKey) && empty($events[$eventKey])) {
return;
} else if (!empty($eventKey)) {
} elseif (!empty($eventKey)) {
$events = array($eventKey => $events[$eventKey]);
}
foreach ($events as $key => $function) {
Expand Down
16 changes: 8 additions & 8 deletions lib/Cake/I18n/L10n.php
Expand Up @@ -355,9 +355,9 @@ protected function _setLanguage($language = null) {
$langKey = null;
if ($language !== null && isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
$langKey = $this->_l10nMap[$language];
} else if ($language !== null && isset($this->_l10nCatalog[$language])) {
} elseif ($language !== null && isset($this->_l10nCatalog[$language])) {
$langKey = $language;
} else if (defined('DEFAULT_LANGUAGE')) {
} elseif (defined('DEFAULT_LANGUAGE')) {
$langKey = $language = DEFAULT_LANGUAGE;
}

Expand All @@ -379,7 +379,7 @@ protected function _setLanguage($language = null) {
if ($this->default) {
if (isset($this->_l10nMap[$this->default]) && isset($this->_l10nCatalog[$this->_l10nMap[$this->default]])) {
$this->languagePath[] = $this->_l10nCatalog[$this->_l10nMap[$this->default]]['localeFallback'];
} else if (isset($this->_l10nCatalog[$this->default])) {
} elseif (isset($this->_l10nCatalog[$this->default])) {
$this->languagePath[] = $this->_l10nCatalog[$this->default]['localeFallback'];
}
}
Expand All @@ -405,7 +405,7 @@ protected function _autoLanguage() {
if (isset($this->_l10nCatalog[$langKey])) {
$this->_setLanguage($langKey);
return true;
} else if (strpos($langKey, '-') !== false) {
} elseif (strpos($langKey, '-') !== false) {
$langKey = substr($langKey, 0, 2);
if (isset($this->_l10nCatalog[$langKey])) {
$this->_setLanguage($langKey);
Expand All @@ -432,10 +432,10 @@ public function map($mixed = null) {
}
}
return $result;
} else if (is_string($mixed)) {
} elseif (is_string($mixed)) {
if (strlen($mixed) === 2 && in_array($mixed, $this->_l10nMap)) {
return array_search($mixed, $this->_l10nMap);
} else if (isset($this->_l10nMap[$mixed])) {
} elseif (isset($this->_l10nMap[$mixed])) {
return $this->_l10nMap[$mixed];
}
return false;
Expand All @@ -459,10 +459,10 @@ public function catalog($language = null) {
}
}
return $result;
} else if (is_string($language)) {
} elseif (is_string($language)) {
if (isset($this->_l10nCatalog[$language])) {
return $this->_l10nCatalog[$language];
} else if (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
} elseif (isset($this->_l10nMap[$language]) && isset($this->_l10nCatalog[$this->_l10nMap[$language]])) {
return $this->_l10nCatalog[$this->_l10nMap[$language]];
}
return false;
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Behavior/ContainableBehavior.php
Expand Up @@ -156,7 +156,7 @@ public function beforeFind($Model, $query) {
}
if (!$reset && empty($instance->__backOriginalAssociation)) {
$instance->__backOriginalAssociation = $backupBindings;
} else if ($reset) {
} elseif ($reset) {
$instance->__backAssociation[$type] = $backupBindings[$type];
}
$instance->{$type}[$assoc] = array_merge($instance->{$type}[$assoc], $model['keep'][$assoc]);
Expand Down Expand Up @@ -198,7 +198,7 @@ public function beforeFind($Model, $query) {
foreach ($mandatory[$Model->alias] as $field) {
if ($field == '--primaryKey--') {
$field = $Model->primaryKey;
} else if (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) {
} elseif (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) {
list($modelName, $field) = explode('.', $field);
if ($Model->useDbConfig == $Model->{$modelName}->useDbConfig) {
$field = $modelName . '.' . (
Expand Down Expand Up @@ -372,7 +372,7 @@ public function fieldDependencies($Model, $map, $fields = array()) {
foreach ($bindings as $dependency) {
if ($type == 'hasAndBelongsToMany') {
$fields[$parent][] = '--primaryKey--';
} else if ($type == 'belongsTo') {
} elseif ($type == 'belongsTo') {
$fields[$parent][] = $dependency . '.--primaryKey--';
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Behavior/TranslateBehavior.php
Expand Up @@ -143,7 +143,7 @@ public function beforeFind($model, $query) {
$addFields = array();
if (empty($query['fields'])) {
$addFields = $fields;
} else if (is_array($query['fields'])) {
} elseif (is_array($query['fields'])) {
foreach ($fields as $key => $value) {
$field = (is_numeric($key)) ? $value : $key;

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/CakeSchema.php
Expand Up @@ -575,7 +575,7 @@ protected function _values($values) {
foreach ($values as $key => $val) {
if (is_array($val)) {
$vals[] = "'{$key}' => array('" . implode("', '", $val) . "')";
} else if (!is_numeric($key)) {
} elseif (!is_numeric($key)) {
$val = var_export($val, true);
$vals[] = "'{$key}' => {$val}";
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Postgres.php
Expand Up @@ -206,7 +206,7 @@ public function describe($model) {
if ($c->type == 'character varying') {
$length = null;
$type = 'text';
} else if ($c->type == 'uuid') {
} elseif ($c->type == 'uuid') {
$length = 36;
} else {
$length = intval($c->oct_length);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Datasource/Database/Sqlserver.php
Expand Up @@ -689,7 +689,7 @@ public function buildIndex($indexes, $table = null) {
foreach ($indexes as $name => $value) {
if ($name == 'PRIMARY') {
$join[] = 'PRIMARY KEY (' . $this->name($value['column']) . ')';
} else if (isset($value['unique']) && $value['unique']) {
} elseif (isset($value['unique']) && $value['unique']) {
$out = "ALTER TABLE {$table} ADD CONSTRAINT {$name} UNIQUE";

if (is_array($value['column'])) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Model/Datasource/DboSource.php
Expand Up @@ -577,9 +577,9 @@ public function query() {
} else {
if (isset($args[1]) && $args[1] === true) {
return $this->fetchAll($args[0], true);
} else if (isset($args[1]) && !is_array($args[1]) ) {
} elseif (isset($args[1]) && !is_array($args[1]) ) {
return $this->fetchAll($args[0], false);
} else if (isset($args[1]) && is_array($args[1])) {
} elseif (isset($args[1]) && is_array($args[1])) {
if (isset($args[2])) {
$cache = $args[2];
} else {
Expand Down Expand Up @@ -1733,7 +1733,7 @@ public function renderStatement($type, $data) {
if (trim($indexes) !== '') {
$columns .= ',';
}
return "CREATE TABLE {$table} (\n{$columns}{$indexes}){$tableParameters};";
return "CREATE TABLE {$table} (\n{$columns}{$indexes}) {$tableParameters};";
case 'alter':
return;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Model/Model.php
Expand Up @@ -793,7 +793,7 @@ public function __isset($name) {
$className = empty($this->__backAssociation[$type][$name]['className']) ?
$name : $this->__backAssociation[$type][$name]['className'];
break;
} else if ($type == 'hasAndBelongsToMany') {
} elseif ($type == 'hasAndBelongsToMany') {
foreach ($this->{$type} as $k => $relation) {
if (empty($relation['with'])) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/CakeResponse.php
Expand Up @@ -972,7 +972,7 @@ public function etag($tag = null, $weak = false) {
protected function _getUTCDate($time = null) {
if ($time instanceof DateTime) {
$result = clone $time;
} else if (is_integer($time)) {
} elseif (is_integer($time)) {
$result = new DateTime(date('Y-m-d H:i:s', $time));
} else {
$result = new DateTime($time);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Network/Http/HttpSocket.php
Expand Up @@ -403,7 +403,7 @@ public function request($request = array()) {
$this->config['request']['cookies'][$Host] = array_merge($this->config['request']['cookies'][$Host], $this->response->cookies);
}

if($this->request['redirect'] && $this->response->isRedirect()) {
if ($this->request['redirect'] && $this->response->isRedirect()) {
$request['uri'] = $this->response->getHeader('Location');
$request['redirect'] = is_int($this->request['redirect']) ? $this->request['redirect'] - 1 : $this->request['redirect'];
$this->response = $this->request($request);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Console/Command/ApiShellTest.php
Expand Up @@ -50,7 +50,7 @@ public function setUp() {
*
* @return void
*/
public function testMethodNameDetection () {
public function testMethodNameDetection() {
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('q'));
$this->Shell->expects($this->at(0))->method('out')->with('Controller');

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Controller/Component/Acl/DbAclTest.php
Expand Up @@ -482,7 +482,7 @@ public function testRevoke() {
* @param bool $treesToo
* @return void
*/
protected function __debug ($printTreesToo = false) {
protected function __debug($printTreesToo = false) {
$this->Acl->Aro->displayField = 'alias';
$this->Acl->Aco->displayField = 'alias';
$aros = $this->Acl->Aro->find('list', array('order' => 'lft'));
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Core/AppTest.php
Expand Up @@ -599,7 +599,7 @@ public function testImportingHelpersFromAlternatePaths() {
*
* @return void
*/
public function testFileLoading () {
public function testFileLoading() {
$file = App::import('File', 'RealFile', false, array(), CAKE . 'Config' . DS . 'config.php');
$this->assertTrue($file);

Expand Down Expand Up @@ -629,7 +629,7 @@ public function testFileLoadingWithArray() {
*
* @return void
*/
public function testFileLoadingReturnValue () {
public function testFileLoadingReturnValue() {
$file = App::import('File', 'Name', false, array(), CAKE . 'Config' . DS . 'config.php', true);
$this->assertTrue(!empty($file));

Expand All @@ -648,7 +648,7 @@ public function testFileLoadingReturnValue () {
*
* @return void
*/
public function testLoadingWithSearch () {
public function testLoadingWithSearch() {
$file = App::import('File', 'NewName', false, array(CAKE . 'Config' . DS), 'config.php');
$this->assertTrue($file);

Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Test/Case/I18n/I18nTest.php
Expand Up @@ -2314,7 +2314,7 @@ public function testMoRulesFourteen() {
*
* @return void
*/
public function testSetLanguageWithSession () {
public function testSetLanguageWithSession() {
$_SESSION['Config']['language'] = 'po';
$singular = $this->__singular();
$this->assertEquals('Po (translated)', $singular);
Expand Down Expand Up @@ -2354,7 +2354,7 @@ public function testSetLanguageWithSession () {
*
* @return void
*/
public function testNoCoreTranslation () {
public function testNoCoreTranslation() {
Configure::write('Config.language', 'po');
$singular = $this->__singular();
$this->assertEquals('Po (translated)', $singular);
Expand Down Expand Up @@ -2439,7 +2439,7 @@ public function testPluginTranslation() {
*
* @return void
*/
public function testPoMultipleLineTranslation () {
public function testPoMultipleLineTranslation() {
Configure::write('Config.language', 'po');

$string = "This is a multiline translation\n";
Expand Down Expand Up @@ -2512,7 +2512,7 @@ public function testPoMultipleLineTranslation () {
*
* @return void
*/
public function testPoNoTranslationNeeded () {
public function testPoNoTranslationNeeded() {
Configure::write('Config.language', 'po');
$result = __('No Translation needed');
$this->assertEquals('No Translation needed', $result);
Expand All @@ -2523,7 +2523,7 @@ public function testPoNoTranslationNeeded () {
*
* @return void
*/
public function testPoQuotedString () {
public function testPoQuotedString() {
Configure::write('Config.language', 'po');
$expected = 'this is a "quoted string" (translated)';
$this->assertEquals($expected, __('this is a "quoted string"'));
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Model/models.php
Expand Up @@ -183,7 +183,7 @@ class User extends CakeTestModel {
*
* @return bool
*/
public function beforeFind ($queryData) {
public function beforeFind($queryData) {
if (!empty($queryData['lazyLoad'])) {
if (!isset($this->Article, $this->Comment, $this->ArticleFeatured)) {
throw new Exception('Unavailable associations');
Expand Down Expand Up @@ -257,7 +257,7 @@ public function beforeSave($options = array()) {
* @param mixed $title
* @return void
*/
static function titleDuplicate ($title) {
static function titleDuplicate($title) {
if ($title === 'My Article Title') {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Routing/DispatcherTest.php
Expand Up @@ -20,7 +20,7 @@

if (!class_exists('AppController', false)) {
require_once CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS . 'AppController.php';
} elseif (!defined('APP_CONTROLLER_EXISTS')){
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
define('APP_CONTROLLER_EXISTS', true);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/View/Helper/CacheHelperTest.php
Expand Up @@ -228,7 +228,7 @@ public function testMultipleNoCacheTagsInViewfile() {
*
* @return void
*/
public function testComplexNoCache () {
public function testComplexNoCache() {
$this->Controller->cache_parsing();
$this->Controller->request->addParams(array(
'controller' => 'cache_test',
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/test_app/View/Emails/html/default.ctp
Expand Up @@ -19,7 +19,7 @@
<?php
$content = explode("\n", $content);

foreach($content as $line):
foreach ($content as $line):
echo '<p> ' . $line . '</p>';
endforeach;
?>
2 changes: 1 addition & 1 deletion lib/Cake/TestSuite/CakeTestLoader.php
Expand Up @@ -61,7 +61,7 @@ protected static function _basePath($params) {
$result = null;
if (!empty($params['core'])) {
$result = CORE_TEST_CASES;
} else if (!empty($params['plugin'])) {
} elseif (!empty($params['plugin'])) {
if (!CakePlugin::loaded($params['plugin'])) {
try {
CakePlugin::load($params['plugin']);
Expand Down

0 comments on commit e94d307

Please sign in to comment.