Skip to content

Commit

Permalink
Add some return types
Browse files Browse the repository at this point in the history
  • Loading branch information
tareqas authored and nicolas-grekas committed Sep 15, 2023
1 parent ae45069 commit dac4f0e
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Cli/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getApi()
return $this->api;
}

public function getLongVersion()
public function getLongVersion(): string
{
$version = parent::getLongVersion().' by <comment>Symfony</comment>';
$commit = '@git-commit@';
Expand Down Expand Up @@ -116,7 +116,7 @@ protected function getDefaultCommands(): array
return $defaultCommands;
}

protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output): int
{
if (!$command instanceof LocalCommand\NeedConfigurationInterface) {
return parent::doRunCommand($command, $input, $output);
Expand Down
4 changes: 2 additions & 2 deletions Cli/Command/AnalysisCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

class AnalysisCommand extends Command implements NeedConfigurationInterface
{
protected function configure()
protected function configure(): void
{
$this
->setName('analysis')
Expand All @@ -32,7 +32,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$api = $this->getApplication()->getApi();
$analysis = $api->getProject($input->getArgument('project-uuid'))->getLastAnalysis();
Expand Down
4 changes: 2 additions & 2 deletions Cli/Command/AnalyzeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class AnalyzeCommand extends Command implements NeedConfigurationInterface
{
protected function configure()
protected function configure(): void
{
$this
->setName('analyze')
Expand All @@ -38,7 +38,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$projectUuid = $input->getArgument('project-uuid');

Expand Down
6 changes: 4 additions & 2 deletions Cli/Command/ConfigureCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@

class ConfigureCommand extends Command
{
protected function configure()
protected function configure(): void
{
$this
->setName('configure')
->setDescription('(Re-)Configure your credentials.')
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->getHelperSet()->get('configuration')->updateConfigurationManually($input, $output);

return 0;
}
}
6 changes: 4 additions & 2 deletions Cli/Command/ProjectsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

class ProjectsCommand extends Command implements NeedConfigurationInterface
{
protected function configure()
protected function configure(): void
{
$this
->setName('projects')
->setDescription('List all your projects')
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$api = $this->getApplication()->getApi();

Expand Down Expand Up @@ -58,5 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
->setRows($rows)
->render()
;

return 0;
}
}
10 changes: 7 additions & 3 deletions Cli/Command/SelfUpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class SelfUpdateCommand extends Command
/**
* {@inheritdoc}
*/
protected function configure()
protected function configure(): void
{
$this
->setName('self-update')
Expand All @@ -44,7 +44,7 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$remoteFilename = 'http://get.insight.sensiolabs.com/insight.phar';
$localFilename = $_SERVER['argv'][0];
Expand All @@ -57,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('<info>insight is already up to date.</info>');
unlink($tempFilename);

return;
return 0;
}

chmod($tempFilename, 0777 & ~umask());
Expand All @@ -69,13 +69,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
rename($tempFilename, $localFilename);

$output->writeln('<info>insight updated.</info>');

return 0;
} catch (\Exception $e) {
if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
throw $e;
}
unlink($tempFilename);
$output->writeln('<error>The download is corrupt ('.$e->getMessage().').</error>');
$output->writeln('<error>Please re-run the self-update command to try again.</error>');

return 1;
}
}
}
2 changes: 1 addition & 1 deletion Cli/Helper/ConfigurationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function getConfiguration(InputInterface $input, OutputInterface $output)
return $configuration;
}

public function getName()
public function getName(): string
{
return 'configuration';
}
Expand Down
2 changes: 1 addition & 1 deletion Cli/Helper/DescriptorHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function register($format, AbstractDescriptor $descriptor)
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return 'descriptor';
}
Expand Down
2 changes: 1 addition & 1 deletion Cli/Helper/FailConditionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function evaluate(Analysis $analysis, $expr)
return 0;
}

public function getName()
public function getName(): string
{
return 'fail_condition';
}
Expand Down

0 comments on commit dac4f0e

Please sign in to comment.