Skip to content

Commit 9356c92

Browse files
alongoszSteveb-pkonradoboza
authored andcommitted
IBX-8138: [Rector] Applied rules from Symfony 5 Rector set lists (#385)
For more details see https://issues.ibexa.co/browse/IBX-8138 and #385 Key changes: * [Rector] Applied Symfony 5.1 CommandConstantReturnCodeRector * [Rector] Applied Symfony 5.2 RenameMethodRector * [Rector] Applied Symfony 5.3 Rector sets * [Rector] Applied Symfony code quality Rector sets Applied rules: * LiteralGetToRequestClassConstantRector * ResponseStatusCodeRector * MakeCommandLazyRector * [Rector] Applied Return type rectors Applied rules: * ReturnTypeFromStrictNativeCallRector * ReturnTypeFromStrictScalarReturnExprRector * [Rector] Applied Symfony 6.0 AddReturnTypeDeclarationRector * [Rector] Added Symfony Bundle::getContainerExtension return type * Added strict types for InstallPlatformCommand consts * Made XML serialization exception more verbose in Author and DateTime converters * Implemented `\Ibexa\Core\MVC\Symfony\Security\User::getUserIdentifier` --------- Co-Authored-By: Paweł Niedzielski <[email protected]> Co-Authored-By: Konrad Oboza <[email protected]>
1 parent 92f15f9 commit 9356c92

File tree

456 files changed

+1033
-957
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

456 files changed

+1033
-957
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"ext-fileinfo": "*",
1313
"ext-intl": "*",
1414
"ext-json": "*",
15+
"ext-libxml": "*",
1516
"ext-mbstring": "*",
1617
"ext-PDO": "*",
1718
"ext-SPL": "*",

src/bundle/Core/Cache/Warmer/ProxyCacheWarmer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ public function isOptional(): bool
4747
return false;
4848
}
4949

50-
public function warmUp($cacheDir): void
50+
public function warmUp($cacheDir): array
5151
{
5252
$this->proxyGenerator->warmUp(self::PROXY_CLASSES);
53+
54+
return [];
5355
}
5456
}

src/bundle/Core/Command/CheckURLsCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
106106
}
107107
$progress->finish();
108108

109-
return 0;
109+
return self::SUCCESS;
110110
}
111111

112112
private function getTotalCount(): int

src/bundle/Core/Command/CleanupVersionsCommand.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,21 @@ class CleanupVersionsCommand extends Command
3131
- Run this command in production environment using <info>--env=prod</info>
3232
EOT;
3333
public const VERSION_DRAFT = 'draft';
34+
3435
public const VERSION_ARCHIVED = 'archived';
3536
public const VERSION_PUBLISHED = 'published';
3637
public const VERSION_ALL = 'all';
38+
3739
public const VERSION_STATUS = [
3840
self::VERSION_DRAFT => VersionInfo::STATUS_DRAFT,
3941
self::VERSION_ARCHIVED => VersionInfo::STATUS_ARCHIVED,
4042
self::VERSION_PUBLISHED => VersionInfo::STATUS_PUBLISHED,
4143
];
4244

45+
protected static $defaultName = 'ibexa:content:cleanup-versions';
46+
47+
protected static $defaultDescription = 'Removes unwanted content versions. Keeps the published version untouched. By default, also keeps the last archived/draft version.';
48+
4349
private readonly Repository $repository;
4450

