Skip to content

Commit

Permalink
Apply PER coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 27, 2024
1 parent 2444076 commit 85a9098
Show file tree
Hide file tree
Showing 234 changed files with 847 additions and 912 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'@PER-CS' => true,
])
->setFinder($finder)
;
2 changes: 1 addition & 1 deletion dist/dev-build-index.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
if ($config->has('application.installer_url')) {
$revertScript = sprintf(
'curl -sfS %s | php',
$config->get('application.installer_url')
$config->get('application.installer_url'),
);
}

Expand Down
4 changes: 2 additions & 2 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
->withImportNames(importShortClasses: false, removeUnusedImports: true)
->withConfiguredRule(
MethodCallToPropertyFetchRector::class,
[new MethodCallToPropertyFetch(CommandBase::class, 'api', 'api')]
[new MethodCallToPropertyFetch(CommandBase::class, 'api', 'api')],
)
->withConfiguredRule(
MethodCallToPropertyFetchRector::class,
[new MethodCallToPropertyFetch(CommandBase::class, 'config', 'config')]
[new MethodCallToPropertyFetch(CommandBase::class, 'config', 'config')],
)
;
4 changes: 2 additions & 2 deletions resources/oauth-listener/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct()
'CLI_OAUTH_CLIENT_ID',
'CLI_OAUTH_FILE',
'CLI_OAUTH_CODE_CHALLENGE',
'CLI_OAUTH_PROMPT'
'CLI_OAUTH_PROMPT',
];
if ($missing = array_diff($required, array_keys($_ENV))) {
throw new \RuntimeException('Invalid environment, missing: ' . implode(', ', $missing));
Expand Down Expand Up @@ -112,7 +112,7 @@ public function run()
// In any other case: redirect to login.
$url = $this->getOAuthUrl();
$this->setRedirect($url);
$this->response->content = '<p><a href="' . htmlspecialchars($url) .'">Log in</a>.</p>';
$this->response->content = '<p><a href="' . htmlspecialchars($url) . '">Log in</a>.</p>';
return;
}

Expand Down
6 changes: 3 additions & 3 deletions resources/router/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
$_SERVER['REMOTE_PORT'],
http_response_code(),
$_SERVER['REQUEST_METHOD'],
$_SERVER['REQUEST_URI']
$_SERVER['REQUEST_URI'],
),
ERROR_LOG_TYPE_SAPI
ERROR_LOG_TYPE_SAPI,
);
});

Expand Down Expand Up @@ -139,7 +139,7 @@
error_log(sprintf(
'Static file "%s" blocked by rule "%s"',
$relative_path,
$pattern
$pattern,
), ERROR_LOG_TYPE_SAPI);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ApiToken/CredentialHelperStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(Config $config, private Manager $manager)
$this->serverUrl = sprintf(
'%s/%s/api-token',
$config->getStr('application.slug'),
$config->getSessionId()
$config->getSessionId(),
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(?Config $config = null)
// Use the configured timezone, or fall back to the system timezone.
date_default_timezone_set(
$this->config->getWithDefault('application.timezone', null)
?: TimezoneUtil::getTimezone()
?: TimezoneUtil::getTimezone(),
);

// Set the Config service.
Expand Down Expand Up @@ -142,7 +142,7 @@ private function container(bool $recompile = false): ContainerInterface
throw new \RuntimeException(sprintf(
'Failed to load services.yaml file %s: %s',
$servicesFile,
$e->getMessage()
$e->getMessage(),
));
}
$this->container->addCompilerPass(new AddConsoleCommandPass());
Expand Down Expand Up @@ -175,7 +175,7 @@ protected function getDefaultInputDefinition(): InputDefinition
null,
InputOption::VALUE_NONE,
'Do not ask any interactive questions; accept default values. '
. sprintf('Equivalent to using the environment variable: <comment>%sNO_INTERACTION=1</comment>', $this->envPrefix)
. sprintf('Equivalent to using the environment variable: <comment>%sNO_INTERACTION=1</comment>', $this->envPrefix),
),
new HiddenInputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
new HiddenInputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
Expand Down Expand Up @@ -213,7 +213,7 @@ public function getHelp(): string
' %-29s %s %s',
'<info>--' . $option->getName() . '</info>',
$option->getShortcut() ? '<info>-' . $option->getShortcut() . '</info>' : ' ',
$option->getDescription()
$option->getDescription(),
);
}

