From 21014091137e728332d6ed608fd80c546233182e Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 4 Sep 2024 12:29:04 -0700 Subject: [PATCH 1/3] chore: test added cs fixer rules --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9dae6dfa3..4f9c4f415 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -44,7 +44,7 @@ jobs: style: name: PHP Style Check - uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@main + uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@add-rules-for-cs-fixer with: path: src From cd3b78b47a2a048d457f09008556ee5376b6e9e6 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Wed, 4 Sep 2024 12:54:33 -0700 Subject: [PATCH 2/3] add lint workflow, fix cs --- .github/workflows/lint.yml | 18 ++++++++++++++++++ .github/workflows/tests.yml | 10 ---------- src/GapicClientTrait.php | 2 +- src/Testing/MockClientStreamingCall.php | 2 +- src/Transport/GrpcFallbackTransport.php | 2 +- src/Transport/Rest/JsonStreamDecoder.php | 4 ++-- 6 files changed, 23 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..fa8ce82ee --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,18 @@ +name: Lint +on: + push: + branches: + - main + pull_request: +permissions: + contents: read +jobs: + style: + name: PHP Style Check + uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@add-rules-for-cs-fixer + with: + path: src + + static-analysis: + name: PHPStan Static Analysis + uses: GoogleCloudPlatform/php-tools/.github/workflows/static-analysis.yml@main diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4f9c4f415..123c88bd2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,13 +41,3 @@ jobs: command: composer update ${{ matrix.composerflags }} - name: Run script run: vendor/bin/phpunit - - style: - name: PHP Style Check - uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@add-rules-for-cs-fixer - with: - path: src - - static-analysis: - name: PHPStan Static Analysis - uses: GoogleCloudPlatform/php-tools/.github/workflows/static-analysis.yml@main diff --git a/src/GapicClientTrait.php b/src/GapicClientTrait.php index 195b06f6d..ebacb3bc7 100644 --- a/src/GapicClientTrait.php +++ b/src/GapicClientTrait.php @@ -515,7 +515,7 @@ private function startApiCall( Message $request = null, array $optionalArgs = [] ) { - $methodDescriptors =$this->validateCallConfig($methodName); + $methodDescriptors = $this->validateCallConfig($methodName); $callType = $methodDescriptors['callType']; // Prepare request-based headers, merge with user-provided headers, diff --git a/src/Testing/MockClientStreamingCall.php b/src/Testing/MockClientStreamingCall.php index c7cb8696f..439a547e9 100644 --- a/src/Testing/MockClientStreamingCall.php +++ b/src/Testing/MockClientStreamingCall.php @@ -86,7 +86,7 @@ public function wait() public function write($request, array $options = []) { if ($this->waitCalled) { - throw new ApiException('Cannot call write() after wait()', Code::INTERNAL, ApiStatus::INTERNAL); + throw new ApiException('Cannot call write() after wait()', Code::INTERNAL, ApiStatus::INTERNAL); } if (is_a($request, '\Google\Protobuf\Internal\Message')) { /** @var Message $newRequest */ diff --git a/src/Transport/GrpcFallbackTransport.php b/src/Transport/GrpcFallbackTransport.php index c20f3c0b1..808c176c7 100644 --- a/src/Transport/GrpcFallbackTransport.php +++ b/src/Transport/GrpcFallbackTransport.php @@ -160,7 +160,7 @@ private function unpackResponse(Call $call, ResponseInterface $response) $decodeType = $call->getDecodeType(); /** @var Message $responseMessage */ $responseMessage = new $decodeType(); - $responseMessage->mergeFromString((string)$response->getBody()); + $responseMessage->mergeFromString((string) $response->getBody()); return $responseMessage; } diff --git a/src/Transport/Rest/JsonStreamDecoder.php b/src/Transport/Rest/JsonStreamDecoder.php index b173cf3a1..c01f21135 100644 --- a/src/Transport/Rest/JsonStreamDecoder.php +++ b/src/Transport/Rest/JsonStreamDecoder.php @@ -164,7 +164,7 @@ private function _decode() if ($b === '}' && !$str) { $level--; if ($level === 1) { - $end = $cursor+1; + $end = $cursor + 1; } } // Track the closing of an array if not in a string value. @@ -195,7 +195,7 @@ private function _decode() // Dump the part of the chunk used for parsing the message // and use the remaining for the next message. - $remaining = $chunkLength-$length; + $remaining = $chunkLength - $length; $chunk = substr($chunk, $end, $remaining); // Reset all indices and exit chunk processing. From 8f5bdc068963a37258286a8b4da36f1e7061fe63 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Thu, 5 Sep 2024 13:17:16 -0600 Subject: [PATCH 3/3] Update .github/workflows/lint.yml --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fa8ce82ee..3a6cd59c5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,7 +9,7 @@ permissions: jobs: style: name: PHP Style Check - uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@add-rules-for-cs-fixer + uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@main with: path: src