'null === ...' can be used.

This commit is contained in:
Yuriy Pikhtarev 2017-05-05 00:59:05 +03:00
parent 6a3bf7cea6
commit ec96f6567b
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
8 changed files with 47 additions and 47 deletions

View file

@ -82,7 +82,7 @@ if ($submit && $mode == 'user') {
$group_id = create_user_group($user_id); $group_id = create_user_group($user_id);
} }
if (!$group_id || !$user_id || is_null($this_user_level)) { if (!$group_id || !$user_id || null === $this_user_level) {
trigger_error('data missing', E_USER_ERROR); trigger_error('data missing', E_USER_ERROR);
} }

View file

@ -904,7 +904,7 @@ if (!isset($_REQUEST['dosearch'])) {
$select_sql .= " $limit"; $select_sql .= " $limit";
if (!is_null($total_sql)) { if (null !== $total_sql) {
if (!$result = DB()->sql_query($total_sql)) { if (!$result = DB()->sql_query($total_sql)) {
bb_die('Could not count users'); bb_die('Could not count users');
} }

View file

@ -334,7 +334,7 @@ if ($tor_reged && $tor_info) {
$sp_up_tot[$x] += $peer['speed_up']; $sp_up_tot[$x] += $peer['speed_up'];
$sp_down_tot[$x] += $peer['speed_down']; $sp_down_tot[$x] += $peer['speed_down'];
$guest = ($peer['user_id'] == GUEST_UID || is_null($peer['username'])); $guest = ($peer['user_id'] == GUEST_UID || null === $peer['username']);
$p_max_up = $peer['uploaded']; $p_max_up = $peer['uploaded'];
$p_max_down = $peer['downloaded']; $p_max_down = $peer['downloaded'];

View file

@ -573,7 +573,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
foreach ($assoc_ary as $key => $var) { foreach ($assoc_ary as $key => $var) {
$fields[] = $key; $fields[] = $key;
if (is_null($var)) { if (null === $var) {
$values[] = 'NULL'; $values[] = 'NULL';
} elseif (is_string($var)) { } elseif (is_string($var)) {
$values[] = "'" . attach_mod_sql_escape($var) . "'"; $values[] = "'" . attach_mod_sql_escape($var) . "'";
@ -590,7 +590,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
foreach ($assoc_ary as $id => $sql_ary) { foreach ($assoc_ary as $id => $sql_ary) {
$values = array(); $values = array();
foreach ($sql_ary as $key => $var) { foreach ($sql_ary as $key => $var) {
if (is_null($var)) { if (null === $var) {
$values[] = 'NULL'; $values[] = 'NULL';
} elseif (is_string($var)) { } elseif (is_string($var)) {
$values[] = "'" . attach_mod_sql_escape($var) . "'"; $values[] = "'" . attach_mod_sql_escape($var) . "'";
@ -605,7 +605,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false)
} elseif ($query == 'UPDATE' || $query == 'SELECT') { } elseif ($query == 'UPDATE' || $query == 'SELECT') {
$values = array(); $values = array();
foreach ($assoc_ary as $key => $var) { foreach ($assoc_ary as $key => $var) {
if (is_null($var)) { if (null === $var) {
$values[] = "$key = NULL"; $values[] = "$key = NULL";
} elseif (is_string($var)) { } elseif (is_string($var)) {
$values[] = "$key = '" . attach_mod_sql_escape($var) . "'"; $values[] = "$key = '" . attach_mod_sql_escape($var) . "'";

View file

@ -593,7 +593,7 @@ class bbcode
if (!$bb_cfg['spam_filter_file_path']) { if (!$bb_cfg['spam_filter_file_path']) {
return $text; return $text;
} }
if (is_null($spam_words)) { if (null === $spam_words) {
$spam_words = file_get_contents($bb_cfg['spam_filter_file_path']); $spam_words = file_get_contents($bb_cfg['spam_filter_file_path']);
$spam_words = strtolower($spam_words); $spam_words = strtolower($spam_words);
$spam_words = explode("\n", $spam_words); $spam_words = explode("\n", $spam_words);
@ -738,7 +738,7 @@ class bbcode
{ {
global $datastore; global $datastore;
if (is_null($this->smilies)) { if (null === $this->smilies) {
$this->smilies = $datastore->get('smile_replacements'); $this->smilies = $datastore->get('smile_replacements');
} }
if ($this->smilies) { if ($this->smilies) {

View file

@ -2275,7 +2275,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -2324,7 +2324,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -2568,7 +2568,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]+/sSX', '', $s); return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]+/sSX', '', $s);
@ -2602,7 +2602,7 @@ class utf8
if (is_string($data)) { if (is_string($data)) {
return ltrim($data, "\x00..\x7f") === ''; return ltrim($data, "\x00..\x7f") === '';
} }
if (is_scalar($data) || is_null($data)) { if (is_scalar($data) || null === $data) {
return true; return true;
} #~ null, integer, float, boolean } #~ null, integer, float, boolean
return false; #object or resource return false; #object or resource
@ -2650,7 +2650,7 @@ class utf8
} }
return true; return true;
} }
if (is_scalar($data) || is_null($data)) { if (is_scalar($data) || null === $data) {
return true; return true;
} #~ null, integer, float, boolean } #~ null, integer, float, boolean
return false; #object or resource return false; #object or resource
@ -2792,7 +2792,7 @@ class utf8
}#foreach }#foreach
return true; return true;
} }
if (is_scalar($data) || is_null($data)) { if (is_scalar($data) || null === $data) {
return true; return true;
} #~ null, integer, float, boolean } #~ null, integer, float, boolean
return false; #object or resource return false; #object or resource
@ -2912,7 +2912,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s1) || is_null($s2)) { if (null === $s1 || null === $s2) {
return null; return null;
} }
if (!function_exists('collator_create')) { if (!function_exists('collator_create')) {
@ -2945,7 +2945,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s1) || is_null($s2)) { if (null === $s1 || null === $s2) {
return null; return null;
} }
return self::strcmp(self::substr($s1, 0, $length), self::substr($s2, 0, $length)); return self::strcmp(self::substr($s1, 0, $length), self::substr($s2, 0, $length));
@ -2966,7 +2966,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s1) || is_null($s2)) { if (null === $s1 || null === $s2) {
return null; return null;
} }
return self::strcmp(self::lowercase($s1), self::lowercase($s2)); return self::strcmp(self::lowercase($s1), self::lowercase($s2));
@ -2984,7 +2984,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3021,7 +3021,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($a)) { if (null === $a) {
return $a; return $a;
} }
@ -3062,7 +3062,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($char)) { if (null === $char) {
return $char; return $char;
} }
@ -3104,7 +3104,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($cp)) { if (null === $cp) {
return $cp; return $cp;
} }
@ -3148,7 +3148,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3433,7 +3433,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3491,7 +3491,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($subject)) { if (null === $subject) {
return null; return null;
} }
@ -3537,7 +3537,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3628,7 +3628,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3665,7 +3665,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3718,7 +3718,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3753,7 +3753,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3797,7 +3797,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3832,7 +3832,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3881,7 +3881,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3905,7 +3905,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3933,7 +3933,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -3995,7 +3995,7 @@ class utf8
}, },
$data); $data);
} }
if (is_scalar($data) || is_null($data)) { if (is_scalar($data) || null === $data) {
return $data; return $data;
} #~ null, integer, float, boolean } #~ null, integer, float, boolean
return false; #object or resource return false; #object or resource
@ -4102,7 +4102,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -4130,7 +4130,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
if ($charlist === null || self::is_ascii($charlist)) { if ($charlist === null || self::is_ascii($charlist)) {
@ -4149,7 +4149,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
if ($charlist === null || self::is_ascii($charlist)) { if ($charlist === null || self::is_ascii($charlist)) {
@ -4168,7 +4168,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
if ($charlist === null || self::is_ascii($charlist)) { if ($charlist === null || self::is_ascii($charlist)) {
@ -4205,7 +4205,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
@ -4412,7 +4412,7 @@ class utf8
if (!ReflectionTypeHint::isValid()) { if (!ReflectionTypeHint::isValid()) {
return false; return false;
} }
if (is_null($s)) { if (null === $s) {
return $s; return $s;
} }
if (is_array($from)) { if (is_array($from)) {

View file

@ -412,7 +412,7 @@ class sql_db
return ($v) ? '1' : '0'; return ($v) ? '1' : '0';
case is_float($v): case is_float($v):
return "'$v'"; return "'$v'";
case is_null($v): case null === $v:
return 'NULL'; return 'NULL';
} }
// if $v has unsuitable type // if $v has unsuitable type

View file

@ -870,10 +870,10 @@ function url_arg($url, $arg, $value, $amp = '&')
// заменяем параметр, если он существует // заменяем параметр, если он существует
if (preg_match("/((\?|&|&)$arg=)[^&]*/s", $url, $m)) { if (preg_match("/((\?|&|&)$arg=)[^&]*/s", $url, $m)) {
$cur = $m[0]; $cur = $m[0];
$new = is_null($value) ? '' : $m[1] . urlencode($value); $new = null === $value ? '' : $m[1] . urlencode($value);
$url = str_replace($cur, $new, $url); $url = str_replace($cur, $new, $url);
} // добавляем параметр } // добавляем параметр
elseif (!is_null($value)) { elseif (null !== $value) {
$div = (strpos($url, '?') !== false) ? $amp : '?'; $div = (strpos($url, '?') !== false) ? $amp : '?';
$url = $url . $div . $arg . '=' . urlencode($value); $url = $url . $div . $arg . '=' . urlencode($value);
} }
@ -1357,10 +1357,10 @@ function get_forum_select($mode = 'guest', $name = POST_FORUM_URL, $selected = n
$not_auth_forums_fary = array_flip($mode); $not_auth_forums_fary = array_flip($mode);
$mode = 'not_auth_forums'; $mode = 'not_auth_forums';
} }
if (is_null($max_length)) { if (null === $max_length) {
$max_length = HTML_SELECT_MAX_LENGTH; $max_length = HTML_SELECT_MAX_LENGTH;
} }
$select = is_null($all_forums_option) ? array() : array($lang['ALL_AVAILABLE'] => $all_forums_option); $select = null === $all_forums_option ? array() : array($lang['ALL_AVAILABLE'] => $all_forums_option);
if (!$forums = $datastore->get('cat_forums')) { if (!$forums = $datastore->get('cat_forums')) {
$datastore->update('cat_forums'); $datastore->update('cat_forums');
$forums = $datastore->get('cat_forums'); $forums = $datastore->get('cat_forums');
@ -2032,7 +2032,7 @@ function get_topic_icon($topic, $is_unread = null)
global $bb_cfg, $images; global $bb_cfg, $images;
$t_hot = ($topic['topic_replies'] >= $bb_cfg['hot_threshold']); $t_hot = ($topic['topic_replies'] >= $bb_cfg['hot_threshold']);
$is_unread = is_null($is_unread) ? is_unread($topic['topic_last_post_time'], $topic['topic_id'], $topic['forum_id']) : $is_unread; $is_unread = null === $is_unread ? is_unread($topic['topic_last_post_time'], $topic['topic_id'], $topic['forum_id']) : $is_unread;
if ($topic['topic_status'] == TOPIC_MOVED) { if ($topic['topic_status'] == TOPIC_MOVED) {
$folder_image = $images['folder']; $folder_image = $images['folder'];