From 123a9afae76f979d870f8338e212551f29217777 Mon Sep 17 00:00:00 2001 From: "Shamiso.Jaravaza" <33659194+ssj365@users.noreply.github.com> Date: Mon, 25 Mar 2024 11:22:27 -0600 Subject: [PATCH] CONTRIB-9525: Fix error on return of get_role (#616) --- classes/local/helpers/roles.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/classes/local/helpers/roles.php b/classes/local/helpers/roles.php index a726b372..f41b02cf 100644 --- a/classes/local/helpers/roles.php +++ b/classes/local/helpers/roles.php @@ -184,9 +184,9 @@ protected static function get_roles_select(context $context = null, bool $onlyvi * * @param string|integer $id * - * @return stdClass $role + * @return stdClass|null $role */ - protected static function get_role($id): stdClass { + protected static function get_role($id): ?stdClass { $roles = (array) role_get_names(); if (is_numeric($id) && isset($roles[$id])) { return (object) $roles[$id]; @@ -196,6 +196,7 @@ protected static function get_role($id): stdClass { return $role; } } + return null; } /**