diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index 68cdeef2ca..0ba0de5ed0 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -31,4 +31,4 @@ jobs: - name: PHP-CS-Fixer uses: docker://oskarstark/php-cs-fixer-ga with: - args: --config=.php-cs-fixer.dist.php -v --dry-run --stop-on-violation --using-cache=no ${{ env.PHPCS_EXTRA_ARGS }} \ No newline at end of file + args: --config=.php-cs-fixer.dist.php -v --dry-run --stop-on-violation --using-cache=no --allow-risky=yes ${{ env.PHPCS_EXTRA_ARGS }} \ No newline at end of file diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 482ca86aca..4cd06e30d7 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -95,6 +95,10 @@ 'nullable_type_declaration' => ['syntax' => 'question_mark'], // Namespace notation. + 'native_function_invocation' => [ + 'include' => ['@compiler_optimized'], + 'scope' => 'namespaced', + ], 'no_leading_namespace_whitespace' => true, // Operator. diff --git a/Sources/Actions/Admin/ACP.php b/Sources/Actions/Admin/ACP.php index afa160dd2f..0d3f693cff 100644 --- a/Sources/Actions/Admin/ACP.php +++ b/Sources/Actions/Admin/ACP.php @@ -778,7 +778,7 @@ public function execute(): void // Is it valid? if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -814,7 +814,7 @@ public static function prepareDBSettingContext(array &$config_vars): void foreach ($config_vars as $config_var) { // HR? - if (!is_array($config_var)) { + if (!\is_array($config_var)) { Utils::$context['config_vars'][] = $config_var; } else { // If it has no name it doesn't have any purpose! @@ -878,10 +878,10 @@ public static function prepareDBSettingContext(array &$config_vars): void } Utils::$context['config_vars'][$config_var[1]] = [ - 'label' => $config_var['text_label'] ?? (Lang::$txt[$config_var[1]] ?? (isset($config_var[3]) && !is_array($config_var[3]) ? $config_var[3] : '')), + 'label' => $config_var['text_label'] ?? (Lang::$txt[$config_var[1]] ?? (isset($config_var[3]) && !\is_array($config_var[3]) ? $config_var[3] : '')), 'help' => isset(Lang::$helptxt[$config_var[1]]) ? $config_var[1] : '', 'type' => $config_var[0], - 'size' => !empty($config_var['size']) ? $config_var['size'] : (!empty($config_var[2]) && !is_array($config_var[2]) ? $config_var[2] : (in_array($config_var[0], ['int', 'float']) ? 6 : 0)), + 'size' => !empty($config_var['size']) ? $config_var['size'] : (!empty($config_var[2]) && !\is_array($config_var[2]) ? $config_var[2] : (\in_array($config_var[0], ['int', 'float']) ? 6 : 0)), 'data' => [], 'name' => $config_var[1], 'value' => $value, @@ -912,7 +912,7 @@ public static function prepareDBSettingContext(array &$config_vars): void } // If this is a select box handle any data. - if (!empty($config_var[2]) && is_array($config_var[2])) { + if (!empty($config_var[2]) && \is_array($config_var[2])) { // If we allow multiple selections, we need to adjust a few things. if ($config_var[0] == 'select' && !empty($config_var['multiple'])) { Utils::$context['config_vars'][$config_var[1]]['name'] .= '[]'; @@ -921,7 +921,7 @@ public static function prepareDBSettingContext(array &$config_vars): void } // If it's associative - if (isset($config_var[2][0]) && is_array($config_var[2][0])) { + if (isset($config_var[2][0]) && \is_array($config_var[2][0])) { Utils::$context['config_vars'][$config_var[1]]['data'] = $config_var[2]; } else { foreach ($config_var[2] as $key => $item) { @@ -930,7 +930,7 @@ public static function prepareDBSettingContext(array &$config_vars): void } if (empty($config_var['size']) && !empty($config_var['multiple'])) { - Utils::$context['config_vars'][$config_var[1]]['size'] = max(4, count($config_var[2])); + Utils::$context['config_vars'][$config_var[1]]['size'] = max(4, \count($config_var[2])); } } @@ -1007,7 +1007,7 @@ public static function prepareDBSettingContext(array &$config_vars): void $sectionTags = array_diff($bbcTags, Utils::$context['legacy_bbc']); } - $totalTags = count($sectionTags); + $totalTags = \count($sectionTags); $tagsPerColumn = ceil($totalTags / $numColumns); $col = 0; @@ -1081,7 +1081,7 @@ public static function saveSettings(array &$config_vars): void $settings_defs = Config::getSettingsDefs(); foreach ($settings_defs as $var => $def) { - if (!is_string($var)) { + if (!\is_string($var)) { continue; } @@ -1089,7 +1089,7 @@ public static function saveSettings(array &$config_vars): void $config_passwords[] = $var; } else { // Special handling if multiple types are allowed. - if (is_array($def['type'])) { + if (\is_array($def['type'])) { // Obviously, we don't need null here. $def['type'] = array_filter( $def['type'], @@ -1098,7 +1098,7 @@ function ($type) { }, ); - $type = count($def['type']) == 1 ? reset($def['type']) : 'multiple'; + $type = \count($def['type']) == 1 ? reset($def['type']) : 'multiple'; } else { $type = $def['type']; } @@ -1115,7 +1115,7 @@ function ($type) { case 'integer': // Some things saved as integers are presented as booleans foreach ($config_vars as $config_var) { - if (is_array($config_var) && $config_var[0] == $var) { + if (\is_array($config_var) && $config_var[0] == $var) { if ($config_var[3] == 'check') { $config_bools[] = $var; break 2; @@ -1141,7 +1141,7 @@ function ($type) { // Figure out which config vars we're saving here... foreach ($config_vars as $config_var) { - if (!is_array($config_var) || $config_var[2] != 'file') { + if (!\is_array($config_var) || $config_var[2] != 'file') { continue; } @@ -1164,15 +1164,15 @@ function ($type) { } } - if (!in_array($var_name, $config_bools) && !isset($_POST[$var_name])) { + if (!\in_array($var_name, $config_bools) && !isset($_POST[$var_name])) { continue; } - if (in_array($var_name, $config_passwords)) { + if (\in_array($var_name, $config_passwords)) { if (isset($_POST[$var_name][1]) && $_POST[$var_name][0] == $_POST[$var_name][1]) { $new_settings[$var_name] = $_POST[$var_name][0]; } - } elseif (in_array($var_name, $config_nums)) { + } elseif (\in_array($var_name, $config_nums)) { $new_settings[$var_name] = (int) $_POST[$var_name]; // If no min is specified, assume 0. This is done to avoid having to specify 'min => 0' for all settings where 0 is the min... @@ -1183,7 +1183,7 @@ function ($type) { if (isset($config_var['max'])) { $new_settings[$var_name] = min($config_var['max'], $new_settings[$var_name]); } - } elseif (in_array($var_name, $config_bools)) { + } elseif (\in_array($var_name, $config_bools)) { $new_settings[$var_name] = !empty($_POST[$var_name]); } elseif (isset($config_multis[$var_name])) { $is_acceptable_type = false; @@ -1215,7 +1215,7 @@ function ($type) { foreach ($config_vars as $config_var) { // We just saved the file-based settings, so skip their definitions. - if (!is_array($config_var) || $config_var[2] == 'file') { + if (!\is_array($config_var) || $config_var[2] == 'file') { continue; } @@ -1268,14 +1268,14 @@ public static function saveDBSettings(array &$config_vars): void $setArray[$var[1]] = !empty($_POST[$var[1]]) ? '1' : '0'; } // Select boxes! - elseif ($var[0] == 'select' && in_array($_POST[$var[1]], array_keys($var[2]))) { + elseif ($var[0] == 'select' && \in_array($_POST[$var[1]], array_keys($var[2]))) { $setArray[$var[1]] = $_POST[$var[1]]; } elseif ($var[0] == 'select' && !empty($var['multiple']) && array_intersect($_POST[$var[1]], array_keys($var[2])) != []) { // For security purposes we validate this line by line. $lOptions = []; foreach ($_POST[$var[1]] as $invar) { - if (in_array($invar, array_keys($var[2]))) { + if (\in_array($invar, array_keys($var[2]))) { $lOptions[] = $invar; } } @@ -1338,7 +1338,7 @@ public static function saveDBSettings(array &$config_vars): void } } // Text! - elseif (in_array($var[0], ['text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'])) { + elseif (\in_array($var[0], ['text', 'large_text', 'color', 'date', 'datetime', 'datetime-local', 'email', 'month', 'time'])) { $setArray[$var[1]] = $_POST[$var[1]]; } // Passwords! @@ -1357,7 +1357,7 @@ public static function saveDBSettings(array &$config_vars): void if (!isset($_POST[$var[1] . '_enabledTags'])) { $_POST[$var[1] . '_enabledTags'] = []; - } elseif (!is_array($_POST[$var[1] . '_enabledTags'])) { + } elseif (!\is_array($_POST[$var[1] . '_enabledTags'])) { $_POST[$var[1] . '_enabledTags'] = [$_POST[$var[1] . '_enabledTags']]; } @@ -1393,13 +1393,13 @@ public static function getServerVersions(array $checkFor): array $versions = []; // Is GD available? If it is, we should show version information for it too. - if (in_array('gd', $checkFor) && function_exists('gd_info')) { + if (\in_array('gd', $checkFor) && \function_exists('gd_info')) { $temp = gd_info(); $versions['gd'] = ['title' => Lang::$txt['support_versions_gd'], 'version' => $temp['GD Version']]; } // Why not have a look at ImageMagick? If it's installed, we should show version information for it too. - if (in_array('imagemagick', $checkFor) && class_exists('Imagick')) { + if (\in_array('imagemagick', $checkFor) && class_exists('Imagick')) { $temp = new \Imagick(); $temp2 = $temp->getVersion(); $im_version = $temp2['versionString']; @@ -1412,7 +1412,7 @@ public static function getServerVersions(array $checkFor): array } // Now lets check for the Database. - if (in_array('db_server', $checkFor)) { + if (\in_array('db_server', $checkFor)) { if (!isset(Db::$db_connection) || Db::$db_connection === false) { Lang::load('Errors'); trigger_error(Lang::$txt['get_server_versions_no_database'], E_USER_NOTICE); @@ -1433,7 +1433,7 @@ public static function getServerVersions(array $checkFor): array foreach (CacheApi::detect() as $class_name => $cache_api) { $class_name_txt_key = strtolower($cache_api->getImplementationClassKeyName()); - if (in_array($class_name_txt_key, $checkFor)) { + if (\in_array($class_name_txt_key, $checkFor)) { $versions[$class_name_txt_key] = [ 'title' => Lang::$txt[$class_name_txt_key . '_cache'] ?? $class_name, 'version' => $cache_api->getVersion(), @@ -1441,7 +1441,7 @@ public static function getServerVersions(array $checkFor): array } } - if (in_array('php', $checkFor)) { + if (\in_array('php', $checkFor)) { $versions['php'] = [ 'title' => 'PHP', 'version' => PHP_VERSION, @@ -1449,7 +1449,7 @@ public static function getServerVersions(array $checkFor): array ]; } - if (in_array('server', $checkFor)) { + if (\in_array('server', $checkFor)) { $versions['server'] = [ 'title' => Lang::$txt['support_versions_server'], 'version' => $_SERVER['SERVER_SOFTWARE'], @@ -1746,7 +1746,7 @@ public static function emailAdmins(string $template, array $replacements = [], a // Any additional users we must email this to? if (!empty($additional_recipients)) { foreach ($additional_recipients as $recipient) { - if (in_array($recipient['email'], $emails_sent)) { + if (\in_array($recipient['email'], $emails_sent)) { continue; } @@ -1779,7 +1779,7 @@ public static function adminLogin(string $type = 'admin'): void // Validate what type of session check this is. $types = []; IntegrationHook::call('integrate_validateSession', [&$types]); - $type = in_array($type, $types) || $type == 'moderate' ? $type : 'admin'; + $type = \in_array($type, $types) || $type == 'moderate' ? $type : 'admin'; // They used a wrong password, log it and unset that. if (isset($_POST[$type . '_hash_pass']) || isset($_POST[$type . '_pass'])) { @@ -1878,11 +1878,11 @@ protected function setAdminAreas(): void array_walk_recursive( $this->admin_areas, function (&$value, $key) { - if (in_array($key, ['title', 'label'])) { + if (\in_array($key, ['title', 'label'])) { $value = Lang::$txt[$value] ?? $value; } - if (is_string($value)) { + if (\is_string($value)) { $value = strtr($value, [ '{scripturl}' => Config::$scripturl, '{boardurl}' => Config::$boardurl, @@ -1943,7 +1943,7 @@ function (&$value, $key) { */ protected static function adminLogin_outputPostVars(string $k, string|array $v): string { - if (!is_array($v)) { + if (!\is_array($v)) { return "\n" . ' '"', '<' => '<', '>' => '>']) . '">'; } diff --git a/Sources/Actions/Admin/AntiSpam.php b/Sources/Actions/Admin/AntiSpam.php index 1099b709ed..dbd04b302e 100644 --- a/Sources/Actions/Admin/AntiSpam.php +++ b/Sources/Actions/Admin/AntiSpam.php @@ -153,7 +153,7 @@ public function execute(): void foreach (Utils::$context['qa_languages'] as $lang_id => $dummy) { // If we had some questions for this language before, but don't now, delete everything from that language. - if ((!isset($_POST['question'][$lang_id]) || !is_array($_POST['question'][$lang_id])) && !empty(Utils::$context['qa_by_lang'][$lang_id])) { + if ((!isset($_POST['question'][$lang_id]) || !\is_array($_POST['question'][$lang_id])) && !empty(Utils::$context['qa_by_lang'][$lang_id])) { $changes['delete'] = array_merge($changes['delete'], Utils::$context['qa_by_lang'][$lang_id]); } @@ -188,7 +188,7 @@ public function execute(): void $question = Utils::htmlspecialchars(trim($question)); // Get the answers. Firstly check there actually might be some. - if (!isset($_POST['answer'][$lang_id][$q_id]) || !is_array($_POST['answer'][$lang_id][$q_id])) { + if (!isset($_POST['answer'][$lang_id][$q_id]) || !\is_array($_POST['answer'][$lang_id][$q_id])) { if (isset(Utils::$context['question_answers'][$q_id])) { $changes['delete'][] = $q_id; } @@ -361,7 +361,7 @@ public static function getConfigVars(): array Lang::load('ManageSettings'); // Generate a sample registration image. - Utils::$context['use_graphic_library'] = in_array('gd', get_loaded_extensions()); + Utils::$context['use_graphic_library'] = \in_array('gd', get_loaded_extensions()); $config_vars = [ ['check', 'reg_verification'], diff --git a/Sources/Actions/Admin/Attachments.php b/Sources/Actions/Admin/Attachments.php index 0ba92c8d20..d0aa276e7d 100644 --- a/Sources/Actions/Admin/Attachments.php +++ b/Sources/Actions/Admin/Attachments.php @@ -94,7 +94,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]) ? [$this, self::$subactions[$this->subaction]] : Utils::getCallable(self::$subactions[$this->subaction]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -139,7 +139,7 @@ public function attachmentSettings(): void !empty($_POST['use_subdirectories_for_attachments']) && !empty(Config::$modSettings['attachment_basedirectories']) ) { - if (!is_array(Config::$modSettings['attachment_basedirectories'])) { + if (!\is_array(Config::$modSettings['attachment_basedirectories'])) { Config::$modSettings['attachment_basedirectories'] = Utils::jsonDecode(Config::$modSettings['attachment_basedirectories'], true); } } else { @@ -149,17 +149,17 @@ public function attachmentSettings(): void if ( !empty($_POST['use_subdirectories_for_attachments']) && !empty($_POST['basedirectory_for_attachments']) - && !in_array($_POST['basedirectory_for_attachments'], Config::$modSettings['attachment_basedirectories']) + && !\in_array($_POST['basedirectory_for_attachments'], Config::$modSettings['attachment_basedirectories']) ) { $currentAttachmentUploadDir = Config::$modSettings['currentAttachmentUploadDir']; - if (!in_array($_POST['basedirectory_for_attachments'], Config::$modSettings['attachmentUploadDir'])) { + if (!\in_array($_POST['basedirectory_for_attachments'], Config::$modSettings['attachmentUploadDir'])) { if (!Attachment::automanageCreateDirectory($_POST['basedirectory_for_attachments'])) { $_POST['basedirectory_for_attachments'] = Config::$modSettings['basedirectory_for_attachments']; } } - if (!in_array($_POST['basedirectory_for_attachments'], Config::$modSettings['attachment_basedirectories'])) { + if (!\in_array($_POST['basedirectory_for_attachments'], Config::$modSettings['attachment_basedirectories'])) { Config::$modSettings['attachment_basedirectories'][Config::$modSettings['currentAttachmentUploadDir']] = $_POST['basedirectory_for_attachments']; Config::updateModSettings([ @@ -545,7 +545,7 @@ public function maintain(): void Utils::$context['attachment_current_files'] = Lang::numberFormat((int) $current_dir_files, 0); - Utils::$context['attach_multiple_dirs'] = count($attach_dirs) > 1 ? true : false; + Utils::$context['attach_multiple_dirs'] = \count($attach_dirs) > 1 ? true : false; Utils::$context['attach_dirs'] = $attach_dirs; @@ -810,7 +810,7 @@ public function repair(): void Utils::$context['repair_errors']['missing_thumbnail_parent']++; // If we are repairing remove the file from disk now. - if ($fix_errors && in_array('missing_thumbnail_parent', $to_fix)) { + if ($fix_errors && \in_array('missing_thumbnail_parent', $to_fix)) { $filename = Attachment::getFilePath((int) $row['id_attach']); @unlink($filename); } @@ -823,7 +823,7 @@ public function repair(): void Db::$db->free_result($result); // Do we need to delete what we have? - if ($fix_errors && !empty($to_remove) && in_array('missing_thumbnail_parent', $to_fix)) { + if ($fix_errors && !empty($to_remove) && \in_array('missing_thumbnail_parent', $to_fix)) { Db::$db->query( '', 'DELETE FROM {db_prefix}attachments @@ -887,7 +887,7 @@ public function repair(): void Db::$db->free_result($result); // Do we need to delete what we have? - if ($fix_errors && !empty($to_update) && in_array('parent_missing_thumbnail', $to_fix)) { + if ($fix_errors && !empty($to_update) && \in_array('parent_missing_thumbnail', $to_fix)) { Db::$db->query( '', 'UPDATE {db_prefix}attachments @@ -957,7 +957,7 @@ public function repair(): void $errors_found[] = 'wrong_folder'; // Are we going to fix this now? - if ($fix_errors && in_array('wrong_folder', $to_fix)) { + if ($fix_errors && \in_array('wrong_folder', $to_fix)) { Db::$db->query( '', 'UPDATE {db_prefix}attachments @@ -983,7 +983,7 @@ public function repair(): void $errors_found[] = 'file_size_of_zero'; // Fixing? - if ($fix_errors && in_array('file_size_of_zero', $to_fix)) { + if ($fix_errors && \in_array('file_size_of_zero', $to_fix)) { $to_remove[] = $row['id_attach']; @unlink($filename); } @@ -992,7 +992,7 @@ public function repair(): void $errors_found[] = 'file_wrong_size'; // Fix it here? - if ($fix_errors && in_array('file_wrong_size', $to_fix)) { + if ($fix_errors && \in_array('file_wrong_size', $to_fix)) { Db::$db->query( '', 'UPDATE {db_prefix}attachments @@ -1007,19 +1007,19 @@ public function repair(): void } } - if (in_array('file_missing_on_disk', $errors_found)) { + if (\in_array('file_missing_on_disk', $errors_found)) { $to_fix[] = 'file_missing_on_disk'; } - if (in_array('file_size_of_zero', $errors_found)) { + if (\in_array('file_size_of_zero', $errors_found)) { $to_fix[] = 'file_size_of_zero'; } - if (in_array('file_wrong_size', $errors_found)) { + if (\in_array('file_wrong_size', $errors_found)) { $to_fix[] = 'file_wrong_size'; } - if (in_array('wrong_folder', $errors_found)) { + if (\in_array('wrong_folder', $errors_found)) { $to_fix[] = 'wrong_folder'; } @@ -1093,7 +1093,7 @@ public function repair(): void Utils::$context['repair_errors']['avatar_no_member']++; // If we are repairing remove the file from disk now. - if ($fix_errors && in_array('avatar_no_member', $to_fix)) { + if ($fix_errors && \in_array('avatar_no_member', $to_fix)) { if ($row['attachment_type'] == 1) { $filename = Config::$modSettings['custom_avatar_dir'] . '/' . $row['filename']; } else { @@ -1110,7 +1110,7 @@ public function repair(): void Db::$db->free_result($result); // Do we need to delete what we have? - if ($fix_errors && !empty($to_remove) && in_array('avatar_no_member', $to_fix)) { + if ($fix_errors && !empty($to_remove) && \in_array('avatar_no_member', $to_fix)) { Db::$db->query( '', 'DELETE FROM {db_prefix}attachments @@ -1177,7 +1177,7 @@ public function repair(): void Utils::$context['repair_errors']['attachment_no_msg']++; // If we are repairing remove the file from disk now. - if ($fix_errors && in_array('attachment_no_msg', $to_fix)) { + if ($fix_errors && \in_array('attachment_no_msg', $to_fix)) { $filename = Attachment::getFilePath((int) $row['id_attach']); @unlink($filename); } @@ -1189,7 +1189,7 @@ public function repair(): void Db::$db->free_result($result); // Do we need to delete what we have? - if ($fix_errors && !empty($to_remove) && in_array('attachment_no_msg', $to_fix)) { + if ($fix_errors && !empty($to_remove) && \in_array('attachment_no_msg', $to_fix)) { Db::$db->query( '', 'DELETE FROM {db_prefix}attachments @@ -1223,7 +1223,7 @@ public function repair(): void foreach ($attach_dirs as $attach_dir) { if ($dir = @opendir($attach_dir)) { while ($file = readdir($dir)) { - if (in_array($file, ['.', '..', '.htaccess', 'index.php'])) { + if (\in_array($file, ['.', '..', '.htaccess', 'index.php'])) { continue; } @@ -1252,7 +1252,7 @@ public function repair(): void ); if (Db::$db->num_rows($request) == 0) { - if ($fix_errors && in_array('files_without_attachment', $to_fix)) { + if ($fix_errors && \in_array('files_without_attachment', $to_fix)) { @unlink($attach_dir . '/' . $file); } else { Utils::$context['repair_errors']['files_without_attachment']++; @@ -1262,7 +1262,7 @@ public function repair(): void Db::$db->free_result($request); } } else { - if ($fix_errors && in_array('files_without_attachment', $to_fix)) { + if ($fix_errors && \in_array('files_without_attachment', $to_fix)) { @unlink($attach_dir . '/' . $file); } else { Utils::$context['repair_errors']['files_without_attachment']++; @@ -1305,7 +1305,7 @@ public function paths(): void // Since this needs to be done eventually. if (!isset(Config::$modSettings['attachment_basedirectories'])) { Config::$modSettings['attachment_basedirectories'] = []; - } elseif (!is_array(Config::$modSettings['attachment_basedirectories'])) { + } elseif (!\is_array(Config::$modSettings['attachment_basedirectories'])) { Config::$modSettings['attachment_basedirectories'] = Utils::jsonDecode(Config::$modSettings['attachment_basedirectories'], true); } @@ -1330,7 +1330,7 @@ public function paths(): void // Sorry, these dirs are NOT valid $invalid_dirs = [Config::$boarddir, Theme::$current->settings['default_theme_dir'], Config::$sourcedir]; - if (in_array($path, $invalid_dirs)) { + if (\in_array($path, $invalid_dirs)) { $errors[] = $path . ': ' . Lang::$txt['attach_dir_invalid']; continue; @@ -1338,9 +1338,9 @@ public function paths(): void // Hmm, a new path maybe? // Don't allow empty paths - if (!array_key_exists($id, Config::$modSettings['attachmentUploadDir']) && !empty($path)) { + if (!\array_key_exists($id, Config::$modSettings['attachmentUploadDir']) && !empty($path)) { // or is it? - if (in_array($path, Config::$modSettings['attachmentUploadDir']) || in_array(Config::$boarddir . DIRECTORY_SEPARATOR . $path, Config::$modSettings['attachmentUploadDir'])) { + if (\in_array($path, Config::$modSettings['attachmentUploadDir']) || \in_array(Config::$boarddir . DIRECTORY_SEPARATOR . $path, Config::$modSettings['attachmentUploadDir'])) { $errors[] = $path . ': ' . Lang::$txt['attach_dir_duplicate_msg']; continue; @@ -1372,7 +1372,7 @@ public function paths(): void } // Update the base directory path - if (!empty(Config::$modSettings['attachment_basedirectories']) && array_key_exists($id, Config::$modSettings['attachment_basedirectories'])) { + if (!empty(Config::$modSettings['attachment_basedirectories']) && \array_key_exists($id, Config::$modSettings['attachment_basedirectories'])) { $base = Config::$modSettings['basedirectory_for_attachments'] == Config::$modSettings['attachmentUploadDir'][$id] ? $path : Config::$modSettings['basedirectory_for_attachments']; Config::$modSettings['attachment_basedirectories'][$id] = $path; @@ -1468,7 +1468,7 @@ public function paths(): void // Find the current directory if there's no value carried, if (empty($_POST['current_dir']) || empty($new_dirs[$_POST['current_dir']])) { - if (array_key_exists(Config::$modSettings['currentAttachmentUploadDir'], Config::$modSettings['attachmentUploadDir'])) { + if (\array_key_exists(Config::$modSettings['currentAttachmentUploadDir'], Config::$modSettings['attachmentUploadDir'])) { $_POST['current_dir'] = Config::$modSettings['currentAttachmentUploadDir']; } else { $_POST['current_dir'] = max(array_keys(Config::$modSettings['attachmentUploadDir'])); @@ -1484,7 +1484,7 @@ public function paths(): void || isset(Config::$modSettings['last_attachments_directory'][0]) ) ) { - if (!is_array(Config::$modSettings['last_attachments_directory'])) { + if (!\is_array(Config::$modSettings['last_attachments_directory'])) { Config::$modSettings['last_attachments_directory'] = Utils::jsonDecode(Config::$modSettings['last_attachments_directory'], true); } @@ -1523,7 +1523,7 @@ public function paths(): void } // Going back to just one path? - if (count($new_dirs) == 1) { + if (\count($new_dirs) == 1) { // We might need to reset the paths. This loop will just loop through once. foreach ($new_dirs as $id => $dir) { if ($id != 1) { @@ -1616,7 +1616,7 @@ public function paths(): void $current_dir = Config::$modSettings['currentAttachmentUploadDir']; - if (!in_array($_POST['new_base_dir'], Config::$modSettings['attachmentUploadDir'])) { + if (!\in_array($_POST['new_base_dir'], Config::$modSettings['attachmentUploadDir'])) { if (!Attachment::automanageCreateDirectory($_POST['new_base_dir'])) { $errors[] = $_POST['new_base_dir'] . ': ' . Lang::$txt['attach_dir_base_no_create']; } @@ -1624,7 +1624,7 @@ public function paths(): void Config::$modSettings['currentAttachmentUploadDir'] = array_search($_POST['new_base_dir'], Config::$modSettings['attachmentUploadDir']); - if (!in_array($_POST['new_base_dir'], Config::$modSettings['attachment_basedirectories'])) { + if (!\in_array($_POST['new_base_dir'], Config::$modSettings['attachment_basedirectories'])) { Config::$modSettings['attachment_basedirectories'][Config::$modSettings['currentAttachmentUploadDir']] = $_POST['new_base_dir']; } @@ -1649,7 +1649,7 @@ public function paths(): void } if (isset($_SESSION['errors'])) { - if (is_array($_SESSION['errors'])) { + if (\is_array($_SESSION['errors'])) { $errors = []; if (!empty($_SESSION['errors']['dir'])) { @@ -2109,7 +2109,7 @@ public static function attachConfigVars(): array if ( empty(Config::$modSettings['attachment_basedirectories']) && Config::$modSettings['currentAttachmentUploadDir'] == 1 - && count(Config::$modSettings['attachmentUploadDir']) == 1 + && \count(Config::$modSettings['attachmentUploadDir']) == 1 ) { Lang::$txt['attachmentUploadDir_path'] = Config::$modSettings['attachmentUploadDir'][1]; } @@ -2130,8 +2130,8 @@ public static function attachConfigVars(): array $testImg = get_extension_funcs('gd') || class_exists('Imagick'); // See if we can find if the server is set up to support the attachment limits - $post_max_kb = floor(Sapi::memoryReturnBytes(ini_get('post_max_size')) / 1024); - $file_max_kb = floor(Sapi::memoryReturnBytes(ini_get('upload_max_filesize')) / 1024); + $post_max_kb = floor(Sapi::memoryReturnBytes(\ini_get('post_max_size')) / 1024); + $file_max_kb = floor(Sapi::memoryReturnBytes(\ini_get('upload_max_filesize')) / 1024); $config_vars = [ ['title', 'attachment_manager_settings'], @@ -2143,7 +2143,7 @@ public static function attachConfigVars(): array ['select', 'automanage_attachments', [0 => Lang::$txt['attachments_normal'], 1 => Lang::$txt['attachments_auto_space'], 2 => Lang::$txt['attachments_auto_years'], 3 => Lang::$txt['attachments_auto_months'], 4 => Lang::$txt['attachments_auto_16']]], ['check', 'use_subdirectories_for_attachments', 'subtext' => Lang::$txt['use_subdirectories_for_attachments_note']], (empty(Config::$modSettings['attachment_basedirectories']) ? ['text', 'basedirectory_for_attachments', 40] : ['var_message', 'basedirectory_for_attachments', 'message' => 'basedirectory_for_attachments_path', 'invalid' => empty(Utils::$context['valid_basedirectory']), 'text_label' => (!empty(Utils::$context['valid_basedirectory']) ? Lang::$txt['basedirectory_for_attachments_current'] : Lang::getTxt('basedirectory_for_attachments_warning', ['scripturl' => Config::$scripturl]))]), - empty(Config::$modSettings['attachment_basedirectories']) && Config::$modSettings['currentAttachmentUploadDir'] == 1 && count(Config::$modSettings['attachmentUploadDir']) == 1 ? ['var_message', 'attachmentUploadDir_path', 'subtext' => Lang::$txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !Utils::$context['valid_upload_dir'], 'text_label' => Lang::$txt['attachmentUploadDir'], 'message' => 'attachmentUploadDir_path'] : ['var_message', 'attach_current_directory', 'subtext' => Lang::$txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty(Utils::$context['valid_upload_dir']), 'text_label' => (!empty(Utils::$context['valid_upload_dir']) ? Lang::$txt['attach_current_dir'] : Lang::getTxt('attach_current_dir_warning', ['scripturl' => Config::$scripturl]))], + empty(Config::$modSettings['attachment_basedirectories']) && Config::$modSettings['currentAttachmentUploadDir'] == 1 && \count(Config::$modSettings['attachmentUploadDir']) == 1 ? ['var_message', 'attachmentUploadDir_path', 'subtext' => Lang::$txt['attachmentUploadDir_multiple_configure'], 40, 'invalid' => !Utils::$context['valid_upload_dir'], 'text_label' => Lang::$txt['attachmentUploadDir'], 'message' => 'attachmentUploadDir_path'] : ['var_message', 'attach_current_directory', 'subtext' => Lang::$txt['attachmentUploadDir_multiple_configure'], 'message' => 'attachment_path', 'invalid' => empty(Utils::$context['valid_upload_dir']), 'text_label' => (!empty(Utils::$context['valid_upload_dir']) ? Lang::$txt['attach_current_dir'] : Lang::getTxt('attach_current_dir_warning', ['scripturl' => Config::$scripturl]))], ['int', 'attachmentDirFileLimit', 'subtext' => Lang::$txt['zero_for_no_limit'], 6], ['int', 'attachmentDirSizeLimit', 'subtext' => Lang::$txt['zero_for_no_limit'], 6, 'postinput' => Lang::$txt['kilobyte']], ['check', 'dont_show_attach_under_post', 'subtext' => Lang::$txt['dont_show_attach_under_post_sub']], @@ -2424,7 +2424,7 @@ public static function list_getAttachDirs(): array $is_base_dir = false; if (!empty(Config::$modSettings['attachment_basedirectories'])) { - $is_base_dir = in_array($dir, Config::$modSettings['attachment_basedirectories']); + $is_base_dir = \in_array($dir, Config::$modSettings['attachment_basedirectories']); // Count any sub-folders. foreach (Config::$modSettings['attachmentUploadDir'] as $sid => $sub) { @@ -2541,7 +2541,7 @@ public static function attachDirStatus(string $dir, int $expected_files): array while ($file = $dir_handle->read()) { // Now do we have a real file here? - if (in_array($file, ['.', '..', '.htaccess', 'index.php'])) { + if (\in_array($file, ['.', '..', '.htaccess', 'index.php'])) { continue; } diff --git a/Sources/Actions/Admin/Bans.php b/Sources/Actions/Admin/Bans.php index 794a2d675f..48014405c0 100644 --- a/Sources/Actions/Admin/Bans.php +++ b/Sources/Actions/Admin/Bans.php @@ -90,7 +90,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]) ? [$this, self::$subactions[$this->subaction]] : Utils::getCallable(self::$subactions[$this->subaction]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -105,7 +105,7 @@ public function execute(): void public function list(): void { // User pressed the 'remove selection button'. - if (!empty($_POST['removeBans']) && !empty($_POST['remove']) && is_array($_POST['remove'])) { + if (!empty($_POST['removeBans']) && !empty($_POST['remove']) && \is_array($_POST['remove'])) { User::$me->checkSession(); // Make sure every entry is a proper integer. @@ -364,7 +364,7 @@ public function edit(): void ], 'data' => [ 'function' => function ($ban_item) { - if (in_array($ban_item['type'], ['ip', 'hostname', 'email'])) { + if (\in_array($ban_item['type'], ['ip', 'hostname', 'email'])) { return '' . Lang::$txt[$ban_item['type']] . ': ' . $ban_item[$ban_item['type']]; } @@ -584,7 +584,7 @@ public function edit(): void */ public function browseTriggers(): void { - if (!empty($_POST['remove_triggers']) && !empty($_POST['remove']) && is_array($_POST['remove'])) { + if (!empty($_POST['remove_triggers']) && !empty($_POST['remove']) && \is_array($_POST['remove'])) { User::$me->checkSession(); self::removeBanTriggers($_POST['remove']); @@ -598,7 +598,7 @@ public function browseTriggers(): void Config::updateModSettings(['banLastUpdated' => time()]); } - Utils::$context['selected_entity'] = isset($_REQUEST['entity']) && in_array($_REQUEST['entity'], ['ip', 'hostname', 'email', 'member']) ? $_REQUEST['entity'] : 'ip'; + Utils::$context['selected_entity'] = isset($_REQUEST['entity']) && \in_array($_REQUEST['entity'], ['ip', 'hostname', 'email', 'member']) ? $_REQUEST['entity'] : 'ip'; $listOptions = [ 'id' => 'ban_trigger_list', @@ -1086,7 +1086,7 @@ public static function updateBanMembers(): void ); while ($row = Db::$db->fetch_assoc($request)) { - if (!in_array($row['id_member'], $allMembers)) { + if (!\in_array($row['id_member'], $allMembers)) { $allMembers[] = $row['id_member']; // Do they need an update? @@ -1129,7 +1129,7 @@ public static function updateBanMembers(): void while ($row = Db::$db->fetch_assoc($request)) { // Don't do this twice! - if (!in_array($row['id_member'], $allMembers)) { + if (!\in_array($row['id_member'], $allMembers)) { $updates[$row['new_value']][] = $row['id_member']; $allMembers[] = $row['id_member']; } @@ -1510,7 +1510,7 @@ protected function __construct() } // Mark the appropriate menu entry as selected - if (array_key_exists($this->subaction, Menu::$loaded['admin']->tab_data['tabs'])) { + if (\array_key_exists($this->subaction, Menu::$loaded['admin']->tab_data['tabs'])) { Menu::$loaded['admin']->tab_data['tabs'][$this->subaction]['is_selected'] = true; } @@ -1535,7 +1535,7 @@ protected function edit2(): void $ban_info['is_new'] = empty($ban_info['id']); $ban_info['expire_date'] = !empty($_POST['expire_date']) ? (int) $_POST['expire_date'] : 0; $ban_info['expiration'] = [ - 'status' => isset($_POST['expiration']) && in_array($_POST['expiration'], ['never', 'one_day', 'expired']) ? $_POST['expiration'] : 'never', + 'status' => isset($_POST['expiration']) && \in_array($_POST['expiration'], ['never', 'one_day', 'expired']) ? $_POST['expiration'] : 'never', 'days' => $ban_info['expire_date'], ]; $ban_info['db_expiration'] = $ban_info['expiration']['status'] == 'never' ? 'NULL' : ($ban_info['expiration']['status'] == 'one_day' ? time() + 24 * 60 * 60 * $ban_info['expire_date'] : 0); @@ -1636,8 +1636,8 @@ protected function banLoadAdditionalIPs(int $member_id): array $return = []; foreach ($search_list as $key => $callable) { - if (is_callable($callable)) { - $return[$key] = call_user_func($callable, $member_id); + if (\is_callable($callable)) { + $return[$key] = \call_user_func($callable, $member_id); } } @@ -1728,7 +1728,7 @@ protected function saveTriggers(array $suggestions, int $ban_group, int $member ]; foreach ($suggestions as $key => $value) { - if (is_array($value)) { + if (\is_array($value)) { $triggers[$key] = $value; } else { $triggers[$value] = !empty($_POST[$value]) ? $_POST[$value] : ''; @@ -1765,7 +1765,7 @@ protected function saveTriggers(array $suggestions, int $ban_group, int $member */ protected function removeBanGroups(array $group_ids): bool { - if (!is_array($group_ids)) { + if (!\is_array($group_ids)) { $group_ids = [$group_ids]; } @@ -1942,7 +1942,7 @@ protected function validateTriggers(array &$triggers): array } else { $ban_triggers['user']['id_member'] = $value; } - } elseif (in_array($key, ['ips_in_messages', 'ips_in_errors'])) { + } elseif (\in_array($key, ['ips_in_messages', 'ips_in_errors'])) { // Special case, those two are arrays themselves $values = array_unique($value); unset($value); @@ -1974,7 +1974,7 @@ protected function validateTriggers(array &$triggers): array Utils::$context['ban_errors'][] = 'no_bantype_selected'; } - if (isset($value) && !is_array($value)) { + if (isset($value) && !\is_array($value)) { $log_info[] = [ 'value' => $value, 'bantype' => $key, @@ -2069,7 +2069,7 @@ protected function addTriggers(int $group_id = 0, array $triggers = [], array $l foreach ($triggers as $key => $trigger) { // Exceptions, exceptions, exceptions...always exceptions... :P - if (in_array($key, ['ips_in_messages', 'ips_in_errors'])) { + if (\in_array($key, ['ips_in_messages', 'ips_in_errors'])) { foreach ($trigger as $real_trigger) { $insertTriggers[] = array_merge($values, $real_trigger); } @@ -2384,7 +2384,7 @@ protected static function removeBanTriggers(array|int $items_ids = [], ?int $gro return false; } - if (!is_array($items_ids)) { + if (!\is_array($items_ids)) { $items_ids = [$items_ids]; } diff --git a/Sources/Actions/Admin/Boards.php b/Sources/Actions/Admin/Boards.php index 40c71fffcf..b37a4fcc58 100644 --- a/Sources/Actions/Admin/Boards.php +++ b/Sources/Actions/Admin/Boards.php @@ -99,7 +99,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction][0]) ? [$this, self::$subactions[$this->subaction][0]] : Utils::getCallable(self::$subactions[$this->subaction][0]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -115,7 +115,7 @@ public function main(): void { Theme::loadTemplate('ManageBoards'); - if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'move' && in_array($_REQUEST['move_to'], ['child', 'before', 'after', 'top'])) { + if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'move' && \in_array($_REQUEST['move_to'], ['child', 'before', 'after', 'top'])) { User::$me->checkSession('get'); SecurityToken::validate('admin-bm-' . (int) $_REQUEST['src_board'], 'request'); @@ -479,8 +479,8 @@ public function editBoard(): void // Load all membergroups except admin and moderator. foreach (Group::loadSimple(Group::LOAD_BOTH, [Group::ADMIN, Group::MOD]) as $group) { - $group->allow = in_array($group->id, $curBoard['member_groups']); - $group->deny = in_array($group->id, $curBoard['deny_groups']); + $group->allow = \in_array($group->id, $curBoard['member_groups']); + $group->deny = \in_array($group->id, $curBoard['deny_groups']); $group->name = $group->id === Group::GUEST ? Lang::$txt['parent_guests_only'] : ($group->id === Group::REGULAR ? Lang::$txt['parent_members_only'] : $group->name); @@ -557,7 +557,7 @@ public function editBoard(): void Utils::$context['board']->moderator_list = empty(Utils::$context['board']->moderators) ? '' : '"' . implode('", "', Utils::$context['board']->moderators) . '"'; if (!empty(Utils::$context['board']->moderators)) { - list(Utils::$context['board']->last_moderator_id) = array_slice(array_keys(Utils::$context['board']->moderators), -1); + list(Utils::$context['board']->last_moderator_id) = \array_slice(array_keys(Utils::$context['board']->moderators), -1); } // Get all the groups assigned as moderators. @@ -581,7 +581,7 @@ public function editBoard(): void Utils::$context['board']->moderator_groups_list = empty(Utils::$context['board']->moderator_groups) ? '' : '"' . implode('", &qout;', Utils::$context['board']->moderator_groups) . '"'; if (!empty(Utils::$context['board']->moderator_groups)) { - list(Utils::$context['board']->last_moderator_group_id) = array_slice(array_keys(Utils::$context['board']->moderator_groups), -1); + list(Utils::$context['board']->last_moderator_group_id) = \array_slice(array_keys(Utils::$context['board']->moderator_groups), -1); } // Get all the themes... @@ -646,7 +646,7 @@ public function editBoard2(): void } // Change the boardorder of this board? elseif (!empty($_POST['placement']) && !empty($_POST['board_order'])) { - if (!in_array($_POST['placement'], ['before', 'after', 'child'])) { + if (!\in_array($_POST['placement'], ['before', 'after', 'child'])) { ErrorHandler::fatalLang('mangled_post', false); } @@ -671,7 +671,7 @@ public function editBoard2(): void } } - if (strlen(implode(',', $boardOptions['access_groups'])) > 255 || strlen(implode(',', $boardOptions['deny_groups'])) > 255) { + if (\strlen(implode(',', $boardOptions['access_groups'])) > 255 || \strlen(implode(',', $boardOptions['deny_groups'])) > 255) { ErrorHandler::fatalLang('too_many_groups', false); } @@ -681,7 +681,7 @@ public function editBoard2(): void $boardOptions['moderator_string'] = $_POST['moderators']; - if (isset($_POST['moderator_list']) && is_array($_POST['moderator_list'])) { + if (isset($_POST['moderator_list']) && \is_array($_POST['moderator_list'])) { $moderators = []; foreach ($_POST['moderator_list'] as $moderator) { @@ -693,7 +693,7 @@ public function editBoard2(): void $boardOptions['moderator_group_string'] = $_POST['moderator_groups']; - if (isset($_POST['moderator_group_list']) && is_array($_POST['moderator_group_list'])) { + if (isset($_POST['moderator_group_list']) && \is_array($_POST['moderator_group_list'])) { $moderator_groups = []; foreach ($_POST['moderator_group_list'] as $moderator_group) { diff --git a/Sources/Actions/Admin/Calendar.php b/Sources/Actions/Admin/Calendar.php index bca716bf96..593213acfb 100644 --- a/Sources/Actions/Admin/Calendar.php +++ b/Sources/Actions/Admin/Calendar.php @@ -91,7 +91,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]) ? [$this, self::$subactions[$this->subaction]] : Utils::getCallable(self::$subactions[$this->subaction]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -294,7 +294,7 @@ public function edit(): void Utils::$context['event']->selected_occurrence->fixTimezone(); Theme::loadTemplate('EventEditor'); - Theme::addJavaScriptVar('monthly_byday_items', count(Utils::$context['event']->byday_items) - 1); + Theme::addJavaScriptVar('monthly_byday_items', \count(Utils::$context['event']->byday_items) - 1); Theme::loadJavaScriptFile('event.js', ['defer' => true], 'smf_event'); } @@ -420,7 +420,7 @@ public function import(): void 'value' => Utils::$context['calendar_subscriptions'], ], 'get_count' => [ - 'value' => count(Utils::$context['calendar_subscriptions']), + 'value' => \count(Utils::$context['calendar_subscriptions']), ], 'no_items_label' => Lang::$txt['none'], 'columns' => [ diff --git a/Sources/Actions/Admin/ErrorLog.php b/Sources/Actions/Admin/ErrorLog.php index f8b8684095..8788d5a510 100644 --- a/Sources/Actions/Admin/ErrorLog.php +++ b/Sources/Actions/Admin/ErrorLog.php @@ -137,7 +137,7 @@ public function view(): void $this->filter = [ 'variable' => $_GET['filter'], 'value' => [ - 'sql' => in_array($_GET['filter'], ['message', 'url', 'file']) ? base64_decode(strtr($_GET['value'], [' ' => '+'])) : Db::$db->escape_wildcard_string($_GET['value']), + 'sql' => \in_array($_GET['filter'], ['message', 'url', 'file']) ? base64_decode(strtr($_GET['value'], [' ' => '+'])) : Db::$db->escape_wildcard_string($_GET['value']), ], 'href' => ';filter=' . $_GET['filter'] . ';value=' . urlencode($_GET['value']), 'entity' => $this->filters[$_GET['filter']]['txt'], @@ -277,7 +277,7 @@ public function view(): void LIMIT {int:members}', [ 'member_list' => $members, - 'members' => count($members), + 'members' => \count($members), ], ); @@ -435,7 +435,7 @@ public function viewFile(): void // We don't want to slice off too many so lets make sure we stop at the last one $max = min($max, max(array_keys($file_data))); - $file_data = array_slice($file_data, $min - 1, (int) ($max - $min)); + $file_data = \array_slice($file_data, $min - 1, (int) ($max - $min)); Utils::$context['file_data'] = [ 'contents' => $file_data, diff --git a/Sources/Actions/Admin/Features.php b/Sources/Actions/Admin/Features.php index 4c6329c0c0..91c0d038e5 100644 --- a/Sources/Actions/Admin/Features.php +++ b/Sources/Actions/Admin/Features.php @@ -96,7 +96,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]) ? [$this, self::$subactions[$this->subaction]] : Utils::getCallable(self::$subactions[$this->subaction]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -208,13 +208,13 @@ public function bbc(): void if (!isset($_POST['disabledBBC_enabledTags'])) { $_POST['disabledBBC_enabledTags'] = []; - } elseif (!is_array($_POST['disabledBBC_enabledTags'])) { + } elseif (!\is_array($_POST['disabledBBC_enabledTags'])) { $_POST['disabledBBC_enabledTags'] = [$_POST['disabledBBC_enabledTags']]; } if (!isset($_POST['legacyBBC_enabledTags'])) { $_POST['legacyBBC_enabledTags'] = []; - } elseif (!is_array($_POST['legacyBBC_enabledTags'])) { + } elseif (!\is_array($_POST['legacyBBC_enabledTags'])) { $_POST['legacyBBC_enabledTags'] = [$_POST['legacyBBC_enabledTags']]; } @@ -222,7 +222,7 @@ public function bbc(): void // Enable all children if parent is enabled foreach ($bbcTagsChildren as $tag => $children) { - if (in_array($tag, $_POST['disabledBBC_enabledTags'])) { + if (\in_array($tag, $_POST['disabledBBC_enabledTags'])) { $_POST['disabledBBC_enabledTags'] = array_merge($_POST['disabledBBC_enabledTags'], $children); } } @@ -350,7 +350,7 @@ public function signature(): void if (!empty($sig_limits[2])) { $count = 0; - for ($i = 0; $i < strlen($sig); $i++) { + for ($i = 0; $i < \strlen($sig); $i++) { if ($sig[$i] == "\n") { $count++; @@ -469,7 +469,7 @@ public function signature(): void if (($width == -1 && $sig_limits[5]) || ($height == -1 && $sig_limits[6])) { $sizes = Image::getSizeExternal($matches[7][$key]); - if (is_array($sizes)) { + if (\is_array($sizes)) { // Too wide? if ($sizes[0] > $sig_limits[5] && $sig_limits[5]) { $width = $sig_limits[5]; @@ -587,7 +587,7 @@ public function signature(): void if (!isset($_POST['signature_bbc_enabledTags'])) { $_POST['signature_bbc_enabledTags'] = []; - } elseif (!is_array($_POST['signature_bbc_enabledTags'])) { + } elseif (!\is_array($_POST['signature_bbc_enabledTags'])) { $_POST['signature_bbc_enabledTags'] = [$_POST['signature_bbc_enabledTags']]; } @@ -673,7 +673,7 @@ public function profile(): void if (!empty($_POST['reg'])) { foreach ($_POST['reg'] as $value) { - if (in_array($value, $standard_fields) && !isset($disable_fields[$value])) { + if (\in_array($value, $standard_fields) && !isset($disable_fields[$value])) { $reg_fields[] = $value; } } @@ -968,7 +968,7 @@ public function profileEdit(): void 'bbc' => $row['bbc'] ? true : false, 'default_check' => $row['field_type'] == 'check' && $row['default_value'] ? true : false, 'default_select' => $row['field_type'] == 'select' || $row['field_type'] == 'radio' ? $row['default_value'] : '', - 'options' => strlen($row['field_options']) > 1 ? explode(',', $row['field_options']) : ['', '', ''], + 'options' => \strlen($row['field_options']) > 1 ? explode(',', $row['field_options']) : ['', '', ''], 'active' => $row['active'], 'private' => $row['private'], 'can_search' => $row['can_search'], @@ -1011,7 +1011,7 @@ public function profileEdit(): void } // Are we moving it? - if (Utils::$context['fid'] && isset($_GET['move']) && in_array(Utils::htmlspecialchars($_GET['move']), $move_to)) { + if (Utils::$context['fid'] && isset($_GET['move']) && \in_array(Utils::htmlspecialchars($_GET['move']), $move_to)) { $fields = []; $new_sort = []; @@ -1031,16 +1031,16 @@ public function profileEdit(): void $idx = array_search(Utils::$context['fid'], $fields); - if ($_GET['move'] == 'down' && count($fields) - 1 > $idx) { - $new_sort = array_slice($fields, 0, $idx, true); + if ($_GET['move'] == 'down' && \count($fields) - 1 > $idx) { + $new_sort = \array_slice($fields, 0, $idx, true); $new_sort[] = $fields[$idx + 1]; $new_sort[] = $fields[$idx]; - $new_sort += array_slice($fields, $idx + 2, count($fields), true); - } elseif (Utils::$context['fid'] > 0 and $idx < count($fields)) { - $new_sort = array_slice($fields, 0, ($idx - 1), true); + $new_sort += \array_slice($fields, $idx + 2, \count($fields), true); + } elseif (Utils::$context['fid'] > 0 and $idx < \count($fields)) { + $new_sort = \array_slice($fields, 0, ($idx - 1), true); $new_sort[] = $fields[$idx]; $new_sort[] = $fields[$idx - 1]; - $new_sort += array_slice($fields, ($idx + 1), count($fields), true); + $new_sort += \array_slice($fields, ($idx + 1), \count($fields), true); } else { // @todo implement an error handler Utils::redirectexit('action=admin;area=featuresettings;sa=profile'); @@ -1166,7 +1166,7 @@ public function profileEdit(): void $i = 0; - while (in_array($col_name, $current_fields)) { + while (\in_array($col_name, $current_fields)) { // First try appending an integer to the supplied name. if ($i <= 9) { $col_name = $initial_col_name . $i; @@ -1226,7 +1226,7 @@ public function profileEdit(): void } // Still exists? - if (in_array($option, $newOptions)) { + if (\in_array($option, $newOptions)) { $takenKeys[] = $k; } } @@ -1234,7 +1234,7 @@ public function profileEdit(): void // Finally - have we renamed it - or is it really gone? foreach ($optionChanges as $k => $option) { // Just been renamed? - if (!in_array($k, $takenKeys) && !empty($newOptions[$k])) { + if (!\in_array($k, $takenKeys) && !empty($newOptions[$k])) { Db::$db->query( '', 'UPDATE {db_prefix}themes @@ -1510,7 +1510,7 @@ public static function basicConfigVars(): array // If admins have set it up as an on-registration thing, they can't set a default value (because it'll never be used) $disabled_fields = isset(Config::$modSettings['disabled_profile_fields']) ? explode(',', Config::$modSettings['disabled_profile_fields']) : []; $reg_fields = isset(Config::$modSettings['registration_fields']) ? explode(',', Config::$modSettings['registration_fields']) : []; - $can_personal_text = !in_array('personal_text', $disabled_fields) && !in_array('personal_text', $reg_fields); + $can_personal_text = !\in_array('personal_text', $disabled_fields) && !\in_array('personal_text', $reg_fields); $config_vars = [ // Big Options... polls, sticky, bbc.... @@ -1757,9 +1757,9 @@ public static function list_getProfileFields(int $start, int $items_per_page, st $list[] = [ 'id' => $field, 'label' => Lang::$txt['standard_profile_field_' . $field] ?? (Lang::$txt[$field] ?? $field), - 'disabled' => in_array($field, $disabled_fields), - 'on_register' => in_array($field, $registration_fields) && !in_array($field, $fields_no_registration), - 'can_show_register' => !in_array($field, $fields_no_registration), + 'disabled' => \in_array($field, $disabled_fields), + 'on_register' => \in_array($field, $registration_fields) && !\in_array($field, $fields_no_registration), + 'can_show_register' => !\in_array($field, $fields_no_registration), ]; } } else { diff --git a/Sources/Actions/Admin/Find.php b/Sources/Actions/Admin/Find.php index 82dc01b803..e877e90cbb 100644 --- a/Sources/Actions/Admin/Find.php +++ b/Sources/Actions/Admin/Find.php @@ -175,7 +175,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]) ? [$this, self::$subactions[$this->subaction]] : Utils::getCallable(self::$subactions[$this->subaction]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } } @@ -229,11 +229,11 @@ public function internal(): void foreach ($this->settings_search as $setting_area) { // Get a list of their variables. - $config_vars = call_user_func($setting_area[0], true); + $config_vars = \call_user_func($setting_area[0], true); foreach ($config_vars as $var) { - if (!empty($var[1]) && !in_array($var[0], ['permissions', 'switch', 'desc'])) { - $search_data['settings'][] = [$var[(isset($var[2]) && in_array($var[2], ['file', 'db'])) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && in_array($var[2], ['file', 'db'])) || isset($var[3]) ? (in_array($var[2], ['file', 'db']) ? $var[1] : $var[3]) : '']; + if (!empty($var[1]) && !\in_array($var[0], ['permissions', 'switch', 'desc'])) { + $search_data['settings'][] = [$var[(isset($var[2]) && \in_array($var[2], ['file', 'db'])) ? 0 : 1], $setting_area[1], 'alttxt' => (isset($var[2]) && \in_array($var[2], ['file', 'db'])) || isset($var[3]) ? (\in_array($var[2], ['file', 'db']) ? $var[1] : $var[3]) : '']; } } } @@ -248,7 +248,7 @@ public function internal(): void foreach ($data as $item) { $found = false; - if (!is_array($item[0])) { + if (!\is_array($item[0])) { $item[0] = [$item[0]]; } diff --git a/Sources/Actions/Admin/Languages.php b/Sources/Actions/Admin/Languages.php index 1a574f4d6c..e4e1599d92 100644 --- a/Sources/Actions/Admin/Languages.php +++ b/Sources/Actions/Admin/Languages.php @@ -84,7 +84,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]) ? [$this, self::$subactions[$this->subaction]] : Utils::getCallable(self::$subactions[$this->subaction]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -362,7 +362,7 @@ public function download(): void // Mark those which are now writable as such. foreach (Utils::$context['files'] as $type => $data) { foreach ($data as $k => $file) { - if (!$file['writable'] && !in_array($file['destination'], Utils::$context['still_not_writable'])) { + if (!$file['writable'] && !\in_array($file['destination'], Utils::$context['still_not_writable'])) { Utils::$context['files'][$type][$k]['writable'] = true; } } @@ -730,7 +730,7 @@ public function editEntries() // Check we have themes with a path and a name - just in case - and add the path. foreach ($themes as $id => $data) { - if (count($data) != 2) { + if (\count($data) != 2) { unset($themes[$id]); } elseif (is_dir($data['theme_dir'] . '/languages')) { $lang_dirs[$id] = $data['theme_dir'] . '/languages'; @@ -930,7 +930,7 @@ function ($val1, $val2) { if (!empty($_POST['edit'])) { foreach ($_POST['edit'] as $k => $v) { - if (is_string($v)) { + if (\is_string($v)) { // Only try to save if 'edit' was specified and if the string has changed if ( $v == 'edit' @@ -949,7 +949,7 @@ function ($val1, $val2) { 'string' => $this->cleanLangString($_POST['entry'][$k], false), ]; } - } elseif (is_array($v)) { + } elseif (\is_array($v)) { foreach ($v as $subk => $subv) { if ( $subv == 'edit' @@ -980,7 +980,7 @@ function ($val1, $val2) { // How many strings will PHP let us edit at once? // Each string needs 3 inputs, and there are 5 others in the form. - Utils::$context['max_inputs'] = floor(ini_get('max_input_vars') / 3) - 5; + Utils::$context['max_inputs'] = floor(\ini_get('max_input_vars') / 3) - 5; // Do we want to override the helptxt for certain types of text variables? $special_groups = [ @@ -995,7 +995,7 @@ function ($val1, $val2) { foreach ($allows_add_remove[$file_id]['add'] as $var_group) { $group = !empty($special_groups[$file_id][$var_group]) ? $special_groups[$file_id][$var_group] : $var_group; - if (in_array($var_group, $allows_add_remove[$file_id]['add'])) { + if (\in_array($var_group, $allows_add_remove[$file_id]['add'])) { Utils::$context['can_add_lang_entry'][$group] = true; } } @@ -1018,7 +1018,7 @@ function ($val1, $val2) { $entries[$matches[2] . (isset($matches[3]) ? '[' . $matches[3] . ']' : '')] = [ 'type' => $matches[1], 'group' => !empty($special_groups[$file_id][$matches[1]]) ? $special_groups[$file_id][$matches[1]] : $matches[1], - 'can_remove' => isset($allows_add_remove[$file_id]['remove']) && in_array($matches[1], $allows_add_remove[$file_id]['remove']), + 'can_remove' => isset($allows_add_remove[$file_id]['remove']) && \in_array($matches[1], $allows_add_remove[$file_id]['remove']), 'key' => $matches[2], 'subkey' => $matches[3], 'full' => $matches[0], @@ -1034,7 +1034,7 @@ function ($val1, $val2) { foreach ($entries as $entryKey => $entryValue) { // Ignore some things we set separately. - if (in_array($entryKey, array_keys($primary_settings))) { + if (\in_array($entryKey, array_keys($primary_settings))) { continue; } @@ -1136,7 +1136,7 @@ function ($val1, $val2) { $save_cache['enabled'] = true; } // Should we remove this one? - elseif (isset($remove_strings[$entryKey]) && in_array($subKey, $remove_strings[$entryKey]) && $entryValue['can_remove']) { + elseif (isset($remove_strings[$entryKey]) && \in_array($subKey, $remove_strings[$entryKey]) && $entryValue['can_remove']) { $save_cache['enabled'] = true; } // Just keep this one as it is @@ -1216,7 +1216,7 @@ function ($val1, $val2) { } // Remove this entry only if it is allowed - if (isset($remove_strings[$entryValue['key']]) && in_array($entryValue['subkey'], $remove_strings[$entryValue['key']]) && $entryValue['can_remove']) { + if (isset($remove_strings[$entryValue['key']]) && \in_array($entryValue['subkey'], $remove_strings[$entryValue['key']]) && $entryValue['can_remove']) { $entryValue['entry'] = '\'\''; $final_saves[$entryKey] = [ @@ -1231,7 +1231,7 @@ function ($val1, $val2) { 'key' => $entryValue['key'], 'subkey' => $entryValue['subkey'], 'value' => $editing_string, - 'rows' => strlen($editing_string) / 38 + substr_count($editing_string, "\n") + 1, + 'rows' => \strlen($editing_string) / 38 + substr_count($editing_string, "\n") + 1, 'can_remove' => $entryValue['can_remove'], ]; } @@ -1254,7 +1254,7 @@ function ($val1, $val2) { } // Remove this entry only if it is allowed - if (in_array($entryValue['key'], $remove_strings) && $entryValue['can_remove']) { + if (\in_array($entryValue['key'], $remove_strings) && $entryValue['can_remove']) { $entryValue['entry'] = '\'\''; $final_saves[$entryKey] = [ @@ -1269,7 +1269,7 @@ function ($val1, $val2) { 'key' => $entryValue['key'], 'subkey' => null, 'value' => $editing_string, - 'rows' => (int) (strlen($editing_string) / 38) + substr_count($editing_string, "\n") + 1, + 'rows' => (int) (\strlen($editing_string) / 38) + substr_count($editing_string, "\n") + 1, 'can_remove' => $entryValue['can_remove'], ]; } @@ -1281,7 +1281,7 @@ function ($val1, $val2) { foreach ($add_strings as $string_key => $string_val) { // Adding a normal string - if (isset($string_val['string']) && is_string($string_val['string'])) { + if (isset($string_val['string']) && \is_string($string_val['string'])) { $type = $special_types[$string_val['group']] ?? $string_val['group']; if (empty(Utils::$context['can_add_lang_entry'][$type])) { @@ -1523,7 +1523,7 @@ public static function list_getLanguagesList(): array */ public static function list_getNumLanguages(): int { - return count(Lang::get()); + return \count(Lang::get()); } /** @@ -1659,7 +1659,7 @@ protected function cleanLangString(string $string, bool $to_display = true): str // We'll revert it back to an entity when saving. $string = str_replace(''', "\\'", $string); - for ($i = 0; $i < strlen($string); $i++) { + for ($i = 0; $i < \strlen($string); $i++) { // Handle escapes first. if ($string[$i] == '\\') { // Toggle the escape. @@ -1726,7 +1726,7 @@ protected function cleanLangString(string $string, bool $to_display = true): str $new_string .= '{%' . $matches[1] . '%}'; // We're not going to reparse this. - $i += strlen($matches[1]) - 1; + $i += \strlen($matches[1]) - 1; } continue; @@ -1754,7 +1754,7 @@ protected function cleanLangString(string $string, bool $to_display = true): str // This is for deciding whether to HTML a quote. $in_html = false; - for ($i = 0; $i < strlen($string); $i++) { + for ($i = 0; $i < \strlen($string); $i++) { // We don't do parsed strings apart from for breaks. if ($in_string == 2) { $in_string = 0; @@ -1780,7 +1780,7 @@ protected function cleanLangString(string $string, bool $to_display = true): str } $new_string .= $matches[1]; - $i += strlen($matches[1]) + 3; + $i += \strlen($matches[1]) + 3; $in_string = 0; } diff --git a/Sources/Actions/Admin/Logs.php b/Sources/Actions/Admin/Logs.php index 84af4fc125..308701fb90 100644 --- a/Sources/Actions/Admin/Logs.php +++ b/Sources/Actions/Admin/Logs.php @@ -163,7 +163,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction][1]) ? [$this, self::$subactions[$this->subaction][1]] : Utils::getCallable(self::$subactions[$this->subaction][1]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -253,7 +253,7 @@ function togglePruned() $vals = []; foreach ($config_vars as $config_var) { - if (!is_array($config_var) || !in_array($config_var[1], self::$prune_toggle)) { + if (!\is_array($config_var) || !\in_array($config_var[1], self::$prune_toggle)) { continue; } @@ -285,7 +285,7 @@ function togglePruned() Config::$modSettings[self::$prune_toggle[$key]] = $value; } } else { - $defaults = array_pad([30, 180, 180, 180, 30, 0], count(self::$prune_toggle), 0); + $defaults = array_pad([30, 180, 180, 180, 30, 0], \count(self::$prune_toggle), 0); foreach (array_combine(self::$prune_toggle, $defaults) as $setting => $default) { Config::$modSettings[$setting] = $default; diff --git a/Sources/Actions/Admin/Mail.php b/Sources/Actions/Admin/Mail.php index 98d80447d3..3e98292ca3 100644 --- a/Sources/Actions/Admin/Mail.php +++ b/Sources/Actions/Admin/Mail.php @@ -90,7 +90,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]) ? [$this, self::$subactions[$this->subaction]] : Utils::getCallable(self::$subactions[$this->subaction]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -281,7 +281,7 @@ public function settings(): void $i = 0; foreach (self::$processedBirthdayEmails as $index => $email) { - $is_last = ++$i == count(self::$processedBirthdayEmails); + $is_last = ++$i == \count(self::$processedBirthdayEmails); Utils::$context['settings_insert_above'] .= ' ' . $index . ': { @@ -407,8 +407,8 @@ public static function getConfigVars(): array '', ['select', 'birthday_email', $emails, 'value' => ['subject' => $subject, 'body' => $body], 'javascript' => 'onchange="fetch_birthday_preview()"'], - 'birthday_subject' => ['var_message', 'birthday_subject', 'var_message' => self::$processedBirthdayEmails[empty(Config::$modSettings['birthday_email']) ? 'happy_birthday' : Config::$modSettings['birthday_email']]['subject'], 'disabled' => true, 'size' => strlen($subject) + 3], - 'birthday_body' => ['var_message', 'birthday_body', 'var_message' => nl2br($body), 'disabled' => true, 'size' => ceil(strlen($body) / 25)], + 'birthday_subject' => ['var_message', 'birthday_subject', 'var_message' => self::$processedBirthdayEmails[empty(Config::$modSettings['birthday_email']) ? 'happy_birthday' : Config::$modSettings['birthday_email']]['subject'], 'disabled' => true, 'size' => \strlen($subject) + 3], + 'birthday_body' => ['var_message', 'birthday_body', 'var_message' => nl2br($body), 'disabled' => true, 'size' => ceil(\strlen($body) / 25)], ]; IntegrationHook::call('integrate_modify_mail_settings', [&$config_vars]); diff --git a/Sources/Actions/Admin/Maintenance.php b/Sources/Actions/Admin/Maintenance.php index 563cc06752..a0429134c8 100644 --- a/Sources/Actions/Admin/Maintenance.php +++ b/Sources/Actions/Admin/Maintenance.php @@ -138,7 +138,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]['function']) ? [$this, self::$subactions[$this->subaction]['function']] : Utils::getCallable(self::$subactions[$this->subaction]['function']); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } // Any special activity? @@ -146,7 +146,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction]['activities'][$this->activity]) ? [$this, self::$subactions[$this->subaction]['activities'][$this->activity]] : Utils::getCallable(self::$subactions[$this->subaction]['activities'][$this->activity]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -159,7 +159,7 @@ public function execute(): void */ public function routine(): void { - if (isset($_GET['done']) && in_array($_GET['done'], ['recount', 'rebuild_settings'])) { + if (isset($_GET['done']) && \in_array($_GET['done'], ['recount', 'rebuild_settings'])) { Utils::$context['maintenance_finished'] = Lang::$txt['maintain_' . $_GET['done']]; } } @@ -956,7 +956,7 @@ public function optimize(): void } // If there aren't any tables then I believe that would mean the world has exploded... - Utils::$context['num_tables'] = count($tables); + Utils::$context['num_tables'] = \count($tables); if (Utils::$context['num_tables'] == 0) { ErrorHandler::fatal('You appear to be running SMF in a flat file mode... fantastic!', false); @@ -1004,7 +1004,7 @@ public function optimize(): void // Number of tables, etc... Utils::$context['database_numb_tables'] = Lang::getTxt('database_numb_tables', [Utils::$context['num_tables']]); - Utils::$context['num_tables_optimized'] = count($_SESSION['optimized_tables']); + Utils::$context['num_tables_optimized'] = \count($_SESSION['optimized_tables']); Utils::$context['optimized_tables'] = $_SESSION['optimized_tables']; unset($_SESSION['optimized_tables']); } @@ -1080,7 +1080,7 @@ public function entitiesToUnicode(): void 'smileys', 'themes', ]; - Utils::$context['num_tables'] = count($tables); + Utils::$context['num_tables'] = \count($tables); // Loop through all tables that need converting. for (; Utils::$context['table'] < Utils::$context['num_tables']; Utils::$context['table']++) { @@ -1149,7 +1149,7 @@ public function entitiesToUnicode(): void while ($row = Db::$db->fetch_assoc($request)) { if ($row['Key_name'] === 'PRIMARY') { - if ((empty($primary_key) || $row['Seq_in_index'] == 1) && !in_array(strtolower($row['Column_name']), $columns)) { + if ((empty($primary_key) || $row['Seq_in_index'] == 1) && !\in_array(strtolower($row['Column_name']), $columns)) { $primary_key = $row['Column_name']; } @@ -1379,9 +1379,9 @@ public function changeMsgBodyLength(): void Utils::$context['sub_template'] = 'convert_msgbody'; if (!empty($id_msg_exceeding)) { - if (count($id_msg_exceeding) > 100) { - $query_msg = array_slice($id_msg_exceeding, 0, 100); - Utils::$context['exceeding_messages_morethan'] = Lang::getTxt('exceeding_messages_morethan', [count($id_msg_exceeding) - 100]); + if (\count($id_msg_exceeding) > 100) { + $query_msg = \array_slice($id_msg_exceeding, 0, 100); + Utils::$context['exceeding_messages_morethan'] = Lang::getTxt('exceeding_messages_morethan', [\count($id_msg_exceeding) - 100]); } else { $query_msg = $id_msg_exceeding; } @@ -1464,7 +1464,7 @@ public function purgeInactiveMembers(): void // Need to get all groups then work out which (if any) we avoid. foreach (Group::loadSimple(Group::LOAD_BOTH, [Group::GUEST, Group::MOD]) as $group) { // Avoid this one? - if (!in_array($group->id, $groups)) { + if (!\in_array($group->id, $groups)) { // Post group? if ($group->min_posts != -1) { $where .= ' AND mem.id_post_group != {int:id_post_group_' . $group->id . '}'; @@ -1477,7 +1477,7 @@ public function purgeInactiveMembers(): void } // If we have ungrouped unselected we need to avoid those guys. - if (!in_array(0, $groups)) { + if (!\in_array(0, $groups)) { $where .= ' AND (mem.id_group != 0 OR mem.additional_groups != {string:blank_add_groups})'; $where_vars['blank_add_groups'] = ''; } @@ -1494,7 +1494,7 @@ public function purgeInactiveMembers(): void $members = []; while ($row = Db::$db->fetch_assoc($request)) { - if (!$row['is_mod'] || !in_array(3, $groups)) { + if (!$row['is_mod'] || !\in_array(3, $groups)) { $members[] = $row['id_member']; } } @@ -1856,7 +1856,7 @@ public function pruneDrafts(): void Db::$db->free_result($request); // If we have old drafts, remove them - if (count($drafts) > 0) { + if (\count($drafts) > 0) { Draft::delete($drafts, false); } } @@ -1936,7 +1936,7 @@ function ($hook) use ($current_filter) { 'value' => array_reduce( $filtered_hooks, function ($accumulator, $functions) { - return $accumulator + count($functions); + return $accumulator + \count($functions); }, 0, ), @@ -2134,7 +2134,7 @@ public static function getIntegrationHooksData($start, $per_page, $sort, $filter array_multisort($sort_array, $sort_types[$sort][1], $temp_data); - return array_slice($temp_data, $start, $per_page, true); + return \array_slice($temp_data, $start, $per_page, true); } /** @@ -2356,7 +2356,7 @@ protected function getIntegrationHooks(): array */ protected static function getFileRecursive(string $dirname): array { - return \iterator_to_array( + return iterator_to_array( new \RecursiveIteratorIterator( new \RecursiveCallbackFilterIterator( new \RecursiveDirectoryIterator($dirname, \FilesystemIterator::UNIX_PATHS), diff --git a/Sources/Actions/Admin/Membergroups.php b/Sources/Actions/Admin/Membergroups.php index f344876f38..b78aac028c 100644 --- a/Sources/Actions/Admin/Membergroups.php +++ b/Sources/Actions/Admin/Membergroups.php @@ -89,7 +89,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction][0]) ? [$this, self::$subactions[$this->subaction][0]] : Utils::getCallable(self::$subactions[$this->subaction][0]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -389,7 +389,7 @@ public function add(): void ); while ($row = Db::$db->fetch_assoc($request)) { - if (empty($illegal_permissions) || !in_array($row['permission'], $illegal_permissions)) { + if (empty($illegal_permissions) || !\in_array($row['permission'], $illegal_permissions)) { $inserts[] = [$id_group, $row['permission'], $row['add_deny']]; } } @@ -466,7 +466,7 @@ public function add(): void } // Make sure all boards selected are stored in a proper array. - $accesses = empty($_POST['boardaccess']) || !is_array($_POST['boardaccess']) ? [] : $_POST['boardaccess']; + $accesses = empty($_POST['boardaccess']) || !\is_array($_POST['boardaccess']) ? [] : $_POST['boardaccess']; $changed_boards['allow'] = []; $changed_boards['deny'] = []; @@ -649,7 +649,7 @@ public function edit(): void // People who can manage boards are a bit special. $board_managers = User::groupsAllowedTo('manage_boards', null); - Utils::$context['can_manage_boards'] = in_array($group->id, $board_managers['allowed']); + Utils::$context['can_manage_boards'] = \in_array($group->id, $board_managers['allowed']); // Can this group moderate any boards? Utils::$context['is_moderator_group'] = $group->is_moderator_group; @@ -667,7 +667,7 @@ public function edit(): void $ext = pathinfo(Theme::$current->settings['default_theme_dir'] . '/images/membericons/' . $value, PATHINFO_EXTENSION); // If the extension is not empty, and it is valid. - if (!empty($ext) && in_array($ext, $imageExts)) { + if (!empty($ext) && \in_array($ext, $imageExts)) { Utils::$context['possible_icons'][] = $value; } } @@ -703,7 +703,7 @@ public function edit(): void $group->set([ 'max_messages' => isset($_POST['max_messages']) ? (int) $_POST['max_messages'] : 0, 'min_posts' => isset($_POST['min_posts']) && isset($_POST['group_type']) && $_POST['group_type'] == -1 && $group->id > Group::MOD ? abs($_POST['min_posts']) : ($group->id == Group::NEWBIE ? 0 : -1), - 'icons' => (empty($_POST['icon_count']) || $_POST['icon_count'] < 0 || !in_array($_POST['icon_image'], Utils::$context['possible_icons'])) ? '' : min((int) $_POST['icon_count'], 99) . '#' . $_POST['icon_image'], + 'icons' => (empty($_POST['icon_count']) || $_POST['icon_count'] < 0 || !\in_array($_POST['icon_image'], Utils::$context['possible_icons'])) ? '' : min((int) $_POST['icon_count'], 99) . '#' . $_POST['icon_image'], 'name' => Utils::htmlspecialchars($_POST['group_name']), 'description' => isset($_POST['group_desc']) && ($group->id == Group::ADMIN || (isset($_POST['group_type']) && $_POST['group_type'] != -1)) ? Utils::htmlTrim(Utils::sanitizeChars(Utils::normalize($_POST['group_desc']))) : '', 'type' => !isset($_POST['group_type']) || $_POST['group_type'] < Group::TYPE_PRIVATE || $_POST['group_type'] > Group::TYPE_FREE || ($_POST['group_type'] == Group::TYPE_PROTECTED && !User::$me->allowedTo('admin_forum')) ? Group::TYPE_PRIVATE : (int) $_POST['group_type'], @@ -753,7 +753,7 @@ public function edit(): void $group->save(); // Time to update the boards this membergroup has access to. - $group->updateBoardAccess(empty($_POST['boardaccess']) || !is_array($_POST['boardaccess']) ? [] : $_POST['boardaccess']); + $group->updateBoardAccess(empty($_POST['boardaccess']) || !\is_array($_POST['boardaccess']) ? [] : $_POST['boardaccess']); // Let's check whether our "show group membership" setting is correct. $request = Db::$db->query( @@ -797,7 +797,7 @@ public function edit(): void $group->moderator_list = empty($group->moderators) ? '' : '"' . implode('", "', $group->moderators) . '"'; if (!empty($group->moderators)) { - list($group->last_moderator_id) = array_slice(array_keys($group->moderators), -1); + list($group->last_moderator_id) = \array_slice(array_keys($group->moderators), -1); } Utils::$context['group'] = $group; diff --git a/Sources/Actions/Admin/Members.php b/Sources/Actions/Admin/Members.php index da779fb8f0..51076a86f0 100644 --- a/Sources/Actions/Admin/Members.php +++ b/Sources/Actions/Admin/Members.php @@ -141,7 +141,7 @@ public function execute(): void $call = method_exists($this, self::$subactions[$this->subaction][0]) ? [$this, self::$subactions[$this->subaction][0]] : Utils::getCallable(self::$subactions[$this->subaction][0]); if (!empty($call)) { - call_user_func($call); + \call_user_func($call); } } @@ -282,14 +282,14 @@ public function view(): void } // Make sure numeric values are really numeric. - if (in_array($param_info['type'], ['int', 'age'])) { + if (\in_array($param_info['type'], ['int', 'age'])) { $search_params[$param_name] = (int) $search_params[$param_name]; } // Date values have to match a date format that PHP recognizes. elseif ($param_info['type'] == 'date') { $search_params[$param_name] = strtotime($search_params[$param_name] . ' ' . User::getTimezone()); - if (!is_int($search_params[$param_name])) { + if (!\is_int($search_params[$param_name])) { continue; } } elseif ($param_info['type'] == 'inet') { @@ -314,12 +314,12 @@ public function view(): void $upperlimit = sprintf('%04d-%02d-%02d', $datearray['year'] - $search_params[$param_name], $datearray['mon'], $datearray['mday']); $lowerlimit = sprintf('%04d-%02d-%02d', $datearray['year'] - $search_params[$param_name] - 1, $datearray['mon'], $datearray['mday']); - if (in_array($search_params['types'][$param_name], ['-', '--', '='])) { + if (\in_array($search_params['types'][$param_name], ['-', '--', '='])) { $query_parts[] = ($param_info['db_fields'][0]) . ' > {string:' . $param_name . '_minlimit}'; $where_params[$param_name . '_minlimit'] = ($search_params['types'][$param_name] == '--' ? $upperlimit : $lowerlimit); } - if (in_array($search_params['types'][$param_name], ['+', '++', '='])) { + if (\in_array($search_params['types'][$param_name], ['+', '++', '='])) { $query_parts[] = ($param_info['db_fields'][0]) . ' <= {string:' . $param_name . '_pluslimit}'; $where_params[$param_name . '_pluslimit'] = ($search_params['types'][$param_name] == '++' ? $lowerlimit : $upperlimit); @@ -351,9 +351,9 @@ public function view(): void elseif ($param_info['type'] == 'checkbox') { // Each checkbox or no checkbox at all is checked -> ignore. if ( - !is_array($search_params[$param_name]) - || count($search_params[$param_name]) == 0 - || count($search_params[$param_name]) == count($param_info['values']) + !\is_array($search_params[$param_name]) + || \count($search_params[$param_name]) == 0 + || \count($search_params[$param_name]) == \count($param_info['values']) ) { continue; } @@ -364,11 +364,11 @@ public function view(): void } // INET. elseif ($param_info['type'] == 'inet') { - if (count($search_params[$param_name]) === 1) { + if (\count($search_params[$param_name]) === 1) { $query_parts[] = '(' . $param_info['db_fields'][0] . ' = {inet:' . $param_name . '})'; $where_params[$param_name] = $search_params[$param_name][0]; - } elseif (count($search_params[$param_name]) === 2) { + } elseif (\count($search_params[$param_name]) === 2) { $query_parts[] = '(' . $param_info['db_fields'][0] . ' <= {inet:' . $param_name . '_high} and ' . $param_info['db_fields'][0] . ' >= {inet:' . $param_name . '_low})'; $where_params[$param_name . '_low'] = $search_params[$param_name]['low']; @@ -392,7 +392,7 @@ public function view(): void $mg_query_parts = []; // Primary membergroups, but only if at least was was not selected. - if (!empty($search_params['membergroups'][1]) && count($this->membergroups) != count($search_params['membergroups'][1])) { + if (!empty($search_params['membergroups'][1]) && \count($this->membergroups) != \count($search_params['membergroups'][1])) { $mg_query_parts[] = 'mem.id_group IN ({array_int:group_check})'; $where_params['group_check'] = $search_params['membergroups'][1]; } @@ -402,7 +402,7 @@ public function view(): void !empty($search_params['membergroups'][2]) && ( empty($search_params['membergroups'][1]) - || count($this->membergroups) != count($search_params['membergroups'][1]) + || \count($this->membergroups) != \count($search_params['membergroups'][1]) ) ) { foreach ($search_params['membergroups'][2] as $mg) { @@ -417,7 +417,7 @@ public function view(): void } // Get all selected post count related membergroups. - if (!empty($search_params['postgroups']) && count($search_params['postgroups']) != count($this->postgroups)) { + if (!empty($search_params['postgroups']) && \count($search_params['postgroups']) != \count($this->postgroups)) { $query_parts[] = 'id_post_group IN ({array_int:post_groups})'; $where_params['post_groups'] = $search_params['postgroups']; } @@ -600,7 +600,7 @@ public function view(): void ], 'data' => [ 'function' => function ($rowData) { - return 'id || $rowData['id_group'] == 1 || in_array(1, explode(',', $rowData['additional_groups'])) ? ' disabled' : '') . '>'; + return 'id || $rowData['id_group'] == 1 || \in_array(1, explode(',', $rowData['additional_groups'])) ? ' disabled' : '') . '>'; }, 'class' => 'centercol', ], @@ -678,14 +678,14 @@ public function browse(): void // Allowed filters are those we can have, in theory. $allowed_filters = $browse_type == 'approve' ? [User::UNAPPROVED, User::REQUESTED_DELETE, User::NEED_COPPA] : [User::NOT_ACTIVATED, User::UNVALIDATED]; - $this->current_filter = isset($_REQUEST['filter']) && in_array($_REQUEST['filter'], $allowed_filters) && !empty($this->activation_numbers[$_REQUEST['filter']]) ? (int) $_REQUEST['filter'] : -1; + $this->current_filter = isset($_REQUEST['filter']) && \in_array($_REQUEST['filter'], $allowed_filters) && !empty($this->activation_numbers[$_REQUEST['filter']]) ? (int) $_REQUEST['filter'] : -1; // Sort out the different sub areas that we can actually filter by. $available_filters = []; foreach ($this->activation_numbers as $type => $amount) { // We have some of these... - if (in_array($type, $allowed_filters) && $amount > 0) { + if (\in_array($type, $allowed_filters) && $amount > 0) { $available_filters[] = [ 'type' => $type, 'amount' => $amount, @@ -980,7 +980,7 @@ function onSelectChange() } // Is there any need to show filters? - if (isset($available_filters) && count($available_filters) > 1) { + if (isset($available_filters) && \count($available_filters) > 1) { $filterOptions = ' ' . Lang::$txt['admin_browse_filter_by'] . ':