Skip to content

Commit dd5f6ef

Browse files
authored
chore: updates from new cs rules (#577)
1 parent 257ba33 commit dd5f6ef

14 files changed

Lines changed: 49 additions & 39 deletions

.github/workflows/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint
2+
on:
3+
push:
4+
branches: [ main ]
5+
pull_request:
6+
7+
permissions:
8+
contents: read
9+
jobs:
10+
style:
11+
name: PHP Style Check
12+
uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@main
13+
14+
staticanalysis:
15+
name: PHPStan Static Analysis
16+
uses: GoogleCloudPlatform/php-tools/.github/workflows/static-analysis.yml@main
17+
with:
18+
autoload-file: tests/phpstan-autoload.php

.github/workflows/tests.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,3 @@ jobs:
4949
command: composer update --prefer-lowest
5050
- name: Run Script
5151
run: vendor/bin/phpunit
52-
53-
style:
54-
name: PHP Style Check
55-
uses: GoogleCloudPlatform/php-tools/.github/workflows/code-standards.yml@main
56-
57-
staticanalysis:
58-
name: PHPStan Static Analysis
59-
uses: GoogleCloudPlatform/php-tools/.github/workflows/static-analysis.yml@main
60-
with:
61-
autoload-file: tests/phpstan-autoload.php

src/CredentialSource/AwsNativeSource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function fetchSubjectToken(callable $httpHandler = null): string
103103
$headers['x-goog-cloud-target-resource'] = $this->audience;
104104

105105
// Format headers as they're expected in the subject token
106-
$formattedHeaders= array_map(
106+
$formattedHeaders = array_map(
107107
fn ($k, $v) => ['key' => $k, 'value' => $v],
108108
array_keys($headers),
109109
$headers,

src/Credentials/GCECredentials.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,12 +426,12 @@ private static function detectResidencyWindows(string $registryProductKey): bool
426426

427427
try {
428428
$productName = $shell->regRead($registryProductKey);
429-
} catch(com_exception) {
429+
} catch (com_exception) {
430430
// This means that we tried to read a key that doesn't exist on the registry
431431
// which might mean that it is a windows instance that is not on GCE
432432
return false;
433433
}
434-
434+
435435
return 0 === strpos($productName, self::PRODUCT_NAME);
436436
}
437437

src/Middleware/AuthTokenMiddleware.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ private function addAuthHeaders(RequestInterface $request)
132132
) {
133133
$token = $this->fetcher->fetchAuthToken();
134134
$request = $request->withHeader(
135-
'authorization', 'Bearer ' . ($token['access_token'] ?? $token['id_token'] ?? '')
135+
'authorization',
136+
'Bearer ' . ($token['access_token'] ?? $token['id_token'] ?? '')
136137
);
137138
} else {
138139
$headers = $this->fetcher->updateMetadata($request->getHeaders(), null, $this->httpHandler);

src/OAuth2.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ public function getSubjectTokenFetcher(): ?ExternalAccountCredentialSourceInterf
724724
*/
725725
public function parseTokenResponse(ResponseInterface $resp)
726726
{
727-
$body = (string)$resp->getBody();
727+
$body = (string) $resp->getBody();
728728
if ($resp->hasHeader('Content-Type') &&
729729
$resp->getHeaderLine('Content-Type') == 'application/x-www-form-urlencoded'
730730
) {
@@ -1009,13 +1009,13 @@ public function setRedirectUri($uri)
10091009
if (!$this->isAbsoluteUri($uri)) {
10101010
// "postmessage" is a reserved URI string in Google-land
10111011
// @see https://developers.google.com/identity/sign-in/web/server-side-flow
1012-
if ('postmessage' !== (string)$uri) {
1012+
if ('postmessage' !== (string) $uri) {
10131013
throw new InvalidArgumentException(
10141014
'Redirect URI must be absolute'
10151015
);
10161016
}
10171017
}
1018-
$this->redirectUri = (string)$uri;
1018+
$this->redirectUri = (string) $uri;
10191019
}
10201020

10211021
/**
@@ -1127,7 +1127,7 @@ public function setGrantType($grantType)
11271127
'invalid grant type'
11281128
);
11291129
}
1130-
$this->grantType = (string)$grantType;
1130+
$this->grantType = (string) $grantType;
11311131
}
11321132
}
11331133

@@ -1460,7 +1460,7 @@ public function setExpiresIn($expiresIn)
14601460
$this->issuedAt = null;
14611461
} else {
14621462
$this->issuedAt = time();
1463-
$this->expiresIn = (int)$expiresIn;
1463+
$this->expiresIn = (int) $expiresIn;
14641464
}
14651465
}
14661466

@@ -1768,7 +1768,8 @@ private function getFirebaseJwtKeys($publicKey, $allowedAlgs)
17681768
throw new \InvalidArgumentException(
17691769
'To have multiple allowed algorithms, You must provide an'
17701770
. ' array of Firebase\JWT\Key objects.'
1771-
. ' See https://github.com/firebase/php-jwt for more information.');
1771+
. ' See https://github.com/firebase/php-jwt for more information.'
1772+
);
17721773
}
17731774
$allowedAlg = array_pop($allowedAlgs);
17741775
} else {

tests/ApplicationDefaultCredentialsTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ public function testImpersonatedServiceAccountCredentials()
168168
);
169169
$this->assertInstanceOf(
170170
'Google\Auth\Credentials\ImpersonatedServiceAccountCredentials',
171-
$creds);
171+
$creds
172+
);
172173

173174
$this->assertEquals('service_account_name@namespace.iam.gserviceaccount.com', $creds->getClientName());
174175

@@ -179,7 +180,8 @@ public function testImpersonatedServiceAccountCredentials()
179180
$sourceCredentials = $sourceCredentialsProperty->getValue($creds);
180181
$this->assertInstanceOf(
181182
'Google\Auth\Credentials\UserRefreshCredentials',
182-
$sourceCredentials);
183+
$sourceCredentials
184+
);
183185
}
184186

185187
public function testUserRefreshCredentials()

tests/Cache/FileSystemCacheItemPoolTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function tearDown(): void
4343
{
4444
$files = scandir($this->defaultCacheDirectory);
4545

46-
foreach($files as $fileName) {
46+
foreach ($files as $fileName) {
4747
if ($fileName === '.' || $fileName === '..') {
4848
continue;
4949
}

tests/CredentialSource/FileSourceTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public function provideFetchSubjectToken()
4545
$file1 = tempnam(sys_get_temp_dir(), 'test1');
4646
file_put_contents($file1, 'abc');
4747

48-
4948
$file2 = tempnam(sys_get_temp_dir(), 'test2');
5049
file_put_contents($file2, json_encode(['token' => 'def']));
5150

tests/Credentials/ExternalAccountCredentialsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ public function testUrlSourceCacheKey()
561561
$expectedKey = 'fakeUrl.scope1...';
562562
$this->assertEquals($expectedKey, $cacheKey);
563563
}
564-
564+
565565
public function testExecutableSourceCacheKey()
566566
{
567567
$this->baseCreds['credential_source'] = [

0 commit comments

Comments
 (0)