Skip to content

Commit 2ac36b2

Browse files
fix: handle Guzzle 8 client config and drop stale phpstan ignore
1 parent d706b2c commit 2ac36b2

2 files changed

Lines changed: 13 additions & 12 deletions

File tree

phpstan.neon.dist

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,3 @@ parameters:
33
level: 5
44
paths:
55
- src
6-
ignoreErrors:
7-
# On Guzzle 7 the base RequestException has getResponse(), so the
8-
# method_exists() guard is statically true; it stays for the Guzzle 8
9-
# code path, where the response lives only on the ResponseException
10-
# subclass.
11-
-
12-
message: '#^Call to function method_exists\(\) with GuzzleHttp\\Exception\\RequestException and ''getResponse'' will always evaluate to true\.$#'
13-
path: src/Http/REST.php

src/AuthHandler/Guzzle6AuthHandler.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ private function attachToHttp(
6767
$tokenCallback
6868
);
6969

70-
$config = $http->getConfig();
70+
$config = $this->getClientConfig($http);
7171
$config['handler']->remove('google_auth');
7272
$config['handler']->push($middleware, 'google_auth');
7373
$config['auth'] = 'google_auth';
@@ -95,7 +95,7 @@ public function attachToken(ClientInterface $http, array $token, array $scopes)
9595
$this->cache
9696
);
9797

98-
$config = $http->getConfig();
98+
$config = $this->getClientConfig($http);
9999
$config['handler']->remove('google_auth');
100100
$config['handler']->push($middleware, 'google_auth');
101101
$config['auth'] = 'scoped';
@@ -108,7 +108,7 @@ public function attachKey(ClientInterface $http, $key)
108108
{
109109
$middleware = new SimpleMiddleware(['key' => $key]);
110110

111-
$config = $http->getConfig();
111+
$config = $this->getClientConfig($http);
112112
$config['handler']->remove('google_auth');
113113
$config['handler']->push($middleware, 'google_auth');
114114
$config['auth'] = 'simple';
@@ -119,6 +119,15 @@ public function attachKey(ClientInterface $http, $key)
119119

120120
private function createAuthHttp(ClientInterface $http)
121121
{
122-
return new Client(['http_errors' => true] + $http->getConfig());
122+
return new Client(['http_errors' => true] + $this->getClientConfig($http));
123+
}
124+
125+
/**
126+
* getConfig() was removed from ClientInterface in Guzzle 8 but remains on
127+
* the concrete Client, which is what these handlers operate on.
128+
*/
129+
private function getClientConfig(ClientInterface $http): array
130+
{
131+
return $http instanceof Client ? $http->getConfig() : [];
123132
}
124133
}

0 commit comments

Comments
 (0)