Expand Down Expand Up @@ -320,7 +320,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output):
}

if (\function_exists('putenv')) {
@putenv('SHELL_VERBOSITY='.$shellVerbosity);
@putenv('SHELL_VERBOSITY=' . $shellVerbosity);
}
$_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
$_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
Expand Down
2 changes: 1 addition & 1 deletion src/Command/Activity/ActivityCancelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'%s: %s (%s)',
$this->propertyFormatter->formatDate($activity->created_at),
ActivityMonitor::getFormattedDescription($activity),
ActivityMonitor::formatState($activity->state)
ActivityMonitor::formatState($activity->state),
);
}
$id = $this->questionHelper->choose($choices, 'Enter a number to choose an activity to cancel:', (string) key($choices));
Expand Down
8 changes: 4 additions & 4 deletions src/Command/Activity/ActivityGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected function configure(): void
'i',
InputOption::VALUE_NONE,
'Include only incomplete activities (when selecting a default activity).'
. "\n" . 'This is a shorthand for <info>--state=in_progress,pending</info>'
. "\n" . 'This is a shorthand for <info>--state=in_progress,pending</info>',
)
->addOption('all', 'a', InputOption::VALUE_NONE, 'Check recent activities on all environments (when selecting a default activity)');
$this->selector->addProjectOption($this->getDefinition());
Expand Down Expand Up @@ -122,7 +122,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln(
'The <comment>payload</comment> property has been omitted for brevity.'
. ' You can still view it with the -P (--property) option.',
OutputInterface::VERBOSITY_VERBOSE
OutputInterface::VERBOSITY_VERBOSE,
);

$header = [];
Expand All @@ -140,11 +140,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln(sprintf(
'To view the log for this activity, run: <info>%s activity:log %s</info>',
$executable,
$activity->id
$activity->id,
));
$this->stdErr->writeln(sprintf(
'To list activities, run: <info>%s activities</info>',
$executable
$executable,
));
}

Expand Down
10 changes: 5 additions & 5 deletions src/Command/Activity/ActivityListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln(sprintf(
'Activities on the project %s, environment %s:',
$this->api->getProjectLabel($project),
$this->api->getEnvironmentLabel($apiResource)
$this->api->getEnvironmentLabel($apiResource),
));
} else {
$this->stdErr->writeln(sprintf(
'Activities on the project %s:',
$this->api->getProjectLabel($project)
$this->api->getProjectLabel($project),
));
}
}
Expand All @@ -170,19 +170,19 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln('More activities may be available.');
$this->stdErr->writeln(sprintf(
'To display older activities, increase <info>--limit</info> above %d, or set <info>--start</info> to a date in the past.',
$max
$max,
));
$this->suggestExclusions($activities);
}

