From 500b0f534abb60b6ae68d6a053071d3228c66658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luca=20B=C3=B6sch?= Date: Thu, 13 Jun 2024 00:36:41 +0200 Subject: [PATCH] Fix deprecation of implicit nullable parameter declarations. --- .github/workflows/moodle-ci.yml | 5 ++++- classes/local/checklist_check.php | 2 +- classes/local/checklist_comment.php | 2 +- classes/local/checklist_comment_student.php | 2 +- classes/local/checklist_item.php | 2 +- tests/dates_test.php | 1 + tests/generator/lib.php | 2 +- tests/group_completion_email_test.php | 2 ++ tests/privacy_provider_test.php | 1 + tests/student_comment_test.php | 2 ++ 10 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.github/workflows/moodle-ci.yml b/.github/workflows/moodle-ci.yml index 8186ff1..b5b086b 100644 --- a/.github/workflows/moodle-ci.yml +++ b/.github/workflows/moodle-ci.yml @@ -30,8 +30,11 @@ jobs: fail-fast: false matrix: include: - - php: '8.2' + - php: '8.3' moodle-branch: 'main' + database: 'mariadb' + - php: '8.3' + moodle-branch: 'MOODLE_404_STABLE' database: 'pgsql' - php: '8.2' moodle-branch: 'MOODLE_403_STABLE' diff --git a/classes/local/checklist_check.php b/classes/local/checklist_check.php index ff4f933..5ed4bcc 100644 --- a/classes/local/checklist_check.php +++ b/classes/local/checklist_check.php @@ -63,7 +63,7 @@ class checklist_check extends data_object { * @param bool $fetch * @throws \coding_exception */ - public function __construct(array $params = null, $fetch = true) { + public function __construct(?array $params = null, $fetch = true) { // Really ugly hack to stop travis complaining about $required_fields. $this->{'required_fields'} = $this->requiredfields; parent::__construct($params, $fetch); diff --git a/classes/local/checklist_comment.php b/classes/local/checklist_comment.php index adda93d..501c2a1 100644 --- a/classes/local/checklist_comment.php +++ b/classes/local/checklist_comment.php @@ -67,7 +67,7 @@ class checklist_comment extends data_object { * @param bool $fetch * @throws \coding_exception */ - public function __construct(array $params = null, $fetch = true) { + public function __construct(?array $params = null, $fetch = true) { // Really ugly hack to stop travis complaining about $required_fields. $this->{'required_fields'} = $this->requiredfields; parent::__construct($params, $fetch); diff --git a/classes/local/checklist_comment_student.php b/classes/local/checklist_comment_student.php index 632a57e..69a56c4 100644 --- a/classes/local/checklist_comment_student.php +++ b/classes/local/checklist_comment_student.php @@ -132,7 +132,7 @@ public static function add_student_names(array $studentcomments) { public static function update_or_create_student_comment( int $checklistitemid, string $commenttext, - checklist_comment_student $existingcomment = null + ?checklist_comment_student $existingcomment = null ): bool { if (!$existingcomment) { $newcomment = new checklist_comment_student(); diff --git a/classes/local/checklist_item.php b/classes/local/checklist_item.php index 7a1daff..cef8dab 100644 --- a/classes/local/checklist_item.php +++ b/classes/local/checklist_item.php @@ -117,7 +117,7 @@ class checklist_item extends data_object { * @param bool $fetch * @throws \coding_exception */ - public function __construct(array $params = null, $fetch = true) { + public function __construct(?array $params = null, $fetch = true) { // Really ugly hack to stop travis complaining about $required_fields. $this->{'required_fields'} = $this->requiredfields; parent::__construct($params, $fetch); diff --git a/tests/dates_test.php b/tests/dates_test.php index b3eca2f..35732f3 100644 --- a/tests/dates_test.php +++ b/tests/dates_test.php @@ -34,6 +34,7 @@ final class dates_test extends \advanced_testcase { * Set up steps */ public function setUp(): void { + parent::setUp(); $this->resetAfterTest(); } diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 87bab23..bcd8639 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -37,7 +37,7 @@ class mod_checklist_generator extends testing_module_generator { * @return stdClass * @throws coding_exception */ - public function create_instance($record = null, array $options = null) { + public function create_instance($record = null, ?array $options = null) { $record = (object)(array)$record; $defaultsettings = [ diff --git a/tests/group_completion_email_test.php b/tests/group_completion_email_test.php index e5ae7d9..9ca9d84 100644 --- a/tests/group_completion_email_test.php +++ b/tests/group_completion_email_test.php @@ -66,6 +66,7 @@ final class group_completion_email_test extends \advanced_testcase { */ public function setUp(): void { global $DB; + parent::setUp(); $this->resetAfterTest(); unset_config('noemailever'); @@ -139,6 +140,7 @@ public function tearDown(): void { $this->mailsink->close(); unset($this->mailsink); previous_completions::override_time(null); + parent::tearDown(); } /** diff --git a/tests/privacy_provider_test.php b/tests/privacy_provider_test.php index 27b6db0..1f37630 100644 --- a/tests/privacy_provider_test.php +++ b/tests/privacy_provider_test.php @@ -46,6 +46,7 @@ final class privacy_provider_test extends \core_privacy\tests\provider_testcase * {@inheritdoc} */ protected function setUp(): void { + parent::setUp(); $this->resetAfterTest(); global $DB; diff --git a/tests/student_comment_test.php b/tests/student_comment_test.php index 7fb74a6..ef62cb9 100644 --- a/tests/student_comment_test.php +++ b/tests/student_comment_test.php @@ -58,6 +58,8 @@ final class student_comment_test extends \advanced_testcase { */ public function setUp(): void { global $USER, $DB; + parent::setUp(); + $this->resetAfterTest(); // Create test checklist with a couple items. $gen = self::getDataGenerator();