Skip to content

Commit

Permalink
Merge branch 'main' into CLI-1192-2
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Jul 11, 2024
2 parents 60ba173 + 6fbaaa3 commit 825051e
Show file tree
Hide file tree
Showing 182 changed files with 4,942 additions and 4,075 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
indent_size = 4
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[composer.{json,lock}]
indent_size = 4
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"zumba/amplitude-php": "^1.0.4"
},
"require-dev": {
"acquia/coding-standards": "^3",
"acquia/coding-standards": "^3.0.1",
"brianium/paratest": "^6.6",
"dealerdirect/phpcodesniffer-composer-installer": "^1.0.0",
"dominikb/composer-license-checker": "^2.4",
Expand Down
38 changes: 19 additions & 19 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<exclude name="Generic.Files.LineLength"/>
</rule>

<rule ref="Generic.PHP.ForbiddenFunctions">
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<property name="forbiddenFunctions" type="array">
<element key="echo" value="$output->writeln"/>
Expand Down
7 changes: 6 additions & 1 deletion src/AcsfApi/AcsfClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public function processResponse(ResponseInterface $response): mixed
throw new ApiErrorException($body);
}
// Throw error for 4xx and 5xx responses.
if (property_exists($body, 'message') && in_array(substr((string) $response->getStatusCode(), 0, 1), ['4', '5'], true)) {
if (
property_exists($body, 'message') && in_array(substr((string) $response->getStatusCode(), 0, 1), [
'4',
'5',
], true)
) {
$body->error = $response->getStatusCode();
throw new ApiErrorException($body);
}
Expand Down
10 changes: 5 additions & 5 deletions src/AcsfApi/AcsfConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public function __construct(array $config, string $baseUri = null, string $urlAc
parent::__construct($config, $baseUri, $urlAccessToken);

$this->client = new GuzzleClient([
'auth' => [
$config['key'],
$config['secret'],
],
'base_uri' => $this->getBaseUri(),
'auth' => [
$config['key'],
$config['secret'],
],
'base_uri' => $this->getBaseUri(),
]);
}

Expand Down
9 changes: 6 additions & 3 deletions src/CloudApi/ClientService.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
class ClientService
{
protected ConnectorInterface $connector;

protected ConnectorFactoryInterface|ConnectorFactory $connectorFactory;

protected Application $application;

protected ?bool $machineIsAuthenticated = null;

public function __construct(ConnectorFactoryInterface $connectorFactory, Application $application, protected ApiCredentialsInterface $credentials)
Expand Down Expand Up @@ -53,7 +56,7 @@ protected function configureClient(Client $client): void
{
$userAgent = sprintf("acli/%s", $this->application->getVersion());
$customHeaders = [
'User-Agent' => [$userAgent],
'User-Agent' => [$userAgent],
];
if ($uuid = getenv("REMOTEIDE_UUID")) {
$customHeaders['X-Cloud-IDE-UUID'] = $uuid;
Expand All @@ -73,8 +76,8 @@ public function isMachineAuthenticated(): bool
protected function checkAuthentication(): bool
{
return (
$this->credentials->getCloudAccessToken() ||
($this->credentials->getCloudKey() && $this->credentials->getCloudSecret())
$this->credentials->getCloudAccessToken() ||
($this->credentials->getCloudKey() && $this->credentials->getCloudSecret())
);
}
}
10 changes: 5 additions & 5 deletions src/CloudApi/ConnectorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public function createConnector(): Connector|AccessTokenConnector
if (!$accessToken->hasExpired()) {
// @todo Add debug log entry indicating that access token is being used.
return new AccessTokenConnector([
'access_token' => $accessToken,
'key' => null,
'secret' => null,
'access_token' => $accessToken,
'key' => null,
'secret' => null,
], $this->baseUri, $this->accountsUri);
}
}
Expand All @@ -47,8 +47,8 @@ public function createConnector(): Connector|AccessTokenConnector
private function createAccessToken(): AccessToken
{
return new AccessToken([
'access_token' => $this->config['accessToken'],
'expires' => $this->config['accessTokenExpiry'],
'access_token' => $this->config['accessToken'],
'expires' => $this->config['accessTokenExpiry'],
]);
}
}
4 changes: 2 additions & 2 deletions src/Command/Acsf/AcsfListCommandBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$command = $this->getApplication()->find('list');
$arguments = [
'command' => 'list',
'namespace' => 'acsf',
'command' => 'list',
'namespace' => 'acsf',
];
$listInput = new ArrayInput($arguments);

Expand Down
35 changes: 19 additions & 16 deletions src/Command/Api/ApiBaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,26 @@ protected function interact(InputInterface $input, OutputInterface $output): voi
foreach ($this->getDefinition()->getArguments() as $argument) {
if ($argument->isRequired() && !$input->getArgument($argument->getName())) {
$this->io->note([
"{$argument->getName()} is a required argument.",
$argument->getDescription(),
"{$argument->getName()} is a required argument.",
$argument->getDescription(),
]);
// Choice question.
if (
array_key_exists($argument->getName(), $params)
&& array_key_exists('schema', $params[$argument->getName()])
&& array_key_exists('enum', $params[$argument->getName()]['schema'])
) {
$choices = $params[$argument->getName()]['schema']['enum'];
$answer = $this->io->choice("Select a value for {$argument->getName()}", $choices, $argument->getDefault());
$choices = $params[$argument->getName()]['schema']['enum'];
$answer = $this->io->choice("Select a value for {$argument->getName()}", $choices, $argument->getDefault());
} elseif (
array_key_exists($argument->getName(), $params)
&& array_key_exists('type', $params[$argument->getName()])
&& $params[$argument->getName()]['type'] === 'boolean'
) {
$answer = $this->io->choice("Select a value for {$argument->getName()}", ['false', 'true'], $argument->getDefault());
$answer = $this->io->choice("Select a value for {$argument->getName()}", [
'false',
'true',
], $argument->getDefault());
$answer = $answer === 'true';
} else {
// Free form.
Expand All @@ -103,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
// API calls returning octet streams (e.g., db backups). It's safe to use
// here because the API command should always return JSON.
$acquiaCloudClient->addOption('headers', [
'Accept' => 'application/hal+json, version=2',
'Accept' => 'application/hal+json, version=2',
]);

try {
Expand Down Expand Up @@ -265,7 +268,7 @@ private function createCallableValidator(InputArgument $argument, array $params)
if (array_key_exists($argument->getName(), $params)) {
$paramSpec = $params[$argument->getName()];
$constraints = [
new NotBlank(),
new NotBlank(),
];
if ($type = $this->getParamType($paramSpec)) {
if (in_array($type, ['int', 'integer'])) {
Expand Down Expand Up @@ -316,8 +319,8 @@ protected function createRegexConstraint(array $schema, array $constraints): arr
}
} elseif (array_key_exists('pattern', $schema)) {
$constraints[] = new Regex([
'message' => 'It must match the pattern ' . $schema['pattern'],
'pattern' => '/' . $schema['pattern'] . '/',
'message' => 'It must match the pattern ' . $schema['pattern'],
'pattern' => '/' . $schema['pattern'] . '/',
]);
}
return $constraints;
Expand All @@ -327,7 +330,7 @@ private function createValidatorFromConstraints(array $constraints): Closure
{
return static function (mixed $value) use ($constraints) {
$violations = Validation::createValidator()
->validate($value, $constraints);
->validate($value, $constraints);
if (count($violations)) {
throw new ValidatorException($violations->get(0)->getMessage());
}
Expand Down Expand Up @@ -362,8 +365,8 @@ private function addPostParamsToClient(InputInterface $input, Client $acquiaClou
}

/**
* @param array|null $paramSpec
*/
* @param array|null $paramSpec
*/
private function addPostParamToClient(string $paramName, ?array $paramSpec, mixed $paramValue, Client $acquiaCloudClient): void
{
$paramName = ApiCommandHelper::restoreRenamedParameter($paramName);
Expand All @@ -372,10 +375,10 @@ private function addPostParamToClient(string $paramName, ?array $paramSpec, mixe
}
if ($paramSpec && array_key_exists('format', $paramSpec) && $paramSpec["format"] === 'binary') {
$acquiaCloudClient->addOption('multipart', [
[
'contents' => Utils::tryFopen($paramValue, 'r'),
'name' => $paramName,
],
[
'contents' => Utils::tryFopen($paramValue, 'r'),
'name' => $paramName,
],
]);
} else {
$acquiaCloudClient->addOption('json', [$paramName => $paramValue]);
Expand Down
Loading

0 comments on commit 825051e

Please sign in to comment.