Skip to content

Commit

Permalink
Code style cleanup (#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell authored May 18, 2023
1 parent 098ec71 commit d014791
Show file tree
Hide file tree
Showing 71 changed files with 122 additions and 357 deletions.
3 changes: 0 additions & 3 deletions src/AcsfApi/AcsfCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ public function getCloudKey(): ?string {
return NULL;
}

/**
* @param array $factory
*/
public function getFactoryActiveUser(array $factory): mixed {
if (array_key_exists('active_user', $factory)) {
$activeUser = $factory['active_user'];
Expand Down
3 changes: 0 additions & 3 deletions src/CloudApi/ClientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ class ClientService implements ClientServiceInterface {
protected Application $application;
protected ?bool $machineIsAuthenticated = NULL;

/**
* @param \Acquia\Cli\CloudApi\ConnectorFactory $connectorFactory
*/
public function __construct(ConnectorFactoryInterface $connectorFactory, Application $application, protected ApiCredentialsInterface $credentials) {
$this->connectorFactory = $connectorFactory;
$this->setConnector($connectorFactory->createConnector());
Expand Down
8 changes: 3 additions & 5 deletions src/Command/Acsf/AcsfApiAuthLoginCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Acquia\Cli\Command\Acsf;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -21,9 +22,6 @@ protected function commandRequiresAuthentication(): bool {
return FALSE;
}

/**
* @return int 0 if everything went fine, or an exit code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
if ($input->getOption('factory-url')) {
$factoryUrl = $input->getOption('factory-url');
Expand Down Expand Up @@ -61,7 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln([
"<info>Acquia CLI is now logged in to <options=bold>{$factory['url']}</> as <options=bold>{$selectedUser['username']}</></info>",
]);
return 0;
return Command::SUCCESS;
}
}
else {
Expand All @@ -74,7 +72,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->writeAcsfCredentialsToDisk($factoryUrl, $username, $key);
$output->writeln("<info>Saved credentials</info>");

return 0;
return Command::SUCCESS;
}

private function writeAcsfCredentialsToDisk(?string $factoryUrl, string $username, string $key): void {
Expand Down
8 changes: 3 additions & 5 deletions src/Command/Acsf/AcsfApiAuthLogoutCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Acquia\Cli\Command\Acsf;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -17,9 +18,6 @@ protected function commandRequiresAuthentication(): bool {
return FALSE;
}

/**
* @return int 0 if everything went fine, or an exit code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
if (!$this->cloudApiClientService->isMachineAuthenticated()) {
$this->io->error(['You are not logged into any factories.']);
Expand All @@ -42,15 +40,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$answer = $this->io->confirm("Are you sure you'd like to logout the user {$activeUser['username']} from $factoryUrl?");
if (!$answer) {
return 0;
return Command::SUCCESS;
}
$factories[$factoryUrl]['active_user'] = NULL;
$this->datastoreCloud->set('acsf_factories', $factories);
$this->datastoreCloud->remove('acsf_active_factory');

$output->writeln("Logged {$activeUser['username']} out of $factoryUrl</info>");

return 0;
return Command::SUCCESS;
}

}
27 changes: 0 additions & 27 deletions src/Command/Api/ApiBaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
parent::interact($input, $output);
}

/**
* @return int 0 if everything went fine, or an exit code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
// Build query from non-null options.
$acquiaCloudClient = $this->cloudApiClientService->getClient();
Expand Down Expand Up @@ -120,16 +117,10 @@ public function setMethod(string $method): void {
$this->method = $method;
}

/**
* @param array $responses
*/
public function setResponses(array $responses): void {
$this->responses = $responses;
}

/**
* @param array $servers
*/
public function setServers(array $servers): void {
$this->servers = $servers;
}
Expand Down Expand Up @@ -178,9 +169,6 @@ public function getPath(): string {
return $this->path;
}

/**
* @param $value
*/
public function addPathParameter(string $paramName, $value): void {
$this->pathParams[$paramName] = $value;
}
Expand All @@ -199,9 +187,6 @@ private function getParamFromInput(InputInterface $input, string $paramName): ar
return NULL;
}

/**
* @param array $paramSpec
*/
private function castParamType(array $paramSpec, array|string $value): array|bool|int|string {
$oneOf = $this->getParamTypeOneOf($paramSpec);
if (isset($oneOf)) {
Expand Down Expand Up @@ -243,16 +228,10 @@ private function doCastParamType(string $type, mixed $value): array|bool|int|str
};
}

/**
* @param $val
*/
public function castBool($val): bool {
return (bool) (is_string($val) ? filter_var($val, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) : $val);
}

/**
* @param array $paramSpec
*/
private function getParamType(array $paramSpec): ?string {
// @todo File a CXAPI ticket regarding the inconsistent nesting of the 'type' property.
if (array_key_exists('type', $paramSpec)) {
Expand All @@ -265,9 +244,6 @@ private function getParamType(array $paramSpec): ?string {
return NULL;
}

/**
* @param array $params
*/
private function createCallableValidator(InputArgument $argument, array $params): ?callable {
$validator = NULL;
if (array_key_exists($argument->getName(), $params)) {
Expand Down Expand Up @@ -336,9 +312,6 @@ protected function createRegexConstraint(array $schema, array $constraints): arr
return $constraints;
}

/**
* @param array $constraints
*/
private function createValidatorFromConstraints(array $constraints): Closure {
return static function ($value) use ($constraints) {
$violations = Validation::createValidator()
Expand Down
21 changes: 0 additions & 21 deletions src/Command/Api/ApiCommandHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ private function useCloudApiSpecCache(): bool {
return !(getenv('ACQUIA_CLI_USE_CLOUD_API_SPEC_CACHE') === '0');
}

/**
* @param array $paramDefinition
*/
protected function addArgumentExampleToUsageForGetEndpoint(array $paramDefinition, string $usage): mixed {
if (array_key_exists('example', $paramDefinition)) {
if (is_array($paramDefinition['example'])) {
Expand All @@ -53,9 +50,6 @@ protected function addArgumentExampleToUsageForGetEndpoint(array $paramDefinitio
return $usage;
}

/**
* @param array $paramDefinition
*/
private function addOptionExampleToUsageForGetEndpoint(array $paramDefinition, string $usage): string {
if (array_key_exists('example', $paramDefinition)) {
$usage .= '--' . $paramDefinition['name'] . '="' . $paramDefinition['example'] . '" ';
Expand Down Expand Up @@ -285,16 +279,10 @@ private function getParameterDefinitionFromSpec(string $paramKey, array $acquiaC
return NULL;
}

/**
* @param array $acquiaCloudSpec
*/
private function getParameterSchemaFromSpec(string $paramKey, array $acquiaCloudSpec): mixed {
return $acquiaCloudSpec['components']['schemas'][$paramKey];
}

/**
* @param $cacheItem
*/
private function isApiSpecChecksumCacheValid($cacheItem, string $acquiaCloudSpecFileChecksum): bool {
// If the spec file doesn't exist, assume cache is valid.
if ($cacheItem->isHit() && !$acquiaCloudSpecFileChecksum) {
Expand Down Expand Up @@ -409,9 +397,6 @@ protected function getSkippedApiCommands(): array {
];
}

/**
* @param array $inputDefinition
*/
private function addAliasUsageExamples(ApiBaseCommand $command, array $inputDefinition, string $usage): void {
foreach ($inputDefinition as $key => $parameter) {
if ($parameter->getName() === 'applicationUuid') {
Expand All @@ -429,9 +414,6 @@ private function addAliasUsageExamples(ApiBaseCommand $command, array $inputDefi
}
}

/**
* @param $paramDefinition
*/
private function addAliasParameterDescriptions(&$paramDefinition): void {
if ($paramDefinition['name'] === 'applicationUuid') {
$paramDefinition['description'] .= ' You may also use an application alias or omit the argument if you run the command in a linked directory.';
Expand Down Expand Up @@ -481,9 +463,6 @@ protected static function getParameterRenameMap(): array {
];
}

/**
* @param $propKey
*/
public static function renameParameter($propKey): mixed {
$parameterRenameMap = self::getParameterRenameMap();
if (array_key_exists($propKey, $parameterRenameMap)) {
Expand Down
6 changes: 2 additions & 4 deletions src/Command/App/AppOpenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Acquia\Cli\Command\CommandBase;
use Acquia\Cli\Helpers\LocalMachineHelper;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -18,14 +19,11 @@ protected function configure(): void {
->setAliases(['open', 'o']);
}

/**
* @return int 0 if everything went fine, or an exit code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$applicationUuid = $this->determineCloudApplication();
$this->localMachineHelper->startBrowser('https://cloud.acquia.com/a/applications/' . $applicationUuid);

return 0;
return Command::SUCCESS;
}

}
3 changes: 0 additions & 3 deletions src/Command/App/AppVcsInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ protected function configure(): void {
$this->acceptApplicationUuid();
}

/**
* @return int 0 if everything went fine, or an exit code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$applicationUuid = $this->determineCloudApplication();

Expand Down
6 changes: 2 additions & 4 deletions src/Command/App/LinkCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Acquia\Cli\Command\App;

use Acquia\Cli\Command\CommandBase;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -16,9 +17,6 @@ protected function configure(): void {
$this->acceptApplicationUuid();
}

/**
* @return int 0 if everything went fine, or an exit code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->validateCwdIsValidDrupalProject();
if ($cloudApplicationUuid = $this->getCloudUuidFromDatastore()) {
Expand All @@ -28,7 +26,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}
$this->determineCloudApplication(TRUE);

return 0;
return Command::SUCCESS;
}

}
6 changes: 2 additions & 4 deletions src/Command/App/LogTailCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Acquia\Cli\Command\CommandBase;
use AcquiaCloudApi\Endpoints\Logs;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

Expand All @@ -17,9 +18,6 @@ protected function configure(): void {
->setAliases(['tail', 'log:tail']);
}

/**
* @return int 0 if everything went fine, or an exit code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$environmentId = $this->determineCloudEnvironment();
$acquiaCloudClient = $this->cloudApiClientService->getClient();
Expand All @@ -34,7 +32,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->logstreamManager->setLogTypeFilter($logTypes);
$output->writeln('<info>Streaming has started and new logs will appear below. Use Ctrl+C to exit.</info>');
$this->logstreamManager->stream();
return 0;
return Command::SUCCESS;
}

}
9 changes: 2 additions & 7 deletions src/Command/App/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Acquia\Cli\Command\CommandBase;
use Acquia\Cli\Exception\AcquiaCliException;
use Acquia\DrupalEnvironmentDetector\AcquiaDrupalEnvironmentDetector;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -20,9 +21,6 @@ protected function configure(): void {
->setAliases(['new']);
}

/**
* @return int 0 if everything went fine, or an exit code
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$this->output->writeln('Acquia recommends most customers use <options=bold>acquia/drupal-recommended-project</> to setup a Drupal project, which includes useful utilities such as Acquia Connector.');
$this->output->writeln('<options=bold>acquia/next-acms</> is a starter template for building a headless site powered by Acquia CMS and Next.js.');
Expand Down Expand Up @@ -62,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln('');
$output->writeln($successMessage);

return 0;
return Command::SUCCESS;
}

protected function commandRequiresAuthentication(): bool {
Expand All @@ -82,9 +80,6 @@ private function createNextJsProject(string $dir): void {
}
}

/**
* @param $project
*/
private function createDrupalProject($project, string $dir): void {
$process = $this->localMachineHelper->execute([
'composer',
Expand Down
3 changes: 2 additions & 1 deletion src/Command/App/TaskWaitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Acquia\Cli\Command\CommandBase;
use Acquia\Cli\Exception\AcquiaCliException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -22,7 +23,7 @@ protected function configure(): void {
protected function execute(InputInterface $input, OutputInterface $output): int {
$notificationUuid = $this->getNotificationUuid($input);
$this->waitForNotificationToComplete($this->cloudApiClientService->getClient(), $notificationUuid, "Waiting for task $notificationUuid to complete");
return 0;
return Command::SUCCESS;
}

private function getNotificationUuid(InputInterface $input): string {
Expand Down
Loading

0 comments on commit d014791

Please sign in to comment.