diff --git a/aborttest.php b/aborttest.php index 23b703d..4113670 100644 --- a/aborttest.php +++ b/aborttest.php @@ -41,7 +41,7 @@ $PAGE->set_context($syscontext); $PAGE->set_pagelayout('standard'); $PAGE->set_cacheable(false); -$url->params(array('stage' => 2)); +$url->params(['stage' => 2]); echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('testabort', 'tool_heartbeat')); diff --git a/adminloginchecker.php b/adminloginchecker.php index 4425579..c747495 100644 --- a/adminloginchecker.php +++ b/adminloginchecker.php @@ -37,11 +37,11 @@ define('NO_UPGRADE_CHECK', true); // @codingStandardsIgnoreEnd -$options = array( +$options = [ 'help' => false, 'critthresh' => 60 * 60 * 24 * 3, 'warnthresh' => 60 * 60 * 24 * 7, -); +]; if (isset($argv)) { // If run from the CLI. @@ -51,9 +51,9 @@ require_once($CFG->libdir . '/clilib.php'); list($options, $unrecognized) = cli_get_params($options, - array( + [ 'h' => 'help', - ) + ] ); if ($unrecognized) { diff --git a/buffercheck.php b/buffercheck.php index 54a6bf1..3f2c1a5 100644 --- a/buffercheck.php +++ b/buffercheck.php @@ -73,7 +73,7 @@ $files = [ $CFG->dirroot . '/backup/backup.php', - $CFG->dirroot . '/backup/restore.php' + $CFG->dirroot . '/backup/restore.php', ]; foreach ($files as $file) { diff --git a/classes/check/authcheck.php b/classes/check/authcheck.php index d68401a..04e3b3e 100644 --- a/classes/check/authcheck.php +++ b/classes/check/authcheck.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Auth method health check. * @@ -56,7 +57,7 @@ public function get_action_link(): ?\action_link { * * @return result */ - public function get_result() : result { + public function get_result(): result { global $DB; // Value must be raw DB value. We will see it here before in settings cache. diff --git a/classes/check/cachecheck.php b/classes/check/cachecheck.php index 2bba4bf..56ea306 100644 --- a/classes/check/cachecheck.php +++ b/classes/check/cachecheck.php @@ -36,7 +36,7 @@ class cachecheck extends check { * * @return result */ - public function get_result() : result { + public function get_result(): result { $results = $this->check('web'); $results += $this->check('cron'); diff --git a/classes/check/dirsizes.php b/classes/check/dirsizes.php index bc95c4a..0c14aa9 100644 --- a/classes/check/dirsizes.php +++ b/classes/check/dirsizes.php @@ -41,7 +41,7 @@ class dirsizes extends check { * * @return result */ - public function get_result() : result { + public function get_result(): result { global $CFG; $sizedataroot = get_directory_size($CFG->dataroot); diff --git a/classes/check/dnscheck.php b/classes/check/dnscheck.php index dcbc218..b00964c 100644 --- a/classes/check/dnscheck.php +++ b/classes/check/dnscheck.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * DNS security check. * @@ -40,7 +41,7 @@ class dnscheck extends check { * * @return result */ - public function get_result() : result { + public function get_result(): result { global $DB, $CFG; $url = new \moodle_url($CFG->wwwroot); diff --git a/classes/check/failingtaskcheck.php b/classes/check/failingtaskcheck.php index 97683ea..9243363 100644 --- a/classes/check/failingtaskcheck.php +++ b/classes/check/failingtaskcheck.php @@ -62,7 +62,7 @@ public function get_action_link(): ?\action_link { * Return result * @return result */ - public function get_result() : result { + public function get_result(): result { global $DB; // Return OK if no task errors. diff --git a/classes/check/rangerequestcheck.php b/classes/check/rangerequestcheck.php index 99f294a..064cf59 100644 --- a/classes/check/rangerequestcheck.php +++ b/classes/check/rangerequestcheck.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Range request performance check. * @@ -47,7 +48,7 @@ class rangerequestcheck extends check { * * @return result */ - public function get_result() : result { + public function get_result(): result { $url = new \moodle_url('/pluginfile.php/1/tool_heartbeat/test'); diff --git a/classes/check/tasklatencycheck.php b/classes/check/tasklatencycheck.php index 77d2966..835bc3e 100644 --- a/classes/check/tasklatencycheck.php +++ b/classes/check/tasklatencycheck.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Individual cron task latency monitoring check check. * diff --git a/classes/checker.php b/classes/checker.php index 7e43505..55f059c 100644 --- a/classes/checker.php +++ b/classes/checker.php @@ -358,7 +358,7 @@ public static function apply_configuration_settings($ref, result $result): resul return $result; } // Get a map of result string to integers representing their "order level". - $map = checker::RESULT_ORDER; + $map = self::RESULT_ORDER; // Get the order value of each status. $maxint = $map[$max]; $realint = $map[$status]; @@ -366,7 +366,7 @@ public static function apply_configuration_settings($ref, result $result): resul $finalint = min($maxint, $realint); // Flip the array to be integer => string constant and return the allowed // final status. - $status = array_flip($map)[$finalint]; + $status = array_flip($map)[$finalint]; return new result($status, $result->get_summary(), $result->get_details()); } /** diff --git a/classes/form/override_form.php b/classes/form/override_form.php index 4593765..5369354 100644 --- a/classes/form/override_form.php +++ b/classes/form/override_form.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Override form * diff --git a/classes/object/override.php b/classes/object/override.php index 44d3dbf..87b7f74 100644 --- a/classes/object/override.php +++ b/classes/object/override.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * * Heartbeat override @@ -44,7 +45,6 @@ class override extends Persistent { * @param int $id If set, this is the id of an existing record, used to load the data. * @param \stdClass $record If set will be passed to {@link self::from_record()}. */ - public function __construct(int $id = 0, \stdClass $record = null) { $this->set_default_status(); $this->set_default_expiry(); diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index dd44631..f9dfa9b 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Privacy Subsystem implementation for tool_heartbeat. * diff --git a/classes/task/cachecheck.php b/classes/task/cachecheck.php index 59b2f69..64185f4 100644 --- a/classes/task/cachecheck.php +++ b/classes/task/cachecheck.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - namespace tool_heartbeat\task; /** diff --git a/cli/testupload.php b/cli/testupload.php index 42e1774..8164148 100644 --- a/cli/testupload.php +++ b/cli/testupload.php @@ -32,22 +32,22 @@ require_once($CFG->libdir.'/clilib.php'); list($options, $unrecognized) = cli_get_params( - array( + [ 'help' => false, 'size' => 1024 * 10, 'chunks' => 100, 'delay' => 0, 'wwwroot' => $CFG->wwwroot, 'verbose' => 0, - ), - array( + ], + [ 'h' => 'help', 's' => 'size', 'c' => 'chunks', 'd' => 'delay', 'w' => 'wwwroot', 'v' => 'verbose', - ) + ] ); if ($unrecognized) { diff --git a/db/install.php b/db/install.php index a8fe591..1dcda52 100644 --- a/db/install.php +++ b/db/install.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Cache split check. * diff --git a/db/tasks.php b/db/tasks.php index 92f9a39..42fb700 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -13,12 +13,14 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Tool heartbeat * * @author Brendan Heywood * @copyright Catalyst IT 2023 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package tool_heartbeat */ defined('MOODLE_INTERNAL') || die(); diff --git a/db/upgrade.php b/db/upgrade.php index ff83916..3699717 100644 --- a/db/upgrade.php +++ b/db/upgrade.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * DB upgrade script. * diff --git a/errors.php b/errors.php index 1c4de4f..2f4519c 100644 --- a/errors.php +++ b/errors.php @@ -34,6 +34,7 @@ echo $OUTPUT->header(); echo $OUTPUT->heading('Tests for all errors in the whole stack'); +// @codingStandardsIgnoreStart ?>

