From 6cf147e8c8eaeca884c40002f0ea68cab9f2c432 Mon Sep 17 00:00:00 2001 From: euromark Date: Fri, 16 Aug 2013 20:12:49 +0200 Subject: [PATCH] unify null checks - avoid method call in favor of strict check --- .../Console/Command/Task/ControllerTask.php | 2 +- lib/Cake/Console/Command/Task/FixtureTask.php | 2 +- .../Controller/Component/AuthComponent.php | 2 +- .../Controller/Component/CookieComponent.php | 6 +++--- lib/Cake/Core/CakePlugin.php | 2 +- lib/Cake/I18n/I18n.php | 2 +- lib/Cake/Model/Behavior/TranslateBehavior.php | 6 +++--- lib/Cake/Model/Behavior/TreeBehavior.php | 10 +++++----- lib/Cake/Model/Datasource/CakeSession.php | 2 +- lib/Cake/Model/Datasource/Database/Mysql.php | 2 +- .../Model/Datasource/Database/Postgres.php | 4 ++-- lib/Cake/Model/Datasource/Database/Sqlite.php | 2 +- .../Model/Datasource/Database/Sqlserver.php | 2 +- lib/Cake/Model/Datasource/DboSource.php | 4 ++-- lib/Cake/Model/Model.php | 2 +- lib/Cake/Network/CakeResponse.php | 18 +++++++++--------- lib/Cake/Network/Email/SmtpTransport.php | 2 +- lib/Cake/Network/Http/HttpSocket.php | 2 +- lib/Cake/Network/Http/HttpSocketResponse.php | 2 +- lib/Cake/Routing/Router.php | 2 +- .../Test/Case/Model/ModelValidationTest.php | 2 +- lib/Cake/TestSuite/CakeTestCase.php | 2 +- lib/Cake/Utility/CakeTime.php | 4 ++-- lib/Cake/Utility/ClassRegistry.php | 2 +- lib/Cake/Utility/Debugger.php | 4 ++-- lib/Cake/Utility/File.php | 2 +- lib/Cake/Utility/Hash.php | 2 +- lib/Cake/Utility/ObjectCollection.php | 2 +- lib/Cake/Utility/Set.php | 2 +- lib/Cake/Utility/Validation.php | 14 +++++++------- lib/Cake/Utility/Xml.php | 2 +- lib/Cake/View/Helper/FormHelper.php | 2 +- lib/Cake/View/Helper/RssHelper.php | 2 +- lib/Cake/View/ScaffoldView.php | 2 +- lib/Cake/View/View.php | 4 ++-- 35 files changed, 62 insertions(+), 62 deletions(-) diff --git a/lib/Cake/Console/Command/Task/ControllerTask.php b/lib/Cake/Console/Command/Task/ControllerTask.php index bea789f25..46e294dff 100644 --- a/lib/Cake/Console/Command/Task/ControllerTask.php +++ b/lib/Cake/Console/Command/Task/ControllerTask.php @@ -407,7 +407,7 @@ class ControllerTask extends BakeTask { * @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); diff --git a/lib/Cake/Console/Command/Task/FixtureTask.php b/lib/Cake/Console/Command/Task/FixtureTask.php index d6831325e..21b8389a1 100644 --- a/lib/Cake/Console/Command/Task/FixtureTask.php +++ b/lib/Cake/Console/Command/Task/FixtureTask.php @@ -219,7 +219,7 @@ class FixtureTask extends BakeTask { } $tableInfo = $data['tables'][$useTable]; - if (is_null($modelImport)) { + if ($modelImport === null) { $schema = $this->_generateSchema($tableInfo); } diff --git a/lib/Cake/Controller/Component/AuthComponent.php b/lib/Cake/Controller/Component/AuthComponent.php index 621c97fc5..50e264f68 100644 --- a/lib/Cake/Controller/Component/AuthComponent.php +++ b/lib/Cake/Controller/Component/AuthComponent.php @@ -661,7 +661,7 @@ class AuthComponent extends Component { * @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')) { diff --git a/lib/Cake/Controller/Component/CookieComponent.php b/lib/Cake/Controller/Component/CookieComponent.php index 7ae79afeb..e2831783d 100644 --- a/lib/Cake/Controller/Component/CookieComponent.php +++ b/lib/Cake/Controller/Component/CookieComponent.php @@ -219,7 +219,7 @@ class CookieComponent extends Component { $this->read(); } - if (is_null($encrypt)) { + if ($encrypt === null) { $encrypt = true; } $this->_encrypted = $encrypt; @@ -262,7 +262,7 @@ class CookieComponent extends Component { 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 @@ class CookieComponent extends Component { * @return integer Unix timestamp */ protected function _expire($expires = null) { - if (is_null($expires)) { + if ($expires === null) { return $this->_expires; } $this->_reset = $this->_expires; diff --git a/lib/Cake/Core/CakePlugin.php b/lib/Cake/Core/CakePlugin.php index 8ba842206..d9d30c1c2 100644 --- a/lib/Cake/Core/CakePlugin.php +++ b/lib/Cake/Core/CakePlugin.php @@ -228,7 +228,7 @@ class CakePlugin { * @return void */ public static function unload($plugin = null) { - if (is_null($plugin)) { + if ($plugin === null) { self::$_plugins = array(); } else { unset(self::$_plugins[$plugin]); diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 04a8ae795..a522bdaa8 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -161,7 +161,7 @@ class I18n { $_this->_lang = $lang; } - if (is_null($domain)) { + if ($domain === null) { $domain = self::$defaultDomain; } if ($domain === '') { diff --git a/lib/Cake/Model/Behavior/TranslateBehavior.php b/lib/Cake/Model/Behavior/TranslateBehavior.php index 1335f06a8..3156d7f70 100644 --- a/lib/Cake/Model/Behavior/TranslateBehavior.php +++ b/lib/Cake/Model/Behavior/TranslateBehavior.php @@ -513,7 +513,7 @@ class TranslateBehavior extends ModelBehavior { * @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 @@ class TranslateBehavior extends ModelBehavior { $this->_removeField($Model, $field); - if (is_null($association)) { + if ($association === null) { if ($reset) { $this->runtime[$Model->alias]['fields'][] = $field; } else { @@ -677,7 +677,7 @@ class TranslateBehavior extends ModelBehavior { $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; } } diff --git a/lib/Cake/Model/Behavior/TreeBehavior.php b/lib/Cake/Model/Behavior/TreeBehavior.php index bcb5e511b..f57865ef7 100644 --- a/lib/Cake/Model/Behavior/TreeBehavior.php +++ b/lib/Cake/Model/Behavior/TreeBehavior.php @@ -307,7 +307,7 @@ class TreeBehavior extends ModelBehavior { extract($this->settings[$Model->alias]); - if (!is_null($overrideRecursive)) { + if ($overrideRecursive !== null) { $recursive = $overrideRecursive; } if (!$order) { @@ -353,7 +353,7 @@ class TreeBehavior extends ModelBehavior { 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 @@ class TreeBehavior extends ModelBehavior { $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 @@ class TreeBehavior extends ModelBehavior { $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 @@ class TreeBehavior extends ModelBehavior { )))); 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]) { diff --git a/lib/Cake/Model/Datasource/CakeSession.php b/lib/Cake/Model/Datasource/CakeSession.php index 51b6f8a46..038613ba6 100644 --- a/lib/Cake/Model/Datasource/CakeSession.php +++ b/lib/Cake/Model/Datasource/CakeSession.php @@ -366,7 +366,7 @@ class CakeSession { if (!self::start()) { return false; } - if (is_null($name)) { + if ($name === null) { return self::_returnSessionVars(); } if (empty($name)) { diff --git a/lib/Cake/Model/Datasource/Database/Mysql.php b/lib/Cake/Model/Datasource/Database/Mysql.php index 58deb848a..839a4d2be 100644 --- a/lib/Cake/Model/Datasource/Database/Mysql.php +++ b/lib/Cake/Model/Datasource/Database/Mysql.php @@ -657,7 +657,7 @@ class Mysql extends DboSource { * @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])) { diff --git a/lib/Cake/Model/Datasource/Database/Postgres.php b/lib/Cake/Model/Datasource/Database/Postgres.php index bfe57ccf7..00093b052 100644 --- a/lib/Cake/Model/Datasource/Database/Postgres.php +++ b/lib/Cake/Model/Datasource/Database/Postgres.php @@ -748,11 +748,11 @@ class Postgres extends DboSource { 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]; diff --git a/lib/Cake/Model/Datasource/Database/Sqlite.php b/lib/Cake/Model/Datasource/Database/Sqlite.php index 613aeeefe..da61aa273 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlite.php +++ b/lib/Cake/Model/Datasource/Database/Sqlite.php @@ -357,7 +357,7 @@ class Sqlite extends DboSource { 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]); } } diff --git a/lib/Cake/Model/Datasource/Database/Sqlserver.php b/lib/Cake/Model/Datasource/Database/Sqlserver.php index 9dadcd834..a1eab7210 100644 --- a/lib/Cake/Model/Datasource/Database/Sqlserver.php +++ b/lib/Cake/Model/Datasource/Database/Sqlserver.php @@ -615,7 +615,7 @@ class Sqlserver extends DboSource { 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]); } } diff --git a/lib/Cake/Model/Datasource/DboSource.php b/lib/Cake/Model/Datasource/DboSource.php index 9521fd2f4..2994ed808 100644 --- a/lib/Cake/Model/Datasource/DboSource.php +++ b/lib/Cake/Model/Datasource/DboSource.php @@ -1035,7 +1035,7 @@ class DboSource extends DataSource { $recursive = $queryData['recursive']; } - if (!is_null($recursive)) { + if ($recursive !== null) { $_recursive = $model->recursive; $model->recursive = $recursive; } @@ -1123,7 +1123,7 @@ class DboSource extends DataSource { } } - if (!is_null($recursive)) { + if ($recursive !== null) { $model->recursive = $_recursive; } return $resultSet; diff --git a/lib/Cake/Model/Model.php b/lib/Cake/Model/Model.php index bed3419c1..385890a87 100644 --- a/lib/Cake/Model/Model.php +++ b/lib/Cake/Model/Model.php @@ -2693,7 +2693,7 @@ class Model extends Object implements CakeEventListener { $this->id = $this->getID(); $query = $this->buildQuery($type, $query); - if (is_null($query)) { + if ($query === null) { return null; } diff --git a/lib/Cake/Network/CakeResponse.php b/lib/Cake/Network/CakeResponse.php index f09212bc9..bf9b5ace3 100644 --- a/lib/Cake/Network/CakeResponse.php +++ b/lib/Cake/Network/CakeResponse.php @@ -514,7 +514,7 @@ class CakeResponse { */ 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 @@ class CakeResponse { * @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 @@ class CakeResponse { return $this->_headers; } - if (!is_null($value)) { + if ($value !== null) { $this->_headers[$header] = $value; return $this->_headers; } @@ -592,7 +592,7 @@ class CakeResponse { * @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 @@ class CakeResponse { * @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 @@ class CakeResponse { * @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 @@ class CakeResponse { * @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 @@ class CakeResponse { $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 @@ class CakeResponse { if (!empty($contentType)) { $this->type($contentType); } - if (is_null($options['name'])) { + if ($options['name'] === null) { $name = $file->name; } else { $name = $options['name']; diff --git a/lib/Cake/Network/Email/SmtpTransport.php b/lib/Cake/Network/Email/SmtpTransport.php index e0b07156b..5070f46c5 100644 --- a/lib/Cake/Network/Email/SmtpTransport.php +++ b/lib/Cake/Network/Email/SmtpTransport.php @@ -231,7 +231,7 @@ class SmtpTransport extends AbstractTransport { * @throws SocketException */ protected function _smtpSend($data, $checkCode = '250') { - if (!is_null($data)) { + if ($data !== null) { $this->_socket->write($data . "\r\n"); } while ($checkCode !== false) { diff --git a/lib/Cake/Network/Http/HttpSocket.php b/lib/Cake/Network/Http/HttpSocket.php index 2ffeaecc2..d61204958 100644 --- a/lib/Cake/Network/Http/HttpSocket.php +++ b/lib/Cake/Network/Http/HttpSocket.php @@ -536,7 +536,7 @@ class HttpSocket extends CakeSocket { * @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)) { diff --git a/lib/Cake/Network/Http/HttpSocketResponse.php b/lib/Cake/Network/Http/HttpSocketResponse.php index 6d79fb9ed..eefcc9dd8 100644 --- a/lib/Cake/Network/Http/HttpSocketResponse.php +++ b/lib/Cake/Network/Http/HttpSocketResponse.php @@ -138,7 +138,7 @@ class HttpSocketResponse implements ArrayAccess { * @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; } /** diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 8327556db..420e64c01 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -175,7 +175,7 @@ class Router { * @throws RouterException */ public static function defaultRouteClass($routeClass = null) { - if (is_null($routeClass)) { + if ($routeClass === null) { return self::$_routeClass; } diff --git a/lib/Cake/Test/Case/Model/ModelValidationTest.php b/lib/Cake/Test/Case/Model/ModelValidationTest.php index 031a9436f..af3b02a4b 100644 --- a/lib/Cake/Test/Case/Model/ModelValidationTest.php +++ b/lib/Cake/Test/Case/Model/ModelValidationTest.php @@ -692,7 +692,7 @@ class ModelValidationTest extends BaseModelTest { $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))); diff --git a/lib/Cake/TestSuite/CakeTestCase.php b/lib/Cake/TestSuite/CakeTestCase.php index 467b6ba10..9073cbf2d 100644 --- a/lib/Cake/TestSuite/CakeTestCase.php +++ b/lib/Cake/TestSuite/CakeTestCase.php @@ -693,7 +693,7 @@ abstract class CakeTestCase extends PHPUnit_Framework_TestCase { * @return Model */ public function getMockForModel($model, $methods = array(), $config = null) { - if (is_null($config)) { + if ($config === null) { $config = ClassRegistry::config('Model'); } diff --git a/lib/Cake/Utility/CakeTime.php b/lib/Cake/Utility/CakeTime.php index dc546d6ce..7cc5d3fe3 100644 --- a/lib/Cake/Utility/CakeTime.php +++ b/lib/Cake/Utility/CakeTime.php @@ -248,7 +248,7 @@ class CakeTime { */ 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 @@ class CakeTime { public static function toRSS($dateString, $timezone = null) { $date = self::fromString($dateString, $timezone); - if (is_null($timezone)) { + if ($timezone === null) { return date("r", $date); } diff --git a/lib/Cake/Utility/ClassRegistry.php b/lib/Cake/Utility/ClassRegistry.php index 1f0108940..3b2a3dc02 100644 --- a/lib/Cake/Utility/ClassRegistry.php +++ b/lib/Cake/Utility/ClassRegistry.php @@ -289,7 +289,7 @@ class ClassRegistry { 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; diff --git a/lib/Cake/Utility/Debugger.php b/lib/Cake/Utility/Debugger.php index c004bdbd1..ed167c557 100644 --- a/lib/Cake/Utility/Debugger.php +++ b/lib/Cake/Utility/Debugger.php @@ -706,7 +706,7 @@ class Debugger { $self = Debugger::getInstance(); $data = null; - if (is_null($format)) { + if ($format === null) { return Debugger::outputAs(); } @@ -815,7 +815,7 @@ class Debugger { if (is_object($var)) { return get_class($var); } - if (is_null($var)) { + if ($var === null) { return 'null'; } if (is_string($var)) { diff --git a/lib/Cake/Utility/File.php b/lib/Cake/Utility/File.php index 7afd7275d..121aae230 100644 --- a/lib/Cake/Utility/File.php +++ b/lib/Cake/Utility/File.php @@ -395,7 +395,7 @@ class File { * @link http://book.cakephp.org/2.0/en/core-utility-libraries/file-folder.html#File::pwd */ public function pwd() { - if (is_null($this->path)) { + if ($this->path === null) { $this->path = $this->Folder->slashTerm($this->Folder->pwd()) . $this->name; } return $this->path; diff --git a/lib/Cake/Utility/Hash.php b/lib/Cake/Utility/Hash.php index a0f64ebee..80d8f291a 100644 --- a/lib/Cake/Utility/Hash.php +++ b/lib/Cake/Utility/Hash.php @@ -816,7 +816,7 @@ class Hash { $stack = array(); foreach ($data as $k => $r) { $id = $k; - if (!is_null($key)) { + if ($key !== null) { $id = $key; } if (is_array($r) && !empty($r)) { diff --git a/lib/Cake/Utility/ObjectCollection.php b/lib/Cake/Utility/ObjectCollection.php index f91977b99..640709d26 100644 --- a/lib/Cake/Utility/ObjectCollection.php +++ b/lib/Cake/Utility/ObjectCollection.php @@ -225,7 +225,7 @@ abstract class ObjectCollection { } foreach ($name as $object => $objectPriority) { if (isset($this->_loaded[$object])) { - if (is_null($objectPriority)) { + if ($objectPriority === null) { $objectPriority = $this->defaultPriority; } $this->_loaded[$object]->settings['priority'] = $objectPriority; diff --git a/lib/Cake/Utility/Set.php b/lib/Cake/Utility/Set.php index 5f668dd0c..23879f2a6 100644 --- a/lib/Cake/Utility/Set.php +++ b/lib/Cake/Utility/Set.php @@ -935,7 +935,7 @@ class Set { $stack = array(); foreach ($results as $k => $r) { $id = $k; - if (!is_null($key)) { + if ($key !== null) { $id = $key; } if (is_array($r) && !empty($r)) { diff --git a/lib/Cake/Utility/Validation.php b/lib/Cake/Utility/Validation.php index 322527040..31685e658 100644 --- a/lib/Cake/Utility/Validation.php +++ b/lib/Cake/Utility/Validation.php @@ -149,7 +149,7 @@ class Validation { return false; } - if (!is_null($regex)) { + if ($regex !== null) { if (self::_check($check, $regex)) { return self::luhn($check, $deep); } @@ -295,7 +295,7 @@ class Validation { * @return boolean Success */ public static function date($check, $format = 'ymd', $regex = null) { - if (!is_null($regex)) { + if ($regex !== null) { return self::_check($check, $regex); } @@ -386,7 +386,7 @@ class Validation { * @return boolean Success */ public static function decimal($check, $places = null, $regex = null) { - if (is_null($regex)) { + if ($regex === null) { $lnum = '[0-9]+'; $dnum = "[0-9]*[\.]{$lnum}"; $sign = '[+-]?'; @@ -426,7 +426,7 @@ class Validation { extract(self::_defaults($check)); } - if (is_null($regex)) { + if ($regex === null) { $regex = '/^[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@' . self::$_pattern['hostname'] . '$/i'; } $return = self::_check($check, $regex); @@ -608,7 +608,7 @@ class Validation { extract(self::_defaults($check)); } - if (is_null($regex)) { + if ($regex === null) { switch ($country) { case 'us': case 'all': @@ -638,7 +638,7 @@ class Validation { extract(self::_defaults($check)); } - if (is_null($regex)) { + if ($regex === null) { switch ($country) { case 'uk': $regex = '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i'; @@ -699,7 +699,7 @@ class Validation { extract(self::_defaults($check)); } - if (is_null($regex)) { + if ($regex === null) { switch ($country) { case 'dk': $regex = '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i'; diff --git a/lib/Cake/Utility/Xml.php b/lib/Cake/Utility/Xml.php index 88d4e19a0..7c0beae28 100644 --- a/lib/Cake/Utility/Xml.php +++ b/lib/Cake/Utility/Xml.php @@ -310,7 +310,7 @@ class Xml { } $child = $dom->createElement($key); - if (!is_null($childValue)) { + if ($childValue !== null) { $child->appendChild($dom->createTextNode($childValue)); } if ($childNS) { diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 743090371..d6f2af627 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -2864,7 +2864,7 @@ class FormHelper extends AppHelper { * @return array inputDefaults */ public function inputDefaults($defaults = null, $merge = false) { - if (!is_null($defaults)) { + if ($defaults !== null) { if ($merge) { $this->_inputDefaults = array_merge($this->_inputDefaults, (array)$defaults); } else { diff --git a/lib/Cake/View/Helper/RssHelper.php b/lib/Cake/View/Helper/RssHelper.php index f1e22faaf..ac0592442 100644 --- a/lib/Cake/View/Helper/RssHelper.php +++ b/lib/Cake/View/Helper/RssHelper.php @@ -260,7 +260,7 @@ class RssHelper extends AppHelper { default: $attrib = $att; } - if (!is_null($val) && $escape) { + if ($val !== null && $escape) { $val = h($val); } $elements[$key] = $this->elem($key, $attrib, $val); diff --git a/lib/Cake/View/ScaffoldView.php b/lib/Cake/View/ScaffoldView.php index bfaa87fec..a82cc25ed 100644 --- a/lib/Cake/View/ScaffoldView.php +++ b/lib/Cake/View/ScaffoldView.php @@ -58,7 +58,7 @@ class ScaffoldView extends View { $scaffoldAction = 'scaffold.' . $name; - if (!is_null($this->subDir)) { + if ($this->subDir !== null) { $subDir = strtolower($this->subDir) . DS; } else { $subDir = null; diff --git a/lib/Cake/View/View.php b/lib/Cake/View/View.php index 7e98108a7..a189ea16b 100644 --- a/lib/Cake/View/View.php +++ b/lib/Cake/View/View.php @@ -972,7 +972,7 @@ class View extends Object { protected function _getViewFileName($name = null) { $subDir = null; - if (!is_null($this->subDir)) { + if ($this->subDir !== null) { $subDir = $this->subDir . DS; } @@ -1054,7 +1054,7 @@ class View extends Object { } $subDir = null; - if (!is_null($this->layoutPath)) { + if ($this->layoutPath !== null) { $subDir = $this->layoutPath . DS; } list($plugin, $name) = $this->pluginSplit($name);