From e4fdf8bae7ee0480239f449eee3b50c52b6eda5d Mon Sep 17 00:00:00 2001 From: Nicky Gerritsen Date: Fri, 12 Jan 2024 12:17:25 +0100 Subject: [PATCH] Update types for submissions restrictions and rejudging judgings. --- phpstan-baseline.neon | 10 ---------- .../src/Controller/API/JudgehostController.php | 2 +- .../src/Controller/Jury/RejudgingController.php | 10 +++++----- .../Jury/ShadowDifferencesController.php | 10 +++++----- .../src/Controller/Jury/SubmissionController.php | 6 +++--- webapp/src/Controller/Jury/TeamController.php | 1 + webapp/src/Service/CheckConfigService.php | 2 +- webapp/src/Service/ConfigurationService.php | 6 +++--- webapp/src/Service/SubmissionService.php | 16 ++++++++++------ 9 files changed, 29 insertions(+), 34 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 691d8098662..60a4f330cce 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -135,11 +135,6 @@ parameters: count: 1 path: webapp/src/Controller/API/JudgehostController.php - - - message: "#^PHPDoc tag @var for variable \\$judgings has no value type specified in iterable type array\\.$#" - count: 1 - path: webapp/src/Controller/API/JudgehostController.php - - message: "#^Method App\\\\Controller\\\\API\\\\JudgementTypeController\\:\\:getJudgementTypes\\(\\) has parameter \\$filteredOn with no value type specified in iterable type array\\.$#" count: 1 @@ -285,11 +280,6 @@ parameters: count: 1 path: webapp/src/Controller/Jury/RejudgingController.php - - - message: "#^PHPDoc tag @var for variable \\$judgings has no value type specified in iterable type array\\.$#" - count: 2 - path: webapp/src/Controller/Jury/RejudgingController.php - - message: "#^Method App\\\\Controller\\\\Jury\\\\SubmissionController\\:\\:determineFileChanged\\(\\) has parameter \\$files with no value type specified in iterable type array\\.$#" count: 1 diff --git a/webapp/src/Controller/API/JudgehostController.php b/webapp/src/Controller/API/JudgehostController.php index bd3491edb1b..714847bd681 100644 --- a/webapp/src/Controller/API/JudgehostController.php +++ b/webapp/src/Controller/API/JudgehostController.php @@ -1129,7 +1129,7 @@ private function maybeUpdateActiveJudging(Judging $judging): void $this->em->flush(); $skipped = []; - /** @var array[] $judgings */ + /** @var Judging[] $judgings */ $judgings = $this->em->createQueryBuilder() ->from(Judging::class, 'j') ->leftJoin('j.submission', 's') diff --git a/webapp/src/Controller/Jury/RejudgingController.php b/webapp/src/Controller/Jury/RejudgingController.php index 7eb150e0013..b51c0bb995b 100644 --- a/webapp/src/Controller/Jury/RejudgingController.php +++ b/webapp/src/Controller/Jury/RejudgingController.php @@ -324,13 +324,13 @@ public function viewAction( $restrictions = ['rejudgingid' => $rejudgingId]; if ($viewTypes[$view] == 'unverified') { - $restrictions['verified'] = 0; + $restrictions['verified'] = false; } if ($viewTypes[$view] == 'unjudged') { - $restrictions['judged'] = 0; + $restrictions['judged'] = false; } if ($viewTypes[$view] == 'diff') { - $restrictions['rejudgingdiff'] = 1; + $restrictions['rejudgingdiff'] = true; } if ($oldverdict !== 'all') { $restrictions['old_result'] = $oldverdict; @@ -604,7 +604,7 @@ public function addAction(Request $request, FormFactoryInterface $formFactory): } } - /** @var array[] $judgings */ + /** @var Judging[] $judgings */ $judgings = $queryBuilder ->getQuery() ->getResult(); @@ -733,7 +733,7 @@ public function createAction(Request $request): Response ->setParameter('correct', 'correct'); } - /** @var array[] $judgings */ + /** @var Judging[] $judgings */ $judgings = $queryBuilder ->getQuery() ->getResult(); diff --git a/webapp/src/Controller/Jury/ShadowDifferencesController.php b/webapp/src/Controller/Jury/ShadowDifferencesController.php index 792dbc6ea32..a7f77c8b4c3 100644 --- a/webapp/src/Controller/Jury/ShadowDifferencesController.php +++ b/webapp/src/Controller/Jury/ShadowDifferencesController.php @@ -165,19 +165,19 @@ public function indexAction( $restrictions = ['with_external_id' => true]; if ($viewTypes[$view] == 'unjudged local') { - $restrictions['judged'] = 0; + $restrictions['judged'] = false; } if ($viewTypes[$view] == 'unjudged external') { - $restrictions['externally_judged'] = 0; + $restrictions['externally_judged'] = false; } if ($viewTypes[$view] == 'diff') { - $restrictions['external_diff'] = 1; + $restrictions['external_diff'] = true; } if ($verificationViewTypes[$verificationView] == 'unverified') { - $restrictions['externally_verified'] = 0; + $restrictions['externally_verified'] = false; } if ($verificationViewTypes[$verificationView] == 'verified') { - $restrictions['externally_verified'] = 1; + $restrictions['externally_verified'] = true; } if ($external !== 'all') { $restrictions['external_result'] = $external; diff --git a/webapp/src/Controller/Jury/SubmissionController.php b/webapp/src/Controller/Jury/SubmissionController.php index b31f0c6cce8..94ee3b50ec0 100644 --- a/webapp/src/Controller/Jury/SubmissionController.php +++ b/webapp/src/Controller/Jury/SubmissionController.php @@ -96,13 +96,13 @@ public function indexAction( $restrictions = []; if ($viewTypes[$view] == 'unverified') { - $restrictions['verified'] = 0; + $restrictions['verified'] = false; } if ($viewTypes[$view] == 'unjudged') { - $restrictions['judged'] = 0; + $restrictions['judged'] = false; } if ($viewTypes[$view] == 'judging') { - $restrictions['judging'] = 1; + $restrictions['judging'] = true; } $contests = $this->dj->getCurrentContests(); diff --git a/webapp/src/Controller/Jury/TeamController.php b/webapp/src/Controller/Jury/TeamController.php index 89af02df104..deb324f77db 100644 --- a/webapp/src/Controller/Jury/TeamController.php +++ b/webapp/src/Controller/Jury/TeamController.php @@ -285,6 +285,7 @@ public function viewAction( $restrictionTexts[] = sprintf('%s %s', $restrictionKeyText, $value); } $restrictionText = implode(', ', $restrictionTexts); + /** @var array{probid?: int, langid?: string, judgehost?: string, ...} $restrictions */ } $restrictions['teamid'] = $teamId; [$submissions, $submissionCounts] = diff --git a/webapp/src/Service/CheckConfigService.php b/webapp/src/Service/CheckConfigService.php index 58975c5a3ea..bfecc2f5373 100644 --- a/webapp/src/Service/CheckConfigService.php +++ b/webapp/src/Service/CheckConfigService.php @@ -40,7 +40,7 @@ public function __construct( } /** - * @return array + * @return array> */ public function runAll(): array { diff --git a/webapp/src/Service/ConfigurationService.php b/webapp/src/Service/ConfigurationService.php index 48d35f2bcc2..7d46b3cfbbe 100644 --- a/webapp/src/Service/ConfigurationService.php +++ b/webapp/src/Service/ConfigurationService.php @@ -103,9 +103,9 @@ public function all(bool $onlyIfPublic = false): array /** * Get all configuration specifications. * - * @return array, key_options?: array, * value_options?: array}> diff --git a/webapp/src/Service/SubmissionService.php b/webapp/src/Service/SubmissionService.php index ee92513bdcc..7a82aca82ed 100644 --- a/webapp/src/Service/SubmissionService.php +++ b/webapp/src/Service/SubmissionService.php @@ -76,21 +76,25 @@ public function __construct( * - userid: filter on specific user * - visible: If true, only return submissions from visible teams * When shadowing another system these keys can also be used: - * - external_diff: Difference with the external system + * - external_diff: If true, only return results with a difference with an + * external system. + * If false, only return results without a difference with an + * external system. * - external_result: result in the external system * - externally_judged: If true, only return externally judged submissions. * If false, only return externally unjudged submissions. * - externally_verified: If true, only return verified submissions. * If false, only return unverified or unjudged submissions. - * - with_external_id: id of the submission in the external system + * - with_external_id: If true, only return submissions with an external ID. * * @param Contest[] $contests * @param array{rejudgingid?: int, verified?: bool, judged?: bool, judging?: bool, - * rejudgingdiff?: bool, teamid?: string, categoryid?: string, - * probid?: string, langid?: string, judgehost?: string, old_result?: string, - * result?: string, userid?: string, visible?: bool, external_diff?: string, + * rejudgingdiff?: bool, teamid?: int, categoryid?: int, + * probid?: string|int|null, langid?: string, judgehost?: string, old_result?: string, + * result?: string, userid?: int, visible?: bool, external_diff?: bool, * external_result?: string, externally_judged?: bool, - * externally_verified?: bool, with_external_id?: string} $restrictions + * externally_verified?: bool, with_external_id?: true} $restrictions + * * @return array{Submission[], array} array An array with * two elements: the first one is the list of submissions * and the second one is an array with counts.