$this->stdErr->writeln('');
$this->stdErr->writeln(sprintf(
'To view the log for an activity, run: <info>%s activity:log [id]</info>',
$executable
$executable,
));
$this->stdErr->writeln(sprintf(
'To view more information about an activity, run: <info>%s activity:get [id]</info>',
$executable
$executable,
));
$this->stdErr->writeln('');
$this->stdErr->writeln(sprintf('For more information, run: <info>%s activity:list -h</info>', $executable));
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Activity/ActivityLogCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function configure(): void
null,
InputOption::VALUE_REQUIRED,
'Activity refresh interval (seconds). Set to 0 to disable refreshing.',
3
3,
)
->addOption('timestamps', 't', InputOption::VALUE_NONE, 'Display a timestamp next to each message')
->addOption(
Expand Down Expand Up @@ -64,7 +64,7 @@ protected function configure(): void
'i',
InputOption::VALUE_NONE,
'Include only incomplete activities (when selecting a default activity).'
. "\n" . 'This is a shorthand for <info>--state=in_progress,pending</info>'
. "\n" . 'This is a shorthand for <info>--state=in_progress,pending</info>',
)
->addOption('all', 'a', InputOption::VALUE_NONE, 'Check recent activities on all environments (when selecting a default activity)');
PropertyFormatter::configureInput($this->getDefinition());
Expand Down
8 changes: 4 additions & 4 deletions src/Command/App/AppListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln(sprintf(
'Applications on the project <info>%s</info>, environment <info>%s</info>:',
$this->api->getProjectLabel($selection->getProject()),
$this->api->getEnvironmentLabel($selection->getEnvironment())
$this->api->getEnvironmentLabel($selection->getEnvironment()),
));
}

