Skip to content

Commit beb02cc

Browse files
committed
Fix PHPStan issues for /src/Twig/TwigExtension.php
All bundled in one commit to not flood the history, all of these should be trivial on itself but help PHPStan to detect more issues. Also fixed an issue for the DOMjudge service as we return the outcome from there.
1 parent fdbe414 commit beb02cc

File tree

3 files changed

+22
-36
lines changed

3 files changed

+22
-36
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -565,11 +565,6 @@ parameters:
565565
count: 1
566566
path: webapp/src/Service/DOMJudgeService.php
567567

568-
-
569-
message: "#^Method App\\\\Service\\\\DOMJudgeService\\:\\:getAssetFiles\\(\\) return type has no value type specified in iterable type array\\.$#"
570-
count: 1
571-
path: webapp/src/Service/DOMJudgeService.php
572-
573568
-
574569
message: "#^Method App\\\\Service\\\\DOMJudgeService\\:\\:getContestStats\\(\\) return type has no value type specified in iterable type array\\.$#"
575570
count: 1
@@ -999,33 +994,3 @@ parameters:
999994
message: "#^Method App\\\\Service\\\\SubmissionService\\:\\:getSubmissionList\\(\\) return type has no value type specified in iterable type array\\.$#"
1000995
count: 1
1001996
path: webapp/src/Service/SubmissionService.php
1002-
1003-
-
1004-
message: "#^Method App\\\\Twig\\\\TwigExtension\\:\\:customAssetFiles\\(\\) return type has no value type specified in iterable type array\\.$#"
1005-
count: 1
1006-
path: webapp/src/Twig/TwigExtension.php
1007-
1008-
-
1009-
message: "#^Method App\\\\Twig\\\\TwigExtension\\:\\:displayTestcaseResults\\(\\) has parameter \\$testcases with no value type specified in iterable type array\\.$#"
1010-
count: 1
1011-
path: webapp/src/Twig/TwigExtension.php
1012-
1013-
-
1014-
message: "#^Method App\\\\Twig\\\\TwigExtension\\:\\:getCommonPrefix\\(\\) has parameter \\$strings with no value type specified in iterable type array\\.$#"
1015-
count: 1
1016-
path: webapp/src/Twig/TwigExtension.php
1017-
1018-
-
1019-
message: "#^Method App\\\\Twig\\\\TwigExtension\\:\\:numTableActions\\(\\) has parameter \\$tableData with no value type specified in iterable type array\\.$#"
1020-
count: 1
1021-
path: webapp/src/Twig/TwigExtension.php
1022-
1023-
-
1024-
message: "#^Method App\\\\Twig\\\\TwigExtension\\:\\:printHosts\\(\\) has parameter \\$hostnames with no value type specified in iterable type array\\.$#"
1025-
count: 1
1026-
path: webapp/src/Twig/TwigExtension.php
1027-
1028-
-
1029-
message: "#^Method App\\\\Twig\\\\TwigExtension\\:\\:runDiff\\(\\) has parameter \\$runOutput with no value type specified in iterable type array\\.$#"
1030-
count: 1
1031-
path: webapp/src/Twig/TwigExtension.php

webapp/src/Service/DOMJudgeService.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,8 @@ public function apiRelativeUrl(string $route, array $params = []): string
13381338

13391339
/**
13401340
* Get asset files in the given directory with the given extension
1341+
*
1342+
* @return string[]
13411343
*/
13421344
public function getAssetFiles(string $path): array
13431345
{

webapp/src/Twig/TwigExtension.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,11 @@ public function testcaseResults(Submission $submission, ?bool $showExternal = fa
426426
}
427427

428428
// TODO: this function shares a lot with the above one, unify them?
429+
/**
430+
* @param Testcase[] $testcases
431+
*/
429432
public function displayTestcaseResults(array $testcases, bool $submissionDone, bool $isExternal = false): string
430433
{
431-
/** @var Testcase[] $testcases */
432434
$results = '';
433435
$lastTypeSample = true;
434436
foreach ($testcases as $testcase) {
@@ -627,6 +629,8 @@ public function printHost(?string $hostname, bool $full = false): string
627629

628630
/**
629631
* Extract the longest common prefix of all the provided strings.
632+
*
633+
* @param string[] $strings
630634
*/
631635
private function getCommonPrefix(array $strings): string
632636
{
@@ -650,6 +654,8 @@ private function getCommonPrefix(array $strings): string
650654

651655
/**
652656
* Formats a list of given hostnames, extracting a common prefix and suffix.
657+
*
658+
* @param string[] $hostnames
653659
*/
654660
public function printHosts(array $hostnames): string
655661
{
@@ -754,6 +760,9 @@ public function interactiveLog(string $log, bool $forTeam = false): string
754760
return $header . $body . "</table>" . $truncation;
755761
}
756762

763+
/**
764+
* @param array{output_run: string, output_reference: string} $runOutput
765+
*/
757766
public function runDiff(array $runOutput): string
758767
{
759768
// TODO: can be improved using diffposition.txt
@@ -896,6 +905,9 @@ public function printContestStart(Contest $contest): string
896905
return $res;
897906
}
898907

908+
/**
909+
* @return string[]
910+
*/
899911
public function customAssetFiles(string $type): array
900912
{
901913
if (in_array($type, ['css', 'js'])) {
@@ -1166,6 +1178,13 @@ public function entityIdBadge(BaseApiEntity $entity, string $idPrefix = ''): str
11661178
return $this->twig->render('jury/entity_id_badge.html.twig', $data);
11671179
}
11681180

1181+
/**
1182+
* @param array<array{data: array<string, array{value: string, sortvalue?: string, title?: string, cssclass?: string}>,
1183+
* link: string,
1184+
* actions?: array{icon: string, title: string, link: string, ajaxModal?: bool},
1185+
* cssclass?: string
1186+
* }> $tableData
1187+
*/
11691188
protected function numTableActions(array $tableData): int
11701189
{
11711190
$maxNumActions = 0;

0 commit comments

Comments
 (0)