Skip to content
Permalink
Browse files

More coding standard corrections.

  • Loading branch information...
dereuromark committed Apr 29, 2014
1 parent 1d1a2f8 commit 7a287a694263f65fd9719695980d4628f484c6f2
Showing with 61 additions and 60 deletions.
  1. +1 −1 lib/Cake/Console/Command/ConsoleShell.php
  2. +1 −1 lib/Cake/Console/Command/ServerShell.php
  3. +1 −1 lib/Cake/Console/Command/Task/DbConfigTask.php
  4. +1 −1 lib/Cake/Console/Command/Task/ExtractTask.php
  5. +2 −2 lib/Cake/Console/Command/Task/ModelTask.php
  6. +1 −1 lib/Cake/Console/Command/Task/TestTask.php
  7. +1 −1 lib/Cake/Console/Command/Task/ViewTask.php
  8. +1 −1 lib/Cake/Console/Command/UpgradeShell.php
  9. +1 −1 lib/Cake/Console/ConsoleInput.php
  10. +1 −1 lib/Cake/Console/Templates/default/views/form.ctp
  11. +1 −1 lib/Cake/Console/Templates/skel/View/Layouts/flash.ctp
  12. +2 −2 lib/Cake/Controller/Component/Acl/PhpAcl.php
  13. +1 −1 lib/Cake/Controller/Component/AuthComponent.php
  14. +1 −1 lib/Cake/Controller/Component/PaginatorComponent.php
  15. +1 −1 lib/Cake/Controller/Component/RequestHandlerComponent.php
  16. +4 −4 lib/Cake/Controller/Component/SecurityComponent.php
  17. +1 −1 lib/Cake/Core/App.php
  18. +1 −1 lib/Cake/Log/Engine/FileLog.php
  19. +2 −2 lib/Cake/Model/Behavior/ContainableBehavior.php
  20. +1 −1 lib/Cake/Model/Behavior/TranslateBehavior.php
  21. +3 −2 lib/Cake/Model/Behavior/TreeBehavior.php
  22. +1 −1 lib/Cake/Model/BehaviorCollection.php
  23. +2 −2 lib/Cake/Model/CakeSchema.php
  24. +2 −2 lib/Cake/Model/Datasource/Database/Mysql.php
  25. +3 −3 lib/Cake/Model/Datasource/Database/Postgres.php
  26. +1 −1 lib/Cake/Model/Datasource/Database/Sqlserver.php
  27. +4 −4 lib/Cake/Model/Datasource/DboSource.php
  28. +3 −3 lib/Cake/Model/Model.php
  29. +1 −1 lib/Cake/Network/CakeRequest.php
  30. +1 −1 lib/Cake/Network/CakeResponse.php
  31. +1 −1 lib/Cake/Routing/Filter/AssetDispatcher.php
  32. +1 −1 lib/Cake/Test/Case/BasicsTest.php
  33. +1 −1 lib/Cake/Test/Case/Model/Datasource/CakeSessionTest.php
  34. +2 −2 lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
  35. +2 −2 lib/Cake/Test/Case/TestSuite/HtmlCoverageReportTest.php
  36. +2 −2 lib/Cake/Test/Case/Utility/DebuggerTest.php
  37. +1 −1 lib/Cake/Utility/CakeTime.php
  38. +2 −2 lib/Cake/Utility/Folder.php
  39. +1 −1 lib/Cake/View/Helper/FormHelper.php
  40. +1 −1 lib/Cake/View/Helper/HtmlHelper.php
