diff --git a/classes/courseformat/stateactions.php b/classes/courseformat/stateactions.php index 503060e..e9937a8 100644 --- a/classes/courseformat/stateactions.php +++ b/classes/courseformat/stateactions.php @@ -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, diff --git a/classes/global_navigation_wrapper.php b/classes/global_navigation_wrapper.php index 7d0915a..6a1bacd 100644 --- a/classes/global_navigation_wrapper.php +++ b/classes/global_navigation_wrapper.php @@ -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'); @@ -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'); @@ -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. diff --git a/classes/output/renderer.php b/classes/output/renderer.php index 0853df1..9e4d5d9 100644 --- a/classes/output/renderer.php +++ b/classes/output/renderer.php @@ -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. @@ -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. } @@ -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(); } @@ -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. diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 5e1c7ea..b2c4ff7 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -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'; } } diff --git a/lib.php b/lib.php index c093d4a..c94fa0c 100644 --- a/lib.php +++ b/lib.php @@ -133,7 +133,7 @@ public function page_title(): string { * * @return bool */ - public function uses_sections() : bool { + public function uses_sections(): bool { return true; } @@ -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; } @@ -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; @@ -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)) { @@ -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'); @@ -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; @@ -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; } @@ -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; @@ -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 => [], @@ -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'); @@ -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) { @@ -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 . @@ -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; @@ -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. } @@ -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. } @@ -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. } @@ -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; } @@ -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; } @@ -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(); } @@ -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'); diff --git a/locallib.php b/locallib.php index 1885727..b738dca 100644 --- a/locallib.php +++ b/locallib.php @@ -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; @@ -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; @@ -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. @@ -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). @@ -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];