Skip to content

Fixed codechecker issues 403 #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: MOODLE_403_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions classes/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ public static function assign_meta(\cm_info $modinst) {
AND ac.subtype='assignsubmission'
AND plugin!='comments'
GROUP BY a.id;";
$submissionsenabled = $DB->get_records_sql($sql, array($courseid));
$submissionsenabled = $DB->get_records_sql($sql, [$courseid]);
$coursequeried = $courseid;
}

Expand Down Expand Up @@ -323,7 +323,7 @@ public static function forum_meta(\cm_info $modinst) {
public static function assign_ungraded($courseids, $since = null) {
global $DB;

$ungraded = array();
$ungraded = [];

if ($since === null) {
$since = time() - (12 * WEEKSECS);
Expand Down Expand Up @@ -415,7 +415,7 @@ public static function quiz_ungraded($courseids, $since = null) {
$since = time() - (12 * WEEKSECS);
}

$ungraded = array();
$ungraded = [];

foreach ($courseids as $courseid) {

Expand Down Expand Up @@ -489,13 +489,13 @@ public static function assign_num_submissions_ungraded($courseid, $modid) {
}

// Check to see if this assign is graded.
$params = array(
$params = [
'courseid' => $courseid,
'itemtype' => 'mod',
'itemmodule' => 'assign',
'gradetypenone' => GRADE_TYPE_NONE,
'gradetypetext' => GRADE_TYPE_TEXT,
);
];

$sql = 'SELECT DISTINCT iteminstance
FROM {grade_items}
Expand Down Expand Up @@ -590,7 +590,7 @@ protected static function std_num_submissions($courseid,
$extraselect = '') {
global $DB;

static $modtotalsbyid = array();
static $modtotalsbyid = [];

if (!isset($modtotalsbyid[$maintable][$courseid])) {
// Results are not cached, so lets get them.
Expand Down Expand Up @@ -640,7 +640,7 @@ protected static function std_num_submissions($courseid,
public static function assign_num_submissions($courseid, $modid) {
global $DB;

static $modtotalsbyid = array();
static $modtotalsbyid = [];

if (!isset($modtotalsbyid['assign'][$courseid])) {
// Results are not cached, so lets get them.
Expand Down Expand Up @@ -799,7 +799,7 @@ public static function get_submission_row($courseid, $mod, $submissiontable, $mo
global $DB, $USER;

// Note: Caches all submissions to minimise database transactions.
static $submissions = array();
static $submissions = [];

// Pull from cache?
if (!PHPUNIT_TEST) {
Expand Down Expand Up @@ -1056,7 +1056,7 @@ public static function instance_activity_dates($courseid, \cm_info $mod, $timeop
$assigninstance = $assign->id;
$dates = $moddates[$courseid . '_' . $modname][$assigninstance];
// Check if there is any extension.
$flags = $DB->get_record('assign_user_flags', array('assignment' => $assigninstance, 'userid' => $USER->id));
$flags = $DB->get_record('assign_user_flags', ['assignment' => $assigninstance, 'userid' => $USER->id]);
if (!empty($flags->extensionduedate)) {
// If there is an extension, then assign the duedate of the extension.
$timeclose = $flags->extensionduedate;
Expand Down Expand Up @@ -1133,7 +1133,7 @@ public static function instance_activity_dates($courseid, \cm_info $mod, $timeop
public static function grade_row($courseid, $mod) {
global $DB, $USER;

static $grades = array();
static $grades = [];

if (isset($grades[$courseid.'_'.$mod->modname])
&& isset($grades[$courseid.'_'.$mod->modname][$mod->instance])
Expand Down Expand Up @@ -1163,12 +1163,12 @@ public static function grade_row($courseid, $mod) {
OR gg.feedback IS NOT NULL
)
";
$params = array(
$params = [
'modname' => $mod->modname,
'courseid1' => $courseid,
'courseid2' => $courseid,
'userid' => $USER->id,
);
];
$grades[$courseid.'_'.$mod->modname] = $DB->get_records_sql($sql, $params);

if (isset($grades[$courseid.'_'.$mod->modname][$mod->instance])) {
Expand Down Expand Up @@ -1218,7 +1218,7 @@ public static function events_graded($onlyactive = true, $showfrom = null) {
$params = array_merge($params, [$USER->id, $showfrom, $showfrom]);
$grades = $DB->get_records_sql($sql, $params, 0, 5);

$eventdata = array();
$eventdata = [];
foreach ($grades as $grade) {
$eventdata[] = $grade;
}
Expand Down Expand Up @@ -1680,7 +1680,7 @@ private static function get_groups_sql($courseid) {

$sqlgroupsjoin = '';
$sqlgroupswhere = '';
$groupparams = array();
$groupparams = [];

$course = get_course($courseid);
$groupmode = groups_get_course_groupmode($course);
Expand All @@ -1703,7 +1703,7 @@ private static function get_groups_sql($courseid) {
WHERE g.courseid = :courseid2
AND gm.userid = :userid)";
}
return array($sqlgroupsjoin, $sqlgroupswhere, $groupparams);
return [$sqlgroupsjoin, $sqlgroupswhere, $groupparams];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/admin_setting_configcolorcategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function write_setting($data) {
*/
private function validate_text($data) {
$temp = $data;
$symbols = array('{', '}', '"');
$symbols = ['{', '}', '"'];
foreach ($symbols as $symbol) {
$temp = str_replace($symbol, '', $temp);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ protected function get_raw_events_legacy_implementation(
) {
global $DB, $CFG;

$params = array();
$params = [];
// Quick test.
if (empty($users) && empty($groups) && empty($courses) && empty($categories)) {
return array();
return [];
}

if (is_numeric($users)) {
$users = array($users);
$users = [$users];
}
if (is_numeric($groups)) {
$groups = array($groups);
$groups = [$groups];
}
if (is_numeric($courses)) {
$courses = array($courses);
$courses = [$courses];
}
if (is_numeric($categories)) {
$categories = array($categories);
$categories = [$categories];
}

// Array of filter conditions. To be concatenated by the OR operator.
Expand Down Expand Up @@ -133,7 +133,7 @@ protected function get_raw_events_legacy_implementation(
// events no matter what. Allowing the code to proceed might return a completely
// valid query with only time constraints, thus selecting ALL events in that time frame!
if (empty($filters)) {
return array();
return [];
}

// Build our clause for the filters.
Expand Down
10 changes: 5 additions & 5 deletions classes/controller/addsection_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ public function addsection_action() {
$numsections = course_get_format($courseid)->get_last_section_number() + 1;
course_create_sections_if_missing($course, range(0, $numsections));

$options = array(
$options = [
'subdirs' => 0,
'maxbytes' => 0,
'maxfiles' => -1,
'context' => $context,
);
];
$modinfo = get_fast_modinfo($course);
$section = $modinfo->get_section_info($numsections, MUST_EXIST);
$summarytext = file_save_draft_area_files($draftitemid, $context->id, 'course', 'section',
$section->id, $options, $summarytext);
$DB->set_field('course_sections', 'name', $sectioname, array('id' => $section->id));
$DB->set_field('course_sections', 'summary', $summarytext, array('id' => $section->id));
$DB->set_field('course_sections', 'summaryformat', $summaryformat, array('id' => $section->id));
$DB->set_field('course_sections', 'name', $sectioname, ['id' => $section->id]);
$DB->set_field('course_sections', 'summary', $summarytext, ['id' => $section->id]);
$DB->set_field('course_sections', 'summaryformat', $summaryformat, ['id' => $section->id]);
rebuild_course_cache($course->id);

redirect(course_get_url($course, $section->section));
Expand Down
2 changes: 1 addition & 1 deletion classes/controller/controller_abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class controller_abstract {
* @param array $params
* @return \moodle_url
*/
public function new_url($params = array()) {
public function new_url($params = []) {
global $PAGE;

$url = $PAGE->url;
Expand Down
2 changes: 1 addition & 1 deletion classes/controller/kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function resolve_controller_callback($action) {

$controller->init($action);

return array($controller, $method);
return [$controller, $method];
}

/**
Expand Down
14 changes: 7 additions & 7 deletions classes/controller/mediaresource_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ private function get_media_html($resource, $context, \cm_info $cm) {
} else {
$file = reset($files);
unset($files);
$embedoptions = array(
$embedoptions = [
\core_media_manager::OPTION_TRUSTED => true,
\core_media_manager::OPTION_BLOCK => true,
);
];
$path = '/'.$context->id.'/mod_resource/content/'.$resource->revision.$file->get_filepath().$file->get_filename();
$moodleurl = new \moodle_url('/pluginfile.php' . $path);
$embedhtml = \core_media_manager::instance()->embed_url($moodleurl, $resource->name, 0, 0, $embedoptions);
Expand Down Expand Up @@ -102,11 +102,11 @@ private function read_media() {
$context = \context_module::instance($cm->id);

// Trigger module instance viewed event.
$event = \mod_resource\event\course_module_viewed::create(array(
$event = \mod_resource\event\course_module_viewed::create([
'objectid' => $cm->instance,
'context' => $context,
));
$resource = $DB->get_record('resource', array('id' => $cm->instance));
]);
$resource = $DB->get_record('resource', ['id' => $cm->instance]);
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $COURSE);
$event->add_record_snapshot('resource', $resource);
Expand All @@ -131,10 +131,10 @@ private function read_media() {
public function get_media_action() {
$media = $this->read_media();

return json_encode(array(
return json_encode([
'html' => $media->content,
'completionhtml' => $media->completionhtml,
));
]);
}

}
12 changes: 6 additions & 6 deletions classes/controller/pagemod_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ private function read_page() {
$context = $PAGE->context;

// Trigger module instance viewed event.
$event = \mod_page\event\course_module_viewed::create(array(
$event = \mod_page\event\course_module_viewed::create([
'objectid' => $page->id,
'context' => $context,
));
]);
$event->add_record_snapshot('course_modules', $cm);
$event->add_record_snapshot('course', $COURSE);
$event->add_record_snapshot('page', $page);
Expand All @@ -90,11 +90,11 @@ private function read_page() {
public function get_page_action() {
$page = $this->read_page();

return json_encode(array(
return json_encode([
'html' => $page->content,
'cmid' => $page->cmid,
'completionhtml' => $page->completionhtml,
));
]);
}

/**
Expand All @@ -105,11 +105,11 @@ public function get_page_action() {
public function read_page_action() {
$page = $this->read_page();

return json_encode(array(
return json_encode([
'id' => $page->id,
'cmid' => $page->cmid,
'completionhtml' => $page->completionhtml,
));
]);
}

}
2 changes: 1 addition & 1 deletion classes/controller/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function route_action($action) {
} else if ($reflection->getMethod($method)->isPublic() !== true) {
throw new coding_exception("The controller callback is not public: $method");
}
return array($controller, $method);
return [$controller, $method];
}
throw new coding_exception("Unable to handle request for $method");
}
Expand Down
20 changes: 10 additions & 10 deletions classes/controller/snap_personal_menu_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public function get_deadlines_action() {
* @return string
*/
public function get_forumposts_action() {
return json_encode(array(
return json_encode([
'html' => \theme_snap\local::render_recent_forum_activity(),
));
]);
}

/**
Expand All @@ -63,9 +63,9 @@ public function get_forumposts_action() {
* @return string
*/
public function get_graded_action() {
return json_encode(array(
return json_encode([
'html' => \theme_snap\local::graded(),
));
]);
}

/**
Expand All @@ -74,9 +74,9 @@ public function get_graded_action() {
* @return string
*/
public function get_messages_action() {
return json_encode(array(
return json_encode([
'html' => \theme_snap\local::messages(),
));
]);
}

/**
Expand All @@ -85,9 +85,9 @@ public function get_messages_action() {
* @return string
*/
public function get_grading_action() {
return json_encode(array(
return json_encode([
'html' => \theme_snap\local::grading(),
));
]);
}

/**
Expand All @@ -101,9 +101,9 @@ public function get_courseinfo_action() {
$courseids = explode(',', $courseids);
}
$courseinfo = \theme_snap\local::courseinfo($courseids);
return json_encode(array(
return json_encode([
'info' => $courseinfo,
));
]);
}

/**
Expand Down
Loading