Skip to content

Commit 8b83b2f

Browse files
wouterjnicolas-grekas
authored andcommitted
[Components] Convert to native return types
1 parent 14816cd commit 8b83b2f

Some content is hidden

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

50 files changed

+181
-600
lines changed

Application.php

+18-53
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ public function setDispatcher(EventDispatcherInterface $dispatcher): void
110110
$this->dispatcher = $dispatcher;
111111
}
112112

113-
/**
114-
* @return void
115-
*/
116-
public function setCommandLoader(CommandLoaderInterface $commandLoader)
113+
public function setCommandLoader(CommandLoaderInterface $commandLoader): void
117114
{
118115
$this->commandLoader = $commandLoader;
119116
}
@@ -127,10 +124,7 @@ public function getSignalRegistry(): SignalRegistry
127124
return $this->signalRegistry;
128125
}
129126

130-
/**
131-
* @return void
132-
*/
133-
public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent)
127+
public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent): void
134128
{
135129
$this->signalsToDispatchEvent = $signalsToDispatchEvent;
136130
}
@@ -220,7 +214,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
220214
*
221215
* @return int 0 if everything went fine, or an error code
222216
*/
223-
public function doRun(InputInterface $input, OutputInterface $output)
217+
public function doRun(InputInterface $input, OutputInterface $output): int
224218
{
225219
if (true === $input->hasParameterOption(['--version', '-V'], true)) {
226220
$output->writeln($this->getLongVersion());
@@ -323,17 +317,11 @@ public function doRun(InputInterface $input, OutputInterface $output)
323317
return $exitCode;
324318
}
325319

326-
/**
327-
* @return void
328-
*/
329-
public function reset()
320+
public function reset(): void
330321
{
331322
}
332323

333-
/**
334-
* @return void
335-
*/
336-
public function setHelperSet(HelperSet $helperSet)
324+
public function setHelperSet(HelperSet $helperSet): void
337325
{
338326
$this->helperSet = $helperSet;
339327
}
@@ -346,10 +334,7 @@ public function getHelperSet(): HelperSet
346334
return $this->helperSet ??= $this->getDefaultHelperSet();
347335
}
348336

349-
/**
350-
* @return void
351-
*/
352-
public function setDefinition(InputDefinition $definition)
337+
public function setDefinition(InputDefinition $definition): void
353338
{
354339
$this->definition = $definition;
355340
}
@@ -419,10 +404,8 @@ public function areExceptionsCaught(): bool
419404

420405
/**
421406
* Sets whether to catch exceptions or not during commands execution.
422-
*
423-
* @return void
424407
*/
425-
public function setCatchExceptions(bool $boolean)
408+
public function setCatchExceptions(bool $boolean): void
426409
{
427410
$this->catchExceptions = $boolean;
428411
}
@@ -437,10 +420,8 @@ public function isAutoExitEnabled(): bool
437420

438421
/**
439422
* Sets whether to automatically exit after a command execution or not.
440-
*
441-
* @return void
442423
*/
443-
public function setAutoExit(bool $boolean)
424+
public function setAutoExit(bool $boolean): void
444425
{
445426
$this->autoExit = $boolean;
446427
}
@@ -455,10 +436,8 @@ public function getName(): string
455436

456437
/**
457438
* Sets the application name.
458-
*
459-
* @return void
460439
*/
461-
public function setName(string $name)
440+
public function setName(string $name): void
462441
{
463442
$this->name = $name;
464443
}
@@ -473,20 +452,16 @@ public function getVersion(): string
473452

474453
/**
475454
* Sets the application version.
476-
*
477-
* @return void
478455
*/
479-
public function setVersion(string $version)
456+
public function setVersion(string $version): void
480457
{
481458
$this->version = $version;
482459
}
483460

