Skip to content

Commit

Permalink
codechecker fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed Feb 1, 2024
1 parent 1e63702 commit d427b5e
Show file tree
Hide file tree
Showing 49 changed files with 830 additions and 830 deletions.
48 changes: 24 additions & 24 deletions backup/moodle2/backup_moodleoverflow_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,49 +44,49 @@ protected function define_structure() {
$userinfo = $this->get_setting_value('userinfo');

// Define the root element describing the moodleoverflow instance.
$moodleoverflow = new backup_nested_element('moodleoverflow', array('id'), array(
$moodleoverflow = new backup_nested_element('moodleoverflow', ['id'], [
'name', 'intro', 'introformat', 'maxbytes', 'maxattachments',
'forcesubscribe', 'trackingtype', 'timecreated', 'timemodified',
'ratingpreference', 'coursewidereputation', 'allownegativereputation'));
'ratingpreference', 'coursewidereputation', 'allownegativereputation', ]);

// Define each element separated.
$discussions = new backup_nested_element('discussions');
$discussion = new backup_nested_element('discussion', array('id'), array(
'name', 'firstpost', 'userid', 'timemodified', 'usermodified', 'timestart'));
$discussion = new backup_nested_element('discussion', ['id'], [
'name', 'firstpost', 'userid', 'timemodified', 'usermodified', 'timestart', ]);

$posts = new backup_nested_element('posts');

$post = new backup_nested_element('post', array('id'), array(
$post = new backup_nested_element('post', ['id'], [
'parent', 'userid', 'created', 'modified',
'mailed', 'message', 'messageformat', 'attachment'));
'mailed', 'message', 'messageformat', 'attachment', ]);

$ratings = new backup_nested_element('ratings');

$rating = new backup_nested_element('rating', array('id'), array(
'userid', 'rating', 'firstrated', 'lastchanged'));
$rating = new backup_nested_element('rating', ['id'], [
'userid', 'rating', 'firstrated', 'lastchanged', ]);

$discussionsubs = new backup_nested_element('discuss_subs');

$discussionsub = new backup_nested_element('discuss_sub', array('id'), array(
$discussionsub = new backup_nested_element('discuss_sub', ['id'], [
'userid',
'preference',
));
]);

$subscriptions = new backup_nested_element('subscriptions');

$subscription = new backup_nested_element('subscription', array('id'), array(
'userid'));
$subscription = new backup_nested_element('subscription', ['id'], [
'userid', ]);

$readposts = new backup_nested_element('readposts');

$read = new backup_nested_element('read', array('id'), array(
$read = new backup_nested_element('read', ['id'], [
'userid', 'discussionid', 'postid', 'firstread',
'lastread'));
'lastread', ]);

$tracking = new backup_nested_element('tracking');

$track = new backup_nested_element('track', array('id'), array(
'userid'));
$track = new backup_nested_element('track', ['id'], [
'userid', ]);

// Build the tree.
$moodleoverflow->add_child($discussions);
Expand All @@ -111,23 +111,23 @@ protected function define_structure() {
$tracking->add_child($track);

// Define data sources.
$moodleoverflow->set_source_table('moodleoverflow', array('id' => backup::VAR_ACTIVITYID));
$moodleoverflow->set_source_table('moodleoverflow', ['id' => backup::VAR_ACTIVITYID]);

// All these source definitions only happen if we are including user info.
if ($userinfo) {
$discussion->set_source_sql('
SELECT *
FROM {moodleoverflow_discussions}
WHERE moodleoverflow = ?',
array(backup::VAR_PARENTID));
[backup::VAR_PARENTID]);

// Need posts ordered by id so parents are always before childs on restore.
$post->set_source_table('moodleoverflow_posts', array('discussion' => backup::VAR_PARENTID), 'id ASC');
$rating->set_source_table('moodleoverflow_ratings', array('postid' => backup::VAR_PARENTID));
$discussionsub->set_source_table('moodleoverflow_discuss_subs', array('discussion' => backup::VAR_PARENTID));
$subscription->set_source_table('moodleoverflow_subscriptions', array('moodleoverflow' => backup::VAR_PARENTID));
$read->set_source_table('moodleoverflow_read', array('moodleoverflowid' => backup::VAR_PARENTID));
$track->set_source_table('moodleoverflow_tracking', array('moodleoverflowid' => backup::VAR_PARENTID));
$post->set_source_table('moodleoverflow_posts', ['discussion' => backup::VAR_PARENTID], 'id ASC');
$rating->set_source_table('moodleoverflow_ratings', ['postid' => backup::VAR_PARENTID]);
$discussionsub->set_source_table('moodleoverflow_discuss_subs', ['discussion' => backup::VAR_PARENTID]);
$subscription->set_source_table('moodleoverflow_subscriptions', ['moodleoverflow' => backup::VAR_PARENTID]);
$read->set_source_table('moodleoverflow_read', ['moodleoverflowid' => backup::VAR_PARENTID]);
$track->set_source_table('moodleoverflow_tracking', ['moodleoverflowid' => backup::VAR_PARENTID]);
}

// Define id annotations.
Expand Down
16 changes: 8 additions & 8 deletions backup/moodle2/restore_moodleoverflow_activity_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ protected function define_my_steps() {
* processed by the link decoder
*/
public static function define_decode_contents() {
$contents = array();
$contents = [];

$contents[] = new restore_decode_content('moodleoverflow', array('intro'), 'moodleoverflow');
$contents[] = new restore_decode_content('moodleoverflow_posts', array('message'), 'moodleoverflow_post');
$contents[] = new restore_decode_content('moodleoverflow', ['intro'], 'moodleoverflow');
$contents[] = new restore_decode_content('moodleoverflow_posts', ['message'], 'moodleoverflow_post');

return $contents;
}
Expand All @@ -72,7 +72,7 @@ public static function define_decode_contents() {
* to the activity to be executed by the link decoder
*/
public static function define_decode_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_decode_rule('MOODLEOVERFLOWVIEWBYID', '/mod/moodleoverflow/view.php?id=$1', 'course_module');
$rules[] = new restore_decode_rule('MOODLEOVERFLOWINDEX', '/mod/moodleoverflow/index.php?id=$1', 'course');
Expand All @@ -85,9 +85,9 @@ public static function define_decode_rules() {
// Link to discussion with parent and with anchor posts.
$rules[] = new restore_decode_rule('MOODLEOVERFLOWDISCUSSIONVIEWPARENT',
'/mod/moodleoverflow/discussion.php?d=$1&parent=$2',
array('moodleoverflow_discussion', 'moodleoverflow_post'));
['moodleoverflow_discussion', 'moodleoverflow_post']);
$rules[] = new restore_decode_rule('MOODLEOVERFLOWDISCUSSIONVIEWINSIDE', '/mod/moodleoverflow/discussion.php?d=$1#$2',
array('moodleoverflow_discussion', 'moodleoverflow_post'));
['moodleoverflow_discussion', 'moodleoverflow_post']);

return $rules;

Expand All @@ -100,7 +100,7 @@ public static function define_decode_rules() {
* of { restore_log_rule} objects
*/
public static function define_restore_log_rules() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('moodleoverflow', 'add',
'view.php?id={course_module}', '{moodleoverflow}');
Expand Down Expand Up @@ -160,7 +160,7 @@ public static function define_restore_log_rules() {
* activity level. All them are rules not linked to any module instance (cmid = 0)
*/
public static function define_restore_log_rules_for_course() {
$rules = array();
$rules = [];

$rules[] = new restore_log_rule('moodleoverflow', 'view all', 'index.php?id={course}', null);

Expand Down
4 changes: 2 additions & 2 deletions backup/moodle2/restore_moodleoverflow_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class restore_moodleoverflow_activity_structure_step extends restore_activity_st
*/
protected function define_structure() {

$paths = array();
$paths = [];
$userinfo = $this->get_setting_value('userinfo');

$paths[] = new restore_path_element('moodleoverflow', '/activity/moodleoverflow');
Expand Down Expand Up @@ -138,7 +138,7 @@ protected function process_moodleoverflow_post($data) {

// If !post->parent, it's the 1st post. Set it in discussion.
if (empty($data->parent)) {
$DB->set_field('moodleoverflow_discussions', 'firstpost', $newitemid, array('id' => $data->discussion));
$DB->set_field('moodleoverflow_discussions', 'firstpost', $newitemid, ['id' => $data->discussion]);
}
}

Expand Down
2 changes: 1 addition & 1 deletion classes/anonymous.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function get_userid_mapping($moodleoverflow, $discussionid) {
if ($moodleoverflow->anonymous == self::QUESTION_ANONYMOUS) {
return [
$DB->get_field('moodleoverflow_posts', 'userid',
['parent' => 0, 'discussion' => $discussionid]) => get_string('questioner', 'mod_moodleoverflow')
['parent' => 0, 'discussion' => $discussionid]) => get_string('questioner', 'mod_moodleoverflow'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion classes/event/readtracking_disabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/moodleoverflow/view.php', array('m' => $this->other['moodleoverflowid']));
return new \moodle_url('/mod/moodleoverflow/view.php', ['m' => $this->other['moodleoverflowid']]);
}
}
2 changes: 1 addition & 1 deletion classes/event/readtracking_enabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ public static function get_name() {
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/moodleoverflow/view.php', array('m' => $this->other['moodleoverflowid']));
return new \moodle_url('/mod/moodleoverflow/view.php', ['m' => $this->other['moodleoverflowid']]);
}
}
8 changes: 4 additions & 4 deletions classes/observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function user_enrolment_deleted(\core\event\user_enrolment_deleted
if ($cp->lastenrol) {

// Get the moodleoverflow instances from which the user was unenrolled from.
$moodleoverflows = $DB->get_records('moodleoverflow', array('course' => $cp->courseid), '', 'id');
$moodleoverflows = $DB->get_records('moodleoverflow', ['course' => $cp->courseid], '', 'id');

// Do not continue if there are no connected moodleoverflow instances.
if (!$moodleoverflows) {
Expand Down Expand Up @@ -93,9 +93,9 @@ public static function role_assigned(\core\event\role_assigned $event) {
JOIN {modules} mo ON (mo.id = cm.module)
LEFT JOIN {moodleoverflow_subscriptions} ms ON (ms.moodleoverflow = m.id AND ms.userid = :userid)
WHERE m.course = :courseid AND m.forcesubscribe = :initial AND mo.name = 'moodleoverflow' AND ms.id IS NULL";
$params = array('courseid' => $context->instanceid,
$params = ['courseid' => $context->instanceid,
'userid' => $userid,
'initial' => MOODLEOVERFLOW_INITIALSUBSCRIBE);
'initial' => MOODLEOVERFLOW_INITIALSUBSCRIBE, ];
$moodleoverflows = $DB->get_records_sql($sql, $params);

// Loop through all moodleoverflows.
Expand Down Expand Up @@ -133,7 +133,7 @@ public static function course_module_created(\core\event\course_module_created $
require_once($CFG->dirroot . '/mod/moodleoverflow/lib.php');

// Create a snapshot of the created moodleoverflow record.
$moodleoverflow = $DB->get_record('moodleoverflow', array('id' => $event->other['instanceid']));
$moodleoverflow = $DB->get_record('moodleoverflow', ['id' => $event->other['instanceid']]);

// Trigger the function for a created moodleoverflow instance.
moodleoverflow_instance_created($event->get_context(), $moodleoverflow);
Expand Down
52 changes: 26 additions & 26 deletions classes/output/moodleoverflow_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class moodleoverflow_email implements \renderable, \templatable {
*
* @var array $writablekeys
*/
protected $writablekeys = array(
protected $writablekeys = [
'viewfullnames' => true,
);
];

/**
* Builds a renderable moodleoverflow mail.
Expand Down Expand Up @@ -154,7 +154,7 @@ public function export_for_template(\renderer_base $renderer, $plaintext = false
*/
protected function export_for_template_text(\mod_moodleoverflow_renderer $renderer) {

return array(
return [
'id' => html_entity_decode($this->post->id, ENT_COMPAT),
'coursename' => html_entity_decode($this->get_coursename(), ENT_COMPAT),
'courselink' => html_entity_decode($this->get_courselink(), ENT_COMPAT),
Expand All @@ -180,7 +180,7 @@ protected function export_for_template_text(\mod_moodleoverflow_renderer $render

// Format some components according to the renderer.
'message' => html_entity_decode($renderer->format_message_text($this->cm, $this->post), ENT_COMPAT),
);
];
}

/**
Expand All @@ -191,7 +191,7 @@ protected function export_for_template_text(\mod_moodleoverflow_renderer $render
* @return stdClass Data ready for use in a mustache template
*/
protected function export_for_template_html(\mod_moodleoverflow_renderer $renderer) {
return array(
return [
'id' => $this->post->id,
'coursename' => $this->get_coursename(),
'courselink' => $this->get_courselink(),
Expand All @@ -217,7 +217,7 @@ protected function export_for_template_html(\mod_moodleoverflow_renderer $render

// Format some components according to the renderer.
'message' => $renderer->format_message_text($this->cm, $this->post),
);
];
}

/**
Expand Down Expand Up @@ -263,7 +263,7 @@ public function get_unsubscribediscussionlink() {
$url = '/mod/moodleoverflow/subscribe.php';

// Generate a link to unsubscribe from the discussion.
$link = new \moodle_url($url, array('id' => $id, 'd' => $d));
$link = new \moodle_url($url, ['id' => $id, 'd' => $d]);

return $link->out(false);
}
Expand Down Expand Up @@ -292,9 +292,9 @@ public function get_courseidnumber() {
* @return string
*/
public function get_coursefullname() {
return format_string($this->course->fullname, true, array(
return format_string($this->course->fullname, true, [
'context' => \context_course::instance($this->course->id),
));
]);
}

/**
Expand All @@ -303,9 +303,9 @@ public function get_coursefullname() {
* @return string
*/
public function get_coursename() {
return format_string($this->course->shortname, true, array(
return format_string($this->course->shortname, true, [
'context' => \context_course::instance($this->course->id),
));
]);
}

/**
Expand All @@ -316,9 +316,9 @@ public function get_coursename() {
public function get_courselink() {
$link = new \moodle_url(
// Posts are viewed on the topic.
'/course/view.php', array(
'/course/view.php', [
'id' => $this->course->id,
)
]
);

return $link->out(false);
Expand Down Expand Up @@ -420,9 +420,9 @@ public function is_firstpost() {
*/
public function get_replylink() {
return new \moodle_url(
'/mod/moodleoverflow/post.php', array(
'/mod/moodleoverflow/post.php', [
'reply' => $this->post->id,
)
]
);
}

Expand All @@ -437,9 +437,9 @@ public function get_unsubscribemoodleoverflowlink() {
return null;
}
$link = new \moodle_url(
'/mod/moodleoverflow/subscribe.php', array(
'/mod/moodleoverflow/subscribe.php', [
'id' => $this->moodleoverflow->id,
)
]
);

return $link->out(false);
Expand All @@ -465,10 +465,10 @@ public function get_parentpostlink() {
protected function get_discussionurl() {
return new \moodle_url(
// Posts are viewed on the topic.
'/mod/moodleoverflow/discussion.php', array(
'/mod/moodleoverflow/discussion.php', [
// Within a discussion.
'd' => $this->discussion->id,
)
]
);
}

Expand All @@ -491,9 +491,9 @@ public function get_discussionlink() {
public function get_moodleoverflowindexlink() {
$link = new \moodle_url(
// Posts are viewed on the topic.
'/mod/moodleoverflow/index.php', array(
'/mod/moodleoverflow/index.php', [
'id' => $this->course->id,
)
]
);

return $link->out(false);
Expand All @@ -507,9 +507,9 @@ public function get_moodleoverflowindexlink() {
public function get_moodleoverflowviewlink() {
$link = new \moodle_url(
// Posts are viewed on the topic.
'/mod/moodleoverflow/view.php', array(
'/mod/moodleoverflow/view.php', [
'm' => $this->moodleoverflow->id,
)
]
);

return $link->out(false);
Expand All @@ -526,10 +526,10 @@ public function get_authorlink() {
}

$link = new \moodle_url(
'/user/view.php', array(
'/user/view.php', [
'id' => $this->post->userid,
'course' => $this->course->id,
)
]
);

return $link->out(false);
Expand All @@ -546,7 +546,7 @@ public function get_author_picture() {
return '';
}

return $OUTPUT->user_picture($this->author, array('courseid' => $this->course->id));
return $OUTPUT->user_picture($this->author, ['courseid' => $this->course->id]);
}

/**
Expand Down
Loading

0 comments on commit d427b5e

Please sign in to comment.