@@ -304,7 +304,7 @@ protected function _unbind($command) {
$validCurrentAssociation = false;
foreach ($currentAssociations as $model => $currentAssociation) {
if ($model == $modelB && $association == $currentAssociation) {
if ($model === $modelB && $association === $currentAssociation) {
$validCurrentAssociation = true;
}
}
@@ -92,7 +92,7 @@ public function startup() {
}
// for windows
if (substr($this->_documentRoot, -1, 1) == DIRECTORY_SEPARATOR) {
if (substr($this->_documentRoot, -1, 1) === DIRECTORY_SEPARATOR) {
$this->_documentRoot = substr($this->_documentRoot, 0, strlen($this->_documentRoot) - 1);
}
if (preg_match("/^([a-z]:)[\\\]+(.+)$/i", $this->_documentRoot, $m)) {
@@ -296,7 +296,7 @@ public function bake($configs) {
foreach ($oldConfigs as $key => $oldConfig) {
foreach ($configs as $config) {
if ($oldConfig['name'] == $config['name']) {
if ($oldConfig['name'] === $config['name']) {
unset($oldConfigs[$key]);
}
}
@@ -411,7 +411,7 @@ protected function _parse($functionName, $map) {
$mapCount = count($map);
$strings = $this->_getStrings($position, $mapCount);
if ($mapCount == count($strings)) {
if ($mapCount === count($strings)) {
extract(array_combine($map, $strings));
$category = isset($category) ? $category : 6;
$category = intval($category);
@@ -611,13 +611,13 @@ public function findHasOneAndMany(Model $model, $associations) {
}
foreach ($tempFieldNames as $fieldName) {
$assoc = false;
if ($fieldName != $model->primaryKey && $fieldName == $foreignKey) {
if ($fieldName !== $model->primaryKey && $fieldName === $foreignKey) {
$assoc = array(
'alias' => $tempOtherModel->name,
'className' => $tempOtherModel->name,
'foreignKey' => $fieldName
);
} elseif ($otherTable == $model->table && $fieldName === 'parent_id') {
} elseif ($otherTable === $model->table && $fieldName === 'parent_id') {
$assoc = array(
'alias' => 'Child' . $model->name,
'className' => $model->name,
@@ -302,7 +302,7 @@ public function getRealClassName($type, $class) {
$position = strpos($class, $type);
if ($position !== false && strlen($class) - $position == strlen($type)) {
if ($position !== false && (strlen($class) - $position) === strlen($type)) {
return $class;
}
return $class . $type;
@@ -151,7 +151,7 @@ protected function _methodsToBake() {
unset($methods[$i]);
}
}
if ($method[0] === '_' || $method == strtolower($this->controllerName . 'Controller')) {
if ($method[0] === '_' || $method === strtolower($this->controllerName . 'Controller')) {
unset($methods[$i]);
}
}
@@ -581,7 +581,7 @@ protected function _moveViewFiles() {
$new = 'View' . DS . Inflector::camelize($old);
$old = 'View' . DS . $old;
if ($new == $old) {
if ($new === $old) {
continue;
}
@@ -47,7 +47,7 @@ class ConsoleInput {
* @param string $handle The location of the stream to use as input.
*/
public function __construct($handle = 'php://stdin') {
$this->_canReadline = extension_loaded('readline') && $handle == 'php://stdin' ? true : false;
$this->_canReadline = extension_loaded('readline') && $handle === 'php://stdin' ? true : false;
$this->_input = fopen($handle, 'r');
}
@@ -23,7 +23,7 @@
<?php
echo "\t<?php\n";
foreach ($fields as $field) {
if (strpos($action, 'add') !== false && $field == $primaryKey) {
if (strpos($action, 'add') !== false && $field === $primaryKey) {
continue;
} elseif (!in_array($field, array('created', 'modified', 'updated'))) {
echo "\t\techo \$this->Form->input('{$field}');\n";
@@ -13,7 +13,7 @@
<?php echo $this->Html->charset(); ?>
<title><?php echo $page_title; ?></title>

<?php if (Configure::read('debug') == 0): ?>
<?php if (!Configure::read('debug')): ?>
<meta http-equiv="Refresh" content="<?php echo $pause; ?>;url=<?php echo $url; ?>"/>
<?php endif ?>
<style><!--
@@ -462,7 +462,7 @@ public function resolve($aro) {
$mapped = '';
if (is_array($aro)) {
if (isset($aro['model']) && isset($aro['foreign_key']) && $aro['model'] == $aroGroup) {
if (isset($aro['model']) && isset($aro['foreign_key']) && $aro['model'] === $aroGroup) {
$mapped = $aroGroup . '/' . $aro['foreign_key'];
} elseif (isset($aro[$model][$field])) {
$mapped = $aroGroup . '/' . $aro[$model][$field];
@@ -479,7 +479,7 @@ public function resolve($aro) {
$aroModel = Inflector::camelize($aroModel);
if ($aroModel == $model || $aroModel == $aroGroup) {
if ($aroModel === $model || $aroModel === $aroGroup) {
$mapped = $aroGroup . '/' . $aroValue;
}
}
@@ -722,7 +722,7 @@ public function redirectUrl($url = null) {
$redir = $this->Session->read('Auth.redirect');
$this->Session->delete('Auth.redirect');
if (Router::normalize($redir) == Router::normalize($this->loginAction)) {
if (Router::normalize($redir) === Router::normalize($this->loginAction)) {
$redir = $this->loginRedirect;
}
} elseif ($this->loginRedirect) {
@@ -392,7 +392,7 @@ public function validateSort(Model $object, array $options, array $whitelist = a
if (strpos($key, '.') !== false) {
list($alias, $field) = explode('.', $key);
}
$correctAlias = ($object->alias == $alias);
$correctAlias = ($object->alias === $alias);
if ($correctAlias && $object->hasField($field)) {
$order[$object->alias . '.' . $field] = $value;
@@ -525,7 +525,7 @@ public function requestedWith($type = null) {
return $this->mapType($contentType);
}
if (is_string($type)) {
return ($type == $this->mapType($contentType));
return ($type === $this->mapType($contentType));
}
}
@@ -230,7 +230,7 @@ public function startup(Controller $controller) {
$controller->request->params['requested'] != 1
);
if ($this->_action == $this->blackHoleCallback) {
if ($this->_action === $this->blackHoleCallback) {
return $this->blackHole($controller, 'auth');
}
@@ -362,7 +362,7 @@ protected function _methodsRequired(Controller $controller) {
$property = 'require' . $method;
if (is_array($this->$property) && !empty($this->$property)) {
$require = $this->$property;
if (in_array($this->_action, $require) || $this->$property == array('*')) {
if (in_array($this->_action, $require) || $this->$property === array('*')) {
if (!$this->request->is($method)) {
if (!$this->blackHole($controller, $method)) {
return null;
@@ -384,7 +384,7 @@ protected function _secureRequired(Controller $controller) {
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
$requireSecure = $this->requireSecure;
if (in_array($this->_action, $requireSecure) || $this->requireSecure == array('*')) {
if (in_array($this->_action, $requireSecure) || $this->requireSecure === array('*')) {
if (!$this->request->is('ssl')) {
if (!$this->blackHole($controller, 'secure')) {
return null;
@@ -405,7 +405,7 @@ protected function _authRequired(Controller $controller) {
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($this->request->data)) {
$requireAuth = $this->requireAuth;
if (in_array($this->request->params['action'], $requireAuth) || $this->requireAuth == array('*')) {
if (in_array($this->request->params['action'], $requireAuth) || $this->requireAuth === array('*')) {
if (!isset($controller->request->data['_Token'])) {
if (!$this->blackHole($controller, 'auth')) {
return null;
@@ -668,7 +668,7 @@ protected static function _loadClass($name, $plugin, $type, $originalType, $pare
$type = 'Console';
} elseif (isset(self::$types[$originalType]['suffix'])) {
$suffix = self::$types[$originalType]['suffix'];
$name .= ($suffix == $name) ? '' : $suffix;
$name .= ($suffix === $name) ? '' : $suffix;
}
if ($parent && isset(self::$types[$originalType]['extends'])) {
$extends = self::$types[$originalType]['extends'];
@@ -165,7 +165,7 @@ protected function _getFilename($type) {
if (!empty($this->_file)) {
$filename = $this->_file;
} elseif ($type == 'error' || $type == 'warning') {
} elseif ($type === 'error' || $type === 'warning') {
$filename = 'error.log';
} elseif (in_array($type, $debugTypes)) {
$filename = 'debug.log';
@@ -188,7 +188,7 @@ public function beforeFind(Model $Model, $query) {
foreach (array('hasOne', 'belongsTo') as $type) {
if (!empty($Model->{$type})) {
foreach ($Model->{$type} as $assoc => $data) {
if ($Model->useDbConfig == $Model->{$assoc}->useDbConfig && !empty($data['fields'])) {
if ($Model->useDbConfig === $Model->{$assoc}->useDbConfig && !empty($data['fields'])) {
foreach ((array)$data['fields'] as $field) {
$query['fields'][] = (strpos($field, '.') === false ? $assoc . '.' : '') . $field;
}
@@ -203,7 +203,7 @@ public function beforeFind(Model $Model, $query) {
$field = $Model->primaryKey;
} elseif (preg_match('/^.+\.\-\-[^-]+\-\-$/', $field)) {
list($modelName, $field) = explode('.', $field);
if ($Model->useDbConfig == $Model->{$modelName}->useDbConfig) {
if ($Model->useDbConfig === $Model->{$modelName}->useDbConfig) {
$field = $modelName . '.' . (
($field === '--primaryKey--') ? $Model->$modelName->primaryKey : $field
);
@@ -121,7 +121,7 @@ public function beforeFind(Model $Model, $query) {
$this->_joinTable = $joinTable;
$this->_runtimeModel = $RuntimeModel;
if (is_string($query['fields']) && "COUNT(*) AS {$db->name('count')}" == $query['fields']) {
if (is_string($query['fields']) && $query['fields'] === "COUNT(*) AS {$db->name('count')}") {
$query['fields'] = "COUNT(DISTINCT({$db->name($Model->escapeField())})) {$db->alias}count";
$query['joins'][] = array(
'type' => 'INNER',
@@ -228,7 +228,8 @@ public function beforeSave(Model $Model, $options = array()) {
if (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
return false;
} elseif ($node[$Model->primaryKey] == $parentNode[$Model->primaryKey]) {
}
if ($node[$Model->primaryKey] === $parentNode[$Model->primaryKey]) {
return false;
}
}
@@ -951,7 +952,7 @@ protected function _setParent(Model $Model, $parentId = null, $created = false)
}
$parentNode = $parentNode[0];
if (($Model->id == $parentId)) {
if (($Model->id === $parentId)) {
return false;
} elseif (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
return false;
@@ -190,7 +190,7 @@ public function unload($name) {
parent::unload($name);
}
foreach ($this->_methods as $m => $callback) {
if (is_array($callback) && $callback[0] == $name) {
if (is_array($callback) && $callback[0] === $name) {
unset($this->_methods[$m]);
}
}
@@ -230,7 +230,7 @@ public function read($options = array()) {
}
if (isset($this->plugin)) {
if ($model == $this->plugin . 'AppModel') {
if ($model === $this->plugin . 'AppModel') {
continue;
}
$importModel = $model;
@@ -608,7 +608,7 @@ protected function _columns(&$Obj) {
$columns = array();
foreach ($fields as $name => $value) {
if ($Obj->primaryKey == $name) {
if ($Obj->primaryKey === $name) {
$value['key'] = 'primary';
}
if (!isset($db->columns[$value['type']])) {
@@ -387,7 +387,7 @@ public function update(Model $model, $fields = array(), $values = null, $conditi
if (!empty($conditions)) {
$alias = $this->name($model->alias);
if ($model->name == $model->alias) {
if ($model->name === $model->alias) {
$joins = implode(' ', $this->_getJoins($model));
}
}
@@ -516,7 +516,7 @@ public function alterSchema($compare, $table = null) {
$colList = array();
foreach ($compare as $curTable => $types) {
$indexes = $tableParameters = $colList = array();
if (!$table || $table == $curTable) {
if (!$table || $table === $curTable) {
$out .= 'ALTER TABLE ' . $this->fullTableName($curTable) . " \n";
foreach ($types as $type => $column) {
if (isset($column['indexes'])) {
@@ -238,7 +238,7 @@ public function describe($model) {
'length' => $length
);
if ($model instanceof Model) {
if ($c->name == $model->primaryKey) {
if ($c->name === $model->primaryKey) {
$fields[$c->name]['key'] = 'primary';
if ($fields[$c->name]['type'] !== 'string') {
$fields[$c->name]['length'] = 11;
@@ -507,7 +507,7 @@ public function alterSchema($compare, $table = null) {
$colList = array();
foreach ($compare as $curTable => $types) {
$indexes = $colList = array();
if (!$table || $table == $curTable) {
if (!$table || $table === $curTable) {
$out .= 'ALTER TABLE ' . $this->fullTableName($curTable) . " \n";
foreach ($types as $type => $column) {
if (isset($column['indexes'])) {
@@ -538,7 +538,7 @@ public function alterSchema($compare, $table = null) {
$default = isset($col['default']) ? $col['default'] : null;
$nullable = isset($col['null']) ? $col['null'] : null;
$boolToInt = $original['type'] == 'boolean' && $col['type'] == 'integer';
$boolToInt = $original['type'] === 'boolean' && $col['type'] === 'integer';
unset($col['default'], $col['null']);
if ($field !== $col['name']) {
$newName = $this->name($col['name']);
@@ -681,7 +681,7 @@ public function buildColumn($column) {
} else {
$result = str_replace('DEFAULT NULL', 'NULL', $result);
}
} elseif (array_keys($column) == array('type', 'name')) {
} elseif (array_keys($column) === array('type', 'name')) {
$result .= ' NULL';
} elseif (strpos($result, "DEFAULT N'")) {
$result = str_replace("DEFAULT N'", "DEFAULT '", $result);
@@ -991,7 +991,7 @@ public function create(Model $model, $fields = null, $values = null) {
for ($i = 0; $i < $count; $i++) {
$valueInsert[] = $this->value($values[$i], $model->getColumnType($fields[$i]));
$fieldInsert[] = $this->name($fields[$i]);
if ($fields[$i] == $model->primaryKey) {
if ($fields[$i] === $model->primaryKey) {
$id = $values[$i];
}
}
@@ -1283,7 +1283,7 @@ public function queryAssociation(Model $model, &$linkModel, $type, $association,
if ($type1 === 'belongsTo' || ($deepModel->alias === $modelAlias && $type === 'belongsTo') || ($deepModel->alias !== $modelAlias)) {
$tmpStack = $stack;
$tmpStack[] = $assoc1;
if ($linkModel->useDbConfig == $deepModel->useDbConfig) {
if ($linkModel->useDbConfig === $deepModel->useDbConfig) {
$db = $this;
} else {
$db = ConnectionManager::getDataSource($deepModel->useDbConfig);
@@ -1973,7 +1973,7 @@ protected function _getJoins(Model $model) {
$joins = array_merge($model->getAssociated('hasOne'), $model->getAssociated('belongsTo'));
foreach ($joins as $assoc) {
if (isset($model->{$assoc}) && $model->useDbConfig == $model->{$assoc}->useDbConfig && $model->{$assoc}->getDataSource()) {
if (isset($model->{$assoc}) && $model->useDbConfig === $model->{$assoc}->useDbConfig && $model->{$assoc}->getDataSource()) {
$assocData = $model->getAssociated($assoc);
$join[] = $this->buildJoinStatement(array(
'table' => $model->{$assoc},
@@ -2969,7 +2969,7 @@ public function createSchema($schema, $tableName = null) {
$out = '';
foreach ($schema->tables as $curTable => $columns) {
if (!$tableName || $tableName == $curTable) {
if (!$tableName || $tableName === $curTable) {
$cols = $indexes = $tableParameters = array();
$primary = null;
$table = $this->fullTableName($curTable);
@@ -1486,7 +1486,7 @@ public function isVirtualField($field) {
if (strpos($field, '.') !== false) {
list($model, $field) = explode('.', $field);
if ($model == $this->alias && isset($this->virtualFields[$field])) {
if ($model === $this->alias && isset($this->virtualFields[$field])) {
return true;
}
}
@@ -1930,7 +1930,7 @@ protected function _saveMulti($joined, $id, $db) {
}
foreach ((array)$data as $row) {
if ((is_string($row) && (strlen($row) == 36 || strlen($row) == 16)) || is_numeric($row)) {
if ((is_string($row) && (strlen($row) === 36 || strlen($row) === 16)) || is_numeric($row)) {
$newJoins[] = $row;
$values = array($id, $row);
@@ -3478,7 +3478,7 @@ public function setDataSource($dataSource = null) {
if (!empty($oldConfig) && isset($db->config['prefix'])) {
$oldDb = ConnectionManager::getDataSource($oldConfig);
if (!isset($this->tablePrefix) || (!isset($oldDb->config['prefix']) || $this->tablePrefix == $oldDb->config['prefix'])) {
if (!isset($this->tablePrefix) || (!isset($oldDb->config['prefix']) || $this->tablePrefix === $oldDb->config['prefix'])) {
$this->tablePrefix = $db->config['prefix'];
}
} elseif (isset($db->config['prefix'])) {
Oops, something went wrong.

0 comments on commit 7a287a6

Please sign in to comment.
You can’t perform that action at this time.