From d6d8523c9727a5f1668a2296e659c102f22a5224 Mon Sep 17 00:00:00 2001 From: Srdjan Date: Thu, 27 Jul 2023 11:58:09 +1000 Subject: [PATCH] Moodle code compliance changes, a noop --- .github/workflows/ci.yml | 5 ++--- classes/cache_administration_helper.php | 8 +++----- classes/cache_config.php | 10 +++++----- classes/cache_config_writer.php | 9 ++++----- classes/cache_factory.php | 5 +++-- classes/check/enabled.php | 11 ++++++----- classes/privacy/provider.php | 5 ++--- lang/en/tool_forcedcache.php | 9 +++++++++ tests/cache_config_test.php | 10 +++++----- 9 files changed, 39 insertions(+), 33 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7f0ff8f..efb8d3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,13 +1,12 @@ # .github/workflows/ci.yml name: ci -env: - PLUGIN: tool_forcedcache - on: [push, pull_request] jobs: ci: uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main + secrets: + moodle_org_token: ${{ secrets.MOODLE_ORG_TOKEN }} with: disable_behat: true diff --git a/classes/cache_administration_helper.php b/classes/cache_administration_helper.php index b957e67..cc70646 100644 --- a/classes/cache_administration_helper.php +++ b/classes/cache_administration_helper.php @@ -15,15 +15,13 @@ // along with Moodle. If not, see . /** - * This class changes the actions that are available to various stores, - * and changes the layout slightly + * This class changes the actions that are available to various stores, and changes the layout slightly * * @package tool_forcedcache * @author Peter Burnett * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class tool_forcedcache_cache_administration_helper extends core_cache\administration_helper { /** @@ -133,7 +131,7 @@ public function get_ruleset_output(): string { /** * Generates a config table for the selected caching store * - * @param integer $mode the mode to generate the table for. + * @param string $name def table name (prefix) * @param array $config the config array from the JSON. * @return string HTML for the table. */ @@ -197,7 +195,7 @@ private function generate_override_table(array $overrides): string { /** * Generates a ruleset table for the selected caching mode. * - * @param integer $mode the mode to generate the table for. + * @param int $mode the mode to generate the table for. * @param array $config the config array from the JSON. * @return string HTML for the table. */ diff --git a/classes/cache_config.php b/classes/cache_config.php index f637adc..8f21b9d 100644 --- a/classes/cache_config.php +++ b/classes/cache_config.php @@ -15,16 +15,15 @@ // along with Moodle. If not, see . /** - * This cache_config class extends the first one, and generates the - * configuration array from reading a hardcoded JSON file instead of - * the configuration file on shared disk. + * This cache_config class generates the configuration array from reading a hardcoded JSON file + * + * Instead of the configuration file on shared disk. * * @package tool_forcedcache * @author Peter Burnett * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class tool_forcedcache_cache_config extends cache_config { /** @@ -283,9 +282,10 @@ public static function get_default_mode_mappings() : array { /** * This function generates the mappings for each cache mode after rules are applied. * + * @param array $rules * @return array the generated mode mappings post-rules. */ - private function generate_mode_mapping($rules): array { + private function generate_mode_mapping(array $rules): array { $modetostr = [ cache_store::MODE_APPLICATION => 'application', cache_store::MODE_SESSION => 'session', diff --git a/classes/cache_config_writer.php b/classes/cache_config_writer.php index b6d1c02..d812fab 100644 --- a/classes/cache_config_writer.php +++ b/classes/cache_config_writer.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +defined('MOODLE_INTERNAL') || die(); +// Manually require locallib as it isn't autoloaded. +require_once(__DIR__.'/../../../../cache/locallib.php'); + /** * This config_writer is readonly, and provides public access to some protected methods. * @@ -22,11 +26,6 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -defined('MOODLE_INTERNAL') || die(); -// Manually require locallib as it isn't autoloaded. -require_once(__DIR__.'/../../../../cache/locallib.php'); - class tool_forcedcache_cache_config_writer extends cache_config_writer { /** diff --git a/classes/cache_factory.php b/classes/cache_factory.php index 1405f78..595e359 100644 --- a/classes/cache_factory.php +++ b/classes/cache_factory.php @@ -22,14 +22,15 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - class tool_forcedcache_cache_factory extends cache_factory { /** * This is a copy of the core class, with the classes swapped out. * TODO: Refactor core method to accept class param, and call parent with param. + * + * @param bool $writer */ - public function create_config_instance($writer = false) { + public function create_config_instance(bool $writer = false) { global $CFG; // The class to use. diff --git a/classes/check/enabled.php b/classes/check/enabled.php index 604060b..93fc55d 100644 --- a/classes/check/enabled.php +++ b/classes/check/enabled.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace tool_forcedcache\check; +use core\check\check; +use core\check\result; + /** * Forcedcache enabled check * @@ -22,10 +26,6 @@ * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -namespace tool_forcedcache\check; -use core\check\check; -use core\check\result; - class enabled extends check { /** * Get the short check name @@ -58,7 +58,8 @@ public function get_result() : result { $dummy = new \tool_forcedcache_cache_config(); $errors = $dummy->get_inclusion_errors(); - $forcedcacheenabled = isset($CFG->alternative_cache_factory_class) && $CFG->alternative_cache_factory_class === 'tool_forcedcache_cache_factory'; + $forcedcacheenabled = isset($CFG->alternative_cache_factory_class) + && $CFG->alternative_cache_factory_class === 'tool_forcedcache_cache_factory'; if (!$forcedcacheenabled || !empty($errors)) { $status = $forcedcacheenabled ? result::ERROR : result::WARNING; diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 602364f..ae3cd03 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace tool_forcedcache\privacy; + /** * Plugin privacy provider * @@ -21,9 +23,6 @@ * @copyright 2020 Peter Burnett * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ - -namespace tool_forcedcache\privacy; - class provider implements // This plugin does not store any personal user data. \core_privacy\local\metadata\null_provider { diff --git a/lang/en/tool_forcedcache.php b/lang/en/tool_forcedcache.php index 73ed947..7c9ae33 100644 --- a/lang/en/tool_forcedcache.php +++ b/lang/en/tool_forcedcache.php @@ -14,6 +14,15 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +/** + * Language strings + * + * @package tool_forcedcache + * @author Peter Burnett + * @copyright 2022, Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + $string['pluginname'] = 'Forced Caching'; // Page Strings. diff --git a/tests/cache_config_test.php b/tests/cache_config_test.php index 17ac70d..81e6294 100644 --- a/tests/cache_config_test.php +++ b/tests/cache_config_test.php @@ -14,18 +14,18 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +namespace tool_forcedcache; + /** - * Test file for tool_forcedcache_cache_config. + * Tests for tool_forcedcache_cache_config. * * @package tool_forcedcache * @author Peter Burnett * @copyright Catalyst IT * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @covers \tool_forcedcache_cache_config */ - -namespace tool_forcedcache\tests; - -class tool_forcedcache_cache_config_testcase extends \advanced_testcase { +class cache_config_test extends \advanced_testcase { /** * We need to load the config files outside of the $CFG->dirroot, so it