484461
/**
485462
* Returns the long version of the application.
486-
*
487-
* @return string
488463
*/
489-
public function getLongVersion()
464+
public function getLongVersion(): string
490465
{
491466
if ('UNKNOWN' !== $this->getName()) {
492467
if ('UNKNOWN' !== $this->getVersion()) {
@@ -513,10 +488,8 @@ public function register(string $name): Command
513488
* If a Command is not enabled it will not be added.
514489
*
515490
* @param Command[] $commands An array of commands
516-
*
517-
* @return void
518491
*/
519-
public function addCommands(array $commands)
492+
public function addCommands(array $commands): void
520493
{
521494
foreach ($commands as $command) {
522495
$this->add($command);
@@ -528,10 +501,8 @@ public function addCommands(array $commands)
528501
*
529502
* If a command with the same name already exists, it will be overridden.
530503
* If the command is not enabled it will not be added.
531-
*
532-
* @return Command|null
533504
*/
534-
public function add(Command $command)
505+
public function add(Command $command): ?Command
535506
{
536507
$this->init();
537508

@@ -564,11 +535,9 @@ public function add(Command $command)
564535
/**
565536
* Returns a registered command by name or alias.
566537
*
567-
* @return Command
568-
*
569538
* @throws CommandNotFoundException When given command name does not exist
570539
*/
571-
public function get(string $name)
540+
public function get(string $name): Command
572541
{
573542
$this->init();
574543

@@ -671,11 +640,9 @@ public function findNamespace(string $namespace): string
671640
* Contrary to get, this command tries to find the best
672641
* match if you give it an abbreviation of a name or alias.
673642
*
674-
* @return Command
675-
*
676643
* @throws CommandNotFoundException When command name is incorrect or ambiguous
677644
*/
678-
public function find(string $name)
645+
public function find(string $name): Command
679646
{
680647
$this->init();
681648

@@ -783,7 +750,7 @@ public function find(string $name)
783750
*
784751
* @return Command[]
785752
*/
786-
public function all(string $namespace = null)
753+
public function all(string $namespace = null): array
787754
{
788755
$this->init();
789756

@@ -924,10 +891,8 @@ protected function doRenderThrowable(\Throwable $e, OutputInterface $output): vo
924891

925892
/**
926893
* Configures the input and output instances based on the user arguments and options.
927-
*
928-
* @return void
929894
*/
930-
protected function configureIO(InputInterface $input, OutputInterface $output)
895+
protected function configureIO(InputInterface $input, OutputInterface $output): void
931896
{
932897
if (true === $input->hasParameterOption(['--ansi'], true)) {
933898
$output->setDecorated(true);
@@ -992,7 +957,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
992957
*
993958
* @return int 0 if everything went fine, or an error code
994959
*/
995-
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
960+
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
996961
{
997962
foreach ($command->getHelperSet() as $helper) {
998963
if ($helper instanceof InputAwareInterface) {

Command/Command.php

+9-27
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,13 @@ public function __construct(string $name = null)
107107
* Ignores validation errors.
108108
*
109109
* This is mainly useful for the help command.
110-
*
111-
* @return void
112110
*/
113-
public function ignoreValidationErrors()
111+
public function ignoreValidationErrors(): void
114112
{
115113
$this->ignoreValidationErrors = true;
116114
}
117115

118-
/**
119-
* @return void
120-
*/
121-
public function setApplication(?Application $application)
116+
public function setApplication(?Application $application): void
122117
{
123118
$this->application = $application;
124119
if ($application) {
@@ -130,10 +125,7 @@ public function setApplication(?Application $application)
130125
$this->fullDefinition = null;
131126
}
132127

133-
/**
134-
* @return void
135-
*/
136-
public function setHelperSet(HelperSet $helperSet)
128+
public function setHelperSet(HelperSet $helperSet): void
137129
{
138130
$this->helperSet = $helperSet;
139131
}
@@ -159,20 +151,16 @@ public function getApplication(): ?Application
159151
*
160152
* Override this to check for x or y and return false if the command cannot
161153
* run properly under the current conditions.
162-
*
163-
* @return bool
164154
*/
165-
public function isEnabled()
155+
public function isEnabled(): bool
166156
{
167157
return true;
168158
}
169159

170160
/**
171161
* Configures the current command.
172-
*
173-
* @return void
174162
*/
175-
protected function configure()
163+
protected function configure(): void
176164
{
177165
}
178166

@@ -190,7 +178,7 @@ protected function configure()
190178
*
191179
* @see setCode()
192180
*/
193-
protected function execute(InputInterface $input, OutputInterface $output)
181+
protected function execute(InputInterface $input, OutputInterface $output): int
194182
{
195183
throw new LogicException('You must override the execute() method in the concrete command class.');
196184
}
@@ -201,10 +189,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
201189
* This method is executed before the InputDefinition is validated.
202190
* This means that this is the only place where the command can
203191
* interactively ask for values of missing required arguments.
204-
*
205-
* @return void
206192
*/
207-
protected function interact(InputInterface $input, OutputInterface $output)
193+
protected function interact(InputInterface $input, OutputInterface $output): void
208194
{
209195
}
210196

@@ -217,10 +203,8 @@ protected function interact(InputInterface $input, OutputInterface $output)
217203
*
218204
* @see InputInterface::bind()
219205
* @see InputInterface::validate()
220-
*
221-
* @return void
222206
*/
223-
protected function initialize(InputInterface $input, OutputInterface $output)
207+
protected function initialize(InputInterface $input, OutputInterface $output): void
224208
{
225209
}
226210

@@ -650,12 +634,10 @@ public function getUsages(): array
650634
/**
651635
* Gets a helper instance by name.
652636
*
653-
* @return HelperInterface
654-
*
655637
* @throws LogicException if no HelperSet is defined
656638
* @throws InvalidArgumentException if the helper is not defined
657639
*/
658-
public function getHelper(string $name): mixed
640+
public function getHelper(string $name): HelperInterface
659641
{
660642
if (null === $this->helperSet) {
661643
throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));

Command/HelpCommand.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ class HelpCommand extends Command
2727
{
2828
private Command $command;
2929

30-
/**
31-
* @return void
32-
*/
33-
protected function configure()
30+
protected function configure(): void
3431
{
3532
$this->ignoreValidationErrors();
3633

@@ -57,10 +54,7 @@ protected function configure()
5754
;
5855
}
5956

60-
/**
61-
* @return void
62-
*/
63-
public function setCommand(Command $command)
57+
public function setCommand(Command $command): void
6458
{
6559
$this->command = $command;
6660
}

Command/ListCommand.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@
2525
*/
2626
class ListCommand extends Command
2727
{
28-
/**
29-
* @return void
30-
*/
31-
protected function configure()
28+
protected function configure(): void
3229
{
3330
$this
3431
->setName('list')

Command/SignalableCommandInterface.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ public function getSubscribedSignals(): array;
2828
*
2929
* @return int|false The exit code to return or false to continue the normal execution
3030
*/
31-
public function handleSignal(int $signal, int|false $previousExitCode = 0);
31+
public function handleSignal(int $signal, int|false $previousExitCode = 0): int|false;
3232
}

DependencyInjection/AddConsoleCommandPass.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,7 @@
2929
*/
3030
class AddConsoleCommandPass implements CompilerPassInterface
3131
{
32-
/**
33-
* @return void
34-
*/
35-
public function process(ContainerBuilder $container)
32+
public function process(ContainerBuilder $container): void
3633
{
3734
$commandServices = $container->findTaggedServiceIds('console.command', true);
3835
$lazyCommandMap = [];

Descriptor/DescriptorInterface.php

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,5 @@
2020
*/
2121
interface DescriptorInterface
2222
{
23-
/**
24-
* @return void
25-
*/
26-
public function describe(OutputInterface $output, object $object, array $options = []);
23+
public function describe(OutputInterface $output, object $object, array $options = []): void;
2724
}

EventListener/ErrorListener.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,7 @@ public function __construct(LoggerInterface $logger = null)
3131
$this->logger = $logger;
3232
}
3333

34-
/**
35-
* @return void
36-
*/
37-
public function onConsoleError(ConsoleErrorEvent $event)
34+
public function onConsoleError(ConsoleErrorEvent $event): void
3835
{
3936
if (null === $this->logger) {
4037
return;
@@ -51,10 +48,7 @@ public function onConsoleError(ConsoleErrorEvent $event)
5148
$this->logger->critical('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]);
5249
}
5350

54-
/**
55-
* @return void
56-
*/
57-
public function onConsoleTerminate(ConsoleTerminateEvent $event)
51+
public function onConsoleTerminate(ConsoleTerminateEvent $event): void
5852
{
5953
if (null === $this->logger) {
6054
return;

0 commit comments

Comments
 (0)