diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index 48ab51440..aef21bfe6 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -507,7 +507,7 @@ class CookieComponent extends Component { $first = substr($string, 0, 1); if ($first === '{' || $first === '[') { $ret = json_decode($string, true); - return ($ret != null) ? $ret : $string; + return ($ret) ? $ret : $string; } $array = array(); foreach (explode(',', $string) as $pair) { diff --git a/lib/Cake/Controller/Component/RequestHandlerComponent.php b/lib/Cake/Controller/Component/RequestHandlerComponent.php index d3147af00..f95411816 100644 --- a/lib/Cake/Controller/Component/RequestHandlerComponent.php +++ b/lib/Cake/Controller/Component/RequestHandlerComponent.php @@ -398,7 +398,7 @@ class RequestHandlerComponent extends Component { * @return string Prototype version of component making Ajax call */ public function getAjaxVersion() { - if (env('HTTP_X_PROTOTYPE_VERSION') != null) { + if (env('HTTP_X_PROTOTYPE_VERSION')) { return env('HTTP_X_PROTOTYPE_VERSION'); } return false; @@ -672,7 +672,7 @@ class RequestHandlerComponent extends Component { $cType = $type; } - if ($cType != null) { + if ($cType) { if (empty($this->request->params['requested'])) { $this->response->type($cType); } diff --git a/lib/Cake/Controller/Controller.php b/lib/Cake/Controller/Controller.php index 4eb68f1b5..15bbc2e69 100644 --- a/lib/Cake/Controller/Controller.php +++ b/lib/Cake/Controller/Controller.php @@ -967,14 +967,15 @@ class Controller extends Object implements CakeEventListener { * @link http://book.cakephp.org/2.0/en/controllers.html#Controller::referer */ public function referer($default = null, $local = false) { - if ($this->request) { - $referer = $this->request->referer($local); - if ($referer == '/' && $default != null) { - return Router::url($default, true); - } - return $referer; + if(!$this->request) { + return '/'; } - return '/'; + + $referer = $this->request->referer($local); + if ($referer == '/' && $default) { + return Router::url($default, true); + } + return $referer; } /** @@ -1062,7 +1063,7 @@ class Controller extends Object implements CakeEventListener { $cond[$key] = $value; } } - if ($bool != null && strtoupper($bool) != 'AND') { + if ($bool && strtoupper($bool) != 'AND') { $cond = array($bool => $cond); } return $cond; diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 6f8050f0f..4c0ff34a3 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -131,7 +131,7 @@ class CakeSession { self::$time = time(); $checkAgent = Configure::read('Session.checkAgent'); - if (($checkAgent === true || $checkAgent === null) && env('HTTP_USER_AGENT') != null) { + if (($checkAgent === true || $checkAgent === null) && env('HTTP_USER_AGENT')) { self::$_userAgent = md5(env('HTTP_USER_AGENT') . Configure::read('Security.salt')); } self::_setPath($base); diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 541bd87aa..02e315e6b 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -175,7 +175,7 @@ class Mysql extends DboSource { */ public function listSources($data = null) { $cache = parent::listSources(); - if ($cache != null) { + if ($cache) { return $cache; } $result = $this->_execute('SHOW TABLES FROM ' . $this->name($this->config['database'])); @@ -280,7 +280,7 @@ class Mysql extends DboSource { public function describe($model) { $key = $this->fullTableName($model, false); $cache = parent::describe($key); - if ($cache != null) { + if ($cache) { return $cache; } $table = $this->fullTableName($model); diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index 9b1fbcf3d..b284f79a6 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -146,7 +146,7 @@ class Postgres extends DboSource { public function listSources($data = null) { $cache = parent::listSources(); - if ($cache != null) { + if ($cache) { return $cache; } @@ -156,17 +156,17 @@ class Postgres extends DboSource { if (!$result) { return array(); - } else { - $tables = array(); - - foreach ($result as $item) { - $tables[] = $item->name; - } - - $result->closeCursor(); - parent::listSources($tables); - return $tables; } + + $tables = array(); + + foreach ($result as $item) { + $tables[] = $item->name; + } + + $result->closeCursor(); + parent::listSources($tables); + return $tables; } /** @@ -671,7 +671,7 @@ class Postgres extends DboSource { if ($col == 'uuid') { return 36; } - if ($limit != null) { + if ($limit) { return intval($limit); } return null; diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 0ca4bc2c3..34e52d256 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -136,7 +136,7 @@ class Sqlite extends DboSource { */ public function listSources($data = null) { $cache = parent::listSources(); - if ($cache != null) { + if ($cache) { return $cache; } @@ -144,14 +144,14 @@ class Sqlite extends DboSource { if (!$result || empty($result)) { return array(); - } else { - $tables = array(); - foreach ($result as $table) { - $tables[] = $table[0]['name']; - } - parent::listSources($tables); - return $tables; } + + $tables = array(); + foreach ($result as $table) { + $tables[] = $table[0]['name']; + } + parent::listSources($tables); + return $tables; } /** @@ -163,7 +163,7 @@ class Sqlite extends DboSource { public function describe($model) { $table = $this->fullTableName($model, false, false); $cache = parent::describe($table); - if ($cache != null) { + if ($cache) { return $cache; } $fields = array(); diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index cb502832b..e2dc00485 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -184,7 +184,7 @@ class Sqlserver extends DboSource { public function describe($model) { $table = $this->fullTableName($model, false); $cache = parent::describe($table); - if ($cache != null) { + if ($cache) { return $cache; } $fields = array(); @@ -619,7 +619,7 @@ class Sqlserver extends DboSource { */ public function insertMulti($table, $fields, $values) { $primaryKey = $this->_getPrimaryKey($table); - $hasPrimaryKey = $primaryKey != null && ( + $hasPrimaryKey = $primaryKey && ( (is_array($fields) && in_array($primaryKey, $fields) || (is_string($fields) && strpos($fields, $this->startQuote . $primaryKey . $this->endQuote) !== false)) ); diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 14dbbfc7b..521080823 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -670,7 +670,7 @@ class DboSource extends DataSource { if ($this->hasResult()) { $first = $this->fetchRow(); - if ($first != null) { + if ($first) { $out[] = $first; } while ($item = $this->fetchResult()) { @@ -1407,10 +1407,9 @@ class DboSource extends DataSource { } } if (!isset($data[$association])) { - if ($merge[0][$association] != null) { + $data[$association] = array(); + if ($merge[0][$association]) { $data[$association] = $merge[0][$association]; - } else { - $data[$association] = array(); } } else { if (is_array($merge[0][$association])) { @@ -2513,7 +2512,7 @@ class DboSource extends DataSource { $data = $this->_parseKey($model, trim($key), $value); } - if ($data != null) { + if ($data) { $out[] = $data; $data = null; } diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index ef987e6ee..462170371 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -1389,7 +1389,7 @@ class Model extends Object implements CakeEventListener { $this->schema(); } - if ($this->_schema != null) { + if ($this->_schema) { return isset($this->_schema[$name]); } return false; @@ -1499,7 +1499,7 @@ class Model extends Object implements CakeEventListener { public function read($fields = null, $id = null) { $this->validationErrors = array(); - if ($id != null) { + if ($id) { $this->id = $id; } @@ -1515,9 +1515,8 @@ class Model extends Object implements CakeEventListener { 'fields' => $fields )); return $this->data; - } else { - return false; } + return false; } /** @@ -3151,7 +3150,7 @@ class Model extends Object implements CakeEventListener { public function setDataSource($dataSource = null) { $oldConfig = $this->useDbConfig; - if ($dataSource != null) { + if ($dataSource) { $this->useDbConfig = $dataSource; } $db = ConnectionManager::getDataSource($this->useDbConfig); diff --git a/lib/Cake/Model/Permission.php b/lib/Cake/Model/Permission.php index e293aa19b..7802703d1 100644 --- a/lib/Cake/Model/Permission.php +++ b/lib/Cake/Model/Permission.php @@ -198,7 +198,7 @@ class Permission extends AppModel { } list($save['aro_id'], $save['aco_id']) = array($perms['aro'], $perms['aco']); - if ($perms['link'] != null && !empty($perms['link'])) { + if ($perms['link'] && !empty($perms['link'])) { $save['id'] = $perms['link'][0][$this->alias]['id']; } else { unset($save['id']); diff --git a/lib/Cake/Network/CakeRequest.php b/lib/Cake/Network/CakeRequest.php index 919e380a3..ab53b4617 100644 --- a/lib/Cake/Network/CakeRequest.php +++ b/lib/Cake/Network/CakeRequest.php @@ -364,17 +364,17 @@ class CakeRequest implements ArrayAccess { * @return string The client IP. */ public function clientIp($safe = true) { - if (!$safe && env('HTTP_X_FORWARDED_FOR') != null) { + if (!$safe && env('HTTP_X_FORWARDED_FOR')) { $ipaddr = preg_replace('/(?:,.*)/', '', env('HTTP_X_FORWARDED_FOR')); } else { - if (env('HTTP_CLIENT_IP') != null) { + if (env('HTTP_CLIENT_IP')) { $ipaddr = env('HTTP_CLIENT_IP'); } else { $ipaddr = env('REMOTE_ADDR'); } } - if (env('HTTP_CLIENTADDRESS') != null) { + if (env('HTTP_CLIENTADDRESS')) { $tmpipaddr = env('HTTP_CLIENTADDRESS'); if (!empty($tmpipaddr)) { diff --git a/lib/Cake/Network/CakeSocket.php b/lib/Cake/Network/CakeSocket.php index aa5ab6dc8..941c0b261 100644 --- a/lib/Cake/Network/CakeSocket.php +++ b/lib/Cake/Network/CakeSocket.php @@ -121,7 +121,7 @@ class CakeSocket { * @throws SocketException */ public function connect() { - if ($this->connection != null) { + if ($this->connection) { $this->disconnect(); } diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 4c6f35528..e43ad97f6 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -1073,7 +1073,7 @@ class Router { * @return string base url with plugin name removed if present */ public static function stripPlugin($base, $plugin = null) { - if ($plugin != null) { + if ($plugin) { $base = preg_replace('/(?:' . $plugin . ')/', '', $base); $base = str_replace('//', '', $base); $pos1 = strrpos($base, '/'); diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 31327e7de..50d195794 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -58,7 +58,7 @@ class ModelWriteTest extends BaseModelTest { $lastInsertId = $TestModel->JoinAsJoinB->getLastInsertID(); $data['id'] = $lastInsertId; $this->assertEquals(array('JoinAsJoinB' => $data), $result); - $this->assertTrue($lastInsertId != null); + $this->assertTrue($lastInsertId); $result = $TestModel->JoinAsJoinB->findById(1); $expected = array( diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index ae19b80f0..1e21c5381 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -1164,7 +1164,7 @@ class CakeEmailTest extends CakeTestCase { $this->CakeEmail->emailFormat('html'); $server = env('SERVER_NAME') ? env('SERVER_NAME') : 'localhost'; - if (env('SERVER_PORT') != null && env('SERVER_PORT') != 80) { + if (env('SERVER_PORT') && env('SERVER_PORT') != 80) { $server .= ':' . env('SERVER_PORT'); } diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index dd1570b6e..e378627fa 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -903,7 +903,7 @@ class CakeTime { */ public static function gmt($dateString = null) { $time = time(); - if ($dateString != null) { + if ($dateString) { $time = self::fromString($dateString); } return gmmktime( diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 6e1ffc6a0..5f1a9f445 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -827,7 +827,7 @@ class Set { } } - if ($groupPath != null) { + if ($groupPath) { $group = Set::extract($data, $groupPath); if (!empty($group)) { $c = count($keys); diff --git a/lib/Cake/View/Helper/HtmlHelper.php b/lib/Cake/View/Helper/HtmlHelper.php index c4da2a8a9..008965d4d 100644 --- a/lib/Cake/View/Helper/HtmlHelper.php +++ b/lib/Cake/View/Helper/HtmlHelper.php @@ -951,13 +951,12 @@ class HtmlHelper extends AppHelper { if (isset($options['escape'])) { $text = h($text); } - if ($class != null && !empty($class)) { + if ($class && !empty($class)) { $options['class'] = $class; } + $tag = 'para'; if ($text === null) { $tag = 'parastart'; - } else { - $tag = 'para'; } return sprintf($this->_tags[$tag], $this->_parseAttributes($options, null, ' ', ''), $text); } diff --git a/lib/Cake/View/Helper/PaginatorHelper.php b/lib/Cake/View/Helper/PaginatorHelper.php index 836877345..373c59679 100644 --- a/lib/Cake/View/Helper/PaginatorHelper.php +++ b/lib/Cake/View/Helper/PaginatorHelper.php @@ -536,7 +536,7 @@ class PaginatorHelper extends AppHelper { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/paginator.html#PaginatorHelper::defaultModel */ public function defaultModel() { - if ($this->_defaultModel != null) { + if ($this->_defaultModel) { return $this->_defaultModel; } if (empty($this->request->params['paging'])) { diff --git a/lib/Cake/View/Helper/RssHelper.php b/lib/Cake/View/Helper/RssHelper.php index 26160f055..0cbd456be 100644 --- a/lib/Cake/View/Helper/RssHelper.php +++ b/lib/Cake/View/Helper/RssHelper.php @@ -167,7 +167,7 @@ class RssHelper extends AppHelper { * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/rss.html#RssHelper::items */ public function items($items, $callback = null) { - if ($callback != null) { + if ($callback) { $items = array_map($callback, $items); }