Permalink
Browse files

unify null checks - avoid method call in favor of strict check

  • Loading branch information...
dereuromark committed Aug 16, 2013
1 parent 8428928 commit 6cf147e8c8eaeca884c40002f0ea68cab9f2c432
Showing with 62 additions and 62 deletions.
  1. +1 −1 lib/Cake/Console/Command/Task/ControllerTask.php
  2. +1 −1 lib/Cake/Console/Command/Task/FixtureTask.php
  3. +1 −1 lib/Cake/Controller/Component/AuthComponent.php
  4. +3 −3 lib/Cake/Controller/Component/CookieComponent.php
  5. +1 −1 lib/Cake/Core/CakePlugin.php
  6. +1 −1 lib/Cake/I18n/I18n.php
  7. +3 −3 lib/Cake/Model/Behavior/TranslateBehavior.php
  8. +5 −5 lib/Cake/Model/Behavior/TreeBehavior.php
  9. +1 −1 lib/Cake/Model/Datasource/CakeSession.php
  10. +1 −1 lib/Cake/Model/Datasource/Database/Mysql.php
  11. +2 −2 lib/Cake/Model/Datasource/Database/Postgres.php
  12. +1 −1 lib/Cake/Model/Datasource/Database/Sqlite.php
  13. +1 −1 lib/Cake/Model/Datasource/Database/Sqlserver.php
  14. +2 −2 lib/Cake/Model/Datasource/DboSource.php
  15. +1 −1 lib/Cake/Model/Model.php
  16. +9 −9 lib/Cake/Network/CakeResponse.php
  17. +1 −1 lib/Cake/Network/Email/SmtpTransport.php
  18. +1 −1 lib/Cake/Network/Http/HttpSocket.php
  19. +1 −1 lib/Cake/Network/Http/HttpSocketResponse.php
  20. +1 −1 lib/Cake/Routing/Router.php
  21. +1 −1 lib/Cake/Test/Case/Model/ModelValidationTest.php
  22. +1 −1 lib/Cake/TestSuite/CakeTestCase.php
  23. +2 −2 lib/Cake/Utility/CakeTime.php
  24. +1 −1 lib/Cake/Utility/ClassRegistry.php
  25. +2 −2 lib/Cake/Utility/Debugger.php
  26. +1 −1 lib/Cake/Utility/File.php
  27. +1 −1 lib/Cake/Utility/Hash.php
  28. +1 −1 lib/Cake/Utility/ObjectCollection.php
  29. +1 −1 lib/Cake/Utility/Set.php
  30. +7 −7 lib/Cake/Utility/Validation.php
  31. +1 −1 lib/Cake/Utility/Xml.php
  32. +1 −1 lib/Cake/View/Helper/FormHelper.php
  33. +1 −1 lib/Cake/View/Helper/RssHelper.php
  34. +1 −1 lib/Cake/View/ScaffoldView.php
  35. +2 −2 lib/Cake/View/View.php