4551
private readonly RepositoryConfigurationProviderInterface $repositoryConfigurationProvider;
@@ -62,8 +68,6 @@ protected function configure()
6268
{
6369
$beforeRunningHints = self::BEFORE_RUNNING_HINTS;
6470
$this
65-
->setName('ibexa:content:cleanup-versions')
66-
->setDescription('Removes unwanted content versions. Keeps the published version untouched. By default, also keeps the last archived/draft version.')
6771
->addOption(
6872
'status',
6973
't',
@@ -144,7 +148,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
144148
if ($contentIdsCount === 0) {
145149
$output->writeln('<info>There is no content matching the given Criteria.</info>');
146150

147-
return 0;
151+
return self::SUCCESS;
148152
}
149153

150154
$output->writeln(sprintf(
@@ -182,7 +186,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
182186
), OutputInterface::VERBOSITY_VERBOSE);
183187

184188
if ($removeAll) {
185-
$versions = array_filter($versions, static function (VersionInfo $version) {
189+
$versions = array_filter($versions, static function (VersionInfo $version): bool {
186190
return $version->status !== VersionInfo::STATUS_PUBLISHED;
187191
});
188192
}
@@ -225,7 +229,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
225229
$contentIdsCount
226230
));
227231

228-
return 0;
232+
return self::SUCCESS;
229233
}
230234

231235
/**

src/bundle/Core/Command/CopySubtreeCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
*/
2929
class CopySubtreeCommand extends Command
3030
{
31+
protected static $defaultName = 'ibexa:copy-subtree';
32+
33+
protected static $defaultDescription = 'Copies a subtree from one Location to another';
34+
3135
/** @var \Ibexa\Contracts\Core\Repository\LocationService */
3236
private $locationService;
3337

@@ -68,7 +72,6 @@ public function __construct(
6872
protected function configure()
6973
{
7074
$this
71-
->setName('ibexa:copy-subtree')
7275
->addArgument(
7376
'source-location-id',
7477
InputArgument::REQUIRED,
@@ -85,8 +88,7 @@ protected function configure()
8588
InputOption::VALUE_OPTIONAL,
8689
'Ibexa username (with Role containing at least content policies: create, read)',
8790
'admin'
88-
)
89-
->setDescription('Copies a subtree from one Location to another');
91+
);
9092
}
9193

9294
/**
@@ -150,7 +152,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
150152
);
151153

152154
if (!$input->getOption('no-interaction') && !$questionHelper->ask($input, $output, $question)) {
153-
return 0;
155+
return self::SUCCESS;
154156
}
155157

156158
$this->locationService->copySubtree(
@@ -162,7 +164,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
162164
'<info>Finished</info>'
163165
);
164166

165-
return 0;
167+
return self::SUCCESS;
166168
}
167169

168170
/**

src/bundle/Core/Command/DebugConfigResolverCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
class DebugConfigResolverCommand extends Command
2121
{
22+
protected static $defaultName = 'ibexa:debug:config-resolver';
23+
2224
/** @var \Ibexa\Contracts\Core\SiteAccess\ConfigResolverInterface */
2325
private $configResolver;
2426

@@ -40,7 +42,6 @@ public function __construct(
4042
*/
4143
public function configure()
4244
{
43-
$this->setName('ibexa:debug:config-resolver');
4445
$this->setAliases(['ibexa:debug:config']);
4546
$this->setDescription('Debugs / Retrieves a parameter from the Config Resolver');
4647
$this->addArgument(
@@ -96,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9697
if ($input->getOption('json')) {
9798
$output->write(json_encode($parameterData));
9899

99-
return 0;
100+
return self::SUCCESS;
100101
}
101102

102103
$output->writeln('<comment>SiteAccess name:</comment> ' . $this->siteAccess->name);
@@ -111,6 +112,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
111112
)
112113
);
113114

114-
return 0;
115+
return self::SUCCESS;
115116
}
116117
}

src/bundle/Core/Command/DeleteContentTranslationCommand.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
*/
2525
class DeleteContentTranslationCommand extends Command
2626
{
27+
protected static $defaultName = 'ibexa:delete-content-translation';
28+
29+
protected static $defaultDescription = 'Deletes a translation from all versions of a Content item';
30+
2731
/** @var \Ibexa\Contracts\Core\Repository\Repository */
2832
private $repository;
2933

@@ -51,7 +55,6 @@ public function __construct(Repository $repository)
5155
protected function configure()
5256
{
5357
$this
54-
->setName('ibexa:delete-content-translation')
5558
->addArgument('content-id', InputArgument::REQUIRED, 'Content Object Id')
5659
->addArgument(
5760
'language-code',
@@ -64,8 +67,7 @@ protected function configure()
6467
InputOption::VALUE_OPTIONAL,
6568
'Ibexa username (with Role containing at least content Policies: read, versionread, edit, remove, versionremove)',
6669
'admin'
67-
)
68-
->setDescription('Deletes a translation from all versions of a Content item');
70+
);
6971
}
7072

7173
protected function initialize(InputInterface $input, OutputInterface $output)
@@ -125,7 +127,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
125127
$this->repository->rollback();
126128
$this->output->writeln('Reverting and aborting.');
127129

128-
return 0;
130+
return self::SUCCESS;
129131
}
130132

131133
// Delete Translation
@@ -142,7 +144,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
142144
throw $e;
143145
}
144146

145-
return 0;
147+
return self::SUCCESS;
146148
}
147149

148150
/**
@@ -167,7 +169,7 @@ private function promptUserForMainLanguageChange(
167169
// get main Translation candidates w/o Translation being removed
168170
$mainTranslationCandidates = array_filter(
169171
$lastVersionLanguageCodes,
170-
static function ($versionLanguageCode) use ($languageCode) {
172+
static function ($versionLanguageCode) use ($languageCode): bool {
171173
return $versionLanguageCode !== $languageCode;
172174
}
173175
);

src/bundle/Core/Command/ExpireUserPasswordsCommand.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ final class ExpireUserPasswordsCommand extends Command
2929
{
3030
protected static $defaultName = 'ibexa:user:expire-password';
3131

32+
protected static $defaultDescription = 'Expire passwords for selected users.';
33+
3234
public const REQUIRE_NEW_PASSWORD_VALUE = true;
3335

3436
public const DEFAULT_BATCH_SIZE = 50;
@@ -71,7 +73,6 @@ protected function configure(): void
7173
{
7274
$beforeRunningHints = self::BEFORE_RUNNING_HINTS;
7375
$this
74-
->setDescription('Expire passwords for selected users.')
7576
->addOption(
7677
'user-id',
7778
'u',
@@ -147,7 +148,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
147148
if ($totalCount === 0) {
148149
$output->writeln('<info>There are no users matching given criteria</info>');
149150

150-
return Command::SUCCESS;
151+
return self::SUCCESS;
151152
}
152153

153154
$output->writeln(sprintf(
@@ -212,7 +213,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
212213
);
213214
}
214215

215-
return Command::SUCCESS;
216+
return self::SUCCESS;
216217
}
217218

218219
/**

src/bundle/Core/Command/NormalizeImagesPathsCommand.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ final class NormalizeImagesPathsCommand extends Command
3939

4040
protected static $defaultName = 'ibexa:images:normalize-paths';
4141

42+
protected static $defaultDescription = 'Normalizes stored paths for images.';
43+
4244
/** @var \Ibexa\Core\FieldType\Image\ImageStorage\Gateway */
4345
private $imageGateway;
4446

