Skip to content

Commit 696cfd0

Browse files
committed
Steer PHPstan for the EventFeed reading
This is always going to be ugly as the event can have different shapes even within the same EventFeedFormat, together with the minor changes between formats.
1 parent 7ce6a77 commit 696cfd0

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ parameters:
6969
count: 1
7070
path: webapp/src/FosRestBundle/FlattenExceptionHandler.php
7171

72-
-
73-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:addPendingEvent\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
74-
count: 1
75-
path: webapp/src/Service/ExternalContestSourceService.php
76-
7772
-
7873
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:compareOrCreateValues\\(\\) has parameter \\$extraDiff with no value type specified in iterable type array\\.$#"
7974
count: 1
@@ -84,36 +79,11 @@ parameters:
8479
count: 1
8580
path: webapp/src/Service/ExternalContestSourceService.php
8681

87-
-
88-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:getEventFeedFormat\\(\\) has parameter \\$event with no value type specified in iterable type array\\.$#"
89-
count: 1
90-
path: webapp/src/Service/ExternalContestSourceService.php
91-
92-
-
93-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:import\\(\\) has parameter \\$eventsToSkip with no value type specified in iterable type array\\.$#"
94-
count: 1
95-
path: webapp/src/Service/ExternalContestSourceService.php
96-
9782
-
9883
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importClarification\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
9984
count: 1
10085
path: webapp/src/Service/ExternalContestSourceService.php
10186

102-
-
103-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importEvent\\(\\) has parameter \\$event with no value type specified in iterable type array\\.$#"
104-
count: 1
105-
path: webapp/src/Service/ExternalContestSourceService.php
106-
107-
-
108-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importEvent\\(\\) has parameter \\$eventsToSKip with no value type specified in iterable type array\\.$#"
109-
count: 1
110-
path: webapp/src/Service/ExternalContestSourceService.php
111-
112-
-
113-
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importFromCcsApi\\(\\) has parameter \\$eventsToSkip with no value type specified in iterable type array\\.$#"
114-
count: 1
115-
path: webapp/src/Service/ExternalContestSourceService.php
116-
11787
-
11888
message: "#^Method App\\\\Service\\\\ExternalContestSourceService\\:\\:importFromContestArchive\\(\\) has parameter \\$eventsToSkip with no value type specified in iterable type array\\.$#"
11989
count: 1

webapp/src/Service/ExternalContestSourceService.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ public function getLastReadEventId(): ?string
240240
->getSingleScalarResult();
241241
}
242242

243+
/**
244+
* @param string[] $eventsToSkip
245+
*/
243246
public function import(bool $fromStart, array $eventsToSkip, ?callable $progressReporter = null): bool
244247
{
245248
// We need the verdicts to validate judgement-types.
@@ -290,6 +293,9 @@ protected function setLastEvent(?string $eventId): void
290293
->execute();
291294
}
292295

296+
/**
297+
* @param string[] $eventsToSkip
298+
*/
293299
protected function importFromCcsApi(array $eventsToSkip, ?callable $progressReporter = null): bool
294300
{
295301
while (true) {
@@ -568,6 +574,17 @@ protected function loadContest(): void
568574

569575
/**
570576
* Import the given event.
577+
*
578+
* @param array{token?: string, id: string, type: string, time: string, op?: string, end_of_updates?: bool,
579+
* data?: array{run_time?: float, time?: string, contest_time?: string, ordinal?: int,
580+
* id: string, judgement_id?: string, judgement_type_id: string|null,
581+
* max_run_time?: float|null, start_time: string, start_contest_time?: string,
582+
* end_time?: string|null, end_contest_time?: string|null, submission_id: string,
583+
* output_compile_as_string: null, language_id?: string, externalid?: null,
584+
* team_id: string, problem_id?: string, entry_point?: string|null, old_result?: null,
585+
* files?: array{href: string}}|mixed[]
586+
* } $event
587+
* @param string[] $eventsToSkip
571588
* @throws DBALException
572589
* @throws NonUniqueResultException
573590
* @throws TransportExceptionInterface
@@ -1776,6 +1793,15 @@ protected function processPendingEvents(string $type, string|int $id): void
17761793
}
17771794
}
17781795

1796+
/**
1797+
* @param array{run_time?: float, time?: string, contest_time?: string, ordinal?: int,
1798+
* id: string, judgement_id?: string, judgement_type_id: string|null,
1799+
* max_run_time?: float|null, start_time: string, start_contest_time?: string,
1800+
* end_time?: string|null, end_contest_time?: string|null, submission_id: string,
1801+
* output_compile_as_string: null, language_id?: string, externalid?: null,
1802+
* team_id: string, problem_id?: string, entry_point?: string|null, old_result?: null,
1803+
* files?: array{href: string}} $data
1804+
*/
17791805
protected function addPendingEvent(string $type, string|int $id, string $operation, string $entityType, ?string $eventId, array $data): void
17801806
{
17811807
// First, check if we already have pending events for this event.
@@ -1996,6 +2022,17 @@ protected function removeWarning(string $entityType, ?string $entityId, string $
19962022
}
19972023
}
19982024

2025+
/**
2026+
* @param array{token?: string, id: string, type: string, time: string, op?: string, end_of_updates?: bool,
2027+
* data?: array{run_time?: float, time?: string, contest_time?: string, ordinal?: int,
2028+
* id: string, judgement_id?: string, judgement_type_id: string|null,
2029+
* max_run_time?: float|null, start_time: string, start_contest_time?: string,
2030+
* end_time?: string|null, end_contest_time?: string|null, submission_id: string,
2031+
* output_compile_as_string: null, language_id?: string, externalid?: null,
2032+
* team_id: string, problem_id?: string, entry_point?: string|null, old_result?: null,
2033+
* files?: array{href: string}}|mixed[]
2034+
* } $event
2035+
*/
19992036
protected function getEventFeedFormat(array $event): EventFeedFormat
20002037
{
20012038
return match ($this->getApiVersion()) {

0 commit comments

Comments
 (0)