Skip to content

Commit 35cdde7

Browse files
committed
Fixing deprecations and cleanup in CLI commands.
1 parent 081c83d commit 35cdde7

18 files changed

Lines changed: 94 additions & 107 deletions

app/commands/BaseCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ private static function indexToLetters(int $idx): string
8484
}
8585

8686
/**
87-
* Perform a select inquery so the user chooses from given options.
88-
* @param string $text of the inquery
87+
* Perform a select inquiry so the user chooses from given options.
88+
* @param string $text of the inquiry
8989
* @param array $options to choose from
9090
* @param callable|null $renderer explicit to-string converter for options
9191
* @return mixed selected option value
@@ -102,7 +102,7 @@ protected function select(string $text, array $options, ?callable $renderer = nu
102102

103103
if ($this->nonInteractive) {
104104
throw new RuntimeException(
105-
"Unable preform the '$text' inquery in non-interactive mode. Operation aborted."
105+
"Unable preform the '$text' inquiry in non-interactive mode. Operation aborted."
106106
);
107107
}
108108

@@ -115,7 +115,7 @@ protected function select(string $text, array $options, ?callable $renderer = nu
115115
$translateBack[$key] = $option;
116116
}
117117

118-
// make the inquery
118+
// make the inquiry
119119
QuestionHelper::disableStty();
120120
/** @var QuestionHelper */
121121
$helper = $this->getHelper('question');

app/commands/DoctrineFixtures.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
9898
$groupFiles = [];
9999

