More coding standard corrections.

This commit is contained in:
euromark 2014-04-29 14:19:33 +02:00
parent 1d1a2f859c
commit 7a287a6942
40 changed files with 61 additions and 60 deletions

View file

@ -304,7 +304,7 @@ class ConsoleShell extends AppShell {
$validCurrentAssociation = false;
foreach ($currentAssociations as $model => $currentAssociation) {
if ($model == $modelB && $association == $currentAssociation) {
if ($model === $modelB && $association === $currentAssociation) {
$validCurrentAssociation = true;
}
}

View file

@ -92,7 +92,7 @@ class ServerShell extends AppShell {
}
// 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)) {

View file

@ -296,7 +296,7 @@ class DbConfigTask extends AppShell {
foreach ($oldConfigs as $key => $oldConfig) {
foreach ($configs as $config) {
if ($oldConfig['name'] == $config['name']) {
if ($oldConfig['name'] === $config['name']) {
unset($oldConfigs[$key]);
}
}

View file

@ -411,7 +411,7 @@ class ExtractTask extends AppShell {
$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);

View file

@ -611,13 +611,13 @@ class ModelTask extends BakeTask {
}
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,

View file

@ -302,7 +302,7 @@ class TestTask extends BakeTask {
$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;

View file

@ -151,7 +151,7 @@ class ViewTask extends BakeTask {
unset($methods[$i]);
}
}
if ($method[0] === '_' || $method == strtolower($this->controllerName . 'Controller')) {
if ($method[0] === '_' || $method === strtolower($this->controllerName . 'Controller')) {
unset($methods[$i]);
}
}

View file

@ -581,7 +581,7 @@ class UpgradeShell extends AppShell {
$new = 'View' . DS . Inflector::camelize($old);
$old = 'View' . DS . $old;
if ($new == $old) {
if ($new === $old) {
continue;
}

View file

@ -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');
}

View file

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

View file

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

View file

@ -462,7 +462,7 @@ class PhpAro {
$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 @@ class PhpAro {
$aroModel = Inflector::camelize($aroModel);
if ($aroModel == $model || $aroModel == $aroGroup) {
if ($aroModel === $model || $aroModel === $aroGroup) {
$mapped = $aroGroup . '/' . $aroValue;
}
}

View file

@ -722,7 +722,7 @@ class AuthComponent extends Component {
$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) {

View file

@ -392,7 +392,7 @@ class PaginatorComponent extends Component {
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;

View file

@ -525,7 +525,7 @@ class RequestHandlerComponent extends Component {
return $this->mapType($contentType);
}
if (is_string($type)) {
return ($type == $this->mapType($contentType));
return ($type === $this->mapType($contentType));
}
}

View file

@ -230,7 +230,7 @@ class SecurityComponent extends Component {
$controller->request->params['requested'] != 1
);
if ($this->_action == $this->blackHoleCallback) {
if ($this->_action === $this->blackHoleCallback) {
return $this->blackHole($controller, 'auth');
}
@ -362,7 +362,7 @@ class SecurityComponent extends Component {
$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 @@ class SecurityComponent extends Component {
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 @@ class SecurityComponent extends Component {
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;

View file

@ -668,7 +668,7 @@ class App {
$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'];

View file

@ -165,7 +165,7 @@ class FileLog extends BaseLog {
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';

View file

@ -188,7 +188,7 @@ class ContainableBehavior extends ModelBehavior {
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 @@ class ContainableBehavior extends ModelBehavior {
$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
);

View file

@ -121,7 +121,7 @@ class TranslateBehavior extends ModelBehavior {
$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',

View file

@ -228,7 +228,8 @@ class TreeBehavior extends ModelBehavior {
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 @@ class TreeBehavior extends ModelBehavior {
}
$parentNode = $parentNode[0];
if (($Model->id == $parentId)) {
if (($Model->id === $parentId)) {
return false;
} elseif (($node[$left] < $parentNode[$left]) && ($parentNode[$right] < $node[$right])) {
return false;

View file

@ -190,7 +190,7 @@ class BehaviorCollection extends ObjectCollection implements CakeEventListener {
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]);
}
}

View file

@ -230,7 +230,7 @@ class CakeSchema extends Object {
}
if (isset($this->plugin)) {
if ($model == $this->plugin . 'AppModel') {
if ($model === $this->plugin . 'AppModel') {
continue;
}
$importModel = $model;
@ -608,7 +608,7 @@ class CakeSchema extends Object {
$columns = array();
foreach ($fields as $name => $value) {
if ($Obj->primaryKey == $name) {
if ($Obj->primaryKey === $name) {
$value['key'] = 'primary';
}
if (!isset($db->columns[$value['type']])) {

View file

@ -387,7 +387,7 @@ class Mysql extends DboSource {
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 @@ class Mysql extends DboSource {
$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'])) {

View file

@ -238,7 +238,7 @@ class Postgres extends DboSource {
'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 @@ class Postgres extends DboSource {
$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 @@ class Postgres extends DboSource {
$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']);

View file

@ -681,7 +681,7 @@ class Sqlserver extends DboSource {
} 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);

View file

@ -991,7 +991,7 @@ class DboSource extends DataSource {
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 @@ class DboSource extends DataSource {
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 @@ class DboSource extends DataSource {
$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 @@ class DboSource extends DataSource {
$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);

View file

@ -1486,7 +1486,7 @@ class Model extends Object implements CakeEventListener {
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 @@ class Model extends Object implements CakeEventListener {
}
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 @@ class Model extends Object implements CakeEventListener {
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'])) {

View file

@ -848,7 +848,7 @@ class CakeRequest implements ArrayAccess {
*/
public function data($name) {
$args = func_get_args();
if (count($args) == 2) {
if (count($args) === 2) {
$this->data = Hash::insert($this->data, $name, $args[1]);
return $this;
}

View file

@ -1147,7 +1147,7 @@ class CakeResponse {
$etagMatches = in_array('*', $etags) || in_array($responseTag, $etags);
}
if ($modifiedSince) {
$timeMatches = strtotime($this->modified()) == strtotime($modifiedSince);
$timeMatches = strtotime($this->modified()) === strtotime($modifiedSince);
}
$checks = compact('etagMatches', 'timeMatches');
if (empty($checks)) {

View file

@ -142,7 +142,7 @@ class AssetDispatcher extends DispatcherFilter {
protected function _deliverAsset(CakeResponse $response, $assetFile, $ext) {
ob_start();
$compressionEnabled = Configure::read('Asset.compress') && $response->compress();
if ($response->type($ext) == $ext) {
if ($response->type($ext) === $ext) {
$contentType = 'application/octet-stream';
$agent = env('HTTP_USER_AGENT');
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {

View file

@ -859,7 +859,7 @@ EXPECTED;
* @return void
*/
public function testPr() {
$this->skipIf(php_sapi_name() == 'cli', 'Skipping web test in cli mode');
$this->skipIf(php_sapi_name() === 'cli', 'Skipping web test in cli mode');
ob_start();
pr('this is a test');
$result = ob_get_clean();

View file

@ -664,7 +664,7 @@ class CakeSessionTest extends CakeTestCase {
$this->assertEquals($expected, TestCakeSession::id());
TestCakeSession::renew();
$this->assertFalse($expected == TestCakeSession::id());
$this->assertFalse($expected === TestCakeSession::id());
$expected = session_id();
$this->assertEquals($expected, TestCakeSession::id());

View file

@ -1136,11 +1136,11 @@ class MysqlTest extends CakeTestCase {
$linkModel = $this->Model->Category2->{$assoc};
$external = isset($assocData['external']);
if ($this->Model->Category2->alias == $linkModel->alias && $type !== 'hasAndBelongsToMany' && $type !== 'hasMany') {
if ($this->Model->Category2->alias === $linkModel->alias && $type !== 'hasAndBelongsToMany' && $type !== 'hasMany') {
$result = $this->Dbo->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null);
$this->assertFalse(empty($result));
} else {
if ($this->Model->Category2->useDbConfig == $linkModel->useDbConfig) {
if ($this->Model->Category2->useDbConfig === $linkModel->useDbConfig) {
$result = $this->Dbo->generateAssociationQuery($this->Model->Category2, $linkModel, $type, $assoc, $assocData, $queryData, $external, $null);
$this->assertFalse(empty($result));
}

View file

@ -127,7 +127,7 @@ class HtmlCoverageReportTest extends CakeTestCase {
if (in_array($i + 1, array(5, 9, 2))) {
$class = 'uncovered';
}
if ($i + 1 == 2) {
if ($i + 1 === 2) {
$class .= ' dead';
}
$this->assertTrue(strpos($class, $result) !== 0, 'Class name is wrong ' . $i);
@ -175,7 +175,7 @@ class HtmlCoverageReportTest extends CakeTestCase {
if (in_array($i + 1, array(5, 9, 2))) {
$class = 'uncovered';
}
if ($i + 1 == 2) {
if ($i + 1 === 2) {
$class .= ' dead';
}
$this->assertTrue(strpos($class, $result) !== 0, 'Class name is wrong ' . $i);

View file

@ -493,8 +493,8 @@ TEXT;
Debugger::dump($var);
$result = ob_get_clean();
$open = php_sapi_name() == 'cli' ? "\n" : '<pre>';
$close = php_sapi_name() == 'cli' ? "\n" : '</pre>';
$open = php_sapi_name() === 'cli' ? "\n" : '<pre>';
$close = php_sapi_name() === 'cli' ? "\n" : '</pre>';
$expected = <<<TEXT
{$open}array(
'People' => array(

View file

@ -472,7 +472,7 @@ class CakeTime {
public static function isToday($dateString, $timezone = null) {
$timestamp = self::fromString($dateString, $timezone);
$now = self::fromString('now', $timezone);
return date('Y-m-d', $timestamp) == date('Y-m-d', $now);
return date('Y-m-d', $timestamp) === date('Y-m-d', $now);
}
/**

View file

@ -681,7 +681,7 @@ class Folder {
}
}
if (is_dir($from) && file_exists($to) && $options['scheme'] == Folder::OVERWRITE) {
if (is_dir($from) && file_exists($to) && $options['scheme'] === Folder::OVERWRITE) {
$this->delete($to);
}
@ -698,7 +698,7 @@ class Folder {
} else {
$this->_errors[] = __d('cake_dev', '%s not created', $to);
}
} elseif (is_dir($from) && $options['scheme'] == Folder::MERGE) {
} elseif (is_dir($from) && $options['scheme'] === Folder::MERGE) {
$options = array_merge($options, array('to' => $to, 'from' => $from));
$this->copy($options);
}

View file

@ -1179,7 +1179,7 @@ class FormHelper extends AppHelper {
} elseif (isset($map[$type])) {
$options['type'] = $map[$type];
}
if ($fieldKey == $primaryKey) {
if ($fieldKey === $primaryKey) {
$options['type'] = 'hidden';
}
if (

View file

@ -453,7 +453,7 @@ class HtmlHelper extends AppHelper {
}
}
if ($options['rel'] == 'import') {
if ($options['rel'] === 'import') {
$out = sprintf(
$this->_tags['style'],
$this->_parseAttributes($options, array('rel', 'block'), '', ' '),