diff --git a/local_moodleappbehat/tests/behat/behat_app.php b/local_moodleappbehat/tests/behat/behat_app.php index 62ba7f6a3..f2a8cde66 100644 --- a/local_moodleappbehat/tests/behat/behat_app.php +++ b/local_moodleappbehat/tests/behat/behat_app.php @@ -283,7 +283,7 @@ class behat_app extends behat_app_helper { // Wait until the main page appears. $this->spin( - function($context, $args) { + function($context) { $initialpage = $context->getSession()->getPage()->find('xpath', '//page-core-mainmenu') ?? $context->getSession()->getPage()->find('xpath', '//page-core-login-change-password') ?? $context->getSession()->getPage()->find('xpath', '//page-core-user-complete-profile'); @@ -780,7 +780,7 @@ class behat_app extends behat_app_helper { if (!is_null($urlpattern)) { $this->getSession()->switchToWindow($windowNames[1]); $windowurl = $this->getSession()->getCurrentUrl(); - $windowhaspattern = !!preg_match("/$urlpattern/", $windowurl); + $windowhaspattern = (bool)preg_match("/$urlpattern/", $windowurl); $this->getSession()->switchToWindow($windowNames[0]); if ($not === $windowhaspattern) { @@ -885,6 +885,8 @@ class behat_app extends behat_app_helper { case 'offline': $this->runtime_js("network.setForceConnectionMode('none');"); break; + default: + break; } } diff --git a/local_moodleappbehat/tests/behat/behat_app_helper.php b/local_moodleappbehat/tests/behat/behat_app_helper.php index 3142ce5f9..1c440ec05 100644 --- a/local_moodleappbehat/tests/behat/behat_app_helper.php +++ b/local_moodleappbehat/tests/behat/behat_app_helper.php @@ -412,12 +412,9 @@ class behat_app_helper extends behat_base { preg_match_all("/\\$\\{([^:}]+):([^}]+)\\}/", $text, $matches); foreach ($matches[0] as $index => $match) { - switch ($matches[2][$index]) { - case 'cmid': - $coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]); - $text = str_replace($match, $coursemodule->id, $text); - - break; + if ($matches[2][$index] == 'cmid') { + $coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]); + $text = str_replace($match, $coursemodule->id, $text); } } @@ -550,7 +547,7 @@ class behat_app_helper extends behat_base { if (!empty($successXPath)) { // Wait until the page appears. $this->spin( - function($context, $args) use ($successXPath) { + function($context) use ($successXPath) { $found = $context->getSession()->getPage()->find('xpath', $successXPath); if ($found) { return true; @@ -597,7 +594,6 @@ class behat_app_helper extends behat_base { $cmfrom = $cmtable->get_from_sql(); $acttable = new \core\dml\table($activity, 'a', 'a'); - $actselect = $acttable->get_field_select(); $actfrom = $acttable->get_from_sql(); $sql = <<longTasks as $longTask) { - $blocking += $longTask['duration'] - 50; + $blockingDuration += $longTask['duration'] - 50; } - $this->blocking = $blocking; + $this->blocking = $blockingDuration; } /** @@ -269,15 +269,15 @@ class performance_measure implements behat_app_listener { private function analysePerformanceLogs(): void { global $CFG; - $scripting = 0; - $styling = 0; - $networking = 0; + $scriptingDuration = 0; + $stylingDuration = 0; + $networkingCount = 0; $logs = $this->getPerformanceLogs(); foreach ($logs as $log) { // TODO this should filter by end time as well, but it seems like the timestamps are not // working as expected. - if (($log['timestamp'] < $this->start)) { + if ($log['timestamp'] < $this->start) { continue; } @@ -285,27 +285,27 @@ class performance_measure implements behat_app_listener { $messagename = $message->params->name ?? ''; if (in_array($messagename, ['FunctionCall', 'GCEvent', 'MajorGC', 'MinorGC', 'EvaluateScript'])) { - $scripting += $message->params->dur; + $scriptingDuration += $message->params->dur; continue; } if (in_array($messagename, ['UpdateLayoutTree', 'RecalculateStyles', 'ParseAuthorStyleSheet'])) { - $styling += $message->params->dur; + $stylingDuration += $message->params->dur; continue; } if (in_array($messagename, ['XHRLoad']) && !str_starts_with($message->params->args->data->url, $CFG->behat_ionic_wwwroot)) { - $networking++; + $networkingCount++; continue; } } - $this->scripting = round($scripting / 1000); - $this->styling = round($styling / 1000); - $this->networking = $networking; + $this->scripting = round($scriptingDuration / 1000); + $this->styling = round($stylingDuration / 1000); + $this->networking = $networkingCount; } /** diff --git a/scripts/get_ws_changes.php b/scripts/get_ws_changes.php index e7ee5ecff..4e5794d81 100644 --- a/scripts/get_ws_changes.php +++ b/scripts/get_ws_changes.php @@ -42,7 +42,7 @@ $versions = array('master', '310', '39', '38', '37', '36', '35', '34', '33', '32 $moodlespath = $argv[1]; $wsname = $argv[2]; -$useparams = !!(isset($argv[3]) && $argv[3]); +$useparams = (bool)(isset($argv[3]) && $argv[3]); $pathseparator = '/'; // Get the path to the script. diff --git a/scripts/get_ws_structure.php b/scripts/get_ws_structure.php index 89d5cac92..961708cc5 100644 --- a/scripts/get_ws_structure.php +++ b/scripts/get_ws_structure.php @@ -39,7 +39,7 @@ if (!defined('SERIALIZED')) { $moodlepath = $argv[1]; $wsname = $argv[2]; -$useparams = !!(isset($argv[3]) && $argv[3]); +$useparams = (bool)(isset($argv[3]) && $argv[3]); define('CLI_SCRIPT', true); diff --git a/scripts/lang_functions.php b/scripts/lang_functions.php index 9fdc5c0b9..7d2dd3990 100644 --- a/scripts/lang_functions.php +++ b/scripts/lang_functions.php @@ -302,7 +302,7 @@ function build_lang($lang) { $text = str_replace(['{{{', '}}}'], ['{{', '}}'], $text); } else { // @TODO: Remove that line when core.cannotconnect and core.login.invalidmoodleversion are completelly changed to use $a - if (($appkey == 'core.cannotconnect' || $appkey == 'core.login.invalidmoodleversion') && strpos($text, '2.4') != false) { + if (($appkey == 'core.cannotconnect' || $appkey == 'core.login.invalidmoodleversion') && strpos($text, '2.4')) { $text = str_replace('2.4', '{{$a}}', $text); } $local++; @@ -471,13 +471,10 @@ function override_component_lang_files($translations) { } switch($type) { case 'core': - switch($component) { - case 'moodle': - $path .= 'core/lang.json'; - break; - default: - $path .= 'core/features/'.str_replace('_', '/', $component).'/lang.json'; - break; + if ($component == 'moodle') { + $path .= 'core/lang.json'; + } else { + $path .= 'core/features/'.str_replace('_', '/', $component).'/lang.json'; } break; case 'addon': diff --git a/scripts/ws_to_ts_functions.php b/scripts/ws_to_ts_functions.php index 228a89649..23db31a5e 100644 --- a/scripts/ws_to_ts_functions.php +++ b/scripts/ws_to_ts_functions.php @@ -70,7 +70,7 @@ function fix_comment($desc) { if (count($lines) > 1) { $desc = array_shift($lines)."\n"; - foreach ($lines as $i => $line) { + foreach ($lines as $line) { $spaces = strlen($line) - strlen(ltrim($line)); $desc .= str_repeat(' ', $spaces - 3) . '// '. ltrim($line)."\n"; } @@ -138,9 +138,7 @@ function convert_to_ts($key, $value, $boolisnumber = false, $indentation = '', $ $type = 'number'; } - $result = convert_key_type($key, $type, $value->required, $indentation); - - return $result; + return convert_key_type($key, $type, $value->required, $indentation); } else if ($value instanceof external_single_structure) { // It's an object. @@ -278,7 +276,7 @@ function remove_default_closures($value) { } else if ($value instanceof external_single_structure) { - foreach ($value->keys as $key => $subvalue) { + foreach ($value->keys as $subvalue) { remove_default_closures($subvalue); }