@@ -73,7 +75,6 @@ protected function configure()
7375
$beforeRunningHints = self::BEFORE_RUNNING_HINTS;
7476

7577
$this
76-
->setDescription('Normalizes stored paths for images.')
7778
->addOption(
7879
self::SKIP_HASHING_COMMAND_PARAMETER,
7980
null,
@@ -112,11 +113,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
112113
if ($imagePathsToNormalizeCount === 0) {
113114
$io->success('No paths to normalize.');
114115

115-
return 0;
116+
return self::SUCCESS;
116117
}
117118

118119
if (!$io->confirm('Do you want to continue?')) {
119-
return 0;
120+
return self::SUCCESS;
120121
}
121122

122123
$io->writeln('Normalizing image paths. Please wait...');
@@ -135,7 +136,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
135136
$io->progressFinish();
136137
$io->success('Done!');
137138

138-
return 0;
139+
return self::SUCCESS;
139140
}
140141

141142
/**
@@ -232,7 +233,7 @@ private function getFinalNormalizedPath(
232233
$processedPaths = array_values(
233234
array_filter(
234235
$imagePathsToNormalize,
235-
static function (array $data) use ($filePath) {
236+
static function (array $data) use ($filePath): bool {
236237
return $data['oldPath'] === $filePath;
237238
}
238239
)

src/bundle/Core/Command/RegenerateUrlAliasesCommand.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Symfony\Component\Console\Question\ConfirmationQuestion;
2222

2323
/**
24-
* The ezplatform:urls:regenerate-aliases Symfony command implementation.
24+
* The ibexa:urls:regenerate-aliases Symfony command implementation.
2525
* Recreates system URL aliases for all existing Locations and cleanups corrupted URL alias nodes.
2626
*/
2727
class RegenerateUrlAliasesCommand extends Command
@@ -36,6 +36,8 @@ class RegenerateUrlAliasesCommand extends Command
3636
- Manually clear HTTP cache after running this command.
3737
EOT;
3838

39+
protected static $defaultName = 'ibexa:urls:regenerate-aliases';
40+
3941
/** @var \Ibexa\Contracts\Core\Repository\Repository */
4042
private $repository;
4143

@@ -61,7 +63,6 @@ protected function configure()
6163
{
6264
$beforeRunningHints = self::BEFORE_RUNNING_HINTS;
6365
$this
64-
->setName('ibexa:urls:regenerate-aliases')
6566
->setDescription(
6667
'Regenerates Location URL aliases (autogenerated) and cleans up custom Location ' .
6768
'and global URL aliases stored in the Legacy Storage Engine'
@@ -116,7 +117,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
116117
$locationsCount = count($locationIds);
117118
} else {
118119
$locationsCount = $this->repository->sudo(
119-
static function (Repository $repository) {
120+
static function (Repository $repository): int {
120121
return $repository->getLocationService()->getAllLocationsCount();
121122
}
122123
);
@@ -125,7 +126,7 @@ static function (Repository $repository) {
125126
if ($locationsCount === 0) {
126127
$output->writeln('<info>No location was found. Exiting.</info>');
127128

128-
return 0;
129+
return self::SUCCESS;
129130
}
130131

131132
if (!$input->getOption('no-interaction')) {
@@ -139,24 +140,24 @@ static function (Repository $repository) {
139140
false
140141
);
141142
if (!$helper->ask($input, $output, $question)) {
142-
return 0;
143+
return self::SUCCESS;
143144
}
144145
} elseif (!$input->getOption('force')) {
145-
return 1;
146+
return self::FAILURE;
146147
}
147148

148149
$this->regenerateSystemUrlAliases($output, $locationsCount, $locationIds, $iterationCount);
149150

150151
$output->writeln('<info>Cleaning up corrupted URL aliases...</info>');
151152
$corruptedAliasesCount = $this->repository->sudo(
152-
static function (Repository $repository) {
153+
static function (Repository $repository): int {
153154
return $repository->getURLAliasService()->deleteCorruptedUrlAliases();
154155
}
155156
);
156157
$output->writeln("<info>Done. Deleted {$corruptedAliasesCount} entries.</info>");
157158
$output->writeln('<comment>Make sure to clear HTTP cache.</comment>');
158159

159-
return 0;
160+
return self::SUCCESS;
160161
}
161162

162163
/**

0 commit comments

Comments
 (0)