From 64df3c55381e87bed09da4ea1e332614c29ce98b Mon Sep 17 00:00:00 2001 From: Yuriy Pikhtarev Date: Fri, 5 May 2017 00:59:05 +0300 Subject: [PATCH] 'null === ...' can be used. (cherry picked from commit ec96f65) --- admin/admin_ug_auth.php | 2 +- admin/admin_user_search.php | 2 +- library/attach_mod/displaying_torrent.php | 2 +- .../attach_mod/includes/functions_attach.php | 6 +- library/includes/bbcode.php | 4 +- library/includes/classes/utf8.php | 66 +++++++++---------- library/includes/core/mysql.php | 2 +- library/includes/functions.php | 10 +-- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/admin/admin_ug_auth.php b/admin/admin_ug_auth.php index 19a0fb1ad..cb96ac37f 100644 --- a/admin/admin_ug_auth.php +++ b/admin/admin_ug_auth.php @@ -82,7 +82,7 @@ if ($submit && $mode == 'user') { $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); } diff --git a/admin/admin_user_search.php b/admin/admin_user_search.php index 18e116feb..6b8febb98 100644 --- a/admin/admin_user_search.php +++ b/admin/admin_user_search.php @@ -904,7 +904,7 @@ if (!isset($_REQUEST['dosearch'])) { $select_sql .= " $limit"; - if (!is_null($total_sql)) { + if (null !== $total_sql) { if (!$result = DB()->sql_query($total_sql)) { bb_die('Could not count users'); } diff --git a/library/attach_mod/displaying_torrent.php b/library/attach_mod/displaying_torrent.php index f75ed00f9..76884d1d2 100644 --- a/library/attach_mod/displaying_torrent.php +++ b/library/attach_mod/displaying_torrent.php @@ -332,7 +332,7 @@ if ($tor_reged && $tor_info) { $sp_up_tot[$x] += $peer['speed_up']; $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_down = $peer['downloaded']; diff --git a/library/attach_mod/includes/functions_attach.php b/library/attach_mod/includes/functions_attach.php index e09944163..0384240e4 100644 --- a/library/attach_mod/includes/functions_attach.php +++ b/library/attach_mod/includes/functions_attach.php @@ -567,7 +567,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) foreach ($assoc_ary as $key => $var) { $fields[] = $key; - if (is_null($var)) { + if (null === $var) { $values[] = 'NULL'; } elseif (is_string($var)) { $values[] = "'" . attach_mod_sql_escape($var) . "'"; @@ -584,7 +584,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) foreach ($assoc_ary as $id => $sql_ary) { $values = array(); foreach ($sql_ary as $key => $var) { - if (is_null($var)) { + if (null === $var) { $values[] = 'NULL'; } elseif (is_string($var)) { $values[] = "'" . attach_mod_sql_escape($var) . "'"; @@ -599,7 +599,7 @@ function attach_mod_sql_build_array($query, $assoc_ary = false) } elseif ($query == 'UPDATE' || $query == 'SELECT') { $values = array(); foreach ($assoc_ary as $key => $var) { - if (is_null($var)) { + if (null === $var) { $values[] = "$key = NULL"; } elseif (is_string($var)) { $values[] = "$key = '" . attach_mod_sql_escape($var) . "'"; diff --git a/library/includes/bbcode.php b/library/includes/bbcode.php index 39d41ed32..adda1a992 100644 --- a/library/includes/bbcode.php +++ b/library/includes/bbcode.php @@ -593,7 +593,7 @@ class bbcode if (!$bb_cfg['spam_filter_file_path']) { return $text; } - if (is_null($spam_words)) { + if (null === $spam_words) { $spam_words = file_get_contents($bb_cfg['spam_filter_file_path']); $spam_words = strtolower($spam_words); $spam_words = explode("\n", $spam_words); @@ -738,7 +738,7 @@ class bbcode { global $datastore; - if (is_null($this->smilies)) { + if (null === $this->smilies) { $this->smilies = $datastore->get('smile_replacements'); } if ($this->smilies) { diff --git a/library/includes/classes/utf8.php b/library/includes/classes/utf8.php index 261fffd3d..f8da0f87e 100644 --- a/library/includes/classes/utf8.php +++ b/library/includes/classes/utf8.php @@ -2275,7 +2275,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -2324,7 +2324,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -2568,7 +2568,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]+/sSX', '', $s); @@ -2602,7 +2602,7 @@ class utf8 if (is_string($data)) { return ltrim($data, "\x00..\x7f") === ''; } - if (is_scalar($data) || is_null($data)) { + if (is_scalar($data) || null === $data) { return true; } #~ null, integer, float, boolean return false; #object or resource @@ -2650,7 +2650,7 @@ class utf8 } return true; } - if (is_scalar($data) || is_null($data)) { + if (is_scalar($data) || null === $data) { return true; } #~ null, integer, float, boolean return false; #object or resource @@ -2792,7 +2792,7 @@ class utf8 }#foreach return true; } - if (is_scalar($data) || is_null($data)) { + if (is_scalar($data) || null === $data) { return true; } #~ null, integer, float, boolean return false; #object or resource @@ -2912,7 +2912,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s1) || is_null($s2)) { + if (null === $s1 || null === $s2) { return null; } if (!function_exists('collator_create')) { @@ -2945,7 +2945,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s1) || is_null($s2)) { + if (null === $s1 || null === $s2) { return null; } return self::strcmp(self::substr($s1, 0, $length), self::substr($s2, 0, $length)); @@ -2966,7 +2966,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s1) || is_null($s2)) { + if (null === $s1 || null === $s2) { return null; } return self::strcmp(self::lowercase($s1), self::lowercase($s2)); @@ -2984,7 +2984,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3021,7 +3021,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($a)) { + if (null === $a) { return $a; } @@ -3062,7 +3062,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($char)) { + if (null === $char) { return $char; } @@ -3104,7 +3104,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($cp)) { + if (null === $cp) { return $cp; } @@ -3148,7 +3148,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3433,7 +3433,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3491,7 +3491,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($subject)) { + if (null === $subject) { return null; } @@ -3537,7 +3537,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3628,7 +3628,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3665,7 +3665,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3718,7 +3718,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3753,7 +3753,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3797,7 +3797,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3832,7 +3832,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3881,7 +3881,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3905,7 +3905,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3933,7 +3933,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -3995,7 +3995,7 @@ class utf8 }, $data); } - if (is_scalar($data) || is_null($data)) { + if (is_scalar($data) || null === $data) { return $data; } #~ null, integer, float, boolean return false; #object or resource @@ -4102,7 +4102,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -4130,7 +4130,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } if ($charlist === null || self::is_ascii($charlist)) { @@ -4149,7 +4149,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } if ($charlist === null || self::is_ascii($charlist)) { @@ -4168,7 +4168,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } if ($charlist === null || self::is_ascii($charlist)) { @@ -4205,7 +4205,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } @@ -4412,7 +4412,7 @@ class utf8 if (!ReflectionTypeHint::isValid()) { return false; } - if (is_null($s)) { + if (null === $s) { return $s; } if (is_array($from)) { diff --git a/library/includes/core/mysql.php b/library/includes/core/mysql.php index d8b420307..ad5107b03 100644 --- a/library/includes/core/mysql.php +++ b/library/includes/core/mysql.php @@ -412,7 +412,7 @@ class sql_db return ($v) ? '1' : '0'; case is_float($v): return "'$v'"; - case is_null($v): + case null === $v: return 'NULL'; } // if $v has unsuitable type diff --git a/library/includes/functions.php b/library/includes/functions.php index 8992bfccc..3e884d398 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -870,10 +870,10 @@ function url_arg($url, $arg, $value, $amp = '&') // заменяем параметр, если он существует if (preg_match("/((\?|&|&)$arg=)[^&]*/s", $url, $m)) { $cur = $m[0]; - $new = is_null($value) ? '' : $m[1] . urlencode($value); + $new = null === $value ? '' : $m[1] . urlencode($value); $url = str_replace($cur, $new, $url); } // добавляем параметр - elseif (!is_null($value)) { + elseif (null !== $value) { $div = (strpos($url, '?') !== false) ? $amp : '?'; $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); $mode = 'not_auth_forums'; } - if (is_null($max_length)) { + if (null === $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')) { $datastore->update('cat_forums'); $forums = $datastore->get('cat_forums'); @@ -2032,7 +2032,7 @@ function get_topic_icon($topic, $is_unread = null) global $bb_cfg, $images; $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) { $folder_image = $images['folder'];