Skip to content

Commit a4b765e

Browse files
nickygerritsenvmcj
authored andcommitted
Fix all reported PHPStan errors
1 parent 2de7534 commit a4b765e

File tree

12 files changed

+52
-18
lines changed

12 files changed

+52
-18
lines changed

webapp/src/Controller/API/JudgehostController.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,9 +1656,7 @@ public function getJudgeTasksAction(Request $request): array
16561656
$judgetasks = [['type' => 'try_again']];
16571657
}
16581658
}
1659-
if (!empty($judgetasks)) {
1660-
return $judgetasks;
1661-
}
1659+
return $judgetasks;
16621660
}
16631661

16641662
if ($this->config->get('enable_parallel_judging')) {

webapp/src/Controller/API/PrintController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\Response;
1717
use Symfony\Component\HttpKernel\Attribute\MapRequestPayload;
18+
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
1819
use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException;
1920
use Symfony\Component\Routing\Attribute\Route;
2021
use Symfony\Component\Security\Http\Attribute\IsGranted;

webapp/src/Controller/Jury/ProblemController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,10 @@ public function testcasesAction(Request $request, int $probId): Response
593593
$content = file_get_contents($file->getRealPath());
594594
if ($type === 'image') {
595595
if (mime_content_type($file->getRealPath()) === 'image/svg+xml') {
596+
$originalContent = $content;
596597
$content = Utils::sanitizeSvg($content);
597598
if ($content === false) {
599+
$imageType = Utils::getImageType($originalContent, $error);
598600
$this->addFlash('danger', sprintf('image: %s', $error));
599601
return $this->redirectToRoute('jury_problem_testcases', ['probId' => $probId]);
600602
}

webapp/src/Entity/Contest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -936,6 +936,9 @@ public function removeLanguage(Language $language): void
936936
$this->languages->removeElement($language);
937937
}
938938

939+
/**
940+
* @return Collection<int, Language>
941+
*/
939942
public function getLanguages(): Collection
940943
{
941944
return $this->languages;

webapp/src/Entity/Language.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ public function removeContest(Contest $contest): Language
447447
return $this;
448448
}
449449

450+
/**
451+
* @return Collection<int, Contest>
452+
*/
450453
public function getContests(): Collection
451454
{
452455
return $this->contests;
@@ -466,6 +469,9 @@ public function removeProblem(Problem $problem): Language
466469
return $this;
467470
}
468471

472+
/**
473+
* @return Collection<int, Problem>
474+
*/
469475
public function getProblems(): Collection
470476
{
471477
return $this->problems;

webapp/src/Entity/Problem.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ class Problem extends BaseApiEntity implements
108108
public const TYPE_INTERACTIVE = 8;
109109
public const TYPE_SUBMIT_ANSWER = 16;
110110

111+
/**
112+
* @var array<int, string>
113+
*/
111114
private array $typesToString = [
112115
self::TYPE_PASS_FAIL => 'pass-fail',
113116
self::TYPE_SCORING => 'scoring',
@@ -292,8 +295,12 @@ public function getSpecialCompareArgs(): ?string
292295
return $this->special_compare_args;
293296
}
294297

298+
/**
299+
* @param list<string> $types
300+
*/
295301
public function setTypesAsString(array $types): Problem
296302
{
303+
/** @var array<string, int> $stringToTypes */
297304
$stringToTypes = array_flip($this->typesToString);
298305
$typeConstants = [];
299306
foreach ($types as $type) {
@@ -320,6 +327,9 @@ public function getTypesAsString(): string
320327
return implode(', ', $typeStrings);
321328
}
322329

330+
/**
331+
* @return list<int>
332+
*/
323333
public function getTypes(): array
324334
{
325335
$ret = [];
@@ -331,6 +341,9 @@ public function getTypes(): array
331341
return $ret;
332342
}
333343

344+
/**
345+
* @param array<int> $types
346+
*/
334347
public function setTypes(array $types): Problem
335348
{
336349
$types = array_unique($types);

webapp/src/Service/ConfigurationService.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ public function addOptions(ConfigurationSpecification $item): ConfigurationSpeci
410410
* identifier key/value pairs. The identifiers try to adhere to
411411
* https://ccs-specs.icpc.io/draft/contest_api#known-judgement-types
412412
*
413+
* @param list<string> $groups
413414
* @return array<string, string>
414415
*/
415416
public function getVerdicts(array $groups = ['final']): array

webapp/src/Service/DOMJudgeService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ public function openZipFile(string $filename): ZipArchive
718718
* @param string $origname The original filename as submitted by the team
719719
* @param string|null $language Langid of the programming language this file is in
720720
* @param bool $asTeam Print the file as the team associated with the user
721+
* @return array{0: bool, 1: string}
721722
*/
722723
public function printUserFile(
723724
string $filename,
@@ -1543,7 +1544,7 @@ public function getScoreboardZip(
15431544
}
15441545

15451546
/**
1546-
* @return array{'backgroundColors', array<TeamCategory>}
1547+
* @return array{backgroundColors: array<string>}
15471548
*/
15481549
public function getScoreboardCategoryColorCss(): array {
15491550
$backgroundColors = array_map(fn($x) => ( $x->getColor() ?? '#FFFFFF' ), $this->em->getRepository(TeamCategory::class)->findAll());

webapp/src/Service/ImportProblemService.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,11 @@ private function searchAndAddValidator(ZipArchive $zip, ?array &$messages, strin
996996
return true;
997997
}
998998

999-
// Returns true iff the yaml could be parsed correctly.
999+
/**
1000+
* Returns true iff the yaml could be parsed correctly.
1001+
*
1002+
* @param array{danger: string[], info: string[]} $messages
1003+
*/
10001004
public static function parseYaml(bool|string $problemYaml, array &$messages, string &$validationMode, PropertyAccessor $propertyAccessor, Problem $problem): bool
10011005
{
10021006
if ($problemYaml === false) {

webapp/src/Utils/Scoreboard/Scoreboard.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Scoreboard
3131
* @param TeamCategory[] $categories
3232
* @param ContestProblem[] $problems
3333
* @param ScoreCache[] $scoreCache
34+
* @param RankCache[] $rankCache
3435
*/
3536
public function __construct(
3637
protected readonly Contest $contest,

0 commit comments

Comments
 (0)