Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions judge/judgedaemon.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,14 +758,14 @@ private function request(string $url, string $verb = 'GET', $data = '', bool $fa
}
}
if ($trial == BACKOFF_STEPS) {
$errstr = $errstr . " Retry limit reached.";
$errstr .= " Retry limit reached.";
} else {
$retry_in_sec = $delay_in_sec + BACKOFF_JITTER_SEC * random_int(0, mt_getrandmax()) / mt_getrandmax();
$warnstr = $errstr . " This request will be retried after about " .
round($retry_in_sec, 2) . "sec... (" . $trial . "/" . BACKOFF_STEPS . ")";
warning($warnstr);
dj_sleep($retry_in_sec);
$delay_in_sec = $delay_in_sec * BACKOFF_FACTOR;
$delay_in_sec *= BACKOFF_FACTOR;
}
}
if (!$succeeded) {
Expand Down Expand Up @@ -860,7 +860,7 @@ private function runCommandSafe(array $command_parts, &$retval = DONT_CARE, $log
return false;
}

$command = implode(' ', array_map('dj_escapeshellarg', $command_parts));
$command = implode(' ', array_map(dj_escapeshellarg(...), $command_parts));

logmsg(LOG_DEBUG, "Executing command: $command");
system($command, $retval_local);
Expand Down Expand Up @@ -1771,10 +1771,10 @@ private function fetchTestcase(string $workdirpath, string $testcase_id, int $ju

private function initsignals(): void
{
pcntl_signal(SIGTERM, [self::class, 'signalHandler']);
pcntl_signal(SIGINT, [self::class, 'signalHandler']);
pcntl_signal(SIGHUP, [self::class, 'signalHandler']);
pcntl_signal(SIGUSR1, [self::class, 'signalHandler']);
pcntl_signal(SIGTERM, self::signalHandler(...));
pcntl_signal(SIGINT, self::signalHandler(...));
pcntl_signal(SIGHUP, self::signalHandler(...));
pcntl_signal(SIGUSR1, self::signalHandler(...));
}
}

Expand Down
1 change: 1 addition & 0 deletions webapp/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
"phpstan/phpstan": "^2.0",
"phpstan/phpstan-doctrine": "^2.0",
"phpunit/phpunit": "^9.6",
"rector/rector": "^2.2",
"sebastian/diff": "*",
"squizlabs/php_codesniffer": "*",
"symfony/debug-bundle": "7.4.*",
Expand Down
62 changes: 61 additions & 1 deletion webapp/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webapp/phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ parameters:
- src
- migrations
- resources/functions.php
- rector.php
- tests
scanFiles:
- vendor/vrana/adminer/adminer/include/functions.inc.php
Expand Down
27 changes: 27 additions & 0 deletions webapp/rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php declare(strict_types=1);

use Rector\CodingStyle\Rector\FuncCall\ConsistentImplodeRector;
use Rector\Config\RectorConfig;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/config',
__DIR__ . '/public',
__DIR__ . '/resources',
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withPhpSets(php82: true)
->withComposerBased(twig: true, doctrine: true, phpunit: true, symfony: true)
->withSkip([
NullToStrictStringFuncCallArgRector::class,
RenameFunctionRector::class,
ConsistentImplodeRector::class,
ClosureToArrowFunctionRector::class,
])
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);
7 changes: 3 additions & 4 deletions webapp/src/Command/AdminerCompileCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
name: 'adminer:compile',
description: 'Compile adminer in vendor',
)]
class AdminerCompileCommand extends Command
class AdminerCompileCommand
{
public function __construct(
#[Autowire('%domjudge.vendordir%')]
private readonly string $vendorDir,
private readonly string $vendorDir
) {
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
public function __invoke(OutputInterface $output): int
{
$process = new Process(
['php', 'compile.php', 'mysql'],
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Command/ResetUserPasswordCommand.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php declare(strict_types=1);

Check warning on line 1 in webapp/src/Command/ResetUserPasswordCommand.php

View workflow job for this annotation

GitHub Actions / phpcs

A file should declare new symbols (classes, functions, constants, etc.) and cause no other side effects, or it should execute logic with side effects, but should not do both. The first symbol is defined on line 18 and the first side effect is on line 18.

namespace App\Command;

Expand Down Expand Up @@ -37,7 +37,7 @@
$style->error('Can not find user with username ' . $username);
return Command::FAILURE;
}
$password = $password ?? Utils::generatePassword();
$password ??= Utils::generatePassword();
$user->setPassword(
$this->passwordHasher->hashPassword($user, $password)
);
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Controller/Jury/ContestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ private function checkTimezones(FormInterface $form): ?Response
$fields = explode('+', $tmpValue);
} elseif (str_contains($tmpValue, '-')) {
$fields = explode('-', $tmpValue);
} elseif (substr($tmpValue, -1) === 'Z') {
} elseif (str_ends_with($tmpValue, 'Z')) {
$timeZones[] = 'UTC';
continue;
}
Expand Down
25 changes: 8 additions & 17 deletions webapp/src/Controller/Jury/ExecutableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function indexAction(Request $request): Response
foreach (['compare', 'run', 'full_debug'] as $config_script) {
try {
$configScripts[] = (string)$this->config->get('default_' . $config_script);
} catch (PHPInvalidArgumentException $e) {
} catch (PHPInvalidArgumentException) {
// If not found this is an older database, as we only use this for visual changes ignore this error;
}
}
Expand Down Expand Up @@ -129,22 +129,13 @@ public function indexAction(Request $request): Response
}
$execdata['execid']['cssclass'] = 'execid';
$type = $execdata['type']['value'];
switch ($type) {
case 'compare':
$execdata['icon']['icon'] = 'code-compare';
break;
case 'compile':
$execdata['icon']['icon'] = 'language';
break;
case 'debug':
$execdata['icon']['icon'] = 'bug';
break;
case 'run':
$execdata['icon']['icon'] = 'person-running';
break;
default:
$execdata['icon']['icon'] = 'question';
}
$execdata['icon']['icon'] = match ($type) {
'compare' => 'code-compare',
'compile' => 'language',
'debug' => 'bug',
'run' => 'person-running',
default => 'question',
};
$execdata['badges']['value'] = $badges;

if ($this->isGranted('ROLE_ADMIN')) {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Controller/Jury/RejudgingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public function viewAction(

// Only load the statistics if desired. The query is quite long and can result in much data, so only have it run
// when needed or when we don't have a lot of data to load.
$showStatistics = $showStatistics ?? $onlyAHandfulOfSubmissions;
$showStatistics ??= $onlyAHandfulOfSubmissions;
if ($showStatistics && count($repetitions) > 0) {
$stats = $this->getStats($rejudging);
} else {
Expand Down
42 changes: 15 additions & 27 deletions webapp/src/DataTransferObject/Shadowing/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,32 +42,20 @@ public static function fromString(string $value): EventType
*/
public function getEventClass(): ?string
{
switch ($this) {
case self::CLARIFICATIONS:
return ClarificationEvent::class;
case self::CONTESTS:
return ContestEvent::class;
case self::GROUPS:
return GroupEvent::class;
case self::JUDGEMENTS:
return JudgementEvent::class;
case self::JUDGEMENT_TYPES:
return JudgementTypeEvent::class;
case self::LANGUAGES:
return LanguageEvent::class;
case self::ORGANIZATIONS:
return OrganizationEvent::class;
case self::PROBLEMS:
return ProblemEvent::class;
case self::RUNS:
return RunEvent::class;
case self::STATE:
return StateEvent::class;
case self::SUBMISSIONS:
return SubmissionEvent::class;
case self::TEAMS:
return TeamEvent::class;
}
return null;
return match ($this) {
self::CLARIFICATIONS => ClarificationEvent::class,
self::CONTESTS => ContestEvent::class,
self::GROUPS => GroupEvent::class,
self::JUDGEMENTS => JudgementEvent::class,
self::JUDGEMENT_TYPES => JudgementTypeEvent::class,
self::LANGUAGES => LanguageEvent::class,
self::ORGANIZATIONS => OrganizationEvent::class,
self::PROBLEMS => ProblemEvent::class,
self::RUNS => RunEvent::class,
self::STATE => StateEvent::class,
self::SUBMISSIONS => SubmissionEvent::class,
self::TEAMS => TeamEvent::class,
default => null,
};
}
}
2 changes: 1 addition & 1 deletion webapp/src/Doctrine/ExternalIdAssigner.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __invoke(PostPersistEventArgs $args): void
return;
}

$entityClass = get_class($entity);
$entityClass = $entity::class;
if ($entity instanceof CalculatedExternalIdBasedOnRelatedFieldInterface) {
$externalid = $entity->getCalculatedExternalId();
} else {
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/Entity/Contest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Contest extends BaseApiEntity implements
options: ['comment' => 'Time contest becomes visible in team/public views', 'unsigned' => true]
)]
#[Serializer\Exclude]
private string|float|null $activatetime;
private string|float|null $activatetime = null;

#[ORM\Column(
type: 'decimal',
Expand Down Expand Up @@ -118,7 +118,7 @@ class Contest extends BaseApiEntity implements
options: ['comment' => 'Time after which no more submissions are accepted', 'unsigned' => true]
)]
#[Serializer\Exclude]
private string|float|null $endtime;
private string|float|null $endtime = null;

#[ORM\Column(
type: 'decimal',
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Entity/Submission.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Submission extends BaseApiEntity implements
options: ['comment' => 'JSON encoded list of expected results - used to validate jury submissions']
)]
#[Serializer\Exclude]
private ?array $expected_results;
private ?array $expected_results = null;

#[ORM\Column(
nullable: true,
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Form/Type/JuryClarificationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void

$builder->add('jurymember', HiddenType::class, [
'constraints' => [
new Callback([$this, 'checkJuryMember'])
new Callback($this->checkJuryMember(...))
]
]);
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Service/BalloonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function updateBalloons(
$this->em->persist($balloon);
try {
$this->em->flush();
} catch (UniqueConstraintViolationException $e) {
} catch (UniqueConstraintViolationException) {
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions webapp/src/Service/ConfigurationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function (ConfigCacheInterface $cache): void {
});

return array_map(
fn(array $item) => ConfigurationSpecification::fromArray($item),
ConfigurationSpecification::fromArray(...),
require $cacheFile
);
}
Expand All @@ -177,8 +177,7 @@ public function saveChanges(
}
unset($spec);

/** @var array<string, Configuration> $options */
$options = $options ?? $this->em->createQueryBuilder()
$options ??= $this->em->createQueryBuilder()
->from(Configuration::class, 'c', 'c.name')
->select('c')
->getQuery()
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/Service/DOMJudgeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -1781,8 +1781,8 @@ public function checkNewVersion(): string|false {

$cache = new FilesystemAdapter();
try {
$versions = $cache->get('domjudge_versions', [$this, 'cacherCheckNewVersion']);
} catch (InvalidArgumentException $e) {
$versions = $cache->get('domjudge_versions', $this->cacherCheckNewVersion(...));
} catch (InvalidArgumentException) {
return false;
}

Expand Down
6 changes: 1 addition & 5 deletions webapp/src/Service/EventLogService.php
Original file line number Diff line number Diff line change
Expand Up @@ -849,10 +849,6 @@ public function endpointForEntity($entity): ?string
$entity = substr($entity, strlen('Proxies\\__CG__\\'));
}

if (isset($this->entityToEndpoint[$entity])) {
return $this->entityToEndpoint[$entity];
}

return null;
return $this->entityToEndpoint[$entity] ?? null;
}
}
2 changes: 1 addition & 1 deletion webapp/src/Service/ImportExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ public function importJson(string $type, UploadedFile $file, ?string &$message =
$content = file_get_contents($file->getRealPath());
try {
$data = Utils::jsonDecode($content);
} catch (JsonException $e) {
} catch (JsonException) {
// Check if we can parse it as YAML
try {
$data = Yaml::parse($content, Yaml::PARSE_DATETIME);
Expand Down
Loading
Loading