Skip to content

Commit

Permalink
Code checker updates for Moodle 4.4
Browse files Browse the repository at this point in the history
  • Loading branch information
james-cnz committed Feb 19, 2024
1 parent 351c5cf commit 8699286
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 34 deletions.
2 changes: 1 addition & 1 deletion classes/courseformat/stateactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public function fmt_section_move_into(
* @param int[] $ids section ids
* @param int $visible the new visible value
*/
protected function set_section_visibility (
protected function set_section_visibility(
\core_courseformat\stateupdates $updates,
\stdClass $course,
array $ids,
Expand Down
6 changes: 3 additions & 3 deletions classes/global_navigation_wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __construct(\global_navigation $inner) {
* @param \stdClass $course
* @return array [$sections, $activities]
*/
protected function generate_sections_and_activities(\stdClass $course) : array {
protected function generate_sections_and_activities(\stdClass $course): array {
global $CFG;
require_once($CFG->dirroot . '/course/lib.php');

Expand Down Expand Up @@ -150,7 +150,7 @@ protected function generate_sections_and_activities(\stdClass $course) : array {
* @param \navigation_node $coursenode
* @return array An array of course section nodes
*/
public function load_generic_course_sections(\stdClass $course, \navigation_node $coursenode) : array {
public function load_generic_course_sections(\stdClass $course, \navigation_node $coursenode): array {
global $CFG, $SITE; // CHANGED: Removed $DB and $USER.
require_once($CFG->dirroot . '/course/lib.php');

Expand Down Expand Up @@ -241,7 +241,7 @@ public function load_generic_course_sections(\stdClass $course, \navigation_node
* @return array Array of activity nodes
*/
protected function load_section_activities(\navigation_node $sectionnode, \section_info $section, array $activities,
\stdClass $course = null) : array {
\stdClass $course = null): array {
// CHANGED ABOVE: Use section info instead of number.
global $CFG, $SITE;
// A static counter for JS function naming.
Expand Down
8 changes: 4 additions & 4 deletions classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function render(\renderable $widget) {
* @param bool $linkifneeded Whether to add link
* @return string HTML to output.
*/
public function section_title($section, $course, bool $linkifneeded = true) : string {
public function section_title($section, $course, bool $linkifneeded = true): string {
// CHANGED LINE ABOVE.

// ADDED.
Expand Down Expand Up @@ -160,7 +160,7 @@ public function section_title($section, $course, bool $linkifneeded = true) : st
* @param int|\stdClass $course The course entry from DB
* @return string HTML to output.
*/
public function section_title_without_link($section, $course) : string {
public function section_title_without_link($section, $course): string {
return $this->section_title($section, $course, false); // CHANGED.
}

Expand Down Expand Up @@ -193,7 +193,7 @@ public function course_index_drawer(\core_courseformat\base $format): String {
* @param \format_multitopic\courseheader $header header to render
* @return string HTML to output.
*/
protected function render_courseheader(\format_multitopic\courseheader $header) : string {
protected function render_courseheader(\format_multitopic\courseheader $header): string {
return $header->output();
}

Expand All @@ -204,7 +204,7 @@ protected function render_courseheader(\format_multitopic\courseheader $header)
* @return string HTML to output.
*/
protected function render_coursecontentheaderfooter(
\format_multitopic\coursecontentheaderfooter $headerfooter) : string {
\format_multitopic\coursecontentheaderfooter $headerfooter): string {
return $headerfooter->output();
}
// END ADDED.
Expand Down
2 changes: 1 addition & 1 deletion classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class provider implements null_provider {
*
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
40 changes: 20 additions & 20 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function page_title(): string {
*
* @return bool
*/
public function uses_sections() : bool {
public function uses_sections(): bool {
return true;
}

Expand All @@ -145,7 +145,7 @@ public function uses_sections() : bool {
*
* @return bool
*/
public function uses_course_index() : bool {
public function uses_course_index(): bool {
return true;
}

Expand All @@ -169,7 +169,7 @@ public function uses_indentation(): bool {
* @param bool $needall do we need all properties
* @return \format_multitopic\section_info_extra[]
*/
final public function fmt_get_sections_extra($needall = true) : array {
final public function fmt_get_sections_extra($needall = true): array {

$course = $this->get_course();
$modinfo = $course ? $this->get_modinfo() : null;
Expand Down Expand Up @@ -385,7 +385,7 @@ final public function fmt_get_section_extra($section, int $strictness = IGNORE_M
* @param int|stdClass|\section_info $section Section object from database.
* @return string Display name that the course format prefers, e.g. "Section 2"
*/
public function get_section_name($section) : string {
public function get_section_name($section): string {

// ADDED.
if (!is_object($section)) {
Expand Down Expand Up @@ -462,7 +462,7 @@ public function get_section_name($section) : string {
* @param stdClass $section Section object from database or just field course_sections section
* @return string The default value for the section name.
*/
public function get_default_section_name($section) : string {
public function get_default_section_name($section): string {
if ($section->section == 0) {
// Return the general section.
return get_string('section0name', 'format_multitopic');
Expand Down Expand Up @@ -740,7 +740,7 @@ public function get_view_url($section, $options = []) {
*
* @return stdClass
*/
public function supports_ajax() : stdClass {
public function supports_ajax(): stdClass {
$ajaxsupport = new stdClass();
$ajaxsupport->capable = true;
return $ajaxsupport;
Expand All @@ -756,7 +756,7 @@ public function supports_ajax() : stdClass {
*
* @return bool if the format is compatible with components.
*/
public function supports_components() : bool {
public function supports_components(): bool {
return true;
}

Expand Down Expand Up @@ -803,7 +803,7 @@ public function extend_course_navigation($navigation, navigation_node $node) {
*
* @return array This will be passed in ajax respose
*/
public function ajax_section_move() : array {
public function ajax_section_move(): array {
global $PAGE;
$titles = [];
$current = -1;
Expand All @@ -828,7 +828,7 @@ public function ajax_section_move() : array {
* @return array of default blocks, must contain two keys BLOCK_POS_LEFT and BLOCK_POS_RIGHT
* each of values is an array of block names (for left and right side columns)
*/
public function get_default_blocks() : array {
public function get_default_blocks(): array {
return [
BLOCK_POS_LEFT => [],
BLOCK_POS_RIGHT => [],
Expand All @@ -846,7 +846,7 @@ public function get_default_blocks() : array {
* @param bool $foreditform
* @return array of options
*/
public function course_format_options($foreditform = false) : array {
public function course_format_options($foreditform = false): array {
static $courseformatoptions = false;
if ($courseformatoptions === false) {
$courseconfig = get_config('moodlecourse');
Expand Down Expand Up @@ -974,7 +974,7 @@ public function course_format_options($foreditform = false) : array {
* @param bool $foreditform
* @return array
*/
public function section_format_options($foreditform = false) : array {
public function section_format_options($foreditform = false): array {
// INCLUDED instead /course/format/topics/lib.php function course_format_options body (excluding array items).
static $sectionformatoptions = false;
if ($sectionformatoptions === false) {
Expand Down Expand Up @@ -1074,7 +1074,7 @@ public function section_format_options($foreditform = false) : array {
* @param bool $forsection 'true' if this is a section edit form, 'false' if this is course edit form.
* @return array array of references to the added form elements.
*/
public function create_edit_form_elements(&$mform, $forsection = false) : array {
public function create_edit_form_elements(&$mform, $forsection = false): array {
$elements = parent::create_edit_form_elements($mform, $forsection);

// REMOVED: numsections .
Expand All @@ -1101,7 +1101,7 @@ public function create_edit_form_elements(&$mform, $forsection = false) : array
* this object contains information about the course before update
* @return bool whether there were any changes to the options values
*/
public function update_course_format_options($data, $oldcourse = null) : bool {
public function update_course_format_options($data, $oldcourse = null): bool {
$data = (array)$data;
if ($oldcourse !== null) {
$oldcourse = (array)$oldcourse;
Expand Down Expand Up @@ -1185,7 +1185,7 @@ public function course_content_footer() {
* @param int|stdClass|section_info $section The section to check. Should specify fmt calculated properties.
* @return bool
*/
public function is_section_current($section) : bool {
public function is_section_current($section): bool {
$sectionextra = $this->fmt_get_section_extra($section); // ADDED.
return ($sectionextra->section && $sectionextra->currentnestedlevel >= FORMAT_MULTITOPIC_SECTION_LEVEL_TOPIC); // CHANGED.
}
Expand Down Expand Up @@ -1244,7 +1244,7 @@ public function section_get_available_hook(section_info $section, &$available, &
* @param int|stdClass|section_info $section The section to check.
* @return bool
*/
public function can_delete_section($section) : bool {
public function can_delete_section($section): bool {
$sectionextra = $this->fmt_get_section_extra($section); // ADDED.
return !$sectionextra->hassubsections; // CHANGED.
}
Expand All @@ -1262,7 +1262,7 @@ public function can_delete_section($section) : bool {
* @return \core\output\inplace_editable
*/
public function inplace_editable_render_section_name($section, $linkifneeded = true,
$editable = null, $edithint = null, $editlabel = null) : \core\output\inplace_editable {
$editable = null, $edithint = null, $editlabel = null): \core\output\inplace_editable {
if (empty($edithint)) {
$edithint = new lang_string('editsectionname'); // CHANGED.
}
Expand Down Expand Up @@ -1312,7 +1312,7 @@ public function inplace_editable_render_section_name($section, $linkifneeded = t
*
* @return bool
*/
public function supports_news() : bool {
public function supports_news(): bool {
return true;
}

Expand All @@ -1324,7 +1324,7 @@ public function supports_news() : bool {
* @param stdClass|section_info $section section where this module is located or will be added to
* @return bool
*/
public function allow_stealth_module_visibility($cm, $section) : bool {
public function allow_stealth_module_visibility($cm, $section): bool {
// Allow the third visibility state inside visible sections or in section 0.
return !$section->section || $section->visible;
}
Expand Down Expand Up @@ -1368,7 +1368,7 @@ public function section_action($section, $action, $sr) {
* @return array the list of configuration settings
* @since Moodle 3.5
*/
public function get_config_for_external() : array {
public function get_config_for_external(): array {
// Return everything (nothing to hide).
return $this->get_format_options();
}
Expand All @@ -1382,7 +1382,7 @@ public function get_config_for_external() : array {
* @param mixed $newvalue
* @return inplace_editable
*/
function format_multitopic_inplace_editable(string $itemtype, int $itemid, $newvalue) : \core\output\inplace_editable {
function format_multitopic_inplace_editable(string $itemtype, int $itemid, $newvalue): \core\output\inplace_editable {
// CHANGED LINE ABOVE.
global $DB, $CFG;
require_once($CFG->dirroot . '/course/lib.php');
Expand Down
10 changes: 5 additions & 5 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
* @param int $visibility The new visibility. 0 = hidden, 1 = visible
* @return array A list of resources which were hidden in the section
*/
function format_multitopic_set_section_visible(int $courseid, $section, int $visibility) : array {
function format_multitopic_set_section_visible(int $courseid, $section, int $visibility): array {
// CHANGED LINE ABOVE: Use sectioninfo, not section number.
global $DB;

Expand Down Expand Up @@ -82,7 +82,7 @@ function format_multitopic_set_section_visible(int $courseid, $section, int $vis
* @param stdClass $section position to insert at. Must specify parentid. May specify level.
* @return stdClass created section object. Has database properties plus parentid and levelsan.
*/
function format_multitopic_course_create_section(\stdClass $courseorid, \stdClass $section) : \stdClass {
function format_multitopic_course_create_section(\stdClass $courseorid, \stdClass $section): \stdClass {
// CHANGED LINE ABOVE: Use section info, specifying parentid and level, instead of section number.
global $DB;
$courseid = is_object($courseorid) ? $courseorid->id : $courseorid;
Expand Down Expand Up @@ -221,7 +221,7 @@ function format_multitopic_move_section_to(\stdClass $course, $origins, \stdClas
* @param section_info $section The section to check. Must specify section (number). Should specify calculated properties.
* @return bool
*/
function format_multitopic_course_can_delete_section(\stdClass $course, \section_info $section) : bool {
function format_multitopic_course_can_delete_section(\stdClass $course, \section_info $section): bool {
// CHANGED LINE ABOVE.
// REMOVED: extract number from section parameter.
if (!$section->section) { // CHANGED: Check inside section info.
Expand Down Expand Up @@ -259,7 +259,7 @@ function format_multitopic_course_can_delete_section(\stdClass $course, \section
* @param \stdClass $target The destination. Must specify parentid, prevupid, or nextupid. May specify level.
* @return array
*/
function format_multitopic_reorder_sections(array $sectionsextra, $origins, \stdClass $target) : array {
function format_multitopic_reorder_sections(array $sectionsextra, $origins, \stdClass $target): array {
// CHANGED THROUGHOUT: Section numbers changed to IDs, used exceptions instead of returning false.
// Reads Calculated section values (levelsan, visiblesan).
// Writes raw section values (level, visible).
Expand Down Expand Up @@ -414,7 +414,7 @@ function format_multitopic_reorder_sections(array $sectionsextra, $origins, \std
* @param string|null $licencecode
* @return string
*/
function format_multitopic_image_attribution($imagename, $authorwithurl, $licencecode) : string {
function format_multitopic_image_attribution($imagename, $authorwithurl, $licencecode): string {
$o = '';
$authorwithurlarray = explode('|', $authorwithurl ?? '');
$authorhtml = $authorwithurlarray[0];
Expand Down

0 comments on commit 8699286

Please sign in to comment.