Skip to content

Commit fab8dc5

Browse files
Doctype fixes for new PHPstan
No functional changes intended.
1 parent d5858ec commit fab8dc5

28 files changed

+91
-118
lines changed

webapp/src/Controller/API/ProblemController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(
5858
/**
5959
* Add one or more problems.
6060
*
61-
* @return int[]
61+
* @return string[]
6262
* @throws BadRequestHttpException
6363
* @throws NonUniqueResultException
6464
*/
@@ -105,7 +105,7 @@ public function addProblemsAction(Request $request): array
105105
$data = Yaml::parseFile($file->getRealPath(), Yaml::PARSE_DATETIME);
106106
$messages = [];
107107
if ($this->importExportService->importProblemsData($contest, $data, $ids, $messages)) {
108-
return $ids;
108+
return $ids ?? [];
109109
}
110110
$message = "Error while adding problems";
111111
if (!empty($messages)) {

webapp/src/Controller/Jury/RejudgingController.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -788,20 +788,8 @@ public function createAction(Request $request): Response
788788
} else {
789789
$redirect = $this->generateUrl('jury_index');
790790
}
791-
} elseif ($res instanceof Rejudging) {
792-
$redirect = $this->generateUrl('jury_rejudging', ['rejudgingId' => $res->getRejudgingid()]);
793791
} else {
794-
$redirect = match ($table) {
795-
'contest' => $this->generateUrl('jury_contest', ['contestId' => $id]),
796-
'judgehost' => $this->generateUrl('jury_judgehost', ['judgehostid' => $id]),
797-
'language' => $this->generateUrl('jury_language', ['langId' => $id]),
798-
'problem' => $this->generateUrl('jury_problem', ['probId' => $id]),
799-
'submission' => $this->generateUrl('jury_submission', ['submitId' => $id]),
800-
'team' => $this->generateUrl('jury_team', ['teamId' => $id]),
801-
// This case never happens, since we already check above.
802-
// Add it here to silence linter warnings.
803-
default => throw new BadRequestHttpException(sprintf('unknown table %s in rejudging', $table)),
804-
};
792+
$redirect = $this->generateUrl('jury_rejudging', ['rejudgingId' => $res->getRejudgingid()]);
805793
}
806794

807795
$progressReporter(100, '', $redirect);

webapp/src/Controller/Team/SubmissionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function createAction(Request $request, ?Problem $problem = null): Respon
7878
$problem = $form->get('problem')->getData();
7979
/** @var Language $language */
8080
$language = $form->get('language')->getData();
81-
/** @var UploadedFile[] $files */
81+
/** @var UploadedFile[]|UploadedFile $files */
8282
$files = $form->get('code')->getData();
8383
if (!is_array($files)) {
8484
$files = [$files];

webapp/src/DataFixtures/DefaultData/UserFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ protected function getRestapiPassword(): string
8989
if ($credential === '' || $credential[0] === '#') {
9090
continue;
9191
}
92-
/** @var string[] $items */
92+
/** @var list<string> $items */
9393
$items = preg_split("/\s+/", $credential);
9494
if (count($items) !== 4) {
9595
throw new Exception("Error parsing REST API credentials. Invalid format in line $lineno.");

webapp/src/DataFixtures/Test/RejudgingStatesFixture.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function load(ObjectManager $manager): void
4545
$manager->flush();
4646
// One rejudging can consist of submissions of multiple contests
4747
foreach ($rejudgingStage[4] as $contestName) {
48-
/** @var Contest $contest */
48+
/** @var Contest|null $contest */
4949
$contest = $manager->getRepository(Contest::class)->findOneBy(['shortname' => $contestName]);
5050
/** @var Team $team */
5151
$team = $manager->getRepository(Team::class)->findOneBy(['name' => 'Example teamname']);

webapp/src/Doctrine/DBAL/Types/JsonType.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st
2929
}
3030

3131
/**
32-
* @return string|false|null
33-
* @throws ConversionException
32+
* @template T
33+
* @param T $value
34+
*
35+
* @return (T is null ? null : string)
36+
* @throws \JsonException
3437
*/
35-
public function convertToDatabaseValue($value, AbstractPlatform $platform)
38+
public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string
3639
{
3740
if ($value === null) {
3841
return null;

webapp/src/Entity/Testcase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class Testcase
9494
private Collection $judging_runs;
9595

9696
/**
97-
* @var Collection<int, ExternalRun>>
97+
* @var Collection<int, ExternalRun>
9898
*/
9999
#[ORM\OneToMany(mappedBy: 'testcase', targetEntity: ExternalRun::class)]
100100
#[Serializer\Exclude]

webapp/src/Form/Type/ExecutableType.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

webapp/src/FosRestBundle/FlattenExceptionHandler.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static function getSubscribingMethods(): array
3939
}
4040

4141
/**
42-
* @param array{params: string[]} $type
42+
* @param array{name: string, params: string[]} $type
4343
*
4444
* @return array{code: int, message: string}
4545
*/
@@ -49,8 +49,7 @@ public function serializeToJson(
4949
array $type,
5050
Context $context
5151
): array {
52-
return $visitor->visitArray($this->convertToArray($exception, $context),
53-
$type);
52+
return $visitor->visitArray($this->convertToArray($exception, $context), $type);
5453
}
5554

5655
/**

webapp/src/Security/DOMJudgeIPAuthenticator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public function onAuthenticationSuccess(Request $request, TokenInterface $token,
122122
&& $request->isMethod('POST')
123123
&& $request->request->get('loginmethod') === 'ipaddress') {
124124
// Use target URL from session if set.
125-
if ($firewallName !== null &&
126-
$targetUrl = $this->getTargetPath($request->getSession(), $firewallName)) {
125+
if ($targetUrl = $this->getTargetPath($request->getSession(), $firewallName)) {
127126
$this->removeTargetPath($request->getSession(), $firewallName);
128127
return new RedirectResponse($targetUrl);
129128
}

0 commit comments

Comments
 (0)