Moodle high level errors

These should all use the moodle theme

@@ -74,6 +75,7 @@
  • A 502 Bad Gateway, proxy cannot connect at all (how to test?)
  • footer(); diff --git a/errors/phpwarnings.php b/errors/phpwarnings.php index 95fce5a..965a8eb 100644 --- a/errors/phpwarnings.php +++ b/errors/phpwarnings.php @@ -36,6 +36,8 @@ trigger_error("This is a notice", E_USER_NOTICE); trigger_error("This is a warning", E_USER_WARNING); +// @codingStandardsIgnoreStart error_log("This is an error_log"); +// @codingStandardsIgnoreEnd file_put_contents("php://stderr", "This writing to php://stderr"); diff --git a/index.php b/index.php index 9cb0959..bceca24 100644 --- a/index.php +++ b/index.php @@ -125,7 +125,7 @@ function failed($reason) { } if ($fullcheck || $checksession) { - $c = new curl(array('cache' => false, 'cookie' => true)); + $c = new curl(['cache' => false, 'cookie' => true]); $response = $c->get(new moodle_url('/admin/tool/heartbeat/sessionone.php')); if ($sessioncheck = json_decode($response)) { if ($sessioncheck->success == 'pass') { diff --git a/lib.php b/lib.php index 7114c3c..de4050b 100644 --- a/lib.php +++ b/lib.php @@ -13,6 +13,7 @@ // // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . + /** * Callback point. * @@ -85,7 +86,7 @@ function tool_heartbeat_security_checks() { * @param array $options More options * @return bool Returns false if we don't find a file. */ -function tool_heartbeat_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) { +function tool_heartbeat_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = []) { global $CFG; // README is just safe content we know exist. Used in the range request check. diff --git a/loginchecker.php b/loginchecker.php index fa0ec91..e9d3fd2 100644 --- a/loginchecker.php +++ b/loginchecker.php @@ -37,12 +37,12 @@ define('NO_UPGRADE_CHECK', true); // @codingStandardsIgnoreEnd -$options = array( +$options = [ 'help' => false, 'critthresh' => 500, 'warnthresh' => 10, 'logtime' => 5, -); +]; if (isset($argv)) { // If run from the CLI. @@ -52,9 +52,9 @@ require_once($CFG->libdir . '/clilib.php'); list($options, $unrecognized) = cli_get_params($options, - array( + [ 'h' => 'help', - ) + ] ); if ($unrecognized) { @@ -106,7 +106,7 @@ WHERE target = 'user_login' AND timecreated > :checktime"; -$tablequery = $DB->get_record_sql($sqlstring, array('checktime' => $checktime)); +$tablequery = $DB->get_record_sql($sqlstring, ['checktime' => $checktime]); $count = $tablequery->logincount; diff --git a/sessionone.php b/sessionone.php index 609cbbc..2e149ff 100644 --- a/sessionone.php +++ b/sessionone.php @@ -14,7 +14,6 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . - /** * Set a random integer in session and redirect to check if persists. * @@ -35,10 +34,10 @@ $SESSION->testnumber = $testnumber; -$params = array( +$params = [ 'testnumber' => $testnumber, 'reqtime' => $testtimemicro, - 'host' => $hostname); + 'host' => $hostname]; $url = new moodle_url('/admin/tool/heartbeat/sessiontwo.php', $params); redirect($url); diff --git a/settings.php b/settings.php index 4567a27..eb884e4 100644 --- a/settings.php +++ b/settings.php @@ -41,11 +41,11 @@ if (!during_initial_install()) { - $options = array( + $options = [ '' => new lang_string('normal', 'tool_heartbeat'), 'warn' => new lang_string('testwarning', 'tool_heartbeat'), 'error' => new lang_string('testerror', 'tool_heartbeat'), - ); + ]; $settings->add(new admin_setting_configselect('tool_heartbeat/testing', new lang_string('testing', 'tool_heartbeat'), new lang_string('testingdesc', 'tool_heartbeat'), @@ -94,7 +94,7 @@ $opts = [ 'critical' => 'CRITICAL', 'criticalbusiness' => get_string('error_critical_business', 'tool_heartbeat'), - 'warning' => 'WARNING' + 'warning' => 'WARNING', ]; $time = new \DateTime('now', core_date::get_server_timezone_object()); $settings->add(new admin_setting_configselect('tool_heartbeat/errorcritical', diff --git a/tests/check/tasklatencycheck_test.php b/tests/check/tasklatencycheck_test.php index 8acead2..3d839f3 100644 --- a/tests/check/tasklatencycheck_test.php +++ b/tests/check/tasklatencycheck_test.php @@ -71,7 +71,7 @@ public function test_start_time_drift() { // Now set a lock on the task. This should prevent critical. $CFG->lock_factory = \tool_lockstats\proxy_lock_factory::class; $DB->insert_record('tool_lockstats_locks', [ - 'resourcekey' => '\\logstore_standard\\task\\cleanup_task' + 'resourcekey' => '\\logstore_standard\\task\\cleanup_task', ]); $result = $check->get_result(); $this->assertEquals(result::OK, $result->get_status()); @@ -120,7 +120,7 @@ public function test_task_not_run() { // Now set a lock on the task. This should prevent critical. $CFG->lock_factory = \tool_lockstats\proxy_lock_factory::class; $DB->insert_record('tool_lockstats_locks', [ - 'resourcekey' => '\\logstore_standard\\task\\cleanup_task' + 'resourcekey' => '\\logstore_standard\\task\\cleanup_task', ]); $result = $check->get_result(); $this->assertEquals(result::OK, $result->get_status()); diff --git a/tests/checker_test.php b/tests/checker_test.php index 449dbe9..9368e5a 100644 --- a/tests/checker_test.php +++ b/tests/checker_test.php @@ -134,8 +134,8 @@ public static function create_summary_provider(): array { ], 'pipe char in output is cleaned' => [ 'messages' => [$criticalwithpipemsg], - 'expectedsummary' => str_replace('|', '|', $criticalwithpipemsg->title) - ] + 'expectedsummary' => str_replace('|', '|', $criticalwithpipemsg->title), + ], ]; }