Skip to content

Commit 5ceb550

Browse files
committed
refactor: review commands
1 parent 24d6800 commit 5ceb550

File tree

2 files changed

+16
-36
lines changed

2 files changed

+16
-36
lines changed

Command/ExtractTranslationCommand.php

+8-16
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,11 @@
3737
*/
3838
class ExtractTranslationCommand extends Command
3939
{
40-
/**
41-
* @var ConfigFactory
42-
*/
43-
private $configFactory;
40+
private ConfigFactory $configFactory;
4441

45-
/**
46-
* @var Updater
47-
*/
48-
private $updater;
42+
private Updater $updater;
4943

50-
/**
51-
* @var array
52-
*/
53-
private $locales;
44+
private array $locales;
5445

5546
public function __construct(ConfigFactory $configFactory, Updater $updater, array $locales)
5647
{
@@ -82,7 +73,8 @@ protected function configure(): void
8273
->addOption('intl-icu', null, InputOption::VALUE_NONE, 'Flag to indicate if translations should be dumped to using the ICU message format.')
8374
->addOption('default-output-format', null, InputOption::VALUE_REQUIRED, 'The default output format (defaults to xlf).')
8475
->addOption('keep', null, InputOption::VALUE_NONE, 'Define if the updater service should keep the old translation (defaults to false).')
85-
->addOption('external-translations-dir', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Load external translation resources');
76+
->addOption('external-translations-dir', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Load external translation resources')
77+
;
8678
}
8779

8880
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -142,18 +134,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int
142134
}
143135
}
144136

145-
return 0;
137+
return Command::SUCCESS;
146138
}
147139

148140
$this->updater->process($config);
149141
}
150142

151143
$output->writeln('done!');
152144

153-
return 0;
145+
return Command::SUCCESS;
154146
}
155147

156-
private function updateWithInput(InputInterface $input, ConfigBuilder $builder)
148+
private function updateWithInput(InputInterface $input, ConfigBuilder $builder): void
157149
{
158150
if ($bundle = $input->getOption('bundle')) {
159151
if ('@' === $bundle[0]) {

Command/ResourcesListCommand.php

+8-20
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,14 @@
3232
*/
3333
class ResourcesListCommand extends Command
3434
{
35-
/**
36-
* @var string
37-
*/
38-
private $projectDir;
35+
private string $projectDir;
3936

4037
/**
4138
* @var string|null
4239
*/
4340
private $rootDir;
4441

45-
/**
46-
* @var array
47-
*/
48-
private $bundles;
42+
private array $bundles;
4943

5044
public function __construct(string $projectDir, array $bundles, ?string $rootDir)
5145
{
@@ -61,7 +55,8 @@ protected function configure(): void
6155
$this
6256
->setName('jms:translation:list-resources')
6357
->setDescription('List translation resources available.')
64-
->addOption('files', null, InputOption::VALUE_OPTIONAL, 'Display only files');
58+
->addOption('files', null, InputOption::VALUE_OPTIONAL, 'Display only files')
59+
;
6560
}
6661

6762
protected function execute(InputInterface $input, OutputInterface $output): int
@@ -88,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8883

8984
$output->writeln('done!');
9085

91-
return 0;
86+
return Command::SUCCESS;
9287
}
9388

9489
$output->writeln('<info>Resources list :</info>');
@@ -102,15 +97,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
10297

10398
$output->writeln('done!');
10499

105-
return 0;
100+
return Command::SUCCESS;
106101
}
107102

108-
/**
109-
* @param array $dirs
110-
*
111-
* @return array
112-
*/
113-
private function retrieveFiles(array $dirs)
103+
private function retrieveFiles(array $dirs): array
114104
{
115105
$files = [];
116106
// Register translation resources
@@ -127,10 +117,8 @@ private function retrieveFiles(array $dirs)
127117

128118
/**
129119
* The following methods is derived from code of the FrameworkExtension.php file from the Symfony2 framework
130-
*
131-
* @return array
132120
*/
133-
private function retrieveDirs()
121+
private function retrieveDirs(): array
134122
{
135123
// Discover translation directories
136124
$dirs = [];

0 commit comments

Comments
 (0)