From 3d819eef6adffba246a8a6a38b895a95954ec3b6 Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Sat, 24 Aug 2024 17:35:58 +0100 Subject: [PATCH] Make code checker happy --- classes/element_helper.php | 5 +++++ classes/report_table.php | 2 +- classes/template.php | 4 ++-- element/expiry/classes/element.php | 2 +- tests/email_certificate_task_test.php | 6 +++--- tests/generator/lib.php | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/classes/element_helper.php b/classes/element_helper.php index cc08e45d..bb72d6b5 100644 --- a/classes/element_helper.php +++ b/classes/element_helper.php @@ -687,6 +687,11 @@ public static function get_grade_item_info($gradeitemid, $gradeformat, $userid) ); } + /** + * Helper function to return all the date formats. + * + * @return array the list of date formats + */ public static function get_date_formats(): array { // Hard-code date so users can see the difference between short dates with and without the leading zero. // Eg. 06/07/18 vs 6/07/18. diff --git a/classes/report_table.php b/classes/report_table.php index 0fb2fab0..6405e3f3 100644 --- a/classes/report_table.php +++ b/classes/report_table.php @@ -24,7 +24,7 @@ namespace mod_customcert; -use \customcertelement_expiry\element as expiry_element; +use customcertelement_expiry\element as expiry_element; defined('MOODLE_INTERNAL') || die; diff --git a/classes/template.php b/classes/template.php index 444af034..79dfdbd6 100644 --- a/classes/template.php +++ b/classes/template.php @@ -266,11 +266,11 @@ public function delete_element($elementid) { * Generate the PDF for the template. * * @param bool $preview true if it is a preview, false otherwise - * @param int $userid the id of the user whose certificate we want to view + * @param int|null $userid the id of the user whose certificate we want to view * @param bool $return Do we want to return the contents of the PDF? * @return string|void Can return the PDF in string format if specified. */ - public function generate_pdf(bool $preview = false, int $userid = null, bool $return = false) { + public function generate_pdf(bool $preview = false, ?int $userid = null, bool $return = false) { global $CFG, $DB, $USER; if (empty($userid)) { diff --git a/element/expiry/classes/element.php b/element/expiry/classes/element.php index 5ee472a3..2d04c1d1 100644 --- a/element/expiry/classes/element.php +++ b/element/expiry/classes/element.php @@ -24,7 +24,7 @@ namespace customcertelement_expiry; -use \mod_customcert\element_helper; +use mod_customcert\element_helper; /** * The customcert element expiry's core interaction API. diff --git a/tests/email_certificate_task_test.php b/tests/email_certificate_task_test.php index fa0c07c4..5334eacd 100644 --- a/tests/email_certificate_task_test.php +++ b/tests/email_certificate_task_test.php @@ -483,10 +483,10 @@ public function test_email_certificates_students_havent_met_required_criteria(): ], ], 'showc' => [ - false + false, ], - ] - ) + ], + ), ]); // Create template object. diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 931d4a44..f15273c0 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -40,7 +40,7 @@ class mod_customcert_generator extends testing_module_generator { * @param array|null $options * @return stdClass */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { $record = (object)(array)$record; $defaultsettings = [