Skip to content

Commit

Permalink
Updates code standards to PSR-12
Browse files Browse the repository at this point in the history
  • Loading branch information
typhonius committed Mar 25, 2020
1 parent f74d7ca commit f719a5b
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 76 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"find src -name '*.php' -print0 | xargs -0 -n1 php -l",
"find tests -name '*.php' -print0 | xargs -0 -n1 php -l"
],
"cs": "phpcs --standard=PSR2 -n src tests",
"cs": "phpcs --standard=PSR12 -n src tests",
"cbf": "phpcbf --standard=PSR2 -n src tests",
"unit": "phpunit --colors=always --coverage-clover ./tests/logs/clover.xml",
"stan": "phpstan analyse --level 7 src tests",
Expand Down
47 changes: 23 additions & 24 deletions src/Cli/AcquiaCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
*/
class AcquiaCli
{

use ConfigAwareTrait;
use LockableTrait;

Expand Down Expand Up @@ -137,29 +136,29 @@ public function getContainer($input, $output, $application, $config, $client)
public function injectParameters($container)
{
$parameterInjection = $container->get('parameterInjection');
$parameterInjection->register('AcquiaCli\Cli\CloudApi', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCli\Cli\Config', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Connector\Client', new AcquiaCliInjector);
$parameterInjection->register('AcquiaLogstream\LogstreamManager', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Applications', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Environments', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Databases', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Servers', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Domains', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Code', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\DatabaseBackups', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Crons', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Account', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Roles', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Permissions', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Teams', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Variables', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Logs', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Notifications', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Insights', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\LogForwardingDestinations', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\SslCertificates', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCloudApi\Endpoints\Organizations', new AcquiaCliInjector);
$parameterInjection->register('AcquiaCli\Cli\CloudApi', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCli\Cli\Config', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Connector\Client', new AcquiaCliInjector());
$parameterInjection->register('AcquiaLogstream\LogstreamManager', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Applications', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Environments', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Databases', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Servers', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Domains', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Code', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\DatabaseBackups', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Crons', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Account', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Roles', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Permissions', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Teams', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Variables', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Logs', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Notifications', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Insights', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\LogForwardingDestinations', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\SslCertificates', new AcquiaCliInjector());
$parameterInjection->register('AcquiaCloudApi\Endpoints\Organizations', new AcquiaCliInjector());
}

/**
Expand Down
26 changes: 14 additions & 12 deletions src/Commands/CodeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,14 @@ public function codeDeploy(
$environmentFrom = $this->cloudapiService->getEnvironment($uuid, $environmentFrom);
$environmentTo = $this->cloudapiService->getEnvironment($uuid, $environmentTo);
if (!$this->confirm(
sprintf(
'Are you sure you want to deploy code from %s to %s?',
$environmentFrom->label,
$environmentTo->label
if (
!$this->confirm(
sprintf(
'Are you sure you want to deploy code from %s to %s?',
$environmentFrom->label,
$environmentTo->label
)
)
)
) {
return;
}
Expand Down Expand Up @@ -115,13 +116,14 @@ public function codeSwitch(CloudApi $cloudapi, Code $codeAdapter, $uuid, $enviro
{
$environment = $cloudapi->getEnvironment($uuid, $environment);
if (!$this->confirm(
sprintf(
'Are you sure you want to switch code on the %s environment to branch: %s?',
$environment->name,
$branch
if (
!$this->confirm(
sprintf(
'Are you sure you want to switch code on the %s environment to branch: %s?',
$environment->name,
$branch
)
)
)
) {
return;
}
Expand Down
7 changes: 4 additions & 3 deletions src/Commands/DbBackupCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ public function dbBackupRestore(DatabaseBackups $databaseBackupsAdapter, $uuid,
{
$environment = $this->cloudapiService->getEnvironment($uuid, $environment);

if ($this->confirm(
sprintf('Are you sure you want to restore backup id %s to %s?', $backupId, $environment->label)
)
if (
$this->confirm(
sprintf('Are you sure you want to restore backup id %s to %s?', $backupId, $environment->label)
)
) {
$this->say(sprintf('Restoring backup %s to %s on %s', $backupId, $dbName, $environment->label));
$response = $databaseBackupsAdapter->restore($environment->uuid, $dbName, $backupId);
Expand Down
28 changes: 15 additions & 13 deletions src/Commands/DbCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ public function dbCopy($uuid, $environmentFrom, $environmentTo, $dbName)
$environmentFrom = $this->cloudapiService->getEnvironment($uuid, $environmentFrom);
$environmentTo = $this->cloudapiService->getEnvironment($uuid, $environmentTo);

if ($this->confirm(
sprintf(
'Are you sure you want to copy database %s from %s to %s?',
$dbName,
$environmentFrom->label,
$environmentTo->label
if (
$this->confirm(
sprintf(
'Are you sure you want to copy database %s from %s to %s?',
$dbName,
$environmentFrom->label,
$environmentTo->label
)
)
)
) {
$this->backupAndMoveDbs($uuid, $environmentFrom, $environmentTo, $dbName);
}
Expand All @@ -141,13 +142,14 @@ public function dbCopyAll($uuid, $environmentFrom, $environmentTo)
$environmentFrom = $this->cloudapiService->getEnvironment($uuid, $environmentFrom);
$environmentTo = $this->cloudapiService->getEnvironment($uuid, $environmentTo);

if ($this->confirm(
sprintf(
'Are you sure you want to copy all databases from %s to %s?',
$environmentFrom->label,
$environmentTo->label
if (
$this->confirm(
sprintf(
'Are you sure you want to copy all databases from %s to %s?',
$environmentFrom->label,
$environmentTo->label
)
)
)
) {
$this->backupAndMoveDbs($uuid, $environmentFrom, $environmentTo);
}
Expand Down
18 changes: 10 additions & 8 deletions src/Commands/DomainCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,15 @@ public function domainMove(Domains $domainAdapter, $uuid, $domain, $environmentF
$environmentFrom = $this->cloudapiService->getEnvironment($uuid, $environmentFrom);
$environmentTo = $this->cloudapiService->getEnvironment($uuid, $environmentTo);

if ($this->confirm(
sprintf(
'Are you sure you want to move %s from environment %s to %s?',
$domain,
$environmentFrom->label,
$environmentTo->label
if (
$this->confirm(
sprintf(
'Are you sure you want to move %s from environment %s to %s?',
$domain,
$environmentFrom->label,
$environmentTo->label
)
)
)
) {
$this->say(sprintf('Moving %s from %s to %s', $domain, $environmentFrom->label, $environmentTo->label));

Expand All @@ -171,7 +172,8 @@ public function domainPurge(Domains $domainAdapter, $uuid, $environment, $domain
{
$environment = $this->cloudapiService->getEnvironment($uuid, $environment);

if ($environment->name === 'prod'
if (
$environment->name === 'prod'
&& !$this->confirm("Are you sure you want to purge varnish on the production environment?")
) {
return;
Expand Down
11 changes: 6 additions & 5 deletions src/Commands/DrushAliasesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ public function downloadDrushAliases(Account $accountAdapter, $options = ['insta
$drushArchive = tempnam(sys_get_temp_dir(), 'AcquiaDrushAliases') . '.tar.gz';
$this->say(sprintf('Acquia Cloud Drush Aliases archive downloaded to %s', $drushArchive));
if (file_put_contents($drushArchive, $aliases, LOCK_EX)) {
if ($options['install'] || $this->confirm(
sprintf(
'Do you want to automatically unpack Acquia Cloud Drush aliases to %s',
getenv('HOME')
if (
$options['install'] || $this->confirm(
sprintf(
'Do you want to automatically unpack Acquia Cloud Drush aliases to %s',
getenv('HOME')
)
)
)
) {
if (!$home = getenv('HOME')) {
throw new \Exception('Home directory not found.');
Expand Down
13 changes: 7 additions & 6 deletions src/Commands/FilesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ public function filesCopy($uuid, $environmentFrom, $environmentTo)
$environmentFrom = $this->cloudapiService->getEnvironment($uuid, $environmentFrom);
$environmentTo = $this->cloudapiService->getEnvironment($uuid, $environmentTo);

if ($this->confirm(
sprintf(
'Are you sure you want to copy files from %s to %s?',
$environmentFrom->label,
$environmentTo->label
if (
$this->confirm(
sprintf(
'Are you sure you want to copy files from %s to %s?',
$environmentFrom->label,
$environmentTo->label
)
)
)
) {
$this->copyFiles($uuid, $environmentFrom, $environmentTo);
}
Expand Down
1 change: 0 additions & 1 deletion src/Commands/LogsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
class LogsCommand extends AcquiaCommand
{

use InputAwareTrait;
use OutputAwareTrait;

Expand Down
2 changes: 1 addition & 1 deletion tests/AcquiaCliApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function testWaitForNotifications()

\Robo\Robo::unsetContainer();

$notificationOutput =<<< OUTPUT
$notificationOutput = <<< OUTPUT
> Backing up DB (database1) on Dev
Looking up notification
< 1 sec [➤⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬⚬] 0%
Expand Down
5 changes: 3 additions & 2 deletions tests/AcquiaCliTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ public function sendRequestCallback($verb, $path)
if ($fixture = $fixtureMap[$path][$verb]) {
// Add in overrides for fixtures which should be downloaded
// rather than responded to e.g. log:download
if ($fixture === 'Logs/downloadLog.dat'
if (
$fixture === 'Logs/downloadLog.dat'
|| $fixture === 'DatabaseBackups/downloadDatabaseBackup.dat'
|| $fixture === 'Account/getDrushAliases.dat'
) {
Expand Down Expand Up @@ -164,7 +165,7 @@ public function execute($command)
$container = Robo::getContainer();
$container->add('logstream', $this->logstream);
$parameterInjection = $container->get('parameterInjection');
$parameterInjection->register('AcquiaLogstream\LogstreamManager', new AcquiaCliInjector);
$parameterInjection->register('AcquiaLogstream\LogstreamManager', new AcquiaCliInjector());
Robo::setContainer($container);

$app->run($input, $output);
Expand Down

0 comments on commit f719a5b

Please sign in to comment.