From 06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 14 Nov 2023 14:47:55 +0100 Subject: Add function param/return types, fix a lot more phpstorm complaints --- modules-available/exams/page.inc.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'modules-available/exams/page.inc.php') diff --git a/modules-available/exams/page.inc.php b/modules-available/exams/page.inc.php index 458ae5b1..d229b883 100644 --- a/modules-available/exams/page.inc.php +++ b/modules-available/exams/page.inc.php @@ -103,7 +103,7 @@ class Page_Exams extends Page } // returns true if user is allowed to edit the exam - protected function userCanEditExam($examid = NULL) + protected function userCanEditExam(string $examid = NULL): bool { if (in_array(0, $this->userEditLocations)) // Trivial case -- don't query if global perms return true; @@ -118,9 +118,12 @@ class Page_Exams extends Page return true; } - // checks if user is allowed to save an exam with all the locations - // needs information if it's add (second para = true) or edit (second para = false) - protected function userCanEditLocation($locationids) { + /** + * checks if user is allowed to save an exam with all the locations + * needs information if it's add (second para = true) or edit (second para = false) + */ + protected function userCanEditLocation(array $locationids): bool + { return empty(array_diff($locationids, $this->userEditLocations)); } @@ -213,7 +216,10 @@ class Page_Exams extends Page return json_encode($out); } - protected function makeExamsForTemplate() + /** + * @return array{exams: array, decollapse: bool} + */ + protected function makeExamsForTemplate(): array { $out = []; $now = time(); @@ -248,7 +254,7 @@ class Page_Exams extends Page return ['exams' => $out, 'decollapse' => $hasCollapsed]; } - protected function makeLectureExamList() + protected function makeLectureExamList(): array { $out = []; $now = time(); @@ -288,7 +294,7 @@ class Page_Exams extends Page ] + $source; } - private function isDateSane($time) + private function isDateSane(int $time): bool { return ($time >= strtotime('-10 years') && $time <= strtotime('+10 years')); } -- cgit v1.2.3-55-g7522