@@ -407,7 +407,7 @@ protected function _doPropertyChoices($prompt, $example) {
* @return array Set of controllers
*/
public function listAll($useDbConfig = null) {
- if (is_null($useDbConfig)) {
+ if ($useDbConfig === null) {
$useDbConfig = $this->connection;
}
$this->__tables = $this->Model->getAllTables($useDbConfig);
@@ -219,7 +219,7 @@ public function bake($model, $useTable = false, $importOptions = array()) {
}
$tableInfo = $data['tables'][$useTable];
- if (is_null($modelImport)) {
+ if ($modelImport === null) {
$schema = $this->_generateSchema($tableInfo);
}
@@ -661,7 +661,7 @@ public function redirect($url = null) {
* @return string Redirect URL
*/
public function redirectUrl($url = null) {
- if (!is_null($url)) {
+ if ($url !== null) {
$redir = $url;
$this->Session->write('Auth.redirect', $redir);
} elseif ($this->Session->check('Auth.redirect')) {
@@ -219,7 +219,7 @@ public function write($key, $value = null, $encrypt = true, $expires = null) {
$this->read();
}
- if (is_null($encrypt)) {
+ if ($encrypt === null) {
$encrypt = true;
}
$this->_encrypted = $encrypt;
@@ -262,7 +262,7 @@ public function read($key = null) {
if (empty($this->_values[$this->name])) {
$this->_values[$this->name] = array();
}
- if (is_null($key)) {
+ if ($key === null) {
return $this->_values[$this->name];
}
@@ -387,7 +387,7 @@ public function type($type = 'cipher') {
* @return integer Unix timestamp
*/
protected function _expire($expires = null) {
- if (is_null($expires)) {
+ if ($expires === null) {
return $this->_expires;
}
$this->_reset = $this->_expires;
@@ -228,7 +228,7 @@ public static function loaded($plugin = null) {
* @return void
*/
public static function unload($plugin = null) {
- if (is_null($plugin)) {
+ if ($plugin === null) {
self::$_plugins = array();
} else {
unset(self::$_plugins[$plugin]);
View
@@ -161,7 +161,7 @@ public static function translate($singular, $plural = null, $domain = null, $cat
$_this->_lang = $lang;
}
- if (is_null($domain)) {
+ if ($domain === null) {
$domain = self::$defaultDomain;
}
if ($domain === '') {
@@ -513,7 +513,7 @@ public function afterDelete(Model $Model) {
* @return mixed string or false
*/
protected function _getLocale(Model $Model) {
- if (!isset($Model->locale) || is_null($Model->locale)) {
+ if (!isset($Model->locale) || $Model->locale === null) {
$I18n = I18n::getInstance();
$I18n->l10n->get(Configure::read('Config.language'));
$Model->locale = $I18n->l10n->locale;
@@ -588,7 +588,7 @@ public function bindTranslation(Model $Model, $fields, $reset = true) {
$this->_removeField($Model, $field);
- if (is_null($association)) {
+ if ($association === null) {
if ($reset) {
$this->runtime[$Model->alias]['fields'][] = $field;
} else {
@@ -677,7 +677,7 @@ public function unbindTranslation(Model $Model, $fields = null) {
$this->_removeField($Model, $field);
- if (!is_null($association) && (isset($Model->hasMany[$association]) || isset($Model->__backAssociation['hasMany'][$association]))) {
+ if ($association !== null && (isset($Model->hasMany[$association]) || isset($Model->__backAssociation['hasMany'][$association]))) {
$associations[] = $association;
}
}
@@ -307,7 +307,7 @@ public function children(Model $Model, $id = null, $direct = false, $fields = nu
extract($this->settings[$Model->alias]);
- if (!is_null($overrideRecursive)) {
+ if ($overrideRecursive !== null) {
$recursive = $overrideRecursive;
}
if (!$order) {
@@ -353,7 +353,7 @@ public function children(Model $Model, $id = null, $direct = false, $fields = nu
public function generateTreeList(Model $Model, $conditions = null, $keyPath = null, $valuePath = null, $spacer = '_', $recursive = null) {
$overrideRecursive = $recursive;
extract($this->settings[$Model->alias]);
- if (!is_null($overrideRecursive)) {
+ if ($overrideRecursive !== null) {
$recursive = $overrideRecursive;
}
@@ -415,7 +415,7 @@ public function getParentNode(Model $Model, $id = null, $fields = null, $recursi
$id = $Model->id;
}
extract($this->settings[$Model->alias]);
- if (!is_null($overrideRecursive)) {
+ if ($overrideRecursive !== null) {
$recursive = $overrideRecursive;
}
$parentId = $Model->find('first', array('conditions' => array($Model->primaryKey => $id), 'fields' => array($parent), 'recursive' => -1));
@@ -448,7 +448,7 @@ public function getPath(Model $Model, $id = null, $fields = null, $recursive = n
$id = $Model->id;
}
extract($this->settings[$Model->alias]);
- if (!is_null($overrideRecursive)) {
+ if ($overrideRecursive !== null) {
$recursive = $overrideRecursive;
}
$result = $Model->find('first', array('conditions' => array($Model->escapeField() => $id), 'fields' => array($left, $right), 'recursive' => $recursive));
@@ -817,7 +817,7 @@ public function verify(Model $Model) {
))));
foreach ($Model->find('all', array('conditions' => $scope, 'recursive' => 0)) as $instance) {
- if (is_null($instance[$Model->alias][$left]) || is_null($instance[$Model->alias][$right])) {
+ if ($instance[$Model->alias][$left] === null || $instance[$Model->alias][$right] === null) {
$errors[] = array('node', $instance[$Model->alias][$Model->primaryKey],
'has invalid left or right values');
} elseif ($instance[$Model->alias][$left] == $instance[$Model->alias][$right]) {
@@ -366,7 +366,7 @@ public static function read($name = null) {
if (!self::start()) {
return false;
}
- if (is_null($name)) {
+ if ($name === null) {
return self::_returnSessionVars();
}
if (empty($name)) {
@@ -657,7 +657,7 @@ protected function _alterIndexes($table, $indexes) {
* @return string Formatted length part of an index field
*/
protected function _buildIndexSubPart($lengths, $column) {
- if (is_null($lengths)) {
+ if ($lengths === null) {
return '';
}
if (!isset($lengths[$column])) {
@@ -748,11 +748,11 @@ public function fetchResult() {
switch ($type) {
case 'bool':
- $resultRow[$table][$column] = is_null($row[$index]) ? null : $this->boolean($row[$index]);
+ $resultRow[$table][$column] = $row[$index] === null ? null : $this->boolean($row[$index]);
break;
case 'binary':
case 'bytea':
- $resultRow[$table][$column] = is_null($row[$index]) ? null : stream_get_contents($row[$index]);
+ $resultRow[$table][$column] = $row[$index] === null ? null : stream_get_contents($row[$index]);
break;
default:
$resultRow[$table][$column] = $row[$index];
@@ -357,7 +357,7 @@ public function fetchResult() {
foreach ($this->map as $col => $meta) {
list($table, $column, $type) = $meta;
$resultRow[$table][$column] = $row[$col];
- if ($type === 'boolean' && !is_null($row[$col])) {
+ if ($type === 'boolean' && $row[$col] !== null) {
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
}
}
@@ -615,7 +615,7 @@ public function fetchResult() {
continue;
}
$resultRow[$table][$column] = $row[$col];
- if ($type === 'boolean' && !is_null($row[$col])) {
+ if ($type === 'boolean' && $row[$col] !== null) {
$resultRow[$table][$column] = $this->boolean($resultRow[$table][$column]);
}
}
@@ -1035,7 +1035,7 @@ public function read(Model $model, $queryData = array(), $recursive = null) {
$recursive = $queryData['recursive'];
}
- if (!is_null($recursive)) {
+ if ($recursive !== null) {
$_recursive = $model->recursive;
$model->recursive = $recursive;
}
@@ -1123,7 +1123,7 @@ public function read(Model $model, $queryData = array(), $recursive = null) {
}
}
- if (!is_null($recursive)) {
+ if ($recursive !== null) {
$model->recursive = $_recursive;
}
return $resultSet;
View
@@ -2693,7 +2693,7 @@ public function find($type = 'first', $query = array()) {
$this->id = $this->getID();
$query = $this->buildQuery($type, $query);
- if (is_null($query)) {
+ if ($query === null) {
return null;
}
@@ -514,7 +514,7 @@ protected function _setContentLength() {
*/
protected function _sendHeader($name, $value = null) {
if (!headers_sent()) {
- if (is_null($value)) {
+ if ($value === null) {
header($name);
} else {
header("{$name}: {$value}");
@@ -560,7 +560,7 @@ protected function _sendContent($content) {
* @return array list of headers to be sent
*/
public function header($header = null, $value = null) {
- if (is_null($header)) {
+ if ($header === null) {
return $this->_headers;
}
if (is_array($header)) {
@@ -574,7 +574,7 @@ public function header($header = null, $value = null) {
return $this->_headers;
}
- if (!is_null($value)) {
+ if ($value !== null) {
$this->_headers[$header] = $value;
return $this->_headers;
}
@@ -592,7 +592,7 @@ public function header($header = null, $value = null) {
* @return string current message buffer if $content param is passed as null
*/
public function body($content = null) {
- if (is_null($content)) {
+ if ($content === null) {
return $this->_body;
}
return $this->_body = $content;
@@ -607,7 +607,7 @@ public function body($content = null) {
* @throws CakeException When an unknown status code is reached.
*/
public function statusCode($code = null) {
- if (is_null($code)) {
+ if ($code === null) {
return $this->_status;
}
if (!isset($this->_statusCodes[$code])) {
@@ -676,7 +676,7 @@ public function httpCodes($code = null) {
* @return mixed current content type or false if supplied an invalid content type
*/
public function type($contentType = null) {
- if (is_null($contentType)) {
+ if ($contentType === null) {
return $this->_contentType;
}
if (is_array($contentType)) {
@@ -741,7 +741,7 @@ public function mapType($ctype) {
* @return string current charset
*/
public function charset($charset = null) {
- if (is_null($charset)) {
+ if ($charset === null) {
return $this->_charset;
}
return $this->_charset = $charset;
@@ -1248,7 +1248,7 @@ public function file($path, $options = array()) {
$extension = strtolower($file->ext());
$download = $options['download'];
- if ((!$extension || $this->type($extension) === false) && is_null($download)) {
+ if ((!$extension || $this->type($extension) === false) && $download === null) {
$download = true;
}
@@ -1265,7 +1265,7 @@ public function file($path, $options = array()) {
if (!empty($contentType)) {
$this->type($contentType);
}
- if (is_null($options['name'])) {
+ if ($options['name'] === null) {
$name = $file->name;
} else {
$name = $options['name'];
@@ -231,7 +231,7 @@ protected function _generateSocket() {
* @throws SocketException
*/
protected function _smtpSend($data, $checkCode = '250') {
- if (!is_null($data)) {
+ if ($data !== null) {
$this->_socket->write($data . "\r\n");
}
while ($checkCode !== false) {
@@ -536,7 +536,7 @@ public function delete($uri = null, $data = array(), $request = array()) {
* @return mixed Either false on failure or a string containing the composed URL.
*/
public function url($url = null, $uriTemplate = null) {
- if (is_null($url)) {
+ if ($url === null) {
$url = '/';
}
if (is_string($url)) {
@@ -138,7 +138,7 @@ public function isOk() {
* @return boolean
*/
public function isRedirect() {
- return in_array($this->code, array(301, 302, 303, 307)) && !is_null($this->getHeader('Location'));
+ return in_array($this->code, array(301, 302, 303, 307)) && $this->getHeader('Location') !== null;
}
/**
@@ -175,7 +175,7 @@ class Router {
* @throws RouterException
*/
public static function defaultRouteClass($routeClass = null) {
- if (is_null($routeClass)) {
+ if ($routeClass === null) {
return self::$_routeClass;
}
@@ -692,7 +692,7 @@ public function testValidatesWithModelsAndSaveAllWithoutId() {
$Author->create();
$result = $Author->saveAll($data, array('validate' => 'first'));
$this->assertTrue($result);
- $this->assertFalse(is_null($Author->id));
+ $this->assertFalse($Author->id === null);
$id = $Author->id;
$count = $Author->find('count', array('conditions' => array('Author.id' => $id)));
@@ -693,7 +693,7 @@ protected function skipUnless($condition, $message = '') {
* @return Model
*/
public function getMockForModel($model, $methods = array(), $config = null) {
- if (is_null($config)) {
+ if ($config === null) {
$config = ClassRegistry::config('Model');
}
@@ -248,7 +248,7 @@ protected static function _translateSpecifier($specifier) {
*/
public static function convert($serverTime, $timezone) {
static $serverTimezone = null;
- if (is_null($serverTimezone) || (date_default_timezone_get() !== $serverTimezone->getName())) {
+ if ($serverTimezone === null || (date_default_timezone_get() !== $serverTimezone->getName())) {
$serverTimezone = new DateTimeZone(date_default_timezone_get());
}
$serverOffset = $serverTimezone->getOffset(new DateTime('@' . $serverTime));
@@ -647,7 +647,7 @@ public static function toAtom($dateString, $timezone = null) {
public static function toRSS($dateString, $timezone = null) {
$date = self::fromString($dateString, $timezone);
- if (is_null($timezone)) {
+ if ($timezone === null) {
return date("r", $date);
}
@@ -289,7 +289,7 @@ public static function config($type, $param = array()) {
if (empty($param) && is_array($type)) {
$param = $type;
$type = 'Model';
- } elseif (is_null($param)) {
+ } elseif ($param === null) {
unset($_this->_config[$type]);
} elseif (empty($param) && is_string($type)) {
return isset($_this->_config[$type]) ? $_this->_config[$type] : null;
Oops, something went wrong.

0 comments on commit 6cf147e

Please sign in to comment.