100100
/** @var SplFileInfo $file */
101-
foreach (Finder::findFiles("*.neon", "*.yml", "*.yaml", "*.json")->in($fixtureDir . "/" . $group) as $file) {
101+
foreach (
102+
Finder::findFiles("*.neon", "*.yml", "*.yaml", "*.json")
103+
->in($fixtureDir . "/" . $group) as $file
104+
) {
102105
$groupFiles[] = $file->getRealPath();
103106
}
104107

app/commands/ExportDatabase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use App\Model\Repository\HardwareGroups;
1010
use App\Model\Repository\Pipelines;
1111
use App\Model\Repository\RuntimeEnvironments;
12-
use Nette\Neon\Encoder;
1312
use Nette\Neon\Neon;
1413
use Nette\Utils\FileSystem;
1514
use Symfony\Component\Console\Command\Command;
@@ -95,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9594
*/
9695
private function encodeResult($content): string
9796
{
98-
return Neon::encode($content, Encoder::BLOCK);
97+
return Neon::encode($content, true);
9998
}
10099

101100
/**

app/commands/GeneralStatsNotification.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@
44

55
use App\Helpers\Notifications\GeneralStatsEmailsSender;
66
use App\Helpers\GeneralStatsHelper;
7-
use App\Model\Repository\Assignments;
8-
use DateTime;
97
use Symfony\Component\Console\Command\Command;
10-
use Symfony\Component\Console\Input\InputArgument;
118
use Symfony\Component\Console\Input\InputInterface;
129
use Symfony\Component\Console\Output\OutputInterface;
1310

app/commands/RemoveInactiveUsers.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
namespace App\Console;
44

5-
use App\Model\Entity\User;
65
use App\Model\Repository\Users;
76
use App\Helpers\AnonymizationHelper;
87
use DateTime;
98
use DateInterval;
10-
use Exception;
119
use Symfony\Component\Console\Command\Command;
1210
use Symfony\Component\Console\Input\InputInterface;
1311
use Symfony\Component\Console\Output\OutputInterface;
@@ -92,7 +90,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
9290

9391
if (!$silent) {
9492
if ($this->roles) {
95-
$output->writeln("The cleanup aims only at users with the following roles: " . join(', ', $this->roles));
93+
$output->writeln("The cleanup aims only at users with the following roles: "
94+
. join(', ', $this->roles));
9695
}
9796
if ($this->disableThreshold) {
9897
$output->writeln("Disabling users not authenticated since: "
@@ -152,7 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
152151
$this->users->persist($user, false);
153152
}
154153

155-
// delete uers
154+
// delete users
156155
foreach ($usersToDelete as $user) {
157156
$this->anonymizationHelper->prepareUserForSoftDelete($user);
158157
$this->users->remove($user, false);

app/commands/SendPendingReviewsNotification.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
use App\Helpers\Notifications\ReviewsEmailsSender;
66
use App\Model\Repository\AssignmentSolutions;
77
use App\Model\Entity\Group;
8-
use App\Model\Entity\User;
98
use Symfony\Component\Console\Command\Command;
10-
use Symfony\Component\Console\Input\InputArgument;
119
use Symfony\Component\Console\Input\InputInterface;
1210
use Symfony\Component\Console\Output\OutputInterface;
1311
use DateTime;

app/commands/SwaggerAnnotator.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,10 @@
44

55
use App\Helpers\Swagger\TempAnnotationFileBuilder;
66
use App\Helpers\Swagger\AnnotationHelper;
7-
use App\V1Module\Router\MethodRoute;
8-
use Nette\Routing\RouteList;
97
use Symfony\Component\Console\Command\Command;
108
use Symfony\Component\Console\Input\InputInterface;
119
use Symfony\Component\Console\Output\OutputInterface;
1210
use Exception;
13-
use ReflectionException;
14-
use ReflectionClass;
1511

1612
/**
1713
* Command that creates a temporary file for swagger documentation generation.
@@ -28,7 +24,7 @@ protected function configure(): void
2824
$filePath = self::$autogeneratedAnnotationFilePath;
2925
$this->setName(self::$defaultName)->setDescription(
3026
"Extracts endpoint method annotations and puts them into a temporary file that can be used to generate"
31-
. " an OpenAPI documentation. The file is located at {$filePath}"
27+
. " an OpenAPI documentation. The file is located at {$filePath}"
3228
);
3329
}
3430

app/commands/cleanup/CleanupExerciseConfigs.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22

33
namespace App\Console;
44

5-
use App\Model\Entity\Assignment;
6-
use App\Model\Entity\Exercise;
7-
use App\Model\Entity\SolutionEvaluation;
85
use App\Model\Repository\Exercises;
96
use DateTime;
107
use Exception;
11-
use Doctrine\DBAL\Connection;
8+
use Doctrine\DBAL\ArrayParameterType;
129
use Doctrine\ORM\EntityManagerInterface;
1310
use Symfony\Component\Console\Command\Command;
1411
use Symfony\Component\Console\Input\InputInterface;
@@ -60,7 +57,7 @@ private function cleanupEnvironmentConfigs(DateTime $limit): int
6057
$deleteQuery = $this->entityManager->createQuery(
6158
'DELETE FROM App\Model\Entity\ExerciseEnvironmentConfig c WHERE c.id IN (:ids)'
6259
);
63-
$deleteQuery->setParameter("ids", $ids, Connection::PARAM_STR_ARRAY);
60+
$deleteQuery->setParameter("ids", $ids, ArrayParameterType::STRING);
6461
return $deleteQuery->execute();
6562
}
6663

@@ -115,7 +112,7 @@ private function cleanupLimits(DateTime $limit): int
115112
$deleteQuery = $this->entityManager->createQuery(
116113
'DELETE FROM App\Model\Entity\ExerciseLimits l WHERE l.id IN (:ids)'
117114
);
118-
$deleteQuery->setParameter("ids", $ids, Connection::PARAM_STR_ARRAY);
115+
$deleteQuery->setParameter("ids", $ids, ArrayParameterType::STRING);
119116
return $deleteQuery->execute();
120117
}
121118

@@ -137,7 +134,7 @@ private function cleanupTests(DateTime $limit): int
137134
$deleteQuery = $this->entityManager->createQuery(
138135
'DELETE FROM App\Model\Entity\ExerciseTest t WHERE t.id IN (:ids)'
139136
);
140-
$deleteQuery->setParameter("ids", $ids, Connection::PARAM_STR_ARRAY);
137+
$deleteQuery->setParameter("ids", $ids, ArrayParameterType::STRING);
141138
return $deleteQuery->execute();
142139
}
143140

@@ -152,7 +149,7 @@ protected function executeUnsafe(DateTime $limit, OutputInterface $output)
152149
'Tests',
153150
];
154151

155-
$report = [ 'Removed:' ];
152+
$report = ['Removed:'];
156153
foreach ($toDelete as $key) {
157154
$method = "cleanup$key";
158155
$deletedCount = $this->$method($limit);

app/commands/cleanup/CleanupExerciseFiles.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ public function __construct(
5252
protected function configure()
5353
{
5454
$this->setName('db:cleanup:exercise-files')
55-
->setDescription('Remove unused supplementary and attachment files (only DB records are removed in case of supplementary files).');
55+
->setDescription('Remove unused supplementary and attachment files "
56+
. "(only DB records are removed in case of supplementary files).');
5657
}
5758

5859
private function removeUnusedSupplementaryFiles(OutputInterface $output)

app/commands/cleanup/CleanupLocalizedTexts.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use App\Model\Repository\Assignments;
88
use App\Model\Repository\Exercises;
99
use DateTime;
10-
use Doctrine\DBAL\Connection;
10+
use Doctrine\DBAL\ArrayParameterType;
1111
use Doctrine\ORM\EntityManagerInterface;
1212
use Symfony\Component\Console\Command\Command;
1313
use Symfony\Component\Console\Input\InputInterface;
@@ -75,7 +75,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7575
$limit->modify("-14 days");
7676
$deleteQuery->setParameter("date", $limit);
7777

78-
$deleteQuery->setParameter("ids", $usedTexts, Connection::PARAM_STR_ARRAY);
78+
$deleteQuery->setParameter("ids", $usedTexts, ArrayParameterType::STRING);
7979

8080
$deleted += $deleteQuery->execute();
8181

0 commit comments

Comments
 (0)