Skip to content

Commit

Permalink
7.2 refactor and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean O'Brien committed Oct 6, 2023
1 parent d83ae0d commit 122e720
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 47 deletions.
1 change: 0 additions & 1 deletion src/Api/Serializer/QuerySerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use Aws\Api\Service;
use Aws\CommandInterface;
use Aws\EndpointV2\EndpointProviderV2;
use Aws\EndpointV2\EndpointV2SerializerTrait;
use Aws\EndpointV2\Ruleset\RulesetEndpoint;
use GuzzleHttp\Psr7\Request;
Expand Down
5 changes: 1 addition & 4 deletions src/Api/Serializer/RestSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Aws\Api\StructureShape;
use Aws\Api\TimestampShape;
use Aws\CommandInterface;
use Aws\EndpointV2\EndpointProviderV2;
use Aws\EndpointV2\EndpointV2SerializerTrait;
use Aws\EndpointV2\Ruleset\RulesetEndpoint;
use GuzzleHttp\Psr7;
Expand Down Expand Up @@ -293,9 +292,7 @@ private function getVarDefinitions($command, $args)
foreach ($command->getInput()->getMembers() as $name => $member) {
if ($member['location'] == 'uri') {
$varDefinitions[$member['locationName'] ?: $name] =
isset($args[$name])
? $args[$name]
: null;
$args[$name] ?? null;
}
}
return $varDefinitions;
Expand Down
32 changes: 4 additions & 28 deletions src/AwsClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,7 @@ public function getConfig($option = null)
{
return $option === null
? $this->config
: (isset($this->config[$option])
? $this->config[$option]
: null);
: ($this->config[$option] ?? null);
}

public function getCredentials()
Expand Down Expand Up @@ -436,10 +434,8 @@ private function addSignatureMiddleware()
}
if (!empty($endpointAuthSchemes = $c->getAuthSchemes())) {
$version = $endpointAuthSchemes['version'];
$name = isset($endpointAuthSchemes['name']) ?
$endpointAuthSchemes['name'] : $name;
$region = isset($endpointAuthSchemes['region']) ?
$endpointAuthSchemes['region'] : $region;
$name = $endpointAuthSchemes['name'] ?? $name;
$region = $endpointAuthSchemes['region'] ?? $region;
}
return SignatureProvider::resolve($provider, $version, $name, $region);
};
Expand Down Expand Up @@ -502,26 +498,6 @@ private function addRecursionDetection()
);
}

/**
* Adds the `builder` middleware such that a client's endpoint
* provider and endpoint resolution arguments can be passed.
*/
// private function addRequestBuilder()
// {
// $handlerList = $this->getHandlerList();
// $endpointProvider = $this->endpointProvider;
// $endpointArgs = $this->getEndpointProviderArgs();
//
// $handlerList->prependBuild(
// Middleware::requestBuilder(
// $serializer,
// $endpointProvider,
// $endpointArgs
// ),
// 'builderV2'
// );
// }

private function addEndpointV2Middleware()
{
$list = $this->getHandlerList();
Expand Down Expand Up @@ -567,7 +543,7 @@ private function setClientBuiltIns($args)
$config = $this->getConfig();
$service = $args['service'];

$builtIns['SDK::Endpoint'] = isset($args['endpoint']) ? $args['endpoint'] : null;
$builtIns['SDK::Endpoint'] = $args['endpoint'] ?? null;
$builtIns['AWS::Region'] = $this->getRegion();
$builtIns['AWS::UseFIPS'] = $config['use_fips_endpoint']->isUseFipsEndpoint();
$builtIns['AWS::UseDualStack'] = $config['use_dual_stack_endpoint']->isUseDualstackEndpoint();
Expand Down
22 changes: 8 additions & 14 deletions src/ClientResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,16 +591,13 @@ public static function _apply_credentials($value, array &$args)

if ($value instanceof CredentialsInterface) {
$args['credentials'] = CredentialProvider::fromCredentials($value);
} elseif (is_array($value)
&& isset($value['key'])
&& isset($value['secret'])
) {
} elseif (isset($value['key'], $value['secret']) && is_array($value)) {
$args['credentials'] = CredentialProvider::fromCredentials(
new Credentials(
$value['key'],
$value['secret'],
isset($value['token']) ? $value['token'] : null,
isset($value['expires']) ? $value['expires'] : null
$value['token'] ?? null,
$value['expires'] ?? null
)
);
} elseif ($value === false) {
Expand Down Expand Up @@ -637,7 +634,7 @@ public static function _apply_token($value, array &$args)
$args['token'] = TokenProvider::fromToken(
new Token(
$value['token'],
isset($value['expires']) ? $value['expires'] : null
$value['expires'] ?? null
)
);
} elseif ($value instanceof CacheInterface) {
Expand Down Expand Up @@ -721,9 +718,7 @@ public static function _apply_endpoint_provider($value, array &$args)
->getPartition($args['region'], $args['service']);
}

$endpointPrefix = isset($args['api']['metadata']['endpointPrefix'])
? $args['api']['metadata']['endpointPrefix']
: $args['service'];
$endpointPrefix = $args['api']['metadata']['endpointPrefix'] ?? $args['service'];

// Check region is a valid host label when it is being used to
// generate an endpoint
Expand Down Expand Up @@ -1041,7 +1036,7 @@ public static function _apply_idempotency_auto_fill(

public static function _default_endpoint_provider(array $args)
{
$service = isset($args['api']) ? $args['api'] : null;
$service = $args['api'] ?? null;
$serviceName = isset($service) ? $service->getServiceName() : null;
$apiVersion = isset($service) ? $service->getApiVersion() : null;

Expand Down Expand Up @@ -1199,7 +1194,7 @@ public static function _default_region(&$args)

public static function _missing_region(array $args)
{
$service = isset($args['service']) ? $args['service'] : '';
$service = $args['service'] ?? '';

$msg = <<<EOT
Missing required client configuration options:
Expand Down Expand Up @@ -1264,8 +1259,7 @@ private function _apply_client_context_params(array $args)
$definition = [
'type' => 'value',
'valid' => [$paramDefinition['type']],
'doc' => isset($paramDefinition['documentation']) ?
$paramDefinition['documentation'] : null
'doc' => $paramDefinition['documentation'] ?? null
];
$this->argDefinitions[$paramName] = $definition;

Expand Down

0 comments on commit 122e720

Please sign in to comment.