diff --git a/app/cdash/include/common.php b/app/cdash/include/common.php index 6f3379f32c..85bdd93fd6 100644 --- a/app/cdash/include/common.php +++ b/app/cdash/include/common.php @@ -610,8 +610,12 @@ function get_dashboard_JSON($projectname, $date, &$response): void $userid = Auth::id(); if ($userid) { $project = App\Models\Project::findOrFail((int) $project->Id); - $response['projectrole'] = $project->users()->withPivot('role')->find((int) $userid)->pivot->role ?? ProjectRole::USER; - if ($response['projectrole'] === ProjectRole::ADMINISTRATOR) { + $projectrole = $project->users()->withPivot('role')->find((int) $userid)->pivot->role ?? ProjectRole::USER; + if (!$projectrole instanceof ProjectRole) { + $projectrole = ProjectRole::from($projectrole); + } + $response['projectrole'] = $projectrole->value; + if ($projectrole === ProjectRole::ADMINISTRATOR) { $response['user']['admin'] = 1; } } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d2ab888878..6c58b77e1d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -11895,6 +11895,18 @@ parameters: count: 1 path: app/cdash/include/common.php + - + rawMessage: 'Function get_dashboard_JSON() throws checked exception TypeError but it''s missing from the PHPDoc @throws tag.' + identifier: missingType.checkedException + count: 1 + path: app/cdash/include/common.php + + - + rawMessage: 'Function get_dashboard_JSON() throws checked exception ValueError but it''s missing from the PHPDoc @throws tag.' + identifier: missingType.checkedException + count: 1 + path: app/cdash/include/common.php + - rawMessage: 'Function get_dates() has parameter $date with no type specified.' identifier: missingType.parameter