Skip to content

Commit

Permalink
Code cleanup (#1854)
Browse files Browse the repository at this point in the history
* Code cleanup for parameter usage, class properties, typehints, etc.

* Formatting tweak
  • Loading branch information
howardlopez committed Jul 29, 2019
1 parent df65815 commit 941de21
Show file tree
Hide file tree
Showing 18 changed files with 38 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Api/DocModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private function clean($content)
return '';
}

$tidy = new \Tidy();
$tidy = new \tidy();
$tidy->parseString($content, [
'indent' => true,
'doctype' => 'omit',
Expand Down
7 changes: 5 additions & 2 deletions src/Api/ErrorParser/AbstractErrorParser.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php
namespace Aws\Api\ErrorParser;

use Aws\Api\DateTimeResult;
use Aws\Api\Parser\MetadataParserTrait;
use Aws\Api\Parser\PayloadParserTrait;
use Aws\Api\Service;
use Aws\Api\Shape;
use Aws\Api\StructureShape;
use Aws\CommandInterface;
use Psr\Http\Message\ResponseInterface;
Expand All @@ -28,6 +26,11 @@ public function __construct(Service $api = null)
$this->api = $api;
}

abstract protected function payload(
ResponseInterface $response,
StructureShape $member
);

protected function extractPayload(
StructureShape $member,
ResponseInterface $response
Expand Down
2 changes: 2 additions & 0 deletions src/Api/ErrorParser/JsonRpcErrorParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class JsonRpcErrorParser extends AbstractErrorParser
{
use JsonParserTrait;

private $parser;

public function __construct(Service $api = null, JsonParser $parser = null)
{
parent::__construct($api);
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Parser/DecodingEventStreamIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DecodingEventStreamIterator implements Iterator
/** @var int Current in-order event key. */
private $key;

/** @var resource|HashContext CRC32 hash context for event validation */
/** @var resource|\HashContext CRC32 hash context for event validation */
private $hashContext;

/** @var int $currentPosition */
Expand Down
1 change: 1 addition & 0 deletions src/Api/Parser/Exception/ParserException.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Aws\HasMonitoringEventsTrait;
use Aws\MonitoringEventsInterface;
use Aws\ResponseContainerInterface;
use Psr\Http\Message\ResponseInterface;

class ParserException extends \RuntimeException implements
MonitoringEventsInterface,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(array $config = [])
/**
* Loads assume role with web identity credentials.
*
* @return PromiseInterface
* @return Promise\PromiseInterface
*/
public function __invoke()
{
Expand Down
3 changes: 3 additions & 0 deletions src/Credentials/EcsCredentialProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class EcsCredentialProvider
/** @var callable */
private $client;

/** @var float|mixed */
private $timeout;

/**
* The constructor accepts following options:
* - timeout: (optional) Connection timeout, in seconds, default 1.0
Expand Down
3 changes: 3 additions & 0 deletions src/Credentials/InstanceProfileProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class InstanceProfileProvider
/** @var int */
private $attempts;

/** @var float|mixed */
private $timeout;

/**
* The constructor accepts the following options:
*
Expand Down
2 changes: 1 addition & 1 deletion src/DynamoDb/DynamoDbClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ function ($retries) {
/** @internal */
public static function _applyApiProvider($value, array &$args, HandlerList $list)
{
ClientResolver::_apply_api_provider($value, $args, $list);
ClientResolver::_apply_api_provider($value, $args);
$args['parser'] = new Crc32ValidatingParser($args['parser']);
}
}
4 changes: 2 additions & 2 deletions src/DynamoDb/SessionConnectionConfigTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ public function setConsistentRead($consistentRead)
}

/**
* @return multitype:
* @return mixed
*/
public function getBatchConfig()
{
return $this->batchConfig;
}

/**
* @param multitype: $batchConfig
* @param mixed $batchConfig
*/
public function setBatchConfig($batchConfig)
{
Expand Down
1 change: 0 additions & 1 deletion src/EndpointDiscovery/EndpointDiscoveryMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public function __invoke(CommandInterface $cmd, RequestInterface $request)
$cmd,
$identifiers,
$isRequired,
$nextHandler,
$originalUri,
$request,
&$endpoint,
Expand Down
5 changes: 5 additions & 0 deletions src/EndpointParameterMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
*/
class EndpointParameterMiddleware
{
/** @var callable */
private $nextHandler;

/** @var Service */
private $service;

/**
* Create a middleware wrapper function
Expand Down
2 changes: 1 addition & 1 deletion src/Glacier/GlacierClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function getChecksumsMiddleware()
if (!$command['checksum']) {
$body = new HashingStream(
$body, new TreeHash(),
function ($result) use ($command, &$request) {
function ($result) use (&$request) {
$request = $request->withHeader(
'x-amz-sha256-tree-hash',
bin2hex($result)
Expand Down
6 changes: 3 additions & 3 deletions src/Handler/GuzzleV5/GuzzleHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function __construct(ClientInterface $client = null)

/**
* @param Psr7Request $request
* @param array $options
*
* @return Promise\Promise
* @param array $options
* @return Promise\Promise|Promise\PromiseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function __invoke(Psr7Request $request, array $options = [])
{
Expand Down
2 changes: 2 additions & 0 deletions src/MultiRegionClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class MultiRegionClient implements AwsClientInterface
private $config;
/** @var HandlerList */
private $handlerList;
/** @var array */
private $aliases;

public static function getArguments()
{
Expand Down
2 changes: 2 additions & 0 deletions src/ResponseContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Aws;

use Psr\Http\Message\ResponseInterface;

interface ResponseContainerInterface
{
/**
Expand Down
2 changes: 1 addition & 1 deletion src/S3/S3Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ public static function _applyRetryConfig($value, $_, HandlerList $list)
/** @internal */
public static function _applyApiProvider($value, array &$args, HandlerList $list)
{
ClientResolver::_apply_api_provider($value, $args, $list);
ClientResolver::_apply_api_provider($value, $args);
$args['parser'] = new GetBucketLocationParser(
new AmbiguousSuccessParser(
new RetryableMalformedResponseParser(
Expand Down
8 changes: 4 additions & 4 deletions src/S3/StreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ public function stream_open($path, $mode, $options, &$opened_path)
return $this->triggerError($errors);
}

return $this->boolCall(function() use ($path) {
return $this->boolCall(function() {
switch ($this->mode) {
case 'r': return $this->openReadStream($path);
case 'a': return $this->openAppendStream($path);
default: return $this->openWriteStream($path);
case 'r': return $this->openReadStream();
case 'a': return $this->openAppendStream();
default: return $this->openWriteStream();
}
});
}
Expand Down

0 comments on commit 941de21

Please sign in to comment.