Expand All @@ -128,20 +128,20 @@ private function recommendOtherCommands(EnvironmentDeployment $deployment): void
if ($deployment->services) {
$lines[] = sprintf(
'To list services, run: <info>%s services</info>',
$executable
$executable,
);
}
if ($deployment->workers) {
$lines[] = sprintf(
'To list workers, run: <info>%s workers</info>',
$executable
$executable,
);
}
if ($info = $deployment->getProperty('project_info', false)) {
if (!empty($info['settings']['sizing_api_enabled']) && $this->config->getBool('api.sizing') && $this->config->isCommandEnabled('resources:set')) {
$lines[] = sprintf(
"To configure resources, run: <info>%s resources:set</info>",
$executable
$executable,
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Auth/AuthInfoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
sprintf(
'You cannot use both the <%s> argument and the --%s option',
'property',
'property'
)
'property',
),
);
}
$property = $input->getOption('property');
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Auth/AuthTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function configure(): void
'This command prints a valid OAuth 2 access token to stdout. It can be used to make API requests via standard Bearer authentication (RFC 6750).'
. "\n\n" . '<comment>Warning: access tokens must be kept secret.</comment>'
. "\n\n" . 'Using this command is not generally recommended, as it increases the chance of the token being leaked.'
. ' Take care not to expose the token in a shared program or system, or to send the token to the wrong API domain.'
. ' Take care not to expose the token in a shared program or system, or to send the token to the wrong API domain.',
);
$executable = $this->config->getStr('application.executable');
$apiUrl = $this->config->getApiUrl();
Expand All @@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
{
if (!$input->getOption('no-warn')) {
$this->stdErr->writeln(
'<fg=yellow>Warning: keep access tokens secret.</>'
'<fg=yellow>Warning: keep access tokens secret.</>',
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Command/Auth/BrowserLoginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln(\sprintf(
'You are already logged in as <info>%s</info> (<info>%s</info>)',
$account['username'],
$account['email']
$account['email'],
));

if (!$this->questionHelper->confirm('Log in anyway?', false)) {
Expand Down Expand Up @@ -145,7 +145,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
'-S',
$localAddress,
'-t',
$listenerDir
$listenerDir,
]);
$codeVerifier = $this->generateCodeVerifier();
$process->setEnv([
Expand Down
4 changes: 2 additions & 2 deletions src/Command/Auth/LogoutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($input->getOption('other') && !$input->getOption('all')) {
$currentSessionId = $this->config->getSessionId();
$this->stdErr->writeln(sprintf('The current session ID is: <info>%s</info>', $currentSessionId));
$other = \array_filter($this->api->listSessionIds(), fn ($sessionId): bool => $sessionId !== $currentSessionId);
$other = \array_filter($this->api->listSessionIds(), fn($sessionId): bool => $sessionId !== $currentSessionId);
if (empty($other)) {
$this->stdErr->writeln('No other sessions exist.');
return 0;
Expand Down Expand Up @@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln('');
$this->stdErr->writeln(sprintf(
'Other sessions exist. Log out of all sessions with: <comment>%s logout --all</comment>',
$this->config->getStr('application.executable')
$this->config->getStr('application.executable'),
));
}

Expand Down
8 changes: 4 additions & 4 deletions src/Command/Backup/BackupCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function configure(): void
InputOption::VALUE_NONE,
'Live backup: do not stop the environment.'
. "\n" . 'If set, this leaves the environment running and open to connections during the backup.'
. "\n" . 'This reduces downtime, at the risk of backing up data in an inconsistent state.'
. "\n" . 'This reduces downtime, at the risk of backing up data in an inconsistent state.',
);
$this->selector->addProjectOption($this->getDefinition());
$this->selector->addEnvironmentOption($this->getDefinition());
Expand All @@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$environmentId = $selectedEnvironment->id;
if (!$selectedEnvironment->operationAvailable('backup', true)) {
$this->stdErr->writeln(
"Operation not available: cannot create a backup of <error>$environmentId</error>"
"Operation not available: cannot create a backup of <error>$environmentId</error>",
);

if ($selectedEnvironment->is_dirty) {
Expand All @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln(sprintf(
'Creating a %s of %s.',
$live ? '<info>live</info> backup' : 'backup',
$this->api->getEnvironmentLabel($selectedEnvironment, 'info', false)
$this->api->getEnvironmentLabel($selectedEnvironment, 'info', false),
));
$this->stdErr->writeln('Note: this may delete an older backup if the quota has been reached.');
$this->stdErr->writeln('');
Expand All @@ -101,7 +101,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// Strongly recommend using --no-wait in a cron job.
if (!$this->io->isTerminal(STDIN)) {
$this->stdErr->writeln(
'<comment>Warning:</comment> use the --no-wait (-W) option if you are running this in a cron job.'
'<comment>Warning:</comment> use the --no-wait (-W) option if you are running this in a cron job.',
);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Backup/BackupListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->stdErr->writeln(sprintf(
'Backups on the project %s, environment %s:',
$this->api->getProjectLabel($selection->getProject()),
$this->api->getEnvironmentLabel($environment)
$this->api->getEnvironmentLabel($environment),
));
}

Expand Down
2 changes: 1 addition & 1 deletion src/Command/Backup/BackupRestoreCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
->setBranchFrom($branchFrom)
->setRestoreCode($input->getOption('no-code') ? false : null)
->setRestoreResources($input->hasOption('no-resources') && $input->getOption('no-resources') ? false : null)
->setResourcesInit($resourcesInit)
->setResourcesInit($resourcesInit),
);

if ($this->activityMonitor->shouldWait($input) && $result->countActivities()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BlueGreen/BlueGreenEnableCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected function configure(): void
'Use this command to enable blue/green deployments on an environment.'
. "\n\n" . 'If multiple environment versions do not already exist, this creates a new version as a copy of the current one.'
. "\n\n" . '100% of traffic is routed to the current version, and 0% to the new version. This can be flipped or changed with the blue-green:deploy command.'
. "\n\n" . 'While blue/green deployments are "enabled" (while multiple versions exist), the current version is "locked", and deployments (e.g. from Git pushes) affect the new version.'
. "\n\n" . 'While blue/green deployments are "enabled" (while multiple versions exist), the current version is "locked", and deployments (e.g. from Git pushes) affect the new version.',
);
$this->selector->addProjectOption($this->getDefinition());
$this->selector->addEnvironmentOption($this->getDefinition());
Expand Down
2 changes: 1 addition & 1 deletion src/Command/BotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private function addSignature(array $frames, string $signature): array
$signature = "\n" . $signatureIndent . '<info>' . $signature . '</info>';
}

return array_map(fn ($frame) => preg_replace('/^/m', $indent, (string) $frame) . $signature, $frames);
return array_map(fn($frame) => preg_replace('/^/m', $indent, (string) $frame) . $signature, $frames);
}

/**
Expand Down
Loading

0 comments on commit 85a9098

Please sign in to comment.