From 383a3512da8159f4728ed438bbf9eaaab6a74d0f Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 11 Dec 2024 16:48:23 -0800 Subject: [PATCH] chore: add php cs fixer from shared workflow (#7647) --- .github/workflows/lint.yaml | 29 ++++++- BigQuery/src/Connection/Rest.php | 1 - BigQuery/src/JobWaitTrait.php | 1 - Bigtable/src/BigtableClient.php | 7 +- Bigtable/src/ChunkFormatter.php | 8 +- Bigtable/src/DataUtil.php | 6 +- Bigtable/src/Filter.php | 8 +- Bigtable/src/Filter/Builder/FamilyFilter.php | 1 - Bigtable/src/Filter/Builder/KeyFilter.php | 2 +- Bigtable/src/Filter/Builder/LimitFilter.php | 4 +- Bigtable/src/Filter/Builder/OffsetFilter.php | 2 +- .../src/Filter/Builder/QualifierFilter.php | 1 - Bigtable/src/Filter/Builder/RegexTrait.php | 2 +- Bigtable/src/Filter/Builder/ValueFilter.php | 2 +- Bigtable/src/Filter/ChainFilter.php | 4 +- Bigtable/src/Filter/ConditionFilter.php | 4 +- Bigtable/src/Filter/InterleaveFilter.php | 4 +- Bigtable/src/Mutations.php | 16 ++-- Bigtable/src/ReadModifyWriteRowRules.php | 4 +- Bigtable/src/ResumableStream.php | 2 +- Bigtable/src/Table.php | 20 +++-- Core/snippet-bootstrap.php | 2 +- Core/src/AnonymousCredentials.php | 2 +- Core/src/ApiHelperTrait.php | 9 +-- Core/src/Batch/BatchTrait.php | 2 - Core/src/Batch/InterruptTrait.php | 8 +- Core/src/ClientTrait.php | 4 +- Core/src/Compute/Metadata.php | 4 +- Core/src/DetectProjectIdTrait.php | 2 +- Core/src/GrpcRequestWrapper.php | 5 +- Core/src/GrpcTrait.php | 6 +- Core/src/Iam/IamManager.php | 5 +- Core/src/Iam/PolicyBuilder.php | 8 +- Core/src/Logger/FormatterTrait.php | 6 +- Core/src/LongRunning/LROTrait.php | 3 +- .../LongRunning/OperationResponseTrait.php | 1 - Core/src/PhpArray.php | 6 +- Core/src/RequestHandler.php | 11 +-- Core/src/RequestProcessorTrait.php | 12 +-- Core/src/RequestWrapper.php | 7 +- Core/src/ServiceBuilder.php | 1 - Core/src/TimeTrait.php | 2 +- Core/src/TimestampTrait.php | 2 - Core/src/Upload/ResumableUploader.php | 1 - Core/src/ValueMapperTrait.php | 2 +- Core/unit-bootstrap.php | 4 +- Datastore/src/Connection/Grpc.php | 18 ++--- Datastore/src/Connection/Rest.php | 2 +- Datastore/src/DatastoreClient.php | 1 - Datastore/src/EntityMapper.php | 8 +- Datastore/src/Key.php | 2 +- Datastore/src/Query/Filter.php | 2 - Datastore/src/Query/GqlQuery.php | 5 +- Datastore/src/Query/Query.php | 2 +- Datastore/src/TransactionTrait.php | 2 +- Debugger/src/Agent.php | 2 +- Debugger/src/Breakpoint.php | 2 +- Debugger/src/Connection/Firebase.php | 8 +- Debugger/src/Connection/Grpc.php | 2 +- Debugger/src/Daemon.php | 6 +- Debugger/src/Debuggee.php | 2 +- Debugger/src/DebuggerClient.php | 2 +- Debugger/src/VariableTable.php | 2 +- ErrorReporting/src/Bootstrap.php | 2 +- Firestore/src/Aggregate.php | 2 - Firestore/src/AggregateQuery.php | 1 - Firestore/src/BulkWriter.php | 4 +- Firestore/src/Connection/Grpc.php | 18 ++--- Firestore/src/DocumentSnapshot.php | 2 +- Firestore/src/FirestoreSessionHandler.php | 2 +- Firestore/src/Query.php | 5 +- Firestore/src/SnapshotTrait.php | 3 +- Firestore/src/ValueMapper.php | 6 +- Firestore/src/WriteBatch.php | 36 ++++----- Logging/src/LoggingClient.php | 2 +- PubSub/src/BatchPublisher.php | 2 - PubSub/src/PubSubClient.php | 7 +- PubSub/src/Schema.php | 6 +- PubSub/src/Snapshot.php | 4 +- PubSub/src/Subscription.php | 12 ++- PubSub/src/Topic.php | 20 ++--- Spanner/src/Backup.php | 10 +-- Spanner/src/Batch/QueryPartition.php | 2 - Spanner/src/Connection/Grpc.php | 76 +++++++++---------- Spanner/src/Database.php | 15 ++-- Spanner/src/Instance.php | 13 ++-- Spanner/src/InstanceConfiguration.php | 2 +- Spanner/src/KeySet.php | 1 - Spanner/src/MutationTrait.php | 1 - Spanner/src/Session/CacheSessionPool.php | 6 +- Spanner/src/Snapshot.php | 3 +- Spanner/src/SnapshotTrait.php | 1 - Spanner/src/SpannerClient.php | 11 +-- Spanner/src/Transaction.php | 2 +- Spanner/src/TransactionConfigurationTrait.php | 2 +- Spanner/src/ValueMapper.php | 15 ++-- Storage/src/Bucket.php | 1 - Storage/src/Connection/Rest.php | 2 - Storage/src/EncryptionTrait.php | 2 +- Storage/src/ReadStream.php | 2 +- Storage/src/SigningHelper.php | 6 +- Storage/src/StreamWrapper.php | 11 ++- Storage/src/WriteStream.php | 4 +- Trace/src/Connection/Grpc.php | 2 +- Trace/src/TimestampTrait.php | 6 +- Trace/src/Trace.php | 1 - 106 files changed, 303 insertions(+), 339 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 70c1114f8d48..1bc84594ec98 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -8,7 +8,7 @@ on: permissions: contents: read jobs: - style: + style_phpcs: runs-on: ubuntu-latest name: PHP Style Check steps: @@ -21,6 +21,33 @@ jobs: run: composer global require "squizlabs/php_codesniffer:3.*" - name: Run PHPCS Code Style Checker run: ~/.composer/vendor/bin/phpcs --standard=phpcs-ruleset.xml -p + + style_csfixer: + name: PHP CS Fixer + uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@main + with: + config: GoogleCloudPlatform/php-tools/.php-cs-fixer.default.php@main + exclude-patterns: | + [ + "#.*/src/V[0-9]+#", + "#.*/src/.*/V[0-9]+#", + "#.*/(tests|samples|metadata)#", + "vendor", + "dev", + "docs", + "AccessContextManager/src/Type", + "Asset/external", + "BigQueryDataExchange/src/Common", + "CommonProtos", + "Core/src/Testing", + "GSuiteAddOns/external", + "OsLogin/src/Common", + "LongRunning/src/ApiCore/LongRunning", + "LongRunning/src/LongRunning", + "Translate/src/Connection", + "Translate/src/TranslateClient.php" + ] + staticanalysis: runs-on: ubuntu-latest name: PHPStan Static Analysis diff --git a/BigQuery/src/Connection/Rest.php b/BigQuery/src/Connection/Rest.php index 8748a22b4c28..46a7854a68b6 100644 --- a/BigQuery/src/Connection/Rest.php +++ b/BigQuery/src/Connection/Rest.php @@ -19,7 +19,6 @@ use Google\Auth\GetUniverseDomainInterface; use Google\Cloud\BigQuery\BigQueryClient; -use Google\Cloud\BigQuery\Connection\ConnectionInterface; use Google\Cloud\Core\RequestBuilder; use Google\Cloud\Core\RequestWrapper; use Google\Cloud\Core\RestTrait; diff --git a/BigQuery/src/JobWaitTrait.php b/BigQuery/src/JobWaitTrait.php index e4339f7ba524..6003fcf32c36 100644 --- a/BigQuery/src/JobWaitTrait.php +++ b/BigQuery/src/JobWaitTrait.php @@ -18,7 +18,6 @@ namespace Google\Cloud\BigQuery; use Google\Cloud\BigQuery\Exception\JobException; -use Google\Cloud\BigQuery\Job; use Google\Cloud\Core\Exception\ServiceException; use Google\Cloud\Core\ExponentialBackoff; use Throwable; diff --git a/Bigtable/src/BigtableClient.php b/Bigtable/src/BigtableClient.php index 7bca91745c72..51d0e0d00ec5 100644 --- a/Bigtable/src/BigtableClient.php +++ b/Bigtable/src/BigtableClient.php @@ -17,16 +17,15 @@ namespace Google\Cloud\Bigtable; +use Google\ApiCore\ArrayTrait; +use Google\ApiCore\ClientOptionsTrait; use Google\ApiCore\CredentialsWrapper; +use Google\ApiCore\Serializer; use Google\ApiCore\Transport\TransportInterface; use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; -use Google\ApiCore\ArrayTrait; -use Google\ApiCore\ClientOptionsTrait; -use Google\ApiCore\Serializer; use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; use Google\Cloud\Core\DetectProjectIdTrait; -use Google\Cloud\Core\RequestHandler; /** * Google Cloud Bigtable is Google's NoSQL Big Data database service. diff --git a/Bigtable/src/ChunkFormatter.php b/Bigtable/src/ChunkFormatter.php index 6e2ef5a5ee5e..32b1bc42af2a 100644 --- a/Bigtable/src/ChunkFormatter.php +++ b/Bigtable/src/ChunkFormatter.php @@ -19,12 +19,12 @@ use Google\ApiCore\ArrayTrait; use Google\Cloud\Bigtable\Exception\BigtableDataOperationException; +use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; use Google\Cloud\Bigtable\V2\ReadRowsRequest; use Google\Cloud\Bigtable\V2\ReadRowsResponse\CellChunk; use Google\Cloud\Bigtable\V2\RowRange; use Google\Cloud\Bigtable\V2\RowSet; use Google\Protobuf\Internal\Message; -use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; /** * Converts cell chunks into an easily digestable format. Please note this class @@ -249,7 +249,7 @@ private function updateReadRowsRequest($request, $options, $prevRowKey) foreach ($rowSet->getRowRanges() as $range) { if (($range->getEndKeyOpen() && $prevRowKey > $range->getEndKeyOpen()) || ($range->getEndKeyClosed() && $prevRowKey >= $range->getEndKeyClosed())) { - continue; + continue; } elseif ((!$range->getStartKeyOpen() || $prevRowKey > $range->getStartKeyOpen()) && (!$range->getStartKeyClosed() || $prevRowKey >= $range->getStartKeyClosed())) { $range->setStartKeyOpen($prevRowKey); @@ -268,8 +268,8 @@ private function updateReadRowsRequest($request, $options, $prevRowKey) $options['requestCompleted'] = true; } } else { - $range = (new RowRange)->setStartKeyOpen($prevRowKey); - $options['rows'] = (new RowSet)->setRowRanges([$range]); + $range = (new RowRange())->setStartKeyOpen($prevRowKey); + $options['rows'] = (new RowSet())->setRowRanges([$range]); } return [$request, $options]; diff --git a/Bigtable/src/DataUtil.php b/Bigtable/src/DataUtil.php index e2951133d33a..fda1b97d760d 100644 --- a/Bigtable/src/DataUtil.php +++ b/Bigtable/src/DataUtil.php @@ -34,7 +34,7 @@ class DataUtil public static function isSystemLittleEndian() { if (self::$isLittleEndian === null) { - self::$isLittleEndian = (pack("P", 2) === pack("Q", 2)); + self::$isLittleEndian = (pack('P', 2) === pack('Q', 2)); } return self::$isLittleEndian; } @@ -75,7 +75,7 @@ public static function intToByteString($intValue) ) ); } - $bytes = pack("J", $intValue); + $bytes = pack('J', $intValue); return $bytes; } @@ -94,6 +94,6 @@ public static function byteStringToInt($bytes) if (self::isSystemLittleEndian()) { $bytes = strrev($bytes); } - return unpack("q", $bytes)[1]; + return unpack('q', $bytes)[1]; } } diff --git a/Bigtable/src/Filter.php b/Bigtable/src/Filter.php index 5662a38e46f5..96ed37949787 100644 --- a/Bigtable/src/Filter.php +++ b/Bigtable/src/Filter.php @@ -17,10 +17,6 @@ namespace Google\Cloud\Bigtable; -use Google\Cloud\Bigtable\Filter\ChainFilter; -use Google\Cloud\Bigtable\Filter\ConditionFilter; -use Google\Cloud\Bigtable\Filter\FilterInterface; -use Google\Cloud\Bigtable\Filter\InterleaveFilter; use Google\Cloud\Bigtable\Filter\Builder\FamilyFilter; use Google\Cloud\Bigtable\Filter\Builder\KeyFilter; use Google\Cloud\Bigtable\Filter\Builder\LimitFilter; @@ -28,6 +24,10 @@ use Google\Cloud\Bigtable\Filter\Builder\QualifierFilter; use Google\Cloud\Bigtable\Filter\Builder\TimestampFilter; use Google\Cloud\Bigtable\Filter\Builder\ValueFilter; +use Google\Cloud\Bigtable\Filter\ChainFilter; +use Google\Cloud\Bigtable\Filter\ConditionFilter; +use Google\Cloud\Bigtable\Filter\FilterInterface; +use Google\Cloud\Bigtable\Filter\InterleaveFilter; use Google\Cloud\Bigtable\Filter\SimpleFilter; use Google\Cloud\Bigtable\V2\RowFilter; diff --git a/Bigtable/src/Filter/Builder/FamilyFilter.php b/Bigtable/src/Filter/Builder/FamilyFilter.php index 93545044269f..2eb048b67708 100644 --- a/Bigtable/src/Filter/Builder/FamilyFilter.php +++ b/Bigtable/src/Filter/Builder/FamilyFilter.php @@ -18,7 +18,6 @@ namespace Google\Cloud\Bigtable\Filter\Builder; use Google\Cloud\Bigtable\Filter\SimpleFilter; -use Google\Cloud\Bigtable\V2\RowFilter; /** * A builder used to configure column family filters. diff --git a/Bigtable/src/Filter/Builder/KeyFilter.php b/Bigtable/src/Filter/Builder/KeyFilter.php index 43d15d25048c..833756601c6a 100644 --- a/Bigtable/src/Filter/Builder/KeyFilter.php +++ b/Bigtable/src/Filter/Builder/KeyFilter.php @@ -109,7 +109,7 @@ public function sample($probability) } return new SimpleFilter( - (new RowFilter)->setRowSampleFilter($probability) + (new RowFilter())->setRowSampleFilter($probability) ); } } diff --git a/Bigtable/src/Filter/Builder/LimitFilter.php b/Bigtable/src/Filter/Builder/LimitFilter.php index 4383d921b420..ae5090a0c138 100644 --- a/Bigtable/src/Filter/Builder/LimitFilter.php +++ b/Bigtable/src/Filter/Builder/LimitFilter.php @@ -49,7 +49,7 @@ class LimitFilter public function cellsPerRow($count) { return new SimpleFilter( - (new RowFilter)->setCellsPerRowLimitFilter($count) + (new RowFilter())->setCellsPerRowLimitFilter($count) ); } @@ -73,7 +73,7 @@ public function cellsPerRow($count) public function cellsPerColumn($count) { return new SimpleFilter( - (new RowFilter)->setCellsPerColumnLimitFilter($count) + (new RowFilter())->setCellsPerColumnLimitFilter($count) ); } } diff --git a/Bigtable/src/Filter/Builder/OffsetFilter.php b/Bigtable/src/Filter/Builder/OffsetFilter.php index 92c3b802ded6..e5feb75b885e 100644 --- a/Bigtable/src/Filter/Builder/OffsetFilter.php +++ b/Bigtable/src/Filter/Builder/OffsetFilter.php @@ -49,7 +49,7 @@ class OffsetFilter public function cellsPerRow($count) { return new SimpleFilter( - (new RowFilter)->setCellsPerRowOffsetFilter($count) + (new RowFilter())->setCellsPerRowOffsetFilter($count) ); } } diff --git a/Bigtable/src/Filter/Builder/QualifierFilter.php b/Bigtable/src/Filter/Builder/QualifierFilter.php index 3257c66ed49a..95d999cc6f16 100644 --- a/Bigtable/src/Filter/Builder/QualifierFilter.php +++ b/Bigtable/src/Filter/Builder/QualifierFilter.php @@ -19,7 +19,6 @@ use Google\Cloud\Bigtable\Filter\QualifierRangeFilter; use Google\Cloud\Bigtable\Filter\SimpleFilter; -use Google\Cloud\Bigtable\V2\RowFilter; /** * A builder used to configure qualifier based filters. diff --git a/Bigtable/src/Filter/Builder/RegexTrait.php b/Bigtable/src/Filter/Builder/RegexTrait.php index aa844a84fbb8..9f4516364723 100644 --- a/Bigtable/src/Filter/Builder/RegexTrait.php +++ b/Bigtable/src/Filter/Builder/RegexTrait.php @@ -37,7 +37,7 @@ trait RegexTrait private function buildRegexFilter($value, $setter) { return new SimpleFilter( - (new RowFilter)->$setter($value) + (new RowFilter())->$setter($value) ); } diff --git a/Bigtable/src/Filter/Builder/ValueFilter.php b/Bigtable/src/Filter/Builder/ValueFilter.php index dcb0f1124d32..db883a23e564 100644 --- a/Bigtable/src/Filter/Builder/ValueFilter.php +++ b/Bigtable/src/Filter/Builder/ValueFilter.php @@ -105,7 +105,7 @@ public function range() public function strip() { return new SimpleFilter( - (new RowFilter)->setStripValueTransformer(true) + (new RowFilter())->setStripValueTransformer(true) ); } } diff --git a/Bigtable/src/Filter/ChainFilter.php b/Bigtable/src/Filter/ChainFilter.php index 39359b2371d7..a6c54e89dd2a 100644 --- a/Bigtable/src/Filter/ChainFilter.php +++ b/Bigtable/src/Filter/ChainFilter.php @@ -67,9 +67,9 @@ public function addFilter(FilterInterface $filter) */ public function toProto() { - $chain = (new Chain) + $chain = (new Chain()) ->setFilters($this->filters); - return (new RowFilter) + return (new RowFilter()) ->setChain($chain); } } diff --git a/Bigtable/src/Filter/ConditionFilter.php b/Bigtable/src/Filter/ConditionFilter.php index e94c000bfa02..5f66c9362668 100644 --- a/Bigtable/src/Filter/ConditionFilter.php +++ b/Bigtable/src/Filter/ConditionFilter.php @@ -123,7 +123,7 @@ public function toProto() ) ); } - $condition = (new Condition) + $condition = (new Condition()) ->setPredicateFilter($this->predicateFilter); if ($this->trueFilter) { $condition->setTrueFilter($this->trueFilter); @@ -131,7 +131,7 @@ public function toProto() if ($this->falseFilter) { $condition->setFalseFilter($this->falseFilter); } - return (new RowFilter) + return (new RowFilter()) ->setCondition($condition); } } diff --git a/Bigtable/src/Filter/InterleaveFilter.php b/Bigtable/src/Filter/InterleaveFilter.php index 9fbe45873ec1..f3e9f06a9ae7 100644 --- a/Bigtable/src/Filter/InterleaveFilter.php +++ b/Bigtable/src/Filter/InterleaveFilter.php @@ -67,9 +67,9 @@ public function addFilter(FilterInterface $filter) */ public function toProto() { - $interleave = (new Interleave) + $interleave = (new Interleave()) ->setFilters($this->filters); - return (new RowFilter) + return (new RowFilter()) ->setInterleave($interleave); } } diff --git a/Bigtable/src/Mutations.php b/Bigtable/src/Mutations.php index 0bb1de804d85..7a12861a46b5 100644 --- a/Bigtable/src/Mutations.php +++ b/Bigtable/src/Mutations.php @@ -49,7 +49,7 @@ class Mutations */ public function upsert($family, $qualifier, $value, $timeStamp = null) { - $mutationSetCell = (new SetCell) + $mutationSetCell = (new SetCell()) ->setFamilyName($family) ->setColumnQualifier($qualifier) ->setValue($value); @@ -63,7 +63,7 @@ public function upsert($family, $qualifier, $value, $timeStamp = null) } else { $mutationSetCell->setTimestampMicros($timeStamp); } - $this->mutations[] = (new Mutation)->setSetCell($mutationSetCell); + $this->mutations[] = (new Mutation())->setSetCell($mutationSetCell); return $this; } @@ -76,9 +76,9 @@ public function upsert($family, $qualifier, $value, $timeStamp = null) */ public function deleteFromFamily($family) { - $this->mutations[] = (new Mutation) + $this->mutations[] = (new Mutation()) ->setDeleteFromFamily( - (new DeleteFromFamily)->setFamilyName($family) + (new DeleteFromFamily())->setFamilyName($family) ); return $this; } @@ -97,11 +97,11 @@ public function deleteFromFamily($family) */ public function deleteFromColumn($family, $qualifier, array $timeRange = []) { - $deleteFromColumn = (new DeleteFromColumn) + $deleteFromColumn = (new DeleteFromColumn()) ->setFamilyName($family) ->setColumnQualifier($qualifier); if (!empty($timeRange)) { - $timestampRange = new TimestampRange; + $timestampRange = new TimestampRange(); if (isset($timeRange['start'])) { $timestampRange->setStartTimestampMicros($timeRange['start']); } @@ -110,7 +110,7 @@ public function deleteFromColumn($family, $qualifier, array $timeRange = []) } $deleteFromColumn->setTimeRange($timestampRange); } - $this->mutations[] = (new Mutation)->setDeleteFromColumn($deleteFromColumn); + $this->mutations[] = (new Mutation())->setDeleteFromColumn($deleteFromColumn); return $this; } @@ -121,7 +121,7 @@ public function deleteFromColumn($family, $qualifier, array $timeRange = []) */ public function deleteRow() { - $this->mutations[] = (new Mutation)->setDeleteFromRow(new DeleteFromRow); + $this->mutations[] = (new Mutation())->setDeleteFromRow(new DeleteFromRow()); return $this; } diff --git a/Bigtable/src/ReadModifyWriteRowRules.php b/Bigtable/src/ReadModifyWriteRowRules.php index 7843331640c8..40e9df45cdad 100644 --- a/Bigtable/src/ReadModifyWriteRowRules.php +++ b/Bigtable/src/ReadModifyWriteRowRules.php @@ -45,7 +45,7 @@ class ReadModifyWriteRowRules */ public function append($familyName, $qualifier, $value) { - $this->rules[] = (new ReadModifyWriteRule) + $this->rules[] = (new ReadModifyWriteRule()) ->setFamilyName($familyName) ->setColumnQualifier($qualifier) ->setAppendValue($value); @@ -65,7 +65,7 @@ public function append($familyName, $qualifier, $value) */ public function increment($familyName, $qualifier, $amount) { - $this->rules[] = (new ReadModifyWriteRule) + $this->rules[] = (new ReadModifyWriteRule()) ->setFamilyName($familyName) ->setColumnQualifier($qualifier) ->setIncrementAmount($amount); diff --git a/Bigtable/src/ResumableStream.php b/Bigtable/src/ResumableStream.php index 5a8c9f2ea550..d85597347eb4 100644 --- a/Bigtable/src/ResumableStream.php +++ b/Bigtable/src/ResumableStream.php @@ -209,7 +209,7 @@ public static function isRetryable($code) return isset(self::$retryableStatusCodes[$code]); } - private function getMaxRetries(array $options) : int + private function getMaxRetries(array $options): int { $retrySettings = $options['retrySettings'] ?? []; diff --git a/Bigtable/src/Table.php b/Bigtable/src/Table.php index 71d5d577f3cd..f0c606956b7a 100644 --- a/Bigtable/src/Table.php +++ b/Bigtable/src/Table.php @@ -18,22 +18,20 @@ namespace Google\Cloud\Bigtable; use Google\ApiCore\ApiException; +use Google\ApiCore\ArrayTrait; use Google\ApiCore\Serializer; use Google\Cloud\Bigtable\Exception\BigtableDataOperationException; use Google\Cloud\Bigtable\Filter\FilterInterface; -use Google\Cloud\Bigtable\Mutations; -use Google\Cloud\Bigtable\ReadModifyWriteRowRules; -use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry; -use Google\Cloud\Bigtable\V2\Row; -use Google\Cloud\Bigtable\V2\RowRange; -use Google\Cloud\Bigtable\V2\RowSet; -use Google\ApiCore\ArrayTrait; use Google\Cloud\Bigtable\V2\CheckAndMutateRowRequest; use Google\Cloud\Bigtable\V2\Client\BigtableClient as GapicClient; use Google\Cloud\Bigtable\V2\MutateRowRequest; use Google\Cloud\Bigtable\V2\MutateRowsRequest; +use Google\Cloud\Bigtable\V2\MutateRowsRequest\Entry; use Google\Cloud\Bigtable\V2\ReadModifyWriteRowRequest; use Google\Cloud\Bigtable\V2\ReadRowsRequest; +use Google\Cloud\Bigtable\V2\Row; +use Google\Cloud\Bigtable\V2\RowRange; +use Google\Cloud\Bigtable\V2\RowSet; use Google\Cloud\Bigtable\V2\SampleRowKeysRequest; use Google\Cloud\Core\ApiHelperTrait; use Google\Rpc\Code; @@ -216,7 +214,7 @@ public function upsert(array $rows, array $options = []) { $entries = []; foreach ($rows as $rowKey => $families) { - $mutations = new Mutations; + $mutations = new Mutations(); foreach ($families as $family => $qualifiers) { foreach ($qualifiers as $qualifier => $value) { if (isset($value['timeStamp'])) { @@ -308,7 +306,7 @@ public function readRows(array $options = []) if ($ranges || $rowKeys) { $data['rows'] = $this->serializer->decodeMessage( - new RowSet, + new RowSet(), [ 'rowKeys' => $rowKeys, 'rowRanges' => $ranges @@ -520,7 +518,7 @@ public function checkAndMutateRow($rowKey, array $options = []) list($data, $optionalArgs) = $this->splitOptionalArgs($options); $data['table_name'] = $this->tableName; $data['row_key'] = $rowKey; - $request = $this->serializer->decodeMessage(new CheckAndMutateRowRequest, $data); + $request = $this->serializer->decodeMessage(new CheckAndMutateRowRequest(), $data); return $this->gapicClient->checkAndMutateRow( $request, @@ -641,7 +639,7 @@ private function appendPendingEntryToFailedMutations( private function toEntry($rowKey, Mutations $mutations) { - return (new Entry) + return (new Entry()) ->setRowKey($rowKey) ->setMutations($mutations->toProto()); } diff --git a/Core/snippet-bootstrap.php b/Core/snippet-bootstrap.php index 156f1a322227..39897661f4bd 100644 --- a/Core/snippet-bootstrap.php +++ b/Core/snippet-bootstrap.php @@ -1,7 +1,7 @@ parseTimeString($value); + list($dt, $nanos) = $this->parseTimeString($value); return [ 'seconds' => (int) $dt->format('U'), @@ -239,11 +238,11 @@ protected function constructGapic($gapicName, array $config) * * @return array The modified array */ - private function convertDataToProtos(array $input, array $map) : array + private function convertDataToProtos(array $input, array $map): array { foreach ($map as $key => $className) { if (isset($input[$key])) { - $input[$key] = $this->serializer->decodeMessage(new $className, $input[$key]); + $input[$key] = $this->serializer->decodeMessage(new $className(), $input[$key]); } } @@ -256,7 +255,7 @@ private function convertDataToProtos(array $input, array $map) : array * We strictly treat the parameters allowed by `CallOptions` in GAX as the optional params * and everything else that is passed is passed to the Proto message constructor. */ - private function splitOptionalArgs(array $input, array $extraAllowedKeys = []) : array + private function splitOptionalArgs(array $input, array $extraAllowedKeys = []): array { $callOptionFields = array_keys((new CallOptions([]))->toArray()); $keys = array_merge($callOptionFields, $extraAllowedKeys); diff --git a/Core/src/Batch/BatchTrait.php b/Core/src/Batch/BatchTrait.php index 3ac284cf1e6b..591410e62b37 100644 --- a/Core/src/Batch/BatchTrait.php +++ b/Core/src/Batch/BatchTrait.php @@ -17,8 +17,6 @@ namespace Google\Cloud\Core\Batch; -use Opis\Closure\SerializableClosure; - /** * A trait to assist in the registering and processing of batch jobs. * diff --git a/Core/src/Batch/InterruptTrait.php b/Core/src/Batch/InterruptTrait.php index dae64456f734..88ef74be60d4 100644 --- a/Core/src/Batch/InterruptTrait.php +++ b/Core/src/Batch/InterruptTrait.php @@ -32,10 +32,10 @@ trait InterruptTrait private function setupSignalHandlers() { // setup signal handlers - pcntl_signal(SIGTERM, [$this, "sigHandler"]); - pcntl_signal(SIGINT, [$this, "sigHandler"]); - pcntl_signal(SIGHUP, [$this, "sigHandler"]); - pcntl_signal(SIGALRM, [$this, "sigHandler"]); + pcntl_signal(SIGTERM, [$this, 'sigHandler']); + pcntl_signal(SIGINT, [$this, 'sigHandler']); + pcntl_signal(SIGHUP, [$this, 'sigHandler']); + pcntl_signal(SIGALRM, [$this, 'sigHandler']); } /** diff --git a/Core/src/ClientTrait.php b/Core/src/ClientTrait.php index 5df03e152e3c..2bd86cc1c48d 100644 --- a/Core/src/ClientTrait.php +++ b/Core/src/ClientTrait.php @@ -17,8 +17,8 @@ namespace Google\Cloud\Core; -use Google\Auth\CredentialsLoader; use Google\Auth\Credentials\GCECredentials; +use Google\Auth\CredentialsLoader; use Google\Cloud\Core\Compute\Metadata; use Google\Cloud\Core\Exception\GoogleException; @@ -256,7 +256,7 @@ protected function onGce($httpHandler) */ protected function getMetaData() { - return new Metadata; + return new Metadata(); } /** diff --git a/Core/src/Compute/Metadata.php b/Core/src/Compute/Metadata.php index d1471c773e86..15a5eea02e9d 100644 --- a/Core/src/Compute/Metadata.php +++ b/Core/src/Compute/Metadata.php @@ -142,7 +142,7 @@ public function getNumericProjectId() */ public function getProjectMetadata($key) { - $path = 'project/attributes/'.$key; + $path = 'project/attributes/' . $key; return $this->get($path); } @@ -159,7 +159,7 @@ public function getProjectMetadata($key) */ public function getInstanceMetadata($key) { - $path = 'instance/attributes/'.$key; + $path = 'instance/attributes/' . $key; return $this->get($path); } } diff --git a/Core/src/DetectProjectIdTrait.php b/Core/src/DetectProjectIdTrait.php index 8cd853076387..f0ce26db9255 100644 --- a/Core/src/DetectProjectIdTrait.php +++ b/Core/src/DetectProjectIdTrait.php @@ -71,7 +71,7 @@ private function detectProjectId(array $config) if ($config['credentials'] && $config['credentials'] instanceof ProjectIdProviderInterface && $projectId = $config['credentials']->getProjectId()) { - return $projectId; + return $projectId; } if (getenv('GOOGLE_CLOUD_PROJECT')) { diff --git a/Core/src/GrpcRequestWrapper.php b/Core/src/GrpcRequestWrapper.php index 9f8d3b50b506..7bcfa7601eb1 100644 --- a/Core/src/GrpcRequestWrapper.php +++ b/Core/src/GrpcRequestWrapper.php @@ -17,10 +17,9 @@ namespace Google\Cloud\Core; -use Google\Auth\HttpHandler\HttpHandlerFactory; -use Google\Cloud\Core\Exception; use Google\ApiCore\ApiException; use Google\ApiCore\Serializer; +use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Rpc\Code; /** @@ -77,7 +76,7 @@ public function __construct(array $config = []) $config += [ 'authHttpHandler' => null, - 'serializer' => new Serializer, + 'serializer' => new Serializer(), 'grpcOptions' => [] ]; diff --git a/Core/src/GrpcTrait.php b/Core/src/GrpcTrait.php index 2573c43192ea..fac9527d7c77 100644 --- a/Core/src/GrpcTrait.php +++ b/Core/src/GrpcTrait.php @@ -17,13 +17,11 @@ namespace Google\Cloud\Core; -use Google\Auth\GetUniverseDomainInterface; use Google\ApiCore\CredentialsWrapper; +use Google\Auth\GetUniverseDomainInterface; use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\Exception\ServiceException; -use Google\Cloud\Core\GrpcRequestWrapper; use Google\Protobuf\NullValue; -use Google\Cloud\Core\Duration; /** * Provides shared functionality for gRPC service implementations. @@ -278,7 +276,7 @@ private function formatTimestampFromApi(array $timestamp) */ private function formatTimestampForApi($value) { - list ($dt, $nanos) = $this->parseTimeString($value); + list($dt, $nanos) = $this->parseTimeString($value); return [ 'seconds' => (int) $dt->format('U'), diff --git a/Core/src/Iam/IamManager.php b/Core/src/Iam/IamManager.php index a9e373fe7b89..7e1670a6e7d2 100644 --- a/Core/src/Iam/IamManager.php +++ b/Core/src/Iam/IamManager.php @@ -19,11 +19,10 @@ use Google\ApiCore\Serializer; use Google\Cloud\Core\ArrayTrait; -use Google\Cloud\Core\Iam\PolicyBuilder; -use Google\Cloud\Iam\V1\Policy; use Google\Cloud\Core\RequestHandler; use Google\Cloud\Iam\V1\GetIamPolicyRequest; use Google\Cloud\Iam\V1\GetPolicyOptions; +use Google\Cloud\Iam\V1\Policy; use Google\Cloud\Iam\V1\SetIamPolicyRequest; use Google\Cloud\Iam\V1\TestIamPermissionsRequest; use InvalidArgumentException; @@ -152,7 +151,7 @@ public function setPolicy($policy, array $options = []) } $policy = $this->serializer->decodeMessage( - new Policy, + new Policy(), $policy ); diff --git a/Core/src/Iam/PolicyBuilder.php b/Core/src/Iam/PolicyBuilder.php index d22962e7cfe5..3de89eb194fb 100644 --- a/Core/src/Iam/PolicyBuilder.php +++ b/Core/src/Iam/PolicyBuilder.php @@ -17,8 +17,8 @@ namespace Google\Cloud\Core\Iam; -use InvalidArgumentException; use BadMethodCallException; +use InvalidArgumentException; /** * Helper class for creating valid IAM policies @@ -284,7 +284,7 @@ public function result() private function validatePolicyVersion() { if (isset($this->version) && $this->version > 1) { - throw new BadMethodCallException("Helper methods cannot be " . + throw new BadMethodCallException('Helper methods cannot be ' . "invoked on policies with version {$this->version}."); } @@ -299,8 +299,8 @@ private function validateConditions() foreach ($this->bindings as $binding) { if (isset($binding['condition'])) { - throw new BadMethodCallException("Helper methods cannot " . - "be invoked on policies containing conditions."); + throw new BadMethodCallException('Helper methods cannot ' . + 'be invoked on policies containing conditions.'); } } } diff --git a/Core/src/Logger/FormatterTrait.php b/Core/src/Logger/FormatterTrait.php index 095228ed2847..329a507e5b77 100644 --- a/Core/src/Logger/FormatterTrait.php +++ b/Core/src/Logger/FormatterTrait.php @@ -36,12 +36,12 @@ protected function formatPayload($record, $message) } list($usec, $sec) = explode(' ', microtime()); - $usec = (int)(((float)$usec)*1000000000); - $sec = (int)$sec; + $usec = (int) (((float) $usec) * 1000000000); + $sec = (int) $sec; $payload = [ 'message' => $message, - 'timestamp'=> ['seconds' => $sec, 'nanos' => $usec], + 'timestamp' => ['seconds' => $sec, 'nanos' => $usec], 'thread' => '', 'severity' => $record['level_name'], ]; diff --git a/Core/src/LongRunning/LROTrait.php b/Core/src/LongRunning/LROTrait.php index 477d5f3ea2b9..ac9a048934aa 100644 --- a/Core/src/LongRunning/LROTrait.php +++ b/Core/src/LongRunning/LROTrait.php @@ -19,7 +19,6 @@ use Google\Cloud\Core\Iterator\ItemIterator; use Google\Cloud\Core\Iterator\PageIterator; -use Google\Cloud\Core\LongRunning\LongRunningConnectionInterface; /** * Provide Long Running Operation support to Google Cloud PHP Clients. @@ -109,7 +108,7 @@ public function longRunningOperations(array $options = []) $resultLimit = $this->pluck('resultLimit', $options, false) ?: 0; - $options['name'] = $this->lroResource .'/operations'; + $options['name'] = $this->lroResource . '/operations'; return new ItemIterator( new PageIterator( diff --git a/Core/src/LongRunning/OperationResponseTrait.php b/Core/src/LongRunning/OperationResponseTrait.php index 2c5cad0b6a1a..90e133936b27 100644 --- a/Core/src/LongRunning/OperationResponseTrait.php +++ b/Core/src/LongRunning/OperationResponseTrait.php @@ -20,7 +20,6 @@ use Google\ApiCore\OperationResponse; use Google\ApiCore\Serializer; use Google\GAX\OperationResponse as GaxOperationResponse; -use Google\GAX\Serializer as GaxSerialzer; /** * Serializes and deserializes ApiCore LRO Response objects. diff --git a/Core/src/PhpArray.php b/Core/src/PhpArray.php index f456e70da85c..efd722657637 100644 --- a/Core/src/PhpArray.php +++ b/Core/src/PhpArray.php @@ -18,10 +18,10 @@ namespace Google\Cloud\Core; use DrSlump\Protobuf; -use google\protobuf\Value; use google\protobuf\ListValue; use google\protobuf\NullValue; use google\protobuf\Struct; +use google\protobuf\Value; /** * Extend the Protobuf-PHP array codec to allow messages to match the format @@ -86,7 +86,7 @@ protected function encodeMessage(Protobuf\Message $message) if ($field->isRepeated()) { // Make sure the value is an array of values - $v = is_array($v) ? $v : array($v); + $v = is_array($v) ? $v : [$v]; $arr = []; foreach ($v as $k => $vv) { @@ -145,7 +145,7 @@ protected function decodeMessage(Protobuf\Message $message, $data) if ($field->isRepeated()) { // Make sure the value is an array of values - $v = is_array($v) && is_int(key($v)) ? $v : array($v); + $v = is_array($v) && is_int(key($v)) ? $v : [$v]; foreach ($v as $k => $vv) { $v[$k] = $this->filterValue($vv, $field); } diff --git a/Core/src/RequestHandler.php b/Core/src/RequestHandler.php index 6e11b4d61e33..f650b942bfa6 100644 --- a/Core/src/RequestHandler.php +++ b/Core/src/RequestHandler.php @@ -17,15 +17,12 @@ namespace Google\Cloud\Core; -use Google\ApiCore\Serializer; -use Google\Cloud\Core\ArrayTrait; -use Google\Cloud\Core\Exception\NotFoundException; -use Google\Cloud\Core\Exception\ServiceException; -use Google\Cloud\Core\TimeTrait; -use Google\Cloud\Core\WhitelistTrait; use \Google\Protobuf\Internal\Message; use Google\ApiCore\ApiException; use Google\ApiCore\OperationResponse; +use Google\ApiCore\Serializer; +use Google\Cloud\Core\Exception\NotFoundException; +use Google\Cloud\Core\Exception\ServiceException; /** * @internal @@ -76,7 +73,7 @@ public function __construct( ); } //@codeCoverageIgnoreEnd - + // Initialize the client classes and store them in memory $this->clients = []; foreach ($clientClasses as $className) { diff --git a/Core/src/RequestProcessorTrait.php b/Core/src/RequestProcessorTrait.php index 72440cd9194f..0f7c28afe662 100644 --- a/Core/src/RequestProcessorTrait.php +++ b/Core/src/RequestProcessorTrait.php @@ -17,14 +17,14 @@ namespace Google\Cloud\Core; -use Google\ApiCore\ServerStream; -use Google\Rpc\Code; +use \Google\Protobuf\Internal\Message; +use Google\ApiCore\OperationResponse; use Google\ApiCore\PagedListResponse; +use Google\ApiCore\ServerStream; use Google\Cloud\Core\Exception\ServiceException; -use Google\ApiCore\OperationResponse; -use \Google\Protobuf\Internal\Message; -use Google\Rpc\RetryInfo; use Google\Rpc\BadRequest; +use Google\Rpc\Code; +use Google\Rpc\RetryInfo; /** * @internal @@ -140,7 +140,7 @@ private function convertToGoogleException(\Exception $ex): ServiceException if (!isset($this->metadataTypes[$type])) { continue; } - $metadataElement = new $this->metadataTypes[$type]; + $metadataElement = new $this->metadataTypes[$type](); $metadataElement->mergeFromString($binaryValue[0]); $metadata[] = $this->serializer->encodeMessage($metadataElement); } diff --git a/Core/src/RequestWrapper.php b/Core/src/RequestWrapper.php index 10e6ff729879..849d15f2bec9 100644 --- a/Core/src/RequestWrapper.php +++ b/Core/src/RequestWrapper.php @@ -24,15 +24,13 @@ use Google\Auth\HttpHandler\Guzzle6HttpHandler; use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Auth\UpdateMetadataInterface; -use Google\Cloud\Core\Exception\ServiceException; -use Google\Cloud\Core\RequestWrapperTrait; use Google\Cloud\Core\Exception\GoogleException; +use Google\Cloud\Core\Exception\ServiceException; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use Psr\Http\Message\StreamInterface; /** * The RequestWrapper is responsible for delivering and signing requests. @@ -370,7 +368,8 @@ private function addAuthHeaders(RequestInterface $request, FetchAuthTokenInterfa return $backoff->execute( function () use ($request, $fetcher) { if (!$fetcher instanceof UpdateMetadataInterface || - ($fetcher instanceof FetchAuthTokenCache && + ( + $fetcher instanceof FetchAuthTokenCache && !$fetcher->getFetcher() instanceof UpdateMetadataInterface ) ) { diff --git a/Core/src/ServiceBuilder.php b/Core/src/ServiceBuilder.php index 8071b2753d50..a3824fa43297 100644 --- a/Core/src/ServiceBuilder.php +++ b/Core/src/ServiceBuilder.php @@ -317,7 +317,6 @@ public function storage(array $config = []) return $this->createClient(StorageClient::class, 'storage', $config); } - /** * Google Stackdriver Trace allows you to collect latency data from your applications * and display it in the Google Cloud Platform Console. Find more information at diff --git a/Core/src/TimeTrait.php b/Core/src/TimeTrait.php index 773729b8bc1f..6e6a650d29be 100644 --- a/Core/src/TimeTrait.php +++ b/Core/src/TimeTrait.php @@ -38,7 +38,7 @@ private function parseTimeString($timestamp) $subSeconds = $matches[1] ?? '0'; if (strlen($subSeconds) > 6) { - $timestamp = str_replace('.'. $subSeconds, '.' . substr($subSeconds, 0, 6), $timestamp); + $timestamp = str_replace('.' . $subSeconds, '.' . substr($subSeconds, 0, 6), $timestamp); } $dt = new \DateTimeImmutable($timestamp); diff --git a/Core/src/TimestampTrait.php b/Core/src/TimestampTrait.php index 4ed589e2f7e9..78ea1d355a1f 100644 --- a/Core/src/TimestampTrait.php +++ b/Core/src/TimestampTrait.php @@ -18,8 +18,6 @@ namespace Google\Cloud\Core; -use Google\Cloud\Core\Timestamp; - /** * Helper methods to work on Google\Cloud\Core\Timestamp. * @internal diff --git a/Core/src/Upload/ResumableUploader.php b/Core/src/Upload/ResumableUploader.php index 220a2a165941..ecea6703f59f 100644 --- a/Core/src/Upload/ResumableUploader.php +++ b/Core/src/Upload/ResumableUploader.php @@ -19,7 +19,6 @@ use Google\Cloud\Core\Exception\GoogleException; use Google\Cloud\Core\Exception\ServiceException; -use Google\Cloud\Core\Exception\UploadException; use Google\Cloud\Core\JsonTrait; use Google\Cloud\Core\RequestWrapper; use GuzzleHttp\Promise\PromiseInterface; diff --git a/Core/src/ValueMapperTrait.php b/Core/src/ValueMapperTrait.php index ddb39b390e8c..c9cd904bb232 100644 --- a/Core/src/ValueMapperTrait.php +++ b/Core/src/ValueMapperTrait.php @@ -47,7 +47,7 @@ public function createTimestampWithNanos($timestamp, $returnType = Timestamp::cl $dt = $this->createDateTimeFromSeconds($timestamp['seconds']); $nanos = $timestamp['nanos']; } else { - list ($dt, $nanos) = $this->parseTimeString($timestamp); + list($dt, $nanos) = $this->parseTimeString($timestamp); } return new $returnType($dt, $nanos); diff --git a/Core/unit-bootstrap.php b/Core/unit-bootstrap.php index 864cd9436790..001e59dd2ab0 100644 --- a/Core/unit-bootstrap.php +++ b/Core/unit-bootstrap.php @@ -1,9 +1,9 @@ register(new MessageAwareArrayComparator()); diff --git a/Datastore/src/Connection/Grpc.php b/Datastore/src/Connection/Grpc.php index 62ff0923a061..e5ef8f1ab097 100644 --- a/Datastore/src/Connection/Grpc.php +++ b/Datastore/src/Connection/Grpc.php @@ -139,7 +139,7 @@ public function beginTransaction(array $args) }); $args['transactionOptions'] = $this->serializer->decodeMessage( - new TransactionOptions, + new TransactionOptions(), $args['transactionOptions'] ); } @@ -165,7 +165,7 @@ public function commit(array $args) $data = $mutation[$mutationType]; if (isset($data['properties'])) { foreach ($data['properties'] as &$property) { - list ($type, $val) = $this->toGrpcValue($property); + list($type, $val) = $this->toGrpcValue($property); $property[$type] = $val; } @@ -173,7 +173,7 @@ public function commit(array $args) $mutation[$mutationType] = $data; - $mutation = $this->serializer->decodeMessage(new Mutation, $mutation); + $mutation = $this->serializer->decodeMessage(new Mutation(), $mutation); } return $this->send([$this->datastoreClient, 'commit'], [ @@ -237,7 +237,7 @@ public function runAggregationQuery(array $args) } $args['aggregationQuery'] = $this->serializer->decodeMessage( - new AggregationQuery, + new AggregationQuery(), $args['aggregationQuery'] ); } @@ -258,7 +258,7 @@ public function runAggregationQuery(array $args) public function runQuery(array $args) { $partitionId = $this->serializer->decodeMessage( - new PartitionId, + new PartitionId(), $this->pluck('partitionId', $args) ); @@ -308,7 +308,7 @@ private function parseQuery(array $query) } $parsedQuery = $this->serializer->decodeMessage( - new Query, + new Query(), $query ); return $parsedQuery; @@ -343,7 +343,7 @@ private function parseGqlQuery(array $gqlQuery) } $parsedGqlQuery = $this->serializer->decodeMessage( - new GqlQuery, + new GqlQuery(), $gqlQuery ); @@ -401,7 +401,7 @@ private function prepareQueryBinding(array $binding) { $value = $binding['value']; - list ($type, $val) = $this->toGrpcValue($value); + list($type, $val) = $this->toGrpcValue($value); $binding['value'][$type] = $val; @@ -435,7 +435,7 @@ private function readOptions(array $readOptions) } return $this->serializer->decodeMessage( - new ReadOptions, + new ReadOptions(), $readOptions ); } diff --git a/Datastore/src/Connection/Rest.php b/Datastore/src/Connection/Rest.php index 69e47c27a7ca..3a6cf226a35b 100644 --- a/Datastore/src/Connection/Rest.php +++ b/Datastore/src/Connection/Rest.php @@ -129,7 +129,7 @@ public function runAggregationQuery(array $args) foreach ($args['aggregationQuery']['aggregations'] as &$aggregation) { $aggregation = array_map( fn ($item) => is_array($item) && count($item) === 0 - ? new \stdClass + ? new \stdClass() : $item, $aggregation ); diff --git a/Datastore/src/DatastoreClient.php b/Datastore/src/DatastoreClient.php index c0773a3a53b5..ae63022fbac5 100644 --- a/Datastore/src/DatastoreClient.php +++ b/Datastore/src/DatastoreClient.php @@ -30,7 +30,6 @@ use Google\Cloud\Datastore\Query\GqlQuery; use Google\Cloud\Datastore\Query\Query; use Google\Cloud\Datastore\Query\QueryInterface; -use InvalidArgumentException; use Psr\Cache\CacheItemPoolInterface; use Psr\Http\Message\StreamInterface; diff --git a/Datastore/src/EntityMapper.php b/Datastore/src/EntityMapper.php index 34dea73d13c0..17f75930c0e0 100644 --- a/Datastore/src/EntityMapper.php +++ b/Datastore/src/EntityMapper.php @@ -19,9 +19,6 @@ use Google\Cloud\Core\ArrayTrait; use Google\Cloud\Core\Int64; -use Google\Cloud\Datastore\Entity; -use Google\Cloud\Datastore\GeoPoint; -use Google\Cloud\Datastore\Key; /** * Utility methods for mapping between datastore and {@see \Google\Cloud\Datastore\Entity}. @@ -329,7 +326,6 @@ public function convertValue($type, $value, $className = Entity::class) break; } - return $result; } @@ -413,7 +409,7 @@ public function valueObject($value, $exclude = false, $meaning = null) ]; break; - //@codeCoverageIgnoreStart + //@codeCoverageIgnoreStart case 'unknown type': throw new \InvalidArgumentException(sprintf( 'Unknown type for `%s', @@ -427,7 +423,7 @@ public function valueObject($value, $exclude = false, $meaning = null) $value )); break; - //@codeCoverageIgnoreEnd + //@codeCoverageIgnoreEnd } if ($exclude) { diff --git a/Datastore/src/Key.php b/Datastore/src/Key.php index fa630ddca213..a74c652fcffb 100644 --- a/Datastore/src/Key.php +++ b/Datastore/src/Key.php @@ -505,7 +505,7 @@ private function normalizePath(array $path) } $incomplete = (!isset($pathElement['id']) && !isset($pathElement['name'])); - if ($index < count($path) -1 && $incomplete) { + if ($index < count($path) - 1 && $incomplete) { throw new InvalidArgumentException( 'Only the final pathElement may omit a name or ID.' ); diff --git a/Datastore/src/Query/Filter.php b/Datastore/src/Query/Filter.php index a435b07b2a82..3d80539b87a5 100644 --- a/Datastore/src/Query/Filter.php +++ b/Datastore/src/Query/Filter.php @@ -17,8 +17,6 @@ namespace Google\Cloud\Datastore\Query; -use Google\Cloud\Datastore\Query\Query; - /** * Represents an interface to create composite and property filters for * Google\Cloud\Datastore\Query\Query via static methods. diff --git a/Datastore/src/Query/GqlQuery.php b/Datastore/src/Query/GqlQuery.php index e6b4427ff4ce..e8b2b746b3aa 100644 --- a/Datastore/src/Query/GqlQuery.php +++ b/Datastore/src/Query/GqlQuery.php @@ -176,7 +176,7 @@ public function queryObject() */ public function queryKey() { - return "gqlQuery"; + return 'gqlQuery'; } public function aggregation() @@ -207,7 +207,8 @@ public function canPaginate() */ public function start($cursor) //@codingStandardsIgnoreStart - {} + { + } //@codingStandardsIgnoreEnd /** diff --git a/Datastore/src/Query/Query.php b/Datastore/src/Query/Query.php index 1da0cf971a08..3ef61ec08b9d 100644 --- a/Datastore/src/Query/Query.php +++ b/Datastore/src/Query/Query.php @@ -507,7 +507,7 @@ public function queryObject() */ public function queryKey() { - return "query"; + return 'query'; } public function aggregation(Aggregation $aggregation) diff --git a/Datastore/src/TransactionTrait.php b/Datastore/src/TransactionTrait.php index 367e3982a7b3..b30176e54f89 100644 --- a/Datastore/src/TransactionTrait.php +++ b/Datastore/src/TransactionTrait.php @@ -17,8 +17,8 @@ namespace Google\Cloud\Datastore; -use Google\Cloud\Datastore\Query\QueryInterface; use Google\Cloud\Datastore\Query\AggregationQuery; +use Google\Cloud\Datastore\Query\QueryInterface; /** * Common operations for datastore transactions. diff --git a/Debugger/src/Agent.php b/Debugger/src/Agent.php index 1cf38d1a75b0..be7db88519b0 100644 --- a/Debugger/src/Agent.php +++ b/Debugger/src/Agent.php @@ -20,8 +20,8 @@ use Google\Cloud\Core\ArrayTrait; use Google\Cloud\Core\Batch\BatchDaemonTrait; use Google\Cloud\Core\Batch\BatchTrait; -use Google\Cloud\Core\ExponentialBackoff; use Google\Cloud\Core\Exception\ServiceException; +use Google\Cloud\Core\ExponentialBackoff; use Google\Cloud\Core\SysvTrait; use Google\Cloud\Debugger\BreakpointStorage\BreakpointStorageInterface; use Google\Cloud\Debugger\BreakpointStorage\FileBreakpointStorage; diff --git a/Debugger/src/Breakpoint.php b/Debugger/src/Breakpoint.php index 17b4b5c515df..ce973ca1bcd5 100644 --- a/Debugger/src/Breakpoint.php +++ b/Debugger/src/Breakpoint.php @@ -509,7 +509,7 @@ public function info() public function finalize() { list($usec, $sec) = explode(' ', microtime()); - $micro = sprintf("%06d", (float) $usec * 1000000); + $micro = sprintf('%06d', (float) $usec * 1000000); $when = new \DateTime(date('Y-m-d H:i:s.' . $micro)); $when->setTimezone(new \DateTimeZone('UTC')); $this->finalTime = $when->format('Y-m-d\TH:i:s.u\Z'); diff --git a/Debugger/src/Connection/Firebase.php b/Debugger/src/Connection/Firebase.php index e22ebb9001c2..986a136e80c1 100644 --- a/Debugger/src/Connection/Firebase.php +++ b/Debugger/src/Connection/Firebase.php @@ -18,8 +18,8 @@ namespace Google\Cloud\Debugger\Connection; use Google\Cloud\Core\ArrayTrait; -use Kreait\Firebase\Factory; use Kreait\Firebase\Database; +use Kreait\Firebase\Factory; /** * Implementation of the Firebase connection @@ -110,9 +110,9 @@ public function registerDebuggee(array $args = []) $descriptionData = explode(':', $debuggee['description']); $debuggee['labels']['module'] = $descriptionData[0]; $debuggee['labels']['version'] = $descriptionData[1]; - $debuggee['registrationTimeUnixMsec'] = $debuggee['lastUpdateTimeUnixMsec'] = round(microtime(true)*1000); + $debuggee['registrationTimeUnixMsec'] = $debuggee['lastUpdateTimeUnixMsec'] = round(microtime(true) * 1000); $reference->set($debuggee); - $args['debuggee']=$existingDebuggee; + $args['debuggee'] = $existingDebuggee; return $args; } @@ -153,7 +153,7 @@ public function updateBreakpoint(array $args) // we remove the breakpoint from the active list $reference = $this->database->getReference('cdbg/breakpoints/' . $debuggeeId . '/active/' . $breakpointId); $reference->remove(); - $breakpoint['finalTimeUnixMsec'] = round(microtime(true)*1000); + $breakpoint['finalTimeUnixMsec'] = round(microtime(true) * 1000); // then we add it to the snapshot list $reference = $this->database->getReference('cdbg/breakpoints/' . $debuggeeId . '/snapshot/' . $breakpointId); $reference->set($breakpoint); diff --git a/Debugger/src/Connection/Grpc.php b/Debugger/src/Connection/Grpc.php index 0ceaec51b4ec..0b741656555e 100644 --- a/Debugger/src/Connection/Grpc.php +++ b/Debugger/src/Connection/Grpc.php @@ -22,8 +22,8 @@ use Google\Cloud\Core\GrpcTrait; use Google\Cloud\Debugger\DebuggerClient; use Google\Cloud\Debugger\V2\Breakpoint; -use Google\Cloud\Debugger\V2\Debuggee; use Google\Cloud\Debugger\V2\Controller2Client; +use Google\Cloud\Debugger\V2\Debuggee; use Google\Cloud\Debugger\V2\Debugger2Client; /** diff --git a/Debugger/src/Daemon.php b/Debugger/src/Daemon.php index 19ad51ea1967..2f2487f89579 100644 --- a/Debugger/src/Daemon.php +++ b/Debugger/src/Daemon.php @@ -19,13 +19,11 @@ use Google\Cloud\Core\Batch\ClosureSerializerInterface; use Google\Cloud\Core\Batch\SimpleJobTrait; -use Google\Cloud\Core\Batch\SerializableClientTrait; -use Google\Cloud\Core\SysvTrait; -use Google\Cloud\Core\Report\MetadataProviderInterface; -use Google\Cloud\Core\Report\MetadataProviderUtils; use Google\Cloud\Core\Exception\ConflictException; use Google\Cloud\Core\Exception\ServiceException; use Google\Cloud\Core\ExponentialBackoff; +use Google\Cloud\Core\Report\MetadataProviderInterface; +use Google\Cloud\Core\Report\MetadataProviderUtils; use Google\Cloud\Debugger\BreakpointStorage\BreakpointStorageInterface; use Google\Cloud\Debugger\BreakpointStorage\FileBreakpointStorage; use Google\Cloud\Debugger\BreakpointStorage\SysvBreakpointStorage; diff --git a/Debugger/src/Debuggee.php b/Debugger/src/Debuggee.php index 08c9b22712ea..4bc5a3899a32 100644 --- a/Debugger/src/Debuggee.php +++ b/Debugger/src/Debuggee.php @@ -17,8 +17,8 @@ namespace Google\Cloud\Debugger; -use Google\Cloud\Debugger\Connection\ConnectionInterface; use Google\Cloud\Core\Exception\ServiceException; +use Google\Cloud\Debugger\Connection\ConnectionInterface; /** * This class represents a debuggee - a service that can handle breakpoints. diff --git a/Debugger/src/DebuggerClient.php b/Debugger/src/DebuggerClient.php index 1de7af632edc..b798748104cd 100644 --- a/Debugger/src/DebuggerClient.php +++ b/Debugger/src/DebuggerClient.php @@ -19,9 +19,9 @@ use Google\Cloud\Core\ClientTrait; use Google\Cloud\Debugger\Connection\ConnectionInterface; +use Google\Cloud\Debugger\Connection\Firebase; use Google\Cloud\Debugger\Connection\Grpc; use Google\Cloud\Debugger\Connection\Rest; -use Google\Cloud\Debugger\Connection\Firebase; use Psr\Cache\CacheItemPoolInterface; /** diff --git a/Debugger/src/VariableTable.php b/Debugger/src/VariableTable.php index 1e1215e358fe..f00ebef0450d 100644 --- a/Debugger/src/VariableTable.php +++ b/Debugger/src/VariableTable.php @@ -273,7 +273,7 @@ private function doRegister($name, $value, $depth, $hash) private function truncatedStringValue($value) { - $ret = (string)$value; + $ret = (string) $value; if (strlen($ret) > $this->maxValueLength) { $ret = substr($ret, 0, $this->maxValueLength - 3) . '...'; } diff --git a/ErrorReporting/src/Bootstrap.php b/ErrorReporting/src/Bootstrap.php index 1a94cac6b389..814246820125 100644 --- a/ErrorReporting/src/Bootstrap.php +++ b/ErrorReporting/src/Bootstrap.php @@ -120,7 +120,7 @@ public static function getErrorLevelString($level) */ public static function exceptionHandler($ex) { - $message = sprintf('PHP Notice: %s', (string)$ex); + $message = sprintf('PHP Notice: %s', (string) $ex); if (self::$psrLogger) { $service = self::$psrLogger->getMetadataProvider()->serviceId(); $version = self::$psrLogger->getMetadataProvider()->versionId(); diff --git a/Firestore/src/Aggregate.php b/Firestore/src/Aggregate.php index 9362a2cb6cb6..be02e3956233 100644 --- a/Firestore/src/Aggregate.php +++ b/Firestore/src/Aggregate.php @@ -17,8 +17,6 @@ namespace Google\Cloud\Firestore; -use InvalidArgumentException; - /** * Represents Aggregate properties. * diff --git a/Firestore/src/AggregateQuery.php b/Firestore/src/AggregateQuery.php index 79a5aeb72862..f042cdde7453 100644 --- a/Firestore/src/AggregateQuery.php +++ b/Firestore/src/AggregateQuery.php @@ -18,7 +18,6 @@ namespace Google\Cloud\Firestore; use Google\Cloud\Firestore\Connection\ConnectionInterface; -use Google\Cloud\Firestore\QueryTrait; /** * A Cloud Firestore Aggregate Query. diff --git a/Firestore/src/BulkWriter.php b/Firestore/src/BulkWriter.php index cd0af73888fe..38ef6113b830 100644 --- a/Firestore/src/BulkWriter.php +++ b/Firestore/src/BulkWriter.php @@ -1132,14 +1132,14 @@ private function createDatabaseWriteOperation($type, $document, array $options = ]; break; - // @codeCoverageIgnoreStart + // @codeCoverageIgnoreStart default: throw new \InvalidArgumentException(sprintf( 'Write operation type `%s is not valid. Allowed values are update, delete, verify, transform.', $type )); break; - // @codeCoverageIgnoreEnd + // @codeCoverageIgnoreEnd } } diff --git a/Firestore/src/Connection/Grpc.php b/Firestore/src/Connection/Grpc.php index 037ee6a7b96f..608b7e18c109 100644 --- a/Firestore/src/Connection/Grpc.php +++ b/Firestore/src/Connection/Grpc.php @@ -18,17 +18,17 @@ namespace Google\Cloud\Firestore\Connection; use Google\ApiCore\Serializer; -use Google\Cloud\Core\GrpcTrait; use Google\Cloud\Core\EmulatorTrait; -use Google\Cloud\Firestore\V1\Write; use Google\Cloud\Core\GrpcRequestWrapper; +use Google\Cloud\Core\GrpcTrait; +use Google\Cloud\Firestore\FirestoreClient as ManualFirestoreClient; use Google\Cloud\Firestore\V1\DocumentMask; use Google\Cloud\Firestore\V1\FirestoreClient; use Google\Cloud\Firestore\V1\StructuredAggregationQuery; use Google\Cloud\Firestore\V1\StructuredQuery; use Google\Cloud\Firestore\V1\TransactionOptions; use Google\Cloud\Firestore\V1\TransactionOptions\ReadWrite; -use Google\Cloud\Firestore\FirestoreClient as ManualFirestoreClient; +use Google\Cloud\Firestore\V1\Write; use Google\Protobuf\Timestamp as ProtobufTimestamp; /** @@ -153,13 +153,13 @@ public function batchGetDocuments(array $args) */ public function beginTransaction(array $args) { - $rw = new ReadWrite; + $rw = new ReadWrite(); $retry = $this->pluck('retryTransaction', $args, false); if ($retry) { $rw->setRetryTransaction($retry); } - $args['options'] = new TransactionOptions; + $args['options'] = new TransactionOptions(); $args['options']->setReadWrite($rw); return $this->send([$this->firestore, 'beginTransaction'], [ @@ -176,7 +176,7 @@ public function commit(array $args) { $writes = $this->pluck('writes', $args); foreach ($writes as $idx => $write) { - $writes[$idx] = $this->serializer->decodeMessage(new Write, $write); + $writes[$idx] = $this->serializer->decodeMessage(new Write(), $write); } return $this->send([$this->firestore, 'commit'], [ @@ -195,7 +195,7 @@ public function batchWrite(array $args) $writes = $this->pluck('writes', $args); foreach ($writes as $idx => $write) { $args['writes'][$idx] = $this->serializer->decodeMessage( - new Write, + new Write(), $write ); } @@ -259,7 +259,7 @@ public function rollback(array $args) public function runQuery(array $args) { $args['structuredQuery'] = $this->serializer->decodeMessage( - new StructuredQuery, + new StructuredQuery(), $this->pluck('structuredQuery', $args) ); $args = $this->decodeTimestamp($args); @@ -283,7 +283,7 @@ public function runAggregationQuery(array $args) ); } $args['structuredAggregationQuery'] = $this->serializer->decodeMessage( - new StructuredAggregationQuery, + new StructuredAggregationQuery(), $this->pluck('structuredAggregationQuery', $args) ); diff --git a/Firestore/src/DocumentSnapshot.php b/Firestore/src/DocumentSnapshot.php index f77cc329a9ac..ce1cea3db73a 100644 --- a/Firestore/src/DocumentSnapshot.php +++ b/Firestore/src/DocumentSnapshot.php @@ -289,7 +289,7 @@ public function get($fieldPath) $fields = $this->data; foreach ($parts as $idx => $part) { - if ($idx === $len-1 && array_key_exists($part, $fields)) { + if ($idx === $len - 1 && array_key_exists($part, $fields)) { $res = $fields[$part]; break; } else { diff --git a/Firestore/src/FirestoreSessionHandler.php b/Firestore/src/FirestoreSessionHandler.php index e3c502301a04..aba076bfe1b5 100644 --- a/Firestore/src/FirestoreSessionHandler.php +++ b/Firestore/src/FirestoreSessionHandler.php @@ -17,8 +17,8 @@ namespace Google\Cloud\Firestore; use Google\Cloud\Core\Exception\ServiceException; -use SessionHandlerInterface; use Google\Cloud\Firestore\Connection\ConnectionInterface; +use SessionHandlerInterface; /** * Custom session handler backed by Cloud Firestore. diff --git a/Firestore/src/Query.php b/Firestore/src/Query.php index 8147d7e89285..9f8fa8066df8 100644 --- a/Firestore/src/Query.php +++ b/Firestore/src/Query.php @@ -20,10 +20,7 @@ use Google\Cloud\Core\DebugInfoTrait; use Google\Cloud\Core\ExponentialBackoff; use Google\Cloud\Firestore\Connection\ConnectionInterface; -use Google\Cloud\Firestore\DocumentSnapshot; use Google\Cloud\Firestore\FieldValue\FieldValueInterface; -use Google\Cloud\Firestore\QueryTrait; -use Google\Cloud\Firestore\SnapshotTrait; use Google\Cloud\Firestore\V1\StructuredQuery\CompositeFilter\Operator; use Google\Cloud\Firestore\V1\StructuredQuery\Direction; use Google\Cloud\Firestore\V1\StructuredQuery\FieldFilter\Operator as FieldFilterOperator; @@ -1114,7 +1111,7 @@ private function createFieldFilter($fieldPath, $operator, $value) ]; } else { $encodedValue = ($operator === FieldFilterOperator::IN || $operator === FieldFilterOperator::NOT_IN) - ? $this->valueMapper->encodeMultiValue((array)$value) + ? $this->valueMapper->encodeMultiValue((array) $value) : $this->valueMapper->encodeValue($value); $filter = [ diff --git a/Firestore/src/SnapshotTrait.php b/Firestore/src/SnapshotTrait.php index 982a5af40de5..5ed0cce630d9 100644 --- a/Firestore/src/SnapshotTrait.php +++ b/Firestore/src/SnapshotTrait.php @@ -20,10 +20,9 @@ use Google\Cloud\Core\ArrayTrait; use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\Timestamp; -use Google\Cloud\Core\TimeTrait; use Google\Cloud\Core\TimestampTrait; +use Google\Cloud\Core\TimeTrait; use Google\Cloud\Firestore\Connection\ConnectionInterface; -use Google\Cloud\Firestore\DocumentReference; /** * Methods common to representing Document Snapshots. diff --git a/Firestore/src/ValueMapper.php b/Firestore/src/ValueMapper.php index 9cff16bb952a..ba128339e3c7 100644 --- a/Firestore/src/ValueMapper.php +++ b/Firestore/src/ValueMapper.php @@ -241,14 +241,14 @@ public function encodeValue($value) return ['nullValue' => NullValue::NULL_VALUE]; break; - // @codeCoverageIgnoreStart + // @codeCoverageIgnoreStart default: throw new \RuntimeException(sprintf( 'Invalid value type %s', $type )); break; - // @codeCoverageIgnoreEnd + // @codeCoverageIgnoreEnd } } @@ -296,7 +296,7 @@ private function encodeObjectValue($value) return [ 'timestampValue' => [ 'seconds' => $value->format('U'), - 'nanos' => (int)($value->format('u') * 1000) + 'nanos' => (int) ($value->format('u') * 1000) ] ]; } diff --git a/Firestore/src/WriteBatch.php b/Firestore/src/WriteBatch.php index eb1f38d03360..442054c820d0 100644 --- a/Firestore/src/WriteBatch.php +++ b/Firestore/src/WriteBatch.php @@ -18,24 +18,24 @@ namespace Google\Cloud\Firestore; if (false) { -/** - * Enqueue and write multiple mutations to Cloud Firestore. - * - * This class may be used directly for multiple non-transactional writes. To - * run changes in a transaction (with automatic retry/rollback on failure), - * use {@see \Google\Cloud\Firestore\Transaction}. Single modifications can be - * made using the various methods on {@see \Google\Cloud\Firestore\DocumentReference}. - * - * Example: - * ``` - * use Google\Cloud\Firestore\FirestoreClient; - * - * $firestore = new FirestoreClient(); - * $batch = $firestore->batch(); - * ``` - * This class is deprecated. Use Google\Cloud\Firestore\BulkWriter instead. - * @deprecated - */ + /** + * Enqueue and write multiple mutations to Cloud Firestore. + * + * This class may be used directly for multiple non-transactional writes. To + * run changes in a transaction (with automatic retry/rollback on failure), + * use {@see \Google\Cloud\Firestore\Transaction}. Single modifications can be + * made using the various methods on {@see \Google\Cloud\Firestore\DocumentReference}. + * + * Example: + * ``` + * use Google\Cloud\Firestore\FirestoreClient; + * + * $firestore = new FirestoreClient(); + * $batch = $firestore->batch(); + * ``` + * This class is deprecated. Use Google\Cloud\Firestore\BulkWriter instead. + * @deprecated + */ class WriteBatch { } diff --git a/Logging/src/LoggingClient.php b/Logging/src/LoggingClient.php index 13eb4fd4fdb8..fd092420bfb5 100644 --- a/Logging/src/LoggingClient.php +++ b/Logging/src/LoggingClient.php @@ -464,7 +464,7 @@ public function entries(array $options = []) $resourceNames = ['projects/' . $this->projectId]; if (isset($options['projectIds'])) { foreach ($options['projectIds'] as $projectId) { - $resourceNames[] = 'projects/' . $projectId; + $resourceNames[] = 'projects/' . $projectId; } unset($options['projectIds']); } diff --git a/PubSub/src/BatchPublisher.php b/PubSub/src/BatchPublisher.php index 9b16d92f6391..4fb98272e45e 100644 --- a/PubSub/src/BatchPublisher.php +++ b/PubSub/src/BatchPublisher.php @@ -17,9 +17,7 @@ namespace Google\Cloud\PubSub; -use Google\Cloud\Core\Batch\BatchRunner; use Google\Cloud\Core\Batch\BatchTrait; -use Google\Cloud\PubSub\Topic; /** * Publishes messages to Google Cloud Pub\Sub with background batching. diff --git a/PubSub/src/PubSubClient.php b/PubSub/src/PubSubClient.php index 69dcd45f31a8..b1acf1365b20 100644 --- a/PubSub/src/PubSubClient.php +++ b/PubSub/src/PubSubClient.php @@ -17,11 +17,12 @@ namespace Google\Cloud\PubSub; +use Google\ApiCore\ClientOptionsTrait; use Google\ApiCore\Serializer; use Google\Cloud\Core\ApiHelperTrait; +use Google\Cloud\Core\DetectProjectIdTrait; use Google\Cloud\Core\Duration; use Google\Cloud\Core\Exception\BadRequestException; -use Google\Cloud\Core\DetectProjectIdTrait; use Google\Cloud\Core\Iterator\ItemIterator; use Google\Cloud\Core\Iterator\PageIterator; use Google\Cloud\Core\RequestHandler; @@ -35,12 +36,10 @@ use Google\Cloud\PubSub\V1\ListSnapshotsRequest; use Google\Cloud\PubSub\V1\ListSubscriptionsRequest; use Google\Cloud\PubSub\V1\ListTopicsRequest; -use InvalidArgumentException; use Google\Cloud\PubSub\V1\Schema as SchemaProto; use Google\Cloud\PubSub\V1\Schema\Type; use Google\Cloud\PubSub\V1\ValidateMessageRequest; use Google\Cloud\PubSub\V1\ValidateSchemaRequest; -use Google\ApiCore\ClientOptionsTrait; /** * Google Cloud Pub/Sub allows you to send and receive @@ -183,7 +182,7 @@ public function __construct(array $config = []) 'transportConfig' => [ 'grpc' => [ // increase default limit to 4MB to prevent metadata exhausted errors - 'stubOpts' => ['grpc.max_metadata_size' => 4 * 1024 * 1024,] + 'stubOpts' => ['grpc.max_metadata_size' => 4 * 1024 * 1024, ] ] ] ]; diff --git a/PubSub/src/Schema.php b/PubSub/src/Schema.php index 6107c9a11900..20af85455faa 100644 --- a/PubSub/src/Schema.php +++ b/PubSub/src/Schema.php @@ -17,8 +17,8 @@ namespace Google\Cloud\PubSub; -use Google\ApiCore\Serializer; use Google\ApiCore\ArrayTrait; +use Google\ApiCore\Serializer; use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\RequestHandler; use Google\Cloud\PubSub\V1\Client\SchemaServiceClient; @@ -27,9 +27,9 @@ use Google\Cloud\PubSub\V1\DeleteSchemaRevisionRequest; use Google\Cloud\PubSub\V1\GetSchemaRequest; use Google\Cloud\PubSub\V1\ListSchemaRevisionsRequest; -use Google\Cloud\PubSub\V1\SchemaView; use Google\Cloud\PubSub\V1\Schema as SchemaProto; use Google\Cloud\PubSub\V1\Schema\Type; +use Google\Cloud\PubSub\V1\SchemaView; /** * Represents a Pub/Sub Schema resource. @@ -313,7 +313,7 @@ public function commit($definition, $type, array $options = []) */ public function deleteRevision($revisionId, $options = []) { - $revisionName = $this->name .'@' . $revisionId; + $revisionName = $this->name . '@' . $revisionId; $request = $this->serializer->decodeMessage( new DeleteSchemaRevisionRequest(), diff --git a/PubSub/src/Snapshot.php b/PubSub/src/Snapshot.php index ad02e6c2b3c1..f2ca2517b24f 100644 --- a/PubSub/src/Snapshot.php +++ b/PubSub/src/Snapshot.php @@ -17,12 +17,12 @@ namespace Google\Cloud\PubSub; -use Google\ApiCore\Serializer; use Google\ApiCore\ArrayTrait; +use Google\ApiCore\Serializer; use Google\Cloud\Core\RequestHandler; +use Google\Cloud\PubSub\V1\Client\SubscriberClient; use Google\Cloud\PubSub\V1\CreateSnapshotRequest; use Google\Cloud\PubSub\V1\DeleteSnapshotRequest; -use Google\Cloud\PubSub\V1\Client\SubscriberClient; /** * Represents a Pub/Sub Snapshot diff --git a/PubSub/src/Subscription.php b/PubSub/src/Subscription.php index d4297f1472e0..0c2a2d7a6074 100644 --- a/PubSub/src/Subscription.php +++ b/PubSub/src/Subscription.php @@ -21,28 +21,26 @@ use Google\ApiCore\Serializer; use Google\Cloud\Core\ApiHelperTrait; use Google\Cloud\Core\Duration; -use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\Exception\BadRequestException; -use Google\Cloud\Core\ExponentialBackoff; +use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\Iam\IamManager; use Google\Cloud\Core\RequestHandler; use Google\Cloud\Core\Timestamp; use Google\Cloud\Core\TimeTrait; use Google\Cloud\Core\ValidateTrait; -use Google\Cloud\PubSub\IncomingMessageTrait; use Google\Cloud\PubSub\V1\AcknowledgeRequest; use Google\Cloud\PubSub\V1\Client\PublisherClient; -use Google\Cloud\PubSub\V1\DeadLetterPolicy; -use Google\Cloud\PubSub\V1\ExpirationPolicy; -use Google\Cloud\PubSub\V1\PushConfig; -use Google\Cloud\PubSub\V1\RetryPolicy; use Google\Cloud\PubSub\V1\Client\SubscriberClient; +use Google\Cloud\PubSub\V1\DeadLetterPolicy; use Google\Cloud\PubSub\V1\DeleteSubscriptionRequest; use Google\Cloud\PubSub\V1\DetachSubscriptionRequest; +use Google\Cloud\PubSub\V1\ExpirationPolicy; use Google\Cloud\PubSub\V1\GetSubscriptionRequest; use Google\Cloud\PubSub\V1\ModifyAckDeadlineRequest; use Google\Cloud\PubSub\V1\ModifyPushConfigRequest; use Google\Cloud\PubSub\V1\PullRequest; +use Google\Cloud\PubSub\V1\PushConfig; +use Google\Cloud\PubSub\V1\RetryPolicy; use Google\Cloud\PubSub\V1\SeekRequest; use Google\Cloud\PubSub\V1\Subscription as SubscriptionProto; use Google\Cloud\PubSub\V1\UpdateSubscriptionRequest; diff --git a/PubSub/src/Topic.php b/PubSub/src/Topic.php index f15405e7b33b..98a3a1c4d522 100644 --- a/PubSub/src/Topic.php +++ b/PubSub/src/Topic.php @@ -17,26 +17,26 @@ namespace Google\Cloud\PubSub; -use Google\Cloud\Core\Exception\NotFoundException; -use Google\Cloud\Core\Iterator\ItemIterator; -use Google\Cloud\Core\Iterator\PageIterator; -use Google\Cloud\PubSub\V1\Encoding; -use InvalidArgumentException; use Google\ApiCore\Serializer; use Google\Cloud\Core\ApiHelperTrait; +use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\Iam\IamManager; -use Google\Cloud\PubSub\V1\Client\PublisherClient; -use Google\Cloud\PubSub\V1\SchemaSettings; -use Google\Protobuf\FieldMask; -use Google\Cloud\PubSub\V1\Topic as TopicProto; -use Google\Cloud\PubSub\V1\PubsubMessage; +use Google\Cloud\Core\Iterator\ItemIterator; +use Google\Cloud\Core\Iterator\PageIterator; use Google\Cloud\Core\RequestHandler; +use Google\Cloud\PubSub\V1\Client\PublisherClient; use Google\Cloud\PubSub\V1\DeleteTopicRequest; +use Google\Cloud\PubSub\V1\Encoding; use Google\Cloud\PubSub\V1\GetTopicRequest; use Google\Cloud\PubSub\V1\ListTopicSubscriptionsRequest; use Google\Cloud\PubSub\V1\MessageStoragePolicy; use Google\Cloud\PubSub\V1\PublishRequest; +use Google\Cloud\PubSub\V1\PubsubMessage; +use Google\Cloud\PubSub\V1\SchemaSettings; +use Google\Cloud\PubSub\V1\Topic as TopicProto; use Google\Cloud\PubSub\V1\UpdateTopicRequest; +use Google\Protobuf\FieldMask; +use InvalidArgumentException; /** * A named resource to which messages are sent by publishers. diff --git a/Spanner/src/Backup.php b/Spanner/src/Backup.php index 8f54a6297ba9..8c791bb1a898 100644 --- a/Spanner/src/Backup.php +++ b/Spanner/src/Backup.php @@ -17,16 +17,16 @@ namespace Google\Cloud\Spanner; +use DateTimeInterface; use Google\ApiCore\ValidationException; use Google\Cloud\Core\ArrayTrait; use Google\Cloud\Core\Exception\NotFoundException; -use Google\Cloud\Spanner\Admin\Database\V1\Backup\State; -use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient; -use Google\Cloud\Spanner\Connection\ConnectionInterface; use Google\Cloud\Core\LongRunning\LongRunningConnectionInterface; use Google\Cloud\Core\LongRunning\LongRunningOperation; use Google\Cloud\Core\LongRunning\LROTrait; -use DateTimeInterface; +use Google\Cloud\Spanner\Admin\Database\V1\Backup\State; +use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient; +use Google\Cloud\Spanner\Connection\ConnectionInterface; /** * Represents a Cloud Spanner Backup. @@ -394,7 +394,7 @@ private function fullyQualifiedBackupName($name) $instance, $name ); - //@codeCoverageIgnoreStart + //@codeCoverageIgnoreStart } catch (ValidationException $e) { return $name; } diff --git a/Spanner/src/Batch/QueryPartition.php b/Spanner/src/Batch/QueryPartition.php index a8fa0a3411ca..2b2589cde8ad 100644 --- a/Spanner/src/Batch/QueryPartition.php +++ b/Spanner/src/Batch/QueryPartition.php @@ -17,8 +17,6 @@ namespace Google\Cloud\Spanner\Batch; -use Google\Cloud\Spanner\Session\Session; - /** * Represents a Query Partition. * diff --git a/Spanner/src/Connection/Grpc.php b/Spanner/src/Connection/Grpc.php index 9f13c46e54da..bdba4de46881 100644 --- a/Spanner/src/Connection/Grpc.php +++ b/Spanner/src/Connection/Grpc.php @@ -25,9 +25,9 @@ use Google\Cloud\Core\GrpcTrait; use Google\Cloud\Core\LongRunning\OperationResponseTrait; use Google\Cloud\Spanner\Admin\Database\V1\Backup; +use Google\Cloud\Spanner\Admin\Database\V1\CopyBackupMetadata; use Google\Cloud\Spanner\Admin\Database\V1\CreateBackupEncryptionConfig; use Google\Cloud\Spanner\Admin\Database\V1\CreateBackupMetadata; -use Google\Cloud\Spanner\Admin\Database\V1\CopyBackupMetadata; use Google\Cloud\Spanner\Admin\Database\V1\CreateDatabaseMetadata; use Google\Cloud\Spanner\Admin\Database\V1\Database; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient; @@ -43,10 +43,9 @@ use Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig; use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceConfigMetadata; use Google\Cloud\Spanner\Admin\Instance\V1\UpdateInstanceMetadata; -use Google\Cloud\Spanner\MutationGroup; use Google\Cloud\Spanner\Operation; -use Google\Cloud\Spanner\SpannerClient as ManualSpannerClient; use Google\Cloud\Spanner\RequestHeaderTrait; +use Google\Cloud\Spanner\SpannerClient as ManualSpannerClient; use Google\Cloud\Spanner\V1\BatchWriteRequest\MutationGroup as MutationGroupProto; use Google\Cloud\Spanner\V1\CreateSessionRequest; use Google\Cloud\Spanner\V1\DeleteSessionRequest; @@ -68,14 +67,13 @@ use Google\Cloud\Spanner\V1\TransactionOptions\ReadWrite; use Google\Cloud\Spanner\V1\TransactionSelector; use Google\Cloud\Spanner\V1\Type; -use Google\Protobuf; use Google\Protobuf\FieldMask; use Google\Protobuf\GPBEmpty; use Google\Protobuf\Internal\RepeatedField; use Google\Protobuf\ListValue; use Google\Protobuf\Struct; -use Google\Protobuf\Value; use Google\Protobuf\Timestamp; +use Google\Protobuf\Value; use GuzzleHttp\Promise\PromiseInterface; /** @@ -588,7 +586,7 @@ public function restoreDatabase(array $args) $instanceName = $this->pluck('instance', $args); if (isset($args['encryptionConfig'])) { $args['encryptionConfig'] = $this->serializer->decodeMessage( - new RestoreDatabaseEncryptionConfig, + new RestoreDatabaseEncryptionConfig(), $this->pluck('encryptionConfig', $args) ); } @@ -634,7 +632,7 @@ public function createBackup(array $args) $instanceName = $this->pluck('instance', $args); if (isset($args['encryptionConfig'])) { $args['encryptionConfig'] = $this->serializer->decodeMessage( - new CreateBackupEncryptionConfig, + new CreateBackupEncryptionConfig(), $this->pluck('encryptionConfig', $args) ); } @@ -713,7 +711,7 @@ public function createDatabase(array $args) $instanceName = $this->pluck('instance', $args); if (isset($args['encryptionConfig'])) { $args['encryptionConfig'] = $this->serializer->decodeMessage( - new EncryptionConfig, + new EncryptionConfig(), $this->pluck('encryptionConfig', $args) ); } @@ -840,7 +838,7 @@ public function createSession(array $args) $session = $this->pluck('session', $args, false); if ($session) { $args['session'] = $this->serializer->decodeMessage( - new Session, + new Session(), array_filter( $session, function ($value) { @@ -901,7 +899,7 @@ public function createSessionAsync(array $args) public function batchCreateSessions(array $args) { $args['sessionTemplate'] = $this->serializer->decodeMessage( - new Session, + new Session(), $this->pluck('sessionTemplate', $args) ); @@ -994,7 +992,7 @@ public function executeStreamingSql(array $args) if ($queryOptions) { $args['queryOptions'] = $this->serializer->decodeMessage( - new QueryOptions, + new QueryOptions(), $queryOptions ); } @@ -1002,7 +1000,7 @@ public function executeStreamingSql(array $args) $requestOptions = $this->pluck('requestOptions', $args, false) ?: []; if ($requestOptions) { $args['requestOptions'] = $this->serializer->decodeMessage( - new RequestOptions, + new RequestOptions(), $requestOptions ); } @@ -1022,12 +1020,12 @@ public function executeStreamingSql(array $args) public function streamingRead(array $args) { $keySet = $this->pluck('keySet', $args); - $keySet = $this->serializer->decodeMessage(new KeySet, $this->formatKeySet($keySet)); + $keySet = $this->serializer->decodeMessage(new KeySet(), $this->formatKeySet($keySet)); $requestOptions = $this->pluck('requestOptions', $args, false) ?: []; if ($requestOptions) { $args['requestOptions'] = $this->serializer->decodeMessage( - new RequestOptions, + new RequestOptions(), $requestOptions ); } @@ -1057,13 +1055,13 @@ public function executeBatchDml(array $args) $statements = []; foreach ($this->pluck('statements', $args) as $statement) { $statement = $this->formatSqlParams($statement); - $statements[] = $this->serializer->decodeMessage(new Statement, $statement); + $statements[] = $this->serializer->decodeMessage(new Statement(), $statement); } $requestOptions = $this->pluck('requestOptions', $args, false) ?: []; if ($requestOptions) { $args['requestOptions'] = $this->serializer->decodeMessage( - new RequestOptions, + new RequestOptions(), $requestOptions ); } @@ -1082,7 +1080,7 @@ public function executeBatchDml(array $args) */ public function beginTransaction(array $args) { - $options = new TransactionOptions; + $options = new TransactionOptions(); $transactionOptions = $this->formatTransactionOptions($this->pluck('transactionOptions', $args)); if (isset($transactionOptions['readOnly'])) { $readOnlyClass = PHP_VERSION_ID >= 80100 @@ -1113,7 +1111,7 @@ public function beginTransaction(array $args) $requestOptions = $this->pluck('requestOptions', $args, false) ?: []; if ($requestOptions) { $args['requestOptions'] = $this->serializer->decodeMessage( - new RequestOptions, + new RequestOptions(), $requestOptions ); } @@ -1137,11 +1135,11 @@ public function commit(array $args) if (isset($args['singleUseTransaction'])) { $readWrite = $this->serializer->decodeMessage( - new ReadWrite, + new ReadWrite(), [] ); - $options = new TransactionOptions; + $options = new TransactionOptions(); $options->setReadWrite($readWrite); $args['singleUseTransaction'] = $options; } @@ -1149,7 +1147,7 @@ public function commit(array $args) $requestOptions = $this->pluck('requestOptions', $args, false) ?: []; if ($requestOptions) { $args['requestOptions'] = $this->serializer->decodeMessage( - new RequestOptions, + new RequestOptions(), $requestOptions ); } @@ -1175,17 +1173,17 @@ public function batchWrite(array $args) array_walk( $mutationGroups, - fn(&$x) => $x['mutations'] = $this->parseMutations($x['mutations']) + fn (&$x) => $x['mutations'] = $this->parseMutations($x['mutations']) ); $mutationGroups = array_map( - fn($x) => $this->serializer->decodeMessage(new MutationGroupProto(), $x), + fn ($x) => $this->serializer->decodeMessage(new MutationGroupProto(), $x), $mutationGroups ); if ($requestOptions) { $args['requestOptions'] = $this->serializer->decodeMessage( - new RequestOptions, + new RequestOptions(), $requestOptions ); } @@ -1221,7 +1219,7 @@ public function partitionQuery(array $args) $args = $this->addLarHeader($args, $this->larEnabled); $args['partitionOptions'] = $this->serializer->decodeMessage( - new PartitionOptions, + new PartitionOptions(), $this->pluck('partitionOptions', $args, false) ?: [] ); @@ -1239,13 +1237,13 @@ public function partitionQuery(array $args) public function partitionRead(array $args) { $keySet = $this->pluck('keySet', $args); - $keySet = $this->serializer->decodeMessage(new KeySet, $this->formatKeySet($keySet)); + $keySet = $this->serializer->decodeMessage(new KeySet(), $this->formatKeySet($keySet)); $args['transaction'] = $this->createTransactionSelector($args); $args = $this->addLarHeader($args, $this->larEnabled); $args['partitionOptions'] = $this->serializer->decodeMessage( - new PartitionOptions, + new PartitionOptions(), $this->pluck('partitionOptions', $args, false) ?: [] ); @@ -1327,13 +1325,13 @@ private function formatSqlParams(array $args) foreach ($params as $key => $param) { $modifiedParams[$key] = $this->fieldValue($param); } - $args['params'] = new Struct; + $args['params'] = new Struct(); $args['params']->setFields($modifiedParams); } if (isset($args['paramTypes']) && is_array($args['paramTypes'])) { foreach ($args['paramTypes'] as $key => $param) { - $args['paramTypes'][$key] = $this->serializer->decodeMessage(new Type, $param); + $args['paramTypes'][$key] = $this->serializer->decodeMessage(new Type(), $param); } } @@ -1378,7 +1376,7 @@ private function formatKeySet(array $keySet) */ private function createTransactionSelector(array &$args) { - $selector = new TransactionSelector; + $selector = new TransactionSelector(); if (isset($args['transaction'])) { $transaction = $this->pluck('transaction', $args); @@ -1499,7 +1497,7 @@ private function fieldMask($instanceArray) */ private function fieldValue($param) { - $field = new Value; + $field = new Value(); $value = $this->formatValueForApi($param); $setter = null; @@ -1522,7 +1520,7 @@ private function fieldValue($param) foreach ($param as $key => $value) { $modifiedParams[$key] = $this->fieldValue($value); } - $value = new Struct; + $value = new Struct(); $value->setFields($modifiedParams); break; @@ -1532,7 +1530,7 @@ private function fieldValue($param) foreach ($param as $item) { $modifiedParams[] = $this->fieldValue($item); } - $list = new ListValue; + $list = new ListValue(); $list->setValues($modifiedParams); $value = $list; @@ -1626,7 +1624,7 @@ private function deserializeMessageArray($message) } $className = $mapper['message']; - $response = new $className; + $response = new $className(); $response->mergeFromString($message['value']); return $this->serializer->encodeMessage($response); } @@ -1652,7 +1650,7 @@ private function setDirectedReadOptions(array &$args) $directedReadOptions = $this->pluck('directedReadOptions', $args, false); if (!empty($directedReadOptions)) { $args['directedReadOptions'] = $this->serializer->decodeMessage( - new DirectedReadOptions, + new DirectedReadOptions(), $directedReadOptions ); } @@ -1743,12 +1741,12 @@ private function parseMutations($rawMutations) } $operation = $this->serializer->decodeMessage( - new Delete, + new Delete(), $data ); break; default: - $operation = new Write; + $operation = new Write(); $operation->setTable($data['table']); $operation->setColumns($data['columns']); @@ -1757,7 +1755,7 @@ private function parseMutations($rawMutations) $modifiedData[$key] = $this->fieldValue($param); } - $list = new ListValue; + $list = new ListValue(); $list->setValues($modifiedData); $values = [$list]; $operation->setValues($values); @@ -1766,7 +1764,7 @@ private function parseMutations($rawMutations) } $setterName = $this->mutationSetters[$type]; - $mutation = new Mutation; + $mutation = new Mutation(); $mutation->$setterName($operation); $mutations[] = $mutation; } diff --git a/Spanner/src/Database.php b/Spanner/src/Database.php index d0bff4802ae2..6974f1e099a3 100644 --- a/Spanner/src/Database.php +++ b/Spanner/src/Database.php @@ -28,16 +28,14 @@ use Google\Cloud\Core\LongRunning\LongRunningOperation; use Google\Cloud\Core\LongRunning\LROTrait; use Google\Cloud\Core\Retry; -use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient; use Google\Cloud\Spanner\Admin\Database\V1\Database\State; +use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseDialect; use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient; use Google\Cloud\Spanner\Connection\ConnectionInterface; use Google\Cloud\Spanner\Connection\IamDatabase; use Google\Cloud\Spanner\Session\Session; use Google\Cloud\Spanner\Session\SessionPoolInterface; -use Google\Cloud\Spanner\Transaction; -use Google\Cloud\Spanner\V1\BatchWriteResponse; use Google\Cloud\Spanner\V1\SpannerClient as GapicSpannerClient; use Google\Cloud\Spanner\V1\TypeCode; use Google\Rpc\Code; @@ -294,7 +292,7 @@ public function state(array $options = []) */ public function backups(array $options = []) { - $filter = "database:" . $this->name(); + $filter = 'database:' . $this->name(); if (isset($options['filter'])) { $filter = sprintf('(%1$s) AND (%2$s)', $filter, $this->pluck('filter', $options)); @@ -2111,9 +2109,10 @@ public function __destruct() { try { $this->close(); - //@codingStandardsIgnoreStart - //@codeCoverageIgnoreStart - } catch (\Exception $ex) {} + //@codingStandardsIgnoreStart + //@codeCoverageIgnoreStart + } catch (\Exception $ex) { + } //@codeCoverageIgnoreEnd //@codingStandardsIgnoreStart } @@ -2268,7 +2267,7 @@ private function fullyQualifiedDatabaseName($name) $instance, $name ); - //@codeCoverageIgnoreStart + //@codeCoverageIgnoreStart } catch (ValidationException $e) { return $name; } diff --git a/Spanner/src/Instance.php b/Spanner/src/Instance.php index 2144a6fde12f..005a98cf5fbe 100644 --- a/Spanner/src/Instance.php +++ b/Spanner/src/Instance.php @@ -29,7 +29,6 @@ use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient; use Google\Cloud\Spanner\Admin\Instance\V1\Instance\State; use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient; -use Google\Cloud\Spanner\Backup; use Google\Cloud\Spanner\Connection\ConnectionInterface; use Google\Cloud\Spanner\Connection\IamInstance; use Google\Cloud\Spanner\Session\SessionPoolInterface; @@ -318,7 +317,7 @@ public function create(InstanceConfiguration $config, array $options = []) ]; if (isset($options['nodeCount']) && isset($options['processingUnits'])) { - throw new \InvalidArgumentException("Must only set either `nodeCount` or `processingUnits`"); + throw new \InvalidArgumentException('Must only set either `nodeCount` or `processingUnits`'); } if (empty($options['nodeCount']) && empty($options['processingUnits'])) { $options['nodeCount'] = self::DEFAULT_NODE_COUNT; @@ -397,7 +396,7 @@ public function state(array $options = []) public function update(array $options = []) { if (isset($options['nodeCount']) && isset($options['processingUnits'])) { - throw new \InvalidArgumentException("Must only set either `nodeCount` or `processingUnits`"); + throw new \InvalidArgumentException('Must only set either `nodeCount` or `processingUnits`'); } $operation = $this->connection->updateInstance([ @@ -770,10 +769,10 @@ public function iam() private function fullyQualifiedInstanceName($name, $project) { // try { - return InstanceAdminClient::instanceName( - $project, - $name - ); + return InstanceAdminClient::instanceName( + $project, + $name + ); // } catch (ValidationException $e) { // return $name; // } diff --git a/Spanner/src/InstanceConfiguration.php b/Spanner/src/InstanceConfiguration.php index 65e81517ffdd..da6d6fbb4f22 100644 --- a/Spanner/src/InstanceConfiguration.php +++ b/Spanner/src/InstanceConfiguration.php @@ -17,6 +17,7 @@ namespace Google\Cloud\Spanner; +use Google\ApiCore\ValidationException; use Google\Cloud\Core\ArrayTrait; use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\LongRunning\LongRunningConnectionInterface; @@ -29,7 +30,6 @@ use Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo; use Google\Cloud\Spanner\Connection\ConnectionInterface; use Google\Cloud\Spanner\Connection\LongRunningConnection; -use Google\ApiCore\ValidationException; /** * Represents a Cloud Spanner Instance Configuration. diff --git a/Spanner/src/KeySet.php b/Spanner/src/KeySet.php index ca11bceee36d..f1573f7971a0 100644 --- a/Spanner/src/KeySet.php +++ b/Spanner/src/KeySet.php @@ -102,7 +102,6 @@ public function ranges() return $this->ranges; } - /** * Add a single KeyRange. * diff --git a/Spanner/src/MutationTrait.php b/Spanner/src/MutationTrait.php index 51ca50c20789..0fd3b5b12728 100644 --- a/Spanner/src/MutationTrait.php +++ b/Spanner/src/MutationTrait.php @@ -18,7 +18,6 @@ namespace Google\Cloud\Spanner; use Google\Cloud\Core\ArrayTrait; -use Google\ApiCore\ValidationException; /** * Common helper methods used for creating array representation of diff --git a/Spanner/src/Session/CacheSessionPool.php b/Spanner/src/Session/CacheSessionPool.php index ec4a04c8e210..aeec330635e8 100644 --- a/Spanner/src/Session/CacheSessionPool.php +++ b/Spanner/src/Session/CacheSessionPool.php @@ -127,7 +127,7 @@ class CacheSessionPool implements SessionPoolInterface use SysvTrait; const CACHE_KEY_TEMPLATE = 'cache-session-pool.%s.%s.%s'; - const DURATION_SESSION_LIFETIME = 28*24*3600; // 28 days + const DURATION_SESSION_LIFETIME = 28 * 24 * 3600; // 28 days const DURATION_TWENTY_MINUTES = 1200; const DURATION_ONE_MINUTE = 60; const WINDOW_SIZE = 600; @@ -471,7 +471,7 @@ public function warmup() } $exception = null; - list ($createdSessions, $exception) = $this->createSessions(count($toCreate)); + list($createdSessions, $exception) = $this->createSessions(count($toCreate)); $this->config['lock']->synchronize(function () use ($toCreate, $createdSessions) { $item = $this->cacheItemPool->getItem($this->cacheKey); @@ -1035,7 +1035,7 @@ public function maintain() $maintainInterval = $now - $prevMaintainTime; $maxLifetime = self::SESSION_EXPIRATION_SECONDS - 600; $totalSessionsCount = min($totalSessionsCount, $maintainedSessionsCount); - $meanRefreshCount = (int)($totalSessionsCount * $maintainInterval / $maxLifetime); + $meanRefreshCount = (int) ($totalSessionsCount * $maintainInterval / $maxLifetime); $meanRefreshCount = min($meanRefreshCount, $maintainedSessionsCount); // There may be sessions already refreshed since previous maintenance, // so we can save some refresh requests. diff --git a/Spanner/src/Snapshot.php b/Spanner/src/Snapshot.php index a6d6081104f7..759bc3715f8d 100644 --- a/Spanner/src/Snapshot.php +++ b/Spanner/src/Snapshot.php @@ -18,7 +18,6 @@ namespace Google\Cloud\Spanner; use Google\Cloud\Spanner\Session\Session; -use Google\Cloud\Spanner\Session\SessionPoolInterface; /** * Read-only snapshot Transaction. @@ -60,7 +59,7 @@ public function __construct(Operation $operation, Session $session, array $optio { if (isset($options['tag'])) { throw new \InvalidArgumentException( - "Cannot set a transaction tag on a read-only transaction." + 'Cannot set a transaction tag on a read-only transaction.' ); } $this->initialize($operation, $session, $options); diff --git a/Spanner/src/SnapshotTrait.php b/Spanner/src/SnapshotTrait.php index b01850b6f277..760c978fa79d 100644 --- a/Spanner/src/SnapshotTrait.php +++ b/Spanner/src/SnapshotTrait.php @@ -19,7 +19,6 @@ use Google\Cloud\Spanner\Session\Session; use Google\Cloud\Spanner\Session\SessionPoolInterface; -use Google\Cloud\Spanner\Timestamp; /** * Common methods for Read-Only transactions (i.e. Snapshots) diff --git a/Spanner/src/SpannerClient.php b/Spanner/src/SpannerClient.php index fc67da9e5abf..6d54e44656fe 100644 --- a/Spanner/src/SpannerClient.php +++ b/Spanner/src/SpannerClient.php @@ -17,6 +17,7 @@ namespace Google\Cloud\Spanner; +use Google\ApiCore\ValidationException; use Google\Auth\FetchAuthTokenInterface; use Google\Cloud\Core\ArrayTrait; use Google\Cloud\Core\ClientTrait; @@ -29,18 +30,14 @@ use Google\Cloud\Core\ValidateTrait; use Google\Cloud\Spanner\Admin\Database\V1\DatabaseAdminClient; use Google\Cloud\Spanner\Admin\Instance\V1\InstanceAdminClient; +use Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo; use Google\Cloud\Spanner\Batch\BatchClient; use Google\Cloud\Spanner\Connection\Grpc; use Google\Cloud\Spanner\Connection\LongRunningConnection; use Google\Cloud\Spanner\Session\SessionPoolInterface; -use Google\Cloud\Spanner\Numeric; -use Google\Cloud\Spanner\Timestamp; -use Google\Cloud\Spanner\Admin\Instance\V1\InstanceConfig; -use Google\Cloud\Spanner\Admin\Instance\V1\ReplicaInfo; use Google\Cloud\Spanner\V1\SpannerClient as GapicSpannerClient; use Psr\Cache\CacheItemPoolInterface; use Psr\Http\StreamInterface; -use Google\ApiCore\ValidationException; /** * Cloud Spanner is a highly scalable, transactional, managed, NewSQL @@ -261,7 +258,7 @@ public function __construct(array $config = []) $instance = $this->instance($instanceName); return $instance->database($databaseName); } - ],[ + ], [ 'typeUrl' => 'type.googleapis.com/google.spanner.admin.instance.v1.CreateInstanceMetadata', 'callable' => function ($instance) { $name = InstanceAdminClient::parseName($instance['name'])['instance']; @@ -889,6 +886,6 @@ public function duration($seconds, $nanos = 0) */ public function commitTimestamp() { - return new CommitTimestamp; + return new CommitTimestamp(); } } diff --git a/Spanner/src/Transaction.php b/Spanner/src/Transaction.php index 0db1e79cef97..3d740cac45f3 100644 --- a/Spanner/src/Transaction.php +++ b/Spanner/src/Transaction.php @@ -122,7 +122,7 @@ public function __construct( if ($this->type == self::TYPE_SINGLE_USE && isset($tag)) { throw new \InvalidArgumentException( - "Cannot set a transaction tag on a single-use transaction." + 'Cannot set a transaction tag on a single-use transaction.' ); } $this->tag = $tag; diff --git a/Spanner/src/TransactionConfigurationTrait.php b/Spanner/src/TransactionConfigurationTrait.php index 642279a39b2d..31dfa76809c7 100644 --- a/Spanner/src/TransactionConfigurationTrait.php +++ b/Spanner/src/TransactionConfigurationTrait.php @@ -81,7 +81,7 @@ private function configureDirectedReadOptions(array $requestOptions, array $clie if (isset($requestOptions['transaction']['singleUse']) || ( isset($requestOptions['transactionContext']) && $requestOptions['transactionContext'] == SessionPoolInterface::CONTEXT_READ - ) || isset($requestOptions['transactionOptions']['readOnly']) + ) || isset($requestOptions['transactionOptions']['readOnly']) ) { if (isset($clientOptions['includeReplicas'])) { return ['includeReplicas' => $clientOptions['includeReplicas']]; diff --git a/Spanner/src/ValueMapper.php b/Spanner/src/ValueMapper.php index 57771a434d6e..542457872875 100644 --- a/Spanner/src/ValueMapper.php +++ b/Spanner/src/ValueMapper.php @@ -20,8 +20,8 @@ use Google\Cloud\Core\ArrayTrait; use Google\Cloud\Core\Int64; use Google\Cloud\Core\TimeTrait; -use Google\Cloud\Spanner\V1\TypeCode; use Google\Cloud\Spanner\V1\TypeAnnotationCode; +use Google\Cloud\Spanner\V1\TypeCode; /** * Manage value mappings between Google Cloud PHP and Cloud Spanner @@ -150,11 +150,11 @@ public function formatParamsForExecuteSql(array $parameters, array $types = []) $definition = null; if ($type) { - list ($type, $definition) = $this->resolveTypeDefinition($type, $key); + list($type, $definition) = $this->resolveTypeDefinition($type, $key); } $paramDefinition = $this->paramType($value, $type, $definition); - list ($parameters[$key], $paramTypes[$key]) = $paramDefinition; + list($parameters[$key], $paramTypes[$key]) = $paramDefinition; } return [ @@ -446,14 +446,14 @@ private function paramType( break; case 'object': - list ($type, $value) = $this->objectParam($value); + list($type, $value) = $this->objectParam($value); break; case 'array': if ($givenType === Database::TYPE_STRUCT) { if (!($definition instanceof StructType)) { throw new \InvalidArgumentException( - 'Struct parameter types must be declared explicitly, and must '. + 'Struct parameter types must be declared explicitly, and must ' . 'be an instance of Google\Cloud\Spanner\StructType.' ); } @@ -462,7 +462,7 @@ private function paramType( $value = (array) $value; } - list ($value, $type) = $this->structParam($value, $definition); + list($value, $type) = $this->structParam($value, $definition); } else { if (!($definition instanceof ArrayType)) { throw new \InvalidArgumentException( @@ -470,7 +470,7 @@ private function paramType( ); } - list ($value, $type) = $this->arrayParam($value, $definition, $allowMixedArrayType); + list($value, $type) = $this->arrayParam($value, $definition, $allowMixedArrayType); } break; @@ -691,7 +691,6 @@ private function arrayParam($value, ArrayType $arrayObj, $allowMixedArrayType = throw new \InvalidArgumentException('Array values may not be of mixed type'); } - // get typeCode either from the array type or the first element's inferred type $typeCode = self::isCustomType($arrayObj->type()) ? self::getTypeCodeFromString($arrayObj->type()) diff --git a/Storage/src/Bucket.php b/Storage/src/Bucket.php index 946245c7f4e1..450c2aa47c3c 100644 --- a/Storage/src/Bucket.php +++ b/Storage/src/Bucket.php @@ -30,7 +30,6 @@ use Google\Cloud\PubSub\Topic; use Google\Cloud\Storage\Connection\ConnectionInterface; use Google\Cloud\Storage\Connection\IamBucket; -use Google\Cloud\Storage\SigningHelper; use GuzzleHttp\Promise\PromiseInterface; use GuzzleHttp\Psr7\MimeType; use GuzzleHttp\Psr7\Utils; diff --git a/Storage/src/Connection/Rest.php b/Storage/src/Connection/Rest.php index 3e9ba793b3b6..2f89fe309a2c 100644 --- a/Storage/src/Connection/Rest.php +++ b/Storage/src/Connection/Rest.php @@ -22,13 +22,11 @@ use Google\Cloud\Core\RequestWrapper; use Google\Cloud\Core\RestTrait; use Google\Cloud\Core\Retry; -use Google\Cloud\Storage\Connection\RetryTrait; use Google\Cloud\Core\Upload\AbstractUploader; use Google\Cloud\Core\Upload\MultipartUploader; use Google\Cloud\Core\Upload\ResumableUploader; use Google\Cloud\Core\Upload\StreamableUploader; use Google\Cloud\Core\UriTrait; -use Google\Cloud\Storage\Connection\ConnectionInterface; use Google\Cloud\Storage\StorageClient; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\MimeType; diff --git a/Storage/src/EncryptionTrait.php b/Storage/src/EncryptionTrait.php index 43d66eb802a1..d57c371cbb95 100644 --- a/Storage/src/EncryptionTrait.php +++ b/Storage/src/EncryptionTrait.php @@ -133,7 +133,7 @@ protected function signString($privateKey, $data, $forceOpenssl = false) $signature = $rsa->sign($data); } elseif (class_exists(RSA2::class) && !$forceOpenssl) { - $rsa = new RSA2; + $rsa = new RSA2(); $rsa->loadKey($privateKey); $rsa->setSignatureMode(RSA2::SIGNATURE_PKCS1); $rsa->setHash('sha256'); diff --git a/Storage/src/ReadStream.php b/Storage/src/ReadStream.php index cfae74d8ed34..eddbacf89b00 100644 --- a/Storage/src/ReadStream.php +++ b/Storage/src/ReadStream.php @@ -61,7 +61,7 @@ public function getSize(): ?int private function getSizeFromMetadata(): int { foreach ($this->stream->getMetadata('wrapper_data') as $value) { - if (substr($value, 0, 15) == "Content-Length:") { + if (substr($value, 0, 15) == 'Content-Length:') { return (int) substr($value, 16); } } diff --git a/Storage/src/SigningHelper.php b/Storage/src/SigningHelper.php index 46cea73ec4c4..41acfbaf9ba1 100644 --- a/Storage/src/SigningHelper.php +++ b/Storage/src/SigningHelper.php @@ -20,10 +20,10 @@ use Google\Auth\CredentialsLoader; use Google\Auth\SignBlobInterface; use Google\Cloud\Core\ArrayTrait; +use Google\Cloud\Core\Exception\ServiceException; use Google\Cloud\Core\JsonTrait; use Google\Cloud\Core\Timestamp; use Google\Cloud\Storage\Connection\ConnectionInterface; -use Google\Cloud\Core\Exception\ServiceException; use Google\Cloud\Storage\Connection\RetryTrait; /** @@ -54,7 +54,7 @@ public static function getHelper() { static $helper; if (!$helper) { - $helper = new static; + $helper = new static(); } return $helper; @@ -343,7 +343,7 @@ public function v4Sign(ConnectionInterface $connection, $expires, $resource, $ge ]); $signature = bin2hex(base64_decode($this->retrySignBlob( - fn() => $credentials->signBlob($stringToSign, [ + fn () => $credentials->signBlob($stringToSign, [ 'forceOpenssl' => $options['forceOpenssl'] ]) ))); diff --git a/Storage/src/StreamWrapper.php b/Storage/src/StreamWrapper.php index 93d2eab0aace..630ae47c5044 100644 --- a/Storage/src/StreamWrapper.php +++ b/Storage/src/StreamWrapper.php @@ -19,7 +19,6 @@ use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\Exception\ServiceException; -use Google\Cloud\Storage\Bucket; use GuzzleHttp\Psr7\CachingStream; /** @@ -232,7 +231,7 @@ public function stream_open($path, $mode, $flags, &$openedPath) } if (isset($options['flush'])) { - $this->flushing = (bool)$options['flush']; + $this->flushing = (bool) $options['flush']; unset($options['flush']); } @@ -312,7 +311,7 @@ public function stream_read($count) public function stream_write($data) { $result = $this->stream->write($data); - $this->dirty = $this->dirty || (bool)$result; + $this->dirty = $this->dirty || (bool) $result; return $result; } @@ -458,7 +457,7 @@ public function dir_rewinddir() // since the service call returns nested results and we only // want to yield results directly within the requested directory, // check if we've already yielded this value. - if ($parts[0] === "" || in_array($parts[0], $yielded)) { + if ($parts[0] === '' || in_array($parts[0], $yielded)) { continue; } @@ -751,11 +750,11 @@ private function urlStatFile() } // equivalent to 100666 and 100444 in octal - $stats = array( + $stats = [ 'mode' => $this->bucket->isWritable() ? self::FILE_WRITABLE_MODE : self::FILE_READABLE_MODE - ); + ]; $this->statsFromFileInfo($info, $stats); return $this->makeStatArray($stats); } diff --git a/Storage/src/WriteStream.php b/Storage/src/WriteStream.php index 3cb816b2690f..28e63ba58a89 100644 --- a/Storage/src/WriteStream.php +++ b/Storage/src/WriteStream.php @@ -18,8 +18,8 @@ namespace Google\Cloud\Storage; use Google\Cloud\Core\Upload\AbstractUploader; -use GuzzleHttp\Psr7\StreamDecoratorTrait; use GuzzleHttp\Psr7\BufferStream; +use GuzzleHttp\Psr7\StreamDecoratorTrait; use Psr\Http\Message\StreamInterface; /** @@ -78,7 +78,7 @@ public function close(): void public function write($data): int { if (!isset($this->uploader)) { - throw new \RuntimeException("No uploader set."); + throw new \RuntimeException('No uploader set.'); } // Ensure we have a resume uri here because we need to create the streaming diff --git a/Trace/src/Connection/Grpc.php b/Trace/src/Connection/Grpc.php index 9fa0c013db9c..48136b3a50e3 100644 --- a/Trace/src/Connection/Grpc.php +++ b/Trace/src/Connection/Grpc.php @@ -21,8 +21,8 @@ use Google\Cloud\Core\GrpcRequestWrapper; use Google\Cloud\Core\GrpcTrait; use Google\Cloud\Trace\TraceClient; -use Google\Cloud\Trace\V2\TraceServiceClient; use Google\Cloud\Trace\V2\Span; +use Google\Cloud\Trace\V2\TraceServiceClient; /** * Implementation of the diff --git a/Trace/src/TimestampTrait.php b/Trace/src/TimestampTrait.php index 618625d319f2..39b498736f26 100644 --- a/Trace/src/TimestampTrait.php +++ b/Trace/src/TimestampTrait.php @@ -36,12 +36,12 @@ private function formatDate($when = null) return $when; } elseif (!$when) { list($usec, $sec) = explode(' ', microtime()); - $micro = sprintf("%06d", $usec * 1000000); + $micro = sprintf('%06d', $usec * 1000000); $when = new \DateTime(date('Y-m-d H:i:s.' . $micro)); } elseif (is_numeric($when)) { // Expect that this is a timestamp - $micro = sprintf("%06d", ($when - floor($when)) * 1000000); - $when = new \DateTime(date('Y-m-d H:i:s.'. $micro, (int) $when)); + $micro = sprintf('%06d', ($when - floor($when)) * 1000000); + $when = new \DateTime(date('Y-m-d H:i:s.' . $micro, (int) $when)); } $when->setTimezone(new \DateTimeZone('UTC')); return $when->format('Y-m-d\TH:i:s.u000\Z'); diff --git a/Trace/src/Trace.php b/Trace/src/Trace.php index d34db42cc3db..8f09abbf1444 100644 --- a/Trace/src/Trace.php +++ b/Trace/src/Trace.php @@ -17,7 +17,6 @@ namespace Google\Cloud\Trace; -use Google\Cloud\Core\Exception\NotFoundException; use Google\Cloud\Core\ValidateTrait; use Ramsey\Uuid\Uuid;