Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add php cs fixer from shared workflow #7647

Merged
merged 18 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
permissions:
contents: read
jobs:
style:
style_phpcs:
runs-on: ubuntu-latest
name: PHP Style Check
steps:
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion BigQuery/src/Connection/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion BigQuery/src/JobWaitTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions Bigtable/src/BigtableClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions Bigtable/src/ChunkFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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];
Expand Down
6 changes: 3 additions & 3 deletions Bigtable/src/DataUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ public static function intToByteString($intValue)
)
);
}
$bytes = pack("J", $intValue);
$bytes = pack('J', $intValue);
return $bytes;
}

Expand All @@ -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];
}
}
8 changes: 4 additions & 4 deletions Bigtable/src/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

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;
use Google\Cloud\Bigtable\Filter\Builder\OffsetFilter;
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;

Expand Down
1 change: 0 additions & 1 deletion Bigtable/src/Filter/Builder/FamilyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Bigtable/src/Filter/Builder/KeyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function sample($probability)
}

return new SimpleFilter(
(new RowFilter)->setRowSampleFilter($probability)
(new RowFilter())->setRowSampleFilter($probability)
);
}
}
4 changes: 2 additions & 2 deletions Bigtable/src/Filter/Builder/LimitFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LimitFilter
public function cellsPerRow($count)
{
return new SimpleFilter(
(new RowFilter)->setCellsPerRowLimitFilter($count)
(new RowFilter())->setCellsPerRowLimitFilter($count)
);
}

Expand All @@ -73,7 +73,7 @@ public function cellsPerRow($count)
public function cellsPerColumn($count)
{
return new SimpleFilter(
(new RowFilter)->setCellsPerColumnLimitFilter($count)
(new RowFilter())->setCellsPerColumnLimitFilter($count)
);
}
}
2 changes: 1 addition & 1 deletion Bigtable/src/Filter/Builder/OffsetFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class OffsetFilter
public function cellsPerRow($count)
{
return new SimpleFilter(
(new RowFilter)->setCellsPerRowOffsetFilter($count)
(new RowFilter())->setCellsPerRowOffsetFilter($count)
);
}
}
1 change: 0 additions & 1 deletion Bigtable/src/Filter/Builder/QualifierFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Bigtable/src/Filter/Builder/RegexTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ trait RegexTrait
private function buildRegexFilter($value, $setter)
{
return new SimpleFilter(
(new RowFilter)->$setter($value)
(new RowFilter())->$setter($value)
);
}

Expand Down
2 changes: 1 addition & 1 deletion Bigtable/src/Filter/Builder/ValueFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function range()
public function strip()
{
return new SimpleFilter(
(new RowFilter)->setStripValueTransformer(true)
(new RowFilter())->setStripValueTransformer(true)
);
}
}
4 changes: 2 additions & 2 deletions Bigtable/src/Filter/ChainFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions Bigtable/src/Filter/ConditionFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ public function toProto()
)
);
}
$condition = (new Condition)
$condition = (new Condition())
->setPredicateFilter($this->predicateFilter);
if ($this->trueFilter) {
$condition->setTrueFilter($this->trueFilter);
}
if ($this->falseFilter) {
$condition->setFalseFilter($this->falseFilter);
}
return (new RowFilter)
return (new RowFilter())
->setCondition($condition);
}
}
4 changes: 2 additions & 2 deletions Bigtable/src/Filter/InterleaveFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
16 changes: 8 additions & 8 deletions Bigtable/src/Mutations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
}

Expand All @@ -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;
}
Expand All @@ -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']);
}
Expand All @@ -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;
}

Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions Bigtable/src/ReadModifyWriteRowRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Bigtable/src/ResumableStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ?? [];

Expand Down
Loading
Loading