From 9566740a991d76c106b755243f2aebf08d6d0b09 Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Sat, 14 Oct 2023 10:45:26 +0200 Subject: [PATCH] Make codechecker happy again --- CHANGES.md | 1 + classes/task/sync_roles.php | 2 +- db/events.php | 8 ++++---- db/tasks.php | 16 ++++++++-------- eventhandler.php | 2 +- settings.php | 22 +++++++++++----------- tests/behat/behat_auth_ldap_syncplus.php | 2 +- version.php | 2 +- 8 files changed, 28 insertions(+), 27 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 55c4eba..aa95bf4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2023-10-14 - Make codechecker happy again * 2023-10-10 - Updated Moodle Plugin CI to latest upstream recommendations * 2023-04-30 - Tests: Updated Moodle Plugin CI to use PHP 8.1 and Postgres 13 from Moodle 4.1 on. diff --git a/classes/task/sync_roles.php b/classes/task/sync_roles.php index f2af455..81c8539 100644 --- a/classes/task/sync_roles.php +++ b/classes/task/sync_roles.php @@ -51,7 +51,7 @@ public function execute() { global $DB; if (is_enabled_auth('ldap_syncplus')) { $auth = get_auth_plugin('ldap_syncplus'); - $users = $DB->get_records('user', array('auth' => 'ldap_syncplus')); + $users = $DB->get_records('user', ['auth' => 'ldap_syncplus']); foreach ($users as $user) { $auth->sync_roles($user); } diff --git a/db/events.php b/db/events.php index bbeb15a..217e36e 100644 --- a/db/events.php +++ b/db/events.php @@ -24,10 +24,10 @@ defined('MOODLE_INTERNAL') || die(); -$observers = array( - array( +$observers = [ + [ 'eventname' => '\core\event\user_created', 'includefile' => '/auth/ldap_syncplus/eventhandler.php', 'callback' => 'update_user_onevent', - ), -); + ], +]; diff --git a/db/tasks.php b/db/tasks.php index 33fece1..2a72571 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -24,8 +24,8 @@ defined('MOODLE_INTERNAL') || die(); -$tasks = array( - array( +$tasks = [ + [ 'classname' => 'auth_ldap_syncplus\task\sync_roles', 'blocking' => 0, 'minute' => '0', @@ -33,9 +33,9 @@ 'day' => '*', 'month' => '*', 'dayofweek' => '*', - 'disabled' => 1 - ), - array( + 'disabled' => 1, + ], + [ 'classname' => 'auth_ldap_syncplus\task\sync_task', 'blocking' => 0, 'minute' => '0', @@ -43,6 +43,6 @@ 'day' => '*', 'month' => '*', 'dayofweek' => '*', - 'disabled' => 1 - ) -); + 'disabled' => 1, + ], +]; diff --git a/eventhandler.php b/eventhandler.php index a5e7bcc..48c8ebd 100644 --- a/eventhandler.php +++ b/eventhandler.php @@ -35,7 +35,7 @@ function update_user_onevent($eventdata) { if (!empty($eventdata->relateduserid)) { // Get user data. - $user = $DB->get_record('user', array('id' => $eventdata->relateduserid)); + $user = $DB->get_record('user', ['id' => $eventdata->relateduserid]); // Do if user was found. if (!empty($user->username)) { diff --git a/settings.php b/settings.php index 066aedd..d906c8b 100644 --- a/settings.php +++ b/settings.php @@ -57,7 +57,7 @@ get_string('auth_ldap_host_url', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); // Version. - $versions = array(); + $versions = []; $versions[2] = '2'; $versions[3] = '3'; $settings->add(new admin_setting_configselect('auth_ldap_syncplus/ldap_version', @@ -65,10 +65,10 @@ new lang_string('auth_ldap_version', 'auth_ldap'), 3, $versions)); // Start TLS. - $yesno = array( + $yesno = [ new lang_string('no'), new lang_string('yes'), - ); + ]; $settings->add(new admin_setting_configselect('auth_ldap_syncplus/start_tls', new lang_string('start_tls_key', 'auth_ldap'), new lang_string('start_tls', 'auth_ldap'), 0 , $yesno)); @@ -123,7 +123,7 @@ new lang_string('auth_ldap_search_sub', 'auth_ldap'), 0 , $yesno)); // Dereference aliases. - $optderef = array(); + $optderef = []; $optderef[LDAP_DEREF_NEVER] = get_string('no'); $optderef[LDAP_DEREF_ALWAYS] = get_string('yes'); @@ -171,7 +171,7 @@ get_string('stdchangepassword_explldap', 'auth'), 0 , $yesno)); // Password Type. - $passtype = array(); + $passtype = []; $passtype['plaintext'] = get_string('plaintext', 'auth'); $passtype['md5'] = get_string('md5', 'auth'); $passtype['sha1'] = get_string('sha1', 'auth'); @@ -200,7 +200,7 @@ $description = new lang_string('auth_ldap_expiration_desc', 'auth_ldap', $langobject); // Now create the options. - $expiration = array(); + $expiration = []; $expiration['0'] = $strno; $expiration['1'] = $strldapserver; @@ -261,9 +261,9 @@ // If we were to manipulate the setting name by removing the hyphens we may get conflicts, eg // 'thisisashortname' and 'this-is-a-short-name'. The same applies for shortening the setting name. if (core_text::strlen($role['settingname']) > 100 || !preg_match('/^[a-zA-Z0-9_]+$/', $role['settingname'])) { - $url = new moodle_url('/admin/roles/define.php', array('action' => 'edit', 'roleid' => $role['id'])); + $url = new moodle_url('/admin/roles/define.php', ['action' => 'edit', 'roleid' => $role['id']]); $a = (object)['rolename' => $role['localname'], 'shortname' => $role['shortname'], 'charlimit' => 93, - 'link' => $url->out()]; + 'link' => $url->out(), ]; $settings->add(new admin_setting_heading('auth_ldap_syncplus/role_not_mapped_' . sha1($role['settingname']), '', get_string('cannotmaprole', 'auth_ldap', $a))); } else { @@ -278,7 +278,7 @@ new lang_string('auth_sync_script', 'auth'), '')); // Remove external user. - $deleteopt = array(); + $deleteopt = []; $deleteopt[AUTH_REMOVEUSER_KEEP] = get_string('auth_remove_keep', 'auth'); $deleteopt[AUTH_REMOVEUSER_SUSPEND] = get_string('auth_remove_suspend', 'auth'); $deleteopt[AUTH_REMOVEUSER_FULLDELETE] = get_string('auth_remove_delete', 'auth'); @@ -318,7 +318,7 @@ get_string('auth_ntlmsso_subnet', 'auth_ldap'), '', PARAM_RAW_TRIMMED)); // NTLM Fast Path. - $fastpathoptions = array(); + $fastpathoptions = []; $fastpathoptions[AUTH_NTLM_FASTPATH_YESFORM] = get_string('auth_ntlmsso_ie_fastpath_yesform', 'auth_ldap'); $fastpathoptions[AUTH_NTLM_FASTPATH_YESATTEMPT] = get_string('auth_ntlmsso_ie_fastpath_yesattempt', 'auth_ldap'); $fastpathoptions[AUTH_NTLM_FASTPATH_ATTEMPT] = get_string('auth_ntlmsso_ie_fastpath_attempt', 'auth_ldap'); @@ -329,7 +329,7 @@ AUTH_NTLM_FASTPATH_ATTEMPT, $fastpathoptions)); // Authentication type. - $types = array(); + $types = []; $types['ntlm'] = 'NTLM'; $types['kerberos'] = 'Kerberos'; diff --git a/tests/behat/behat_auth_ldap_syncplus.php b/tests/behat/behat_auth_ldap_syncplus.php index 05d0782..20e5b0f 100644 --- a/tests/behat/behat_auth_ldap_syncplus.php +++ b/tests/behat/behat_auth_ldap_syncplus.php @@ -48,7 +48,7 @@ public function i_pretend_that_the_suspended_user_was_already_suspended_days_ago global $DB; // Get the user record of the given user. - $user = $DB->get_record('user', array('username' => $username)); + $user = $DB->get_record('user', ['username' => $username]); // Update the suspended field in the user record. $user->suspended = 1; diff --git a/version.php b/version.php index 3df6750..849c574 100644 --- a/version.php +++ b/version.php @@ -30,4 +30,4 @@ $plugin->requires = 2022112800; $plugin->supported = [401, 401]; $plugin->maturity = MATURITY_STABLE; -$plugin->dependencies = array('auth_ldap' => 2022041900); +$plugin->dependencies = ['auth_ldap' => 2022041900];