Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ? to nullable non-mixed properties #2850

Merged
merged 1 commit into from
Nov 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
)]
class CheckDatabaseConfigurationDefaultValuesCommand extends Command
{
public function __construct(protected readonly ConfigurationService $config, string $name = null)
public function __construct(protected readonly ConfigurationService $config, ?string $name = null)
{
parent::__construct($name);
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Command/ImportEventFeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(
protected readonly TokenStorageInterface $tokenStorage,
protected readonly ?Profiler $profiler,
protected readonly ExternalContestSourceService $sourceService,
string $name = null
?string $name = null
) {
parent::__construct($name);
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Command/ScoreboardMergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
protected readonly RouterInterface $router,
#[Autowire('%kernel.project_dir%')]
protected readonly string $projectDir,
string $name = null
?string $name = null
) {
parent::__construct($name);
}
Expand Down Expand Up @@ -280,7 +280,7 @@
$scoreCacheObj
->setSolveTimePublic($problem['time'] * 60)
->setSolveTimeRestricted($problem['time'] * 60);
if (

Check failure on line 283 in webapp/src/Command/ScoreboardMergeCommand.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 0 spaces after opening bracket; newline found
$firstSolve[$name] === null or
$problem['time'] * 60 < $firstSolve[$name]
) {
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/Config/Loader/YamlConfigLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class YamlConfigLoader extends FileLoader
/**
* @return mixed
*/
public function load(mixed $resource, string $type = null)
public function load(mixed $resource, ?string $type = null)
{
return Yaml::parse(file_get_contents($resource));
}

public function supports($resource, string $type = null): bool
public function supports($resource, ?string $type = null): bool
{
return is_string($resource) &&
pathinfo($resource, PATHINFO_EXTENSION) === 'yaml';
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Controller/API/JudgementTypeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function singleAction(Request $request, string $id): JudgementType
*
* @return JudgementType[]
*/
protected function getJudgementTypes(array $filteredOn = null): array
protected function getJudgementTypes(?array $filteredOn = null): array
{
$verdicts = $this->dj->getVerdicts(mergeExternal: true);

Expand Down
1 change: 1 addition & 0 deletions webapp/src/Controller/API/ProblemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function addProblemsAction(Request $request): array
// Note: we read the JSON as YAML, since any JSON is also YAML and this allows us
// to import files with YAML inside them that match the JSON format
$data = Yaml::parseFile($file->getRealPath(), Yaml::PARSE_DATETIME);
$messages = [];
if ($this->importExportService->importProblemsData($contest, $data, $ids, $messages)) {
return $ids;
}
Expand Down
1 change: 1 addition & 0 deletions webapp/src/Controller/Jury/ImportExportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ public function indexAction(Request $request): Response
$this->addFlash('danger', "Parse error in YAML/JSON file (" . $file->getClientOriginalName() . "): " . $e->getMessage());
return $this->redirectToRoute('jury_import_export');
}
$messages = [];
if ($this->importExportService->importProblemsData($problemsImportForm->get('contest')->getData(), $data, $ids, $messages)) {
$this->addFlash('success',
sprintf('The file %s is successfully imported.', $file->getClientOriginalName()));
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Entity/Balloon.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getDone(): bool
return $this->done;
}

public function setSubmission(Submission $submission = null): Balloon
public function setSubmission(?Submission $submission = null): Balloon
{
$this->submission = $submission;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Entity/ExecutableFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function getRank(): int
return $this->rank;
}

public function setImmutableExecutable(ImmutableExecutable $immutableExecutable = null): ExecutableFile
public function setImmutableExecutable(?ImmutableExecutable $immutableExecutable = null): ExecutableFile
{
$this->immutableExecutable = $immutableExecutable;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Entity/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public function setClearPhoto(bool $clearPhoto): Team
return $this;
}

public function setAffiliation(TeamAffiliation $affiliation = null): Team
public function setAffiliation(?TeamAffiliation $affiliation = null): Team
{
$this->affiliation = $affiliation;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Security/DOMJudgeIPAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function onAuthenticationFailure(Request $request, AuthenticationExceptio
return null;
}

public function start(Request $request, AuthenticationException $authException = null): Response
public function start(Request $request, ?AuthenticationException $authException = null): Response
{
// If this is the guard that fails/is configured to allow access as the entry_point
// send the user a basic auth dialog, as that's probably what they're expecting.
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/Service/ImportExportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected function convertImportedTime(array $fields, array $data, ?string &$err
return $time instanceof DateTime ? DateTimeImmutable::createFromMutable($time) : $time;
}

public function importContestData(mixed $data, ?string &$errorMessage = null, string &$cid = null): bool
public function importContestData(mixed $data, ?string &$errorMessage = null, ?string &$cid = null): bool
{
if (empty($data) || !is_array($data)) {
$errorMessage = 'Error parsing YAML file.';
Expand Down Expand Up @@ -327,7 +327,7 @@ public function importContestData(mixed $data, ?string &$errorMessage = null, st
* @param string[]|null $ids
* @param array<string, string[]> $messages
*/
public function importProblemsData(Contest $contest, array $problems, array &$ids = null, ?array &$messages = []): bool
public function importProblemsData(Contest $contest, array $problems, ?array &$ids = null, array &$messages = []): bool
{
// For problemset.yaml the root key is called `problems`, so handle that case
// TODO: Move this check away to make the $problems array shape easier
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/Service/ScoreboardService.php
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ public function getScoreboardTwigData(
* Get the teams to display on the scoreboard.
* @return Team[]
*/
protected function getTeams(Contest $contest, bool $jury = false, Filter $filter = null): array
protected function getTeams(Contest $contest, bool $jury = false, ?Filter $filter = null): array
{
$queryBuilder = $this->em->createQueryBuilder()
->from(Team::class, 't', 't.teamid')
Expand Down
Loading