From e62bedecc827b4c971d8e35d9b7eb8fb1836265a Mon Sep 17 00:00:00 2001 From: Marcus Green Date: Sun, 28 Apr 2024 22:32:05 +0100 Subject: [PATCH] undeclared class variables were throwing errors with PHP 8.2 --- question.php | 8 ++++++++ tests/helper.php | 7 ++++++- tests/question_test.php | 10 ++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/question.php b/question.php index fbf4071..f10d517 100755 --- a/question.php +++ b/question.php @@ -37,6 +37,14 @@ class qtype_gapfill_question extends question_graded_automatically_with_countbac */ public $answer; + /** + * Only used for testing + * + * @var $gapstofill int + */ + + public $gapstofill; + /** * Display draggables after the body of the question * @var boolean diff --git a/tests/helper.php b/tests/helper.php index 64ea1f0..223f42b 100755 --- a/tests/helper.php +++ b/tests/helper.php @@ -33,13 +33,18 @@ */ class qtype_gapfill_test_helper extends question_test_helper { + /** + * @var int $gapstofill + */ + public $gapstofill; + /** * must be implemented or class made abstract * * @return string */ public function get_test_questions() { - return array('catmat'); + return ['catmat']; } /** diff --git a/tests/question_test.php b/tests/question_test.php index fb6ee78..969c6eb 100755 --- a/tests/question_test.php +++ b/tests/question_test.php @@ -43,6 +43,15 @@ * @coversDefaultClass \question\type\gapfill\question */ class question_test extends \advanced_testcase { + + /** + * + * @var qtype_gapfill $gapfill + * An instance of the question type + */ + public $qtype; + + /** * Test value returned by questionid_column_name() * @@ -255,6 +264,7 @@ public function test_is_same_response() { } public function setUp(): void { $this->qtype = \question_bank::get_qtype('gapfill'); + } protected function tearDown(): void {