Skip to content

Commit

Permalink
update cs
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Aug 16, 2024
1 parent 4690bbd commit 37514f5
Show file tree
Hide file tree
Showing 61 changed files with 225 additions and 258 deletions.
Binary file modified metadata/ApiCore/Testing/Mocks.php
Binary file not shown.
6 changes: 3 additions & 3 deletions metadata/Google/ApiCore/Tests/Unit/Example.php

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

13 changes: 0 additions & 13 deletions ruleset.xml

This file was deleted.

4 changes: 2 additions & 2 deletions src/AgentHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ public static function buildAgentHeader(array $headerInfo)

$metricsList = [];
foreach ($metricsHeaders as $key => $value) {
$metricsList[] = $key . "/" . $value;
$metricsList[] = $key . '/' . $value;
}
return [self::AGENT_HEADER_KEY => [implode(" ", $metricsList)]];
return [self::AGENT_HEADER_KEY => [implode(' ', $metricsList)]];
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/ApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
use Google\Protobuf\Internal\RepeatedField;
use Google\Rpc\Status;
use GuzzleHttp\Exception\RequestException;
use Google\ApiCore\Testing\MockStatus;
use stdClass;

/**
Expand Down
8 changes: 4 additions & 4 deletions src/BidiStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public function __construct(BidiStreamingCall $bidiStreamingCall, array $streami
public function write($request)
{
if ($this->isComplete) {
throw new ValidationException("Cannot call write() after streaming call is complete.");
throw new ValidationException('Cannot call write() after streaming call is complete.');
}
if ($this->writesClosed) {
throw new ValidationException("Cannot call write() after calling closeWrite().");
throw new ValidationException('Cannot call write() after calling closeWrite().');
}
$this->call->write($request);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public function closeWrite()
{
if ($this->isComplete) {
throw new ValidationException(
"Cannot call closeWrite() after streaming call is complete."
'Cannot call closeWrite() after streaming call is complete.'
);
}
if (!$this->writesClosed) {
Expand All @@ -119,7 +119,7 @@ public function closeWrite()
public function read()
{
if ($this->isComplete) {
throw new ValidationException("Cannot call read() after streaming call is complete.");
throw new ValidationException('Cannot call read() after streaming call is complete.');
}
$resourcesGetMethod = $this->resourcesGetMethod;
if (!is_null($resourcesGetMethod)) {
Expand Down
2 changes: 1 addition & 1 deletion src/ClientStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ClientStream
* @param ClientStreamingCall $clientStreamingCall The gRPC client streaming call object
* @param array $streamingDescriptor
*/
public function __construct( // @phpstan-ignore-line
public function __construct(// @phpstan-ignore-line
ClientStreamingCall $clientStreamingCall,
array $streamingDescriptor = []
) {
Expand Down
9 changes: 3 additions & 6 deletions src/CredentialsWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,15 @@
use DomainException;
use Exception;
use Google\Auth\ApplicationDefaultCredentials;
use Google\Auth\ProjectIdProviderInterface;
use Google\Auth\Cache\MemoryCacheItemPool;
use Google\Auth\Credentials\GCECredentials;
use Google\Auth\Credentials\ServiceAccountCredentials;
use Google\Auth\CredentialsLoader;
use Google\Auth\FetchAuthTokenCache;
use Google\Auth\FetchAuthTokenInterface;
use Google\Auth\GetQuotaProjectInterface;
use Google\Auth\GetUniverseDomainInterface;
use Google\Auth\Credentials\GCECredentials;
use Google\Auth\HttpHandler\Guzzle6HttpHandler;
use Google\Auth\HttpHandler\Guzzle7HttpHandler;
use Google\Auth\HttpHandler\HttpHandlerFactory;
use Google\Auth\ProjectIdProviderInterface;
use Google\Auth\UpdateMetadataInterface;
use Psr\Cache\CacheItemPoolInterface;

Expand Down Expand Up @@ -335,7 +332,7 @@ private static function buildApplicationDefaultCredentials(
$defaultScopes
);
} catch (DomainException $ex) {
throw new ValidationException("Could not construct ApplicationDefaultCredentials", $ex->getCode(), $ex);
throw new ValidationException('Could not construct ApplicationDefaultCredentials', $ex->getCode(), $ex);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/FixedSizeCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(Page $initialPage, int $collectionSize)
if ($collectionSize < $initialPage->getPageElementCount()) {
$ipc = $initialPage->getPageElementCount();
throw new InvalidArgumentException(
"collectionSize must be greater than or equal to the number of " .
'collectionSize must be greater than or equal to the number of ' .
"elements in initialPage. collectionSize: $collectionSize, " .
"initialPage size: $ipc"
);
Expand Down Expand Up @@ -178,8 +178,8 @@ private static function createPageArray(Page $initialPage, int $collectionSize)
$currentPage = $currentPage->getNextPage($remainingCount);
$rxElementCount = $currentPage->getPageElementCount();
if ($rxElementCount > $remainingCount) {
throw new LengthException("API returned a number of elements " .
"exceeding the specified page size limit. page size: " .
throw new LengthException('API returned a number of elements ' .
'exceeding the specified page size limit. page size: ' .
"$remainingCount, elements received: $rxElementCount");
}
array_push($pageList, $currentPage);
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/CredentialsWrapperMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

use Google\ApiCore\Call;
use Google\ApiCore\CredentialsWrapper;
use GuzzleHttp\Promise\PromiseInterface;

/**
* Middleware which adds a CredentialsWrapper object to the call options.
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/FixedHeaderMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
namespace Google\ApiCore\Middleware;

use Google\ApiCore\Call;
use GuzzleHttp\Promise\PromiseInterface;

/**
* Middleware to add fixed headers to an API call.
Expand Down
4 changes: 2 additions & 2 deletions src/Middleware/MiddlewareInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

namespace Google\ApiCore\Middleware;

use Google\ApiCore\BidiStream;
use Google\ApiCore\Call;
use GuzzleHttp\Promise\PromiseInterface;
use Google\ApiCore\ClientStream;
use Google\ApiCore\ServerStream;
use Google\ApiCore\BidiStream;
use GuzzleHttp\Promise\PromiseInterface;

/**
* Middlewares must take a MiddlewareInterface as their first constructor
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/OperationsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
use Google\ApiCore\Call;
use Google\ApiCore\OperationResponse;
use Google\Protobuf\Internal\Message;
use GuzzleHttp\Promise\PromiseInterface;

/**
* Middleware which wraps the response in an OperationResponse object.
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/OptionsFilterMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

use Google\ApiCore\ArrayTrait;
use Google\ApiCore\Call;
use GuzzleHttp\Promise\PromiseInterface;

/**
* Middleware which filters the $options array.
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/PagedMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use Google\ApiCore\PagedListResponse;
use Google\ApiCore\PageStreamingDescriptor;
use Google\Protobuf\Internal\Message;
use GuzzleHttp\Promise\PromiseInterface;

/**
* Middleware which wraps the response in an PagedListResponses object.
Expand Down
2 changes: 1 addition & 1 deletion src/Middleware/RequestAutoPopulationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function __invoke(Call $call, array $options)
break;
default:
throw new \UnexpectedValueException(sprintf(
"Value type %s::%s not supported for auto population of the field %s",
'Value type %s::%s not supported for auto population of the field %s',
Format::class,
Format::name($valueType),
$fieldName
Expand Down
6 changes: 3 additions & 3 deletions src/OperationResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

namespace Google\ApiCore;

use Google\LongRunning\Client\OperationsClient;
use Google\LongRunning\OperationsClient as LegacyOperationsClient;
use Google\LongRunning\CancelOperationRequest;
use Google\LongRunning\Client\OperationsClient;
use Google\LongRunning\DeleteOperationRequest;
use Google\LongRunning\GetOperationRequest;
use Google\LongRunning\Operation;
use Google\LongRunning\OperationsClient as LegacyOperationsClient;
use Google\Protobuf\Any;
use Google\Protobuf\Internal\Message;
use Google\Rpc\Status;
Expand Down Expand Up @@ -272,7 +272,7 @@ public function pollUntilComplete(array $options = [])
public function reload()
{
if ($this->deleted) {
throw new ValidationException("Cannot call reload() on a deleted operation");
throw new ValidationException('Cannot call reload() on a deleted operation');
}

$requestClass = $this->isNewSurfaceOperationsClient() ? $this->getOperationRequest : null;
Expand Down
2 changes: 1 addition & 1 deletion src/Options/ClientOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

use ArrayAccess;
use Closure;
use InvalidArgumentException;
use Google\ApiCore\CredentialsWrapper;
use Google\ApiCore\Transport\TransportInterface;
use Google\Auth\FetchAuthTokenInterface;
use InvalidArgumentException;

/**
* The ClientOptions class adds typing to the associative array of options
Expand Down
2 changes: 1 addition & 1 deletion src/Options/OptionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

namespace Google\ApiCore\Options;

use Google\ApiCore\ValidationException;
use BadMethodCallException;
use Google\ApiCore\ValidationException;

/**
* Trait implemented by any class representing an associative array of PHP options.
Expand Down
4 changes: 2 additions & 2 deletions src/Options/TransportOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@

namespace Google\ApiCore\Options;

use Google\ApiCore\Options\TransportOptions\GrpcTransportOptions;
use ArrayAccess;
use Google\ApiCore\Options\TransportOptions\GrpcFallbackTransportOptions;
use Google\ApiCore\Options\TransportOptions\GrpcTransportOptions;
use Google\ApiCore\Options\TransportOptions\RestTransportOptions;
use ArrayAccess;

class TransportOptions implements ArrayAccess
{
Expand Down
2 changes: 1 addition & 1 deletion src/Options/TransportOptions/GrpcTransportOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
use ArrayAccess;
use Closure;
use Google\ApiCore\Options\OptionsTrait;
use Google\ApiCore\Transport\Grpc\UnaryInterceptorInterface;
use Grpc\Channel;
use Grpc\Interceptor;
use Google\ApiCore\Transport\Grpc\UnaryInterceptorInterface;

/**
* The GrpcTransportOptions class provides typing to the associative array of options used to
Expand Down
20 changes: 10 additions & 10 deletions src/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
class Page implements IteratorAggregate
{
const FINAL_PAGE_TOKEN = "";
const FINAL_PAGE_TOKEN = '';

private $call;
private $callable;
Expand Down Expand Up @@ -243,26 +243,26 @@ public function expandToFixedSizeCollection($collectionSize)
{
if (!$this->pageStreamingDescriptor->requestHasPageSizeField()) {
throw new ValidationException(
"FixedSizeCollection is not supported for this method, because " .
"the method does not support an optional argument to set the " .
"page size."
'FixedSizeCollection is not supported for this method, because ' .
'the method does not support an optional argument to set the ' .
'page size.'
);
}
$request = $this->getRequestObject();
$pageSizeGetMethod = $this->pageStreamingDescriptor->getRequestPageSizeGetMethod();
$pageSize = $request->$pageSizeGetMethod();
if (is_null($pageSize)) {
throw new ValidationException(
"Error while expanding Page to FixedSizeCollection: No page size " .
"parameter found. The page size parameter must be set in the API " .
"optional arguments array, and must be less than the collectionSize " .
"parameter, in order to create a FixedSizeCollection object."
'Error while expanding Page to FixedSizeCollection: No page size ' .
'parameter found. The page size parameter must be set in the API ' .
'optional arguments array, and must be less than the collectionSize ' .
'parameter, in order to create a FixedSizeCollection object.'
);
}
if ($pageSize > $collectionSize) {
throw new ValidationException(
"Error while expanding Page to FixedSizeCollection: collectionSize " .
"parameter is less than the page size optional argument specified in " .
'Error while expanding Page to FixedSizeCollection: collectionSize ' .
'parameter is less than the page size optional argument specified in ' .
"the API call. collectionSize: $collectionSize, page size: $pageSize"
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function build(string $path, Message $message, array $headers = [])

// Request enum fields will be encoded as numbers rather than strings (in the response).
if ($numericEnums) {
$queryParams['$alt'] = "json;enum-encoding=int";
$queryParams['$alt'] = 'json;enum-encoding=int';
}

$uri = $this->buildUri($pathTemplate, $queryParams);
Expand All @@ -132,8 +132,8 @@ public function build(string $path, Message $message, array $headers = [])
}

throw new ValidationException("Could not map bindings for $path to any Uri template.\n" .
"Bindings: " . print_r($bindings, true) .
"UriTemplates: " . print_r($uriTemplates, true));
'Bindings: ' . print_r($bindings, true) .
'UriTemplates: ' . print_r($uriTemplates, true));
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/ResourceHelperTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

namespace Google\ApiCore;

use Google\ApiCore\ValidationException;

/**
* Provides functionality for loading a resource name template map from a descriptor config,
* retrieving a PathTemplate, and parsing values using registered templates.
Expand Down
6 changes: 3 additions & 3 deletions src/ResourceTemplate/AbsoluteResourceTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ public function __construct(string $path)
*/
public function __toString()
{
return sprintf("/%s%s", $this->resourceTemplate, $this->renderVerb());
return sprintf('/%s%s', $this->resourceTemplate, $this->renderVerb());
}

/**
* @inheritdoc
*/
public function render(array $bindings)
{
return sprintf("/%s%s", $this->resourceTemplate->render($bindings), $this->renderVerb());
return sprintf('/%s%s', $this->resourceTemplate->render($bindings), $this->renderVerb());
}

/**
Expand All @@ -112,7 +112,7 @@ public function matches(string $path)
public function match(string $path)
{
if (empty($path)) {
throw $this->matchException($path, "path cannot be empty");
throw $this->matchException($path, 'path cannot be empty');
}
if ($path[0] !== '/') {
throw $this->matchException($path, "missing leading '/'");
Expand Down
Loading

0 comments on commit 37514f5

Please sign in to comment.