diff --git a/CHANGES.md b/CHANGES.md index 5f18e21..9c7a82d 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/cohort_form.php b/classes/cohort_form.php index 795316c..c518eb4 100644 --- a/classes/cohort_form.php +++ b/classes/cohort_form.php @@ -45,13 +45,13 @@ protected function definition() { $mform->addElement('html', \html_writer::tag('div', get_string('cohortsintro', 'local_profilecohort').'
'. get_string('invisiblecohortsnote', 'local_profilecohort'), - array('id' => 'intro', 'class' => 'box generalbox'))); + ['id' => 'intro', 'class' => 'box generalbox'])); if (!$cohorts) { $cohorturl = new \moodle_url('/cohort/index.php'); $link = \html_writer::link($cohorturl, get_string('cohorts', 'core_cohort')); $mform->addElement('html', \html_writer::tag('div', get_string('nocohorts', 'local_profilecohort', $link), - array('class' => 'alert alert-warning'))); + ['class' => 'alert alert-warning'])); } else { foreach ($cohorts as $cohort) { $mform->addElement('advcheckbox', "cohort[$cohort->id]", null, format_string($cohort->name)); diff --git a/classes/field_base.php b/classes/field_base.php index 1f32510..3f41d61 100644 --- a/classes/field_base.php +++ b/classes/field_base.php @@ -249,7 +249,7 @@ public function delete($tablename) { if (!$this->id) { return; } - $DB->delete_records($tablename, array('id' => $this->id)); + $DB->delete_records($tablename, ['id' => $this->id]); $this->id = null; } @@ -348,7 +348,7 @@ public function add_form_field(MoodleQuickForm $mform, $values, $rulecount) { $prefix = ''; if ($this->id) { - $actiongroup = array(); + $actiongroup = []; $actiongroup[] = $mform->createElement('static', '', '', '
'); if ($rulecount > 1) { $moveopts = range(1, $rulecount); diff --git a/classes/field_text.php b/classes/field_text.php index 3fef597..5e3ed90 100644 --- a/classes/field_text.php +++ b/classes/field_text.php @@ -65,7 +65,7 @@ class field_text extends field_base { self::MATCH_EXACT, self::MATCH_CONTAINS, self::MATCH_NOTEXACT, self::MATCH_NOTCONTAINS, self::MATCH_ISDEFINED, self::MATCH_NOTDEFINED, - self::MATCH_EMPTY, self::MATCH_NOTEMPTY + self::MATCH_EMPTY, self::MATCH_NOTEMPTY, ]; /** @@ -143,7 +143,7 @@ protected function validation_internal($formdata, $id) { $errors = []; if (!in_array($formdata['matchtype'][$id], [ self::MATCH_ISDEFINED, self::MATCH_NOTDEFINED, - self::MATCH_EMPTY, self::MATCH_NOTEMPTY + self::MATCH_EMPTY, self::MATCH_NOTEMPTY, ])) { if (empty($formdata['matchvalue'][$id])) { $errors["matchvalue[$id]"] = get_string('required'); diff --git a/classes/profilecohort.php b/classes/profilecohort.php index 3130f95..8b9aafb 100644 --- a/classes/profilecohort.php +++ b/classes/profilecohort.php @@ -86,7 +86,7 @@ protected function extra_tabs() { new \tabobject('members', new \moodle_url($this->get_index_url(), ['action' => 'members']), get_string('members', 'local_profilecohort')), new \tabobject('cohorts', new \moodle_url('/local/profilecohort/cohorts.php'), - get_string('selectcohorts', 'local_profilecohort')) + get_string('selectcohorts', 'local_profilecohort')), ]; } @@ -103,7 +103,7 @@ protected function output_members() { $out .= \html_writer::tag('div', get_string('membersintro', 'local_profilecohort').'
'. get_string('invisiblecohortsnote', 'local_profilecohort'), - array('id' => 'intro', 'class' => 'box generalbox')); + ['id' => 'intro', 'class' => 'box generalbox']); $namefields = \core_user\fields::get_name_fields(); $namefields = preg_filter('/^/', 'u.', $namefields); @@ -162,7 +162,7 @@ private function output_members_entry($cohortname, $cohortmembers, $lastcohortid $out .= html_writer::start_div('card-header', ['id' => $id.'-heading']); $out .= html_writer::start_tag('h2', ['class' => 'mb-0']); $out .= html_writer::start_tag('button', ['class' => 'btn btn-link btn-block text-left pl-0', 'type' => 'button', - 'data-toggle' => 'collapse', 'data-target' => '#'.$id, 'aria-expanded' => 'false', 'aria-controls' => $id]); + 'data-toggle' => 'collapse', 'data-target' => '#'.$id, 'aria-expanded' => 'false', 'aria-controls' => $id, ]); $out .= format_string($cohortname); if ($cohortmembers) { $out .= html_writer::tag('span', get_string('countusers', 'local_profilecohort', count($cohortmembers)), @@ -190,7 +190,7 @@ private function output_members_entry($cohortname, $cohortmembers, $lastcohortid } $out .= html_writer::start_div('collapse', ['id' => $id, 'aria-labelledby' => $id.'-heading', - 'data-parent' => '#profilecohort-cohortlist']); + 'data-parent' => '#profilecohort-cohortlist', ]); $out .= html_writer::div($content, 'card-body'); $out .= html_writer::end_div(); diff --git a/classes/profilefields.php b/classes/profilefields.php index 7112816..a25523d 100644 --- a/classes/profilefields.php +++ b/classes/profilefields.php @@ -105,7 +105,7 @@ public function process_form() { if ($this->action == 'add') { // Add a new, empty, rule to the end of the list, if requested. if ($addid = optional_param('add', null, PARAM_INT)) { - $field = $DB->get_record('user_info_field', array('id' => $addid), 'id AS fieldid, name, datatype, param1', + $field = $DB->get_record('user_info_field', ['id' => $addid], 'id AS fieldid, name, datatype, param1', MUST_EXIST); if ($rule = field_base::make_instance($field)) { $rules[] = $rule; @@ -116,7 +116,7 @@ public function process_form() { // Instantiate the form. $custom = [ 'rules' => $rules, - 'values' => $this->get_possible_values() + 'values' => $this->get_possible_values(), ]; $this->form = new fields_form(null, $custom); $toform = ['action' => $this->action]; @@ -207,11 +207,11 @@ public function output_form() { if ($this->action == 'view') { $out .= \html_writer::tag('div', get_string('viewintro', 'local_profilecohort').'
'. get_string('invisiblecohortsnote', 'local_profilecohort'), - array('id' => 'intro', 'class' => 'box generalbox')); + ['id' => 'intro', 'class' => 'box generalbox']); } else if ($this->action == 'add') { $out .= \html_writer::tag('div', get_string('addintro', 'local_profilecohort'). '
'.get_string('invisiblecohortsnote', 'local_profilecohort'), - array('id' => 'intro', 'class' => 'box generalbox')); + ['id' => 'intro', 'class' => 'box generalbox']); } if (!$this->get_possible_fields()) { diff --git a/db/events.php b/db/events.php index 1e50349..b57a6fb 100644 --- a/db/events.php +++ b/db/events.php @@ -27,18 +27,18 @@ $observers = [ [ 'eventname' => '\core\event\user_loggedin', - 'callback' => '\local_profilecohort\profilecohort::set_cohorts_from_profile' + 'callback' => '\local_profilecohort\profilecohort::set_cohorts_from_profile', ], [ 'eventname' => '\core\event\user_loggedinas', - 'callback' => '\local_profilecohort\profilecohort::set_cohorts_from_profile_loginas' + 'callback' => '\local_profilecohort\profilecohort::set_cohorts_from_profile_loginas', ], [ 'eventname' => '\core\event\user_created', - 'callback' => '\local_profilecohort\profilecohort::set_cohorts_from_profile_created' + 'callback' => '\local_profilecohort\profilecohort::set_cohorts_from_profile_created', ], [ 'eventname' => '\core\event\user_updated', - 'callback' => '\local_profilecohort\profilecohort::set_cohorts_from_profile_updated' - ] + 'callback' => '\local_profilecohort\profilecohort::set_cohorts_from_profile_updated', + ], ]; diff --git a/db/tasks.php b/db/tasks.php index 2445753..e18b4b2 100644 --- a/db/tasks.php +++ b/db/tasks.php @@ -33,5 +33,5 @@ 'day' => '*', 'dayofweek' => '*', 'month' => '*', - ] + ], ]; diff --git a/tests/behat/behat_local_profilecohort.php b/tests/behat/behat_local_profilecohort.php index 88e4cd6..169ad80 100644 --- a/tests/behat/behat_local_profilecohort.php +++ b/tests/behat/behat_local_profilecohort.php @@ -47,7 +47,7 @@ public function the_following_custom_user_profile_fields_exist(TableNode $table) 'datatype', ]; $optional = [ - 'param1' => '' + 'param1' => '', ]; $data = $table->getHash(); diff --git a/tests/rules_test.php b/tests/rules_test.php index 0d19564..b272b49 100644 --- a/tests/rules_test.php +++ b/tests/rules_test.php @@ -209,14 +209,14 @@ public function test_delete_rule() { $ruledata = (object) [ 'fieldid' => $this->fieldids['textfield'], 'datatype' => 'text', 'matchtype' => field_text::MATCH_EXACT, - 'matchvalue' => 'testing', 'value' => $this->cohortids[0] + 'matchvalue' => 'testing', 'value' => $this->cohortids[0], ]; $rule = field_base::make_instance($ruledata); $rule->save(self::TABLENAME); // Create a 'menu' rule. $ruledata2 = (object) [ 'fieldid' => $this->fieldids['menufield'], 'datatype' => 'menu', - 'matchvalue' => 'Opt 2', 'value' => $this->cohortids[1] + 'matchvalue' => 'Opt 2', 'value' => $this->cohortids[1], ]; $rule = field_base::make_instance($ruledata2); $rule->save(self::TABLENAME); @@ -353,7 +353,7 @@ public function test_match_checkbox() { // Create a 'checkbox' rule. $ruledata = (object) [ 'fieldid' => $this->fieldids['checkboxfield'], 'datatype' => 'checkbox', - 'matchvalue' => 1, 'value' => $this->cohortids[0] + 'matchvalue' => 1, 'value' => $this->cohortids[0], ]; $rule = field_base::make_instance($ruledata); $rule->save(self::TABLENAME); @@ -397,7 +397,7 @@ public function test_match_menu() { // Create a 'menu' rule. $ruledata = (object) [ 'fieldid' => $this->fieldids['menufield'], 'datatype' => 'menu', - 'matchvalue' => 'Opt 2', 'value' => $this->cohortids[0] + 'matchvalue' => 'Opt 2', 'value' => $this->cohortids[0], ]; $rule = field_base::make_instance($ruledata); $rule->save(self::TABLENAME); @@ -446,7 +446,7 @@ public function test_match_text() { $ruledata = (object) [ 'fieldid' => $this->fieldids['textfield'], 'datatype' => 'text', 'matchtype' => field_text::MATCH_EXACT, - 'matchvalue' => 'Another test', 'value' => $this->cohortids[0] + 'matchvalue' => 'Another test', 'value' => $this->cohortids[0], ]; $rule = field_base::make_instance($ruledata); $rule->save(self::TABLENAME); @@ -528,13 +528,13 @@ public function test_update_all_cohort_memberships() { // the other matching 'Opt 2' to 'cohorts[1]'. $ruledata1 = (object) [ 'fieldid' => $this->fieldids['menufield'], 'datatype' => 'menu', - 'matchvalue' => 'Opt 1', 'value' => $this->cohortids[0] + 'matchvalue' => 'Opt 1', 'value' => $this->cohortids[0], ]; $rule1 = field_base::make_instance($ruledata1); $rule1->save(self::TABLENAME); $ruledata2 = (object) [ 'fieldid' => $this->fieldids['menufield'], 'datatype' => 'menu', - 'matchvalue' => 'Opt 2', 'value' => $this->cohortids[1] + 'matchvalue' => 'Opt 2', 'value' => $this->cohortids[1], ]; $rule2 = field_base::make_instance($ruledata2); $rule2->save(self::TABLENAME); @@ -590,13 +590,13 @@ public function test_update_cohort_membership() { // the other matching 'Opt 2' to 'cohorts[1]'. $ruledata1 = (object)[ 'fieldid' => $this->fieldids['menufield'], 'datatype' => 'menu', - 'matchvalue' => 'Opt 1', 'value' => $this->cohortids[0] + 'matchvalue' => 'Opt 1', 'value' => $this->cohortids[0], ]; $rule1 = field_base::make_instance($ruledata1); $rule1->save(self::TABLENAME); $ruledata2 = (object)[ 'fieldid' => $this->fieldids['menufield'], 'datatype' => 'menu', - 'matchvalue' => 'Opt 2', 'value' => $this->cohortids[1] + 'matchvalue' => 'Opt 2', 'value' => $this->cohortids[1], ]; $rule2 = field_base::make_instance($ruledata2); $rule2->save(self::TABLENAME); @@ -668,28 +668,28 @@ public function test_and_rules() { // As 'menufield' == 'Opt 1' => cohort 0 AND next rule must match. $ruledata1 = (object)[ 'fieldid' => $this->fieldids['menufield'], 'datatype' => 'menu', - 'matchvalue' => 'Opt 1', 'value' => $this->cohortids[0], 'andnextrule' => 1 + 'matchvalue' => 'Opt 1', 'value' => $this->cohortids[0], 'andnextrule' => 1, ]; $rule1 = field_base::make_instance($ruledata1); $rule1->save(self::TABLENAME); // As 'checkboxfield' == 0 => cohort 1 AND next rule must match. $ruledata2 = (object)[ 'fieldid' => $this->fieldids['checkboxfield'], 'datatype' => 'checkbox', - 'matchvalue' => '0', 'value' => $this->cohortids[1], 'andnextrule' => 1 + 'matchvalue' => '0', 'value' => $this->cohortids[1], 'andnextrule' => 1, ]; $rule2 = field_base::make_instance($ruledata2); $rule2->save(self::TABLENAME); // As 'textfield' == 'Fred' => cohort 2. $ruledata3 = (object)[ 'fieldid' => $this->fieldids['textfield'], 'datatype' => 'text', - 'matchvalue' => 'Fred', 'value' => $this->cohortids[2], 'andnextrule' => 0 + 'matchvalue' => 'Fred', 'value' => $this->cohortids[2], 'andnextrule' => 0, ]; $rule3 = field_base::make_instance($ruledata3); $rule3->save(self::TABLENAME); // As 'textfield' == 'Fred' => cohort 3 - this rule should match on its own. $ruledata4 = (object)[ 'fieldid' => $this->fieldids['textfield'], 'datatype' => 'text', - 'matchvalue' => 'Fred', 'value' => $this->cohortids[3], 'andnextrule' => 0 + 'matchvalue' => 'Fred', 'value' => $this->cohortids[3], 'andnextrule' => 0, ]; $rule4 = field_base::make_instance($ruledata4); $rule4->save(self::TABLENAME); @@ -759,14 +759,14 @@ public function test_and_rules_ending_in_and() { // As 'menufield' == 'Opt 1' => cohort 0 AND next rule must match. $ruledata1 = (object)[ 'fieldid' => $this->fieldids['menufield'], 'datatype' => 'menu', - 'matchvalue' => 'Opt 1', 'value' => $this->cohortids[0], 'andnextrule' => 1 + 'matchvalue' => 'Opt 1', 'value' => $this->cohortids[0], 'andnextrule' => 1, ]; $rule1 = field_base::make_instance($ruledata1); $rule1->save(self::TABLENAME); // As 'checkboxfield' == 0 => cohort 1 AND next rule must match. $ruledata2 = (object)[ 'fieldid' => $this->fieldids['checkboxfield'], 'datatype' => 'checkbox', - 'matchvalue' => '0', 'value' => $this->cohortids[1], 'andnextrule' => 1 + 'matchvalue' => '0', 'value' => $this->cohortids[1], 'andnextrule' => 1, ]; $rule2 = field_base::make_instance($ruledata2); $rule2->save(self::TABLENAME);