diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 000000000..3a6cd59c5 --- /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@main + 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 9dae6dfa3..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@main - 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.