Skip to content

Commit ec78764

Browse files
committed
codechecker issues customfielddelay
1 parent cb0e9ae commit ec78764

File tree

4 files changed

+13
-19
lines changed

4 files changed

+13
-19
lines changed

trigger/customfielddelay/classes/privacy/provider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class provider implements null_provider {
3333
*
3434
* @return string
3535
*/
36-
public static function get_reason() : string {
36+
public static function get_reason(): string {
3737
return 'privacy:metadata';
3838
}
3939
}

trigger/customfielddelay/lib.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,14 @@ public function get_course_recordset_where($triggerid) {
5656
global $DB;
5757
$delay = settings_manager::get_settings($triggerid, settings_type::TRIGGER)['delay'];
5858
$fieldname = settings_manager::get_settings($triggerid, settings_type::TRIGGER)['customfield'];
59-
if (!($field = $DB->get_record('customfield_field', array('shortname' => $fieldname, 'type' => 'date')))) {
59+
if (!($field = $DB->get_record('customfield_field', ['shortname' => $fieldname, 'type' => 'date']))) {
6060
throw new \moodle_exception("missingfield");
6161
}
6262
$where = "{course}.id in (select cxt.instanceid from {context} cxt join {customfield_data} d " .
6363
"ON d.contextid = cxt.id AND cxt.contextlevel=" . CONTEXT_COURSE . " " .
6464
"WHERE d.fieldid = :customfieldid AND d.intvalue > 0 AND d.intvalue < :customfielddelay)";
65-
$params = array(
66-
"customfielddelay" => time() - $delay,
67-
"customfieldid" => $field->id,
68-
);
69-
return array($where, $params);
65+
$params = ["customfielddelay" => time() - $delay, "customfieldid" => $field->id];
66+
return [$where, $params];
7067
}
7168

7269
/**
@@ -82,10 +79,7 @@ public function get_subpluginname() {
8279
* @return instance_setting[] containing settings keys and PARAM_TYPES
8380
*/
8481
public function instance_settings() {
85-
return array(
86-
new instance_setting('delay', PARAM_INT),
87-
new instance_setting('customfield', PARAM_TEXT),
88-
);
82+
return [new instance_setting('delay', PARAM_INT), new instance_setting('customfield', PARAM_TEXT)];
8983
}
9084

9185
/**
@@ -98,8 +92,8 @@ public function extend_add_instance_form_definition($mform) {
9892
global $DB;
9993
$mform->addElement('duration', 'delay', get_string('delay', 'lifecycletrigger_customfielddelay'));
10094
$mform->addHelpButton('delay', 'delay', 'lifecycletrigger_customfielddelay');
101-
$fields = $DB->get_records('customfield_field', array('type' => 'date'));
102-
$choices = array();
95+
$fields = $DB->get_records('customfield_field', ['type' => 'date']);
96+
$choices = [];
10397
foreach ($fields as $field) {
10498
$choices[$field->shortname] = $field->name;
10599
}

trigger/customfielddelay/tests/trigger_test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
* @copyright 2020 Tobias Reischmann WWU
4141
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4242
*/
43-
class trigger_test extends \advanced_testcase {
43+
final class trigger_test extends \advanced_testcase {
4444

4545
/** @var $triggerinstance trigger_subplugin Instance of the trigger. */
4646
private $triggerinstance;
@@ -58,7 +58,7 @@ class trigger_test extends \advanced_testcase {
5858
* @return void
5959
* @throws \moodle_exception
6060
*/
61-
public function setUp() : void {
61+
public function setUp(): void {
6262
$this->resetAfterTest(true);
6363
$this->setAdminUser();
6464

@@ -82,7 +82,7 @@ public function setUp() : void {
8282
* @throws \coding_exception
8383
* @throws \dml_exception
8484
*/
85-
public function test_young_course() {
85+
public function test_young_course(): void {
8686
$customfieldvalue = ['shortname' => 'test', 'value' => time() + 1000000];
8787
$course = $this->getDataGenerator()->create_course(['customfields' => [$customfieldvalue]]);
8888

@@ -106,7 +106,7 @@ public function test_young_course() {
106106
* @throws \coding_exception
107107
* @throws \dml_exception
108108
*/
109-
public function test_young_course_with_second_customcourse_field() {
109+
public function test_young_course_with_second_customcourse_field(): void {
110110

111111
// Add additional course field.
112112
$customfield = ['shortname' => 'test2', 'name' => 'Custom field2', 'type' => 'date',
@@ -136,7 +136,7 @@ public function test_young_course_with_second_customcourse_field() {
136136
* @throws \coding_exception
137137
* @throws \dml_exception
138138
*/
139-
public function test_old_course() {
139+
public function test_old_course(): void {
140140

141141
$customfieldvalue = ['shortname' => 'test', 'value' => time() - 1000000];
142142
$course = $this->getDataGenerator()->create_course(['customfields' => [$customfieldvalue]]);

trigger/customfielddelay/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
$plugin->component = 'lifecycletrigger_customfielddelay';
3232
$plugin->release = 'v4.5-r1';
3333
$plugin->maturity = MATURITY_STABLE;
34-
$plugin->dependencies = ['customfield_semester' => 2020041304,];
34+
$plugin->dependencies = ['customfield_semester' => 2020041304];

0 commit comments

Comments
 (0)