Skip to content

Commit de57db2

Browse files
authored
fix: Implicitly marking parameter as nullable is deprecated (#2638)
1 parent 846f149 commit de57db2

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

src/AccessToken/Revoke.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Revoke
3939
* Instantiates the class, but does not initiate the login flow, leaving it
4040
* to the discretion of the caller.
4141
*/
42-
public function __construct(ClientInterface $http = null)
42+
public function __construct(?ClientInterface $http = null)
4343
{
4444
$this->http = $http;
4545
}

src/AccessToken/Verify.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ class Verify
5959

6060
/**
6161
* @var \Firebase\JWT\JWT
62-
*/
62+
*/
6363
public $jwt;
6464

6565
/**
6666
* Instantiates the class, but does not initiate the login flow, leaving it
6767
* to the discretion of the caller.
6868
*/
6969
public function __construct(
70-
ClientInterface $http = null,
71-
CacheItemPoolInterface $cache = null,
72-
$jwt = null
70+
?ClientInterface $http = null,
71+
?CacheItemPoolInterface $cache = null,
72+
?string $jwt = null
7373
) {
7474
if (null === $http) {
7575
$http = new Client();
@@ -130,7 +130,7 @@ public function verifyIdToken($idToken, $audience = null)
130130
return false;
131131
}
132132

133-
return (array) $payload;
133+
return (array)$payload;
134134
} catch (ExpiredException $e) { // @phpstan-ignore-line
135135
return false;
136136
} catch (ExpiredExceptionV3 $e) {
@@ -154,17 +154,17 @@ private function getCache()
154154
* Retrieve and cache a certificates file.
155155
*
156156
* @param string $url location
157-
* @throws \Google\Exception
158157
* @return array certificates
158+
* @throws \Google\Exception
159159
*/
160160
private function retrieveCertsFromLocation($url)
161161
{
162162
// If we're retrieving a local file, just grab it.
163163
if (0 !== strpos($url, 'http')) {
164164
if (!$file = file_get_contents($url)) {
165165
throw new GoogleException(
166-
"Failed to retrieve verification certificates: '" .
167-
$url . "'."
166+
"Failed to retrieve verification certificates: '".
167+
$url."'."
168168
);
169169
}
170170

@@ -175,7 +175,7 @@ private function retrieveCertsFromLocation($url)
175175
$response = $this->http->get($url);
176176

177177
if ($response->getStatusCode() == 200) {
178-
return json_decode((string) $response->getBody(), true);
178+
return json_decode((string)$response->getBody(), true);
179179
}
180180
throw new GoogleException(
181181
sprintf(

src/AuthHandler/Guzzle6AuthHandler.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Guzzle6AuthHandler
2020
protected $cache;
2121
protected $cacheConfig;
2222

23-
public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
23+
public function __construct(?CacheItemPoolInterface $cache = null, array $cacheConfig = [])
2424
{
2525
$this->cache = $cache;
2626
$this->cacheConfig = $cacheConfig;
@@ -29,7 +29,7 @@ public function __construct(CacheItemPoolInterface $cache = null, array $cacheCo
2929
public function attachCredentials(
3030
ClientInterface $http,
3131
CredentialsLoader $credentials,
32-
callable $tokenCallback = null
32+
?callable $tokenCallback = null
3333
) {
3434
// use the provided cache
3535
if ($this->cache) {
@@ -46,7 +46,7 @@ public function attachCredentials(
4646
public function attachCredentialsCache(
4747
ClientInterface $http,
4848
FetchAuthTokenCache $credentials,
49-
callable $tokenCallback = null
49+
?callable $tokenCallback = null
5050
) {
5151
// if we end up needing to make an HTTP request to retrieve credentials, we
5252
// can use our existing one, but we need to throw exceptions so the error

src/Client.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public function refreshTokenWithAssertion()
321321
* @param ClientInterface $authHttp optional.
322322
* @return array access token
323323
*/
324-
public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null)
324+
public function fetchAccessTokenWithAssertion(?ClientInterface $authHttp = null)
325325
{
326326
if (!$this->isUsingApplicationDefaultCredentials()) {
327327
throw new DomainException(
@@ -454,7 +454,7 @@ public function createAuthUrl($scope = null, array $queryParams = [])
454454
* @param ClientInterface $http the http client object.
455455
* @return ClientInterface the http client object
456456
*/
457-
public function authorize(ClientInterface $http = null)
457+
public function authorize(?ClientInterface $http = null)
458458
{
459459
$http = $http ?: $this->getHttpClient();
460460
$authHandler = $this->getAuthHandler();

src/Http/REST.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function execute(
5454
) {
5555
$runner = new Runner(
5656
$config,
57-
sprintf('%s %s', $request->getMethod(), (string) $request->getUri()),
57+
sprintf('%s %s', $request->getMethod(), (string)$request->getUri()),
5858
[self::class, 'doExecute'],
5959
[$client, $request, $expectedClass]
6060
);
@@ -120,15 +120,15 @@ interface_exists('\GuzzleHttp\Message\ResponseInterface')
120120
*/
121121
public static function decodeHttpResponse(
122122
ResponseInterface $response,
123-
RequestInterface $request = null,
123+
?RequestInterface $request = null,
124124
$expectedClass = null
125125
) {
126126
$code = $response->getStatusCode();
127127

128128
// retry strategy
129129
if (intVal($code) >= 400) {
130130
// if we errored out, it should be safe to grab the response body
131-
$body = (string) $response->getBody();
131+
$body = (string)$response->getBody();
132132

133133
// Check if we received errors, and add those to the Exception for convenience
134134
throw new GoogleServiceException($body, $code, null, self::getResponseErrors($body));
@@ -147,17 +147,17 @@ public static function decodeHttpResponse(
147147
return $response;
148148
}
149149

150-
private static function decodeBody(ResponseInterface $response, RequestInterface $request = null)
150+
private static function decodeBody(ResponseInterface $response, ?RequestInterface $request = null)
151151
{
152152
if (self::isAltMedia($request)) {
153153
// don't decode the body, it's probably a really long string
154154
return '';
155155
}
156156

157-
return (string) $response->getBody();
157+
return (string)$response->getBody();
158158
}
159159

160-
private static function determineExpectedClass($expectedClass, RequestInterface $request = null)
160+
private static function determineExpectedClass($expectedClass, ?RequestInterface $request = null)
161161
{
162162
// "false" is used to explicitly prevent an expected class from being returned
163163
if (false === $expectedClass) {
@@ -184,7 +184,7 @@ private static function getResponseErrors($body)
184184
return null;
185185
}
186186

187-
private static function isAltMedia(RequestInterface $request = null)
187+
private static function isAltMedia(?RequestInterface $request = null)
188188
{
189189
if ($request && $qs = $request->getUri()->getQuery()) {
190190
parse_str($qs, $query);

src/Service/Exception.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Exception extends GoogleException
3939
public function __construct(
4040
$message,
4141
$code = 0,
42-
Exception $previous = null,
42+
?Exception $previous = null,
4343
$errors = []
4444
) {
4545
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {

src/Task/Composer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Composer
3030
*/
3131
public static function cleanup(
3232
Event $event,
33-
Filesystem $filesystem = null
33+
?Filesystem $filesystem = null
3434
) {
3535
$composer = $event->getComposer();
3636
$extra = $composer->getPackage()->getExtra();

0 commit comments

Comments
 (0)