Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

converting if ($foo != null) to if ($foo)

  • Loading branch information...
commit b1f26b59a39ea753b1557b2acd01248a412b2a95 1 parent f5a8eb6
@dogmatic69 dogmatic69 authored
View
2  lib/Cake/Controller/Component/CookieComponent.php
@@ -507,7 +507,7 @@ protected function _explode($string) {
$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) {
View
4 lib/Cake/Controller/Component/RequestHandlerComponent.php
@@ -398,7 +398,7 @@ public function isDelete() {
* @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 @@ public function respondAs($type, $options = array()) {
$cType = $type;
}
- if ($cType != null) {
+ if ($cType) {
if (empty($this->request->params['requested'])) {
$this->response->type($cType);
}
View
17 lib/Cake/Controller/Controller.php
@@ -967,14 +967,15 @@ public function render($view = null, $layout = null) {
* @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 '/';
+ }
+
+ $referer = $this->request->referer($local);
+ if ($referer == '/' && $default) {
+ return Router::url($default, true);
}
- return '/';
+ return $referer;
}
/**
@@ -1062,7 +1063,7 @@ public function postConditions($data = array(), $op = null, $bool = 'AND', $excl
$cond[$key] = $value;
}
}
- if ($bool != null && strtoupper($bool) != 'AND') {
+ if ($bool && strtoupper($bool) != 'AND') {
$cond = array($bool => $cond);
}
return $cond;
View
2  lib/Cake/Model/Datasource/CakeSession.php
@@ -131,7 +131,7 @@ public static function init($base = null) {
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);
View
4 lib/Cake/Model/Datasource/Database/Mysql.php
@@ -175,7 +175,7 @@ public function enabled() {
*/
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 @@ public function getCharsetName($name) {
public function describe($model) {
$key = $this->fullTableName($model, false);
$cache = parent::describe($key);
- if ($cache != null) {
+ if ($cache) {
return $cache;
}
$table = $this->fullTableName($model);
View
20 lib/Cake/Model/Datasource/Database/Postgres.php
@@ -146,7 +146,7 @@ public function enabled() {
public function listSources($data = null) {
$cache = parent::listSources();
- if ($cache != null) {
+ if ($cache) {
return $cache;
}
@@ -156,17 +156,17 @@ public function listSources($data = null) {
if (!$result) {
return array();
- } else {
- $tables = array();
+ }
- foreach ($result as $item) {
- $tables[] = $item->name;
- }
+ $tables = array();
- $result->closeCursor();
- parent::listSources($tables);
- return $tables;
+ foreach ($result as $item) {
+ $tables[] = $item->name;
}
+
+ $result->closeCursor();
+ parent::listSources($tables);
+ return $tables;
}
/**
@@ -671,7 +671,7 @@ public function length($real) {
if ($col == 'uuid') {
return 36;
}
- if ($limit != null) {
+ if ($limit) {
return intval($limit);
}
return null;
View
18 lib/Cake/Model/Datasource/Database/Sqlite.php
@@ -136,7 +136,7 @@ public function enabled() {
*/
public function listSources($data = null) {
$cache = parent::listSources();
- if ($cache != null) {
+ if ($cache) {
return $cache;
}
@@ -144,14 +144,14 @@ public function listSources($data = null) {
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 @@ public function listSources($data = null) {
public function describe($model) {
$table = $this->fullTableName($model, false, false);
$cache = parent::describe($table);
- if ($cache != null) {
+ if ($cache) {
return $cache;
}
$fields = array();
View
4 lib/Cake/Model/Datasource/Database/Sqlserver.php
@@ -184,7 +184,7 @@ public function listSources($data = null) {
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 @@ public function fetchResult() {
*/
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))
);
View
9 lib/Cake/Model/Datasource/DboSource.php
@@ -670,7 +670,7 @@ public function fetchAll($sql, $params = array(), $options = array()) {
if ($this->hasResult()) {
$first = $this->fetchRow();
- if ($first != null) {
+ if ($first) {
$out[] = $first;
}
while ($item = $this->fetchResult()) {
@@ -1407,10 +1407,9 @@ protected function _mergeAssociation(&$data, &$merge, $association, $type, $self
}
}
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 @@ public function conditionKeysToString($conditions, $quoteValues = true, $model =
$data = $this->_parseKey($model, trim($key), $value);
}
- if ($data != null) {
+ if ($data) {
$out[] = $data;
$data = null;
}
View
9 lib/Cake/Model/Model.php
@@ -1389,7 +1389,7 @@ public function hasField($name, $checkVirtual = false) {
$this->schema();
}
- if ($this->_schema != null) {
+ if ($this->_schema) {
return isset($this->_schema[$name]);
}
return false;
@@ -1499,7 +1499,7 @@ public function create($data = array(), $filterKey = false) {
public function read($fields = null, $id = null) {
$this->validationErrors = array();
- if ($id != null) {
+ if ($id) {
$this->id = $id;
}
@@ -1515,9 +1515,8 @@ public function read($fields = null, $id = null) {
'fields' => $fields
));
return $this->data;
- } else {
- return false;
}
+ return false;
}
/**
@@ -3151,7 +3150,7 @@ public function getAffectedRows() {
public function setDataSource($dataSource = null) {
$oldConfig = $this->useDbConfig;
- if ($dataSource != null) {
+ if ($dataSource) {
$this->useDbConfig = $dataSource;
}
$db = ConnectionManager::getDataSource($this->useDbConfig);
View
2  lib/Cake/Model/Permission.php
@@ -198,7 +198,7 @@ public function allow($aro, $aco, $actions = "*", $value = 1) {
}
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']);
View
6 lib/Cake/Network/CakeRequest.php
@@ -364,17 +364,17 @@ protected function _processFileData($path, $data, $field) {
* @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)) {
View
2  lib/Cake/Network/CakeSocket.php
@@ -121,7 +121,7 @@ public function __construct($config = array()) {
* @throws SocketException
*/
public function connect() {
- if ($this->connection != null) {
+ if ($this->connection) {
$this->disconnect();
}
View
2  lib/Cake/Routing/Router.php
@@ -1073,7 +1073,7 @@ public static function &currentRoute() {
* @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, '/');
View
2  lib/Cake/Test/Case/Model/ModelWriteTest.php
@@ -58,7 +58,7 @@ public function testInsertAnotherHabtmRecordWithSameForeignKey() {
$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(
View
2  lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
@@ -1164,7 +1164,7 @@ public function testSendRenderWithImage() {
$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');
}
View
2  lib/Cake/Utility/CakeTime.php
@@ -903,7 +903,7 @@ public static function isWithinNext($timeInterval, $dateString, $timezone = null
*/
public static function gmt($dateString = null) {
$time = time();
- if ($dateString != null) {
+ if ($dateString) {
$time = self::fromString($dateString);
}
return gmmktime(
View
2  lib/Cake/Utility/Set.php
@@ -827,7 +827,7 @@ public static function combine($data, $path1 = null, $path2 = null, $groupPath =
}
}
- if ($groupPath != null) {
+ if ($groupPath) {
$group = Set::extract($data, $groupPath);
if (!empty($group)) {
$c = count($keys);
View
5 lib/Cake/View/Helper/HtmlHelper.php
@@ -951,13 +951,12 @@ public function para($class, $text, $options = array()) {
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);
}
View
2  lib/Cake/View/Helper/PaginatorHelper.php
@@ -536,7 +536,7 @@ protected function _hasPage($model, $page) {
* @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'])) {
View
2  lib/Cake/View/Helper/RssHelper.php
@@ -167,7 +167,7 @@ public function channel($attrib = array(), $elements = array(), $content = null)
* @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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.