Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Implicitly marking parameter as nullable is deprecated #2638

Merged
merged 2 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AccessToken/Revoke.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Revoke
* Instantiates the class, but does not initiate the login flow, leaving it
* to the discretion of the caller.
*/
public function __construct(ClientInterface $http = null)
public function __construct(?ClientInterface $http = null)
{
$this->http = $http;
}
Expand Down
18 changes: 9 additions & 9 deletions src/AccessToken/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ class Verify

/**
* @var \Firebase\JWT\JWT
*/
*/
public $jwt;

/**
* Instantiates the class, but does not initiate the login flow, leaving it
* to the discretion of the caller.
*/
public function __construct(
ClientInterface $http = null,
CacheItemPoolInterface $cache = null,
$jwt = null
?ClientInterface $http = null,
?CacheItemPoolInterface $cache = null,
?string $jwt = null
) {
if (null === $http) {
$http = new Client();
Expand Down Expand Up @@ -130,7 +130,7 @@ public function verifyIdToken($idToken, $audience = null)
return false;
}

return (array) $payload;
return (array)$payload;
} catch (ExpiredException $e) { // @phpstan-ignore-line
return false;
} catch (ExpiredExceptionV3 $e) {
Expand All @@ -154,17 +154,17 @@ private function getCache()
* Retrieve and cache a certificates file.
*
* @param string $url location
* @throws \Google\Exception
* @return array certificates
* @throws \Google\Exception
*/
private function retrieveCertsFromLocation($url)
{
// If we're retrieving a local file, just grab it.
if (0 !== strpos($url, 'http')) {
if (!$file = file_get_contents($url)) {
throw new GoogleException(
"Failed to retrieve verification certificates: '" .
$url . "'."
"Failed to retrieve verification certificates: '".
$url."'."
);
}

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

if ($response->getStatusCode() == 200) {
return json_decode((string) $response->getBody(), true);
return json_decode((string)$response->getBody(), true);
}
throw new GoogleException(
sprintf(
Expand Down
6 changes: 3 additions & 3 deletions src/AuthHandler/Guzzle6AuthHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Guzzle6AuthHandler
protected $cache;
protected $cacheConfig;

public function __construct(CacheItemPoolInterface $cache = null, array $cacheConfig = [])
public function __construct(?CacheItemPoolInterface $cache = null, array $cacheConfig = [])
{
$this->cache = $cache;
$this->cacheConfig = $cacheConfig;
Expand All @@ -29,7 +29,7 @@ public function __construct(CacheItemPoolInterface $cache = null, array $cacheCo
public function attachCredentials(
ClientInterface $http,
CredentialsLoader $credentials,
callable $tokenCallback = null
?callable $tokenCallback = null
) {
// use the provided cache
if ($this->cache) {
Expand All @@ -46,7 +46,7 @@ public function attachCredentials(
public function attachCredentialsCache(
ClientInterface $http,
FetchAuthTokenCache $credentials,
callable $tokenCallback = null
?callable $tokenCallback = null
) {
// if we end up needing to make an HTTP request to retrieve credentials, we
// can use our existing one, but we need to throw exceptions so the error
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public function refreshTokenWithAssertion()
* @param ClientInterface $authHttp optional.
* @return array access token
*/
public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null)
public function fetchAccessTokenWithAssertion(?ClientInterface $authHttp = null)
{
if (!$this->isUsingApplicationDefaultCredentials()) {
throw new DomainException(
Expand Down Expand Up @@ -454,7 +454,7 @@ public function createAuthUrl($scope = null, array $queryParams = [])
* @param ClientInterface $http the http client object.
* @return ClientInterface the http client object
*/
public function authorize(ClientInterface $http = null)
public function authorize(?ClientInterface $http = null)
{
$http = $http ?: $this->getHttpClient();
$authHandler = $this->getAuthHandler();
Expand Down
14 changes: 7 additions & 7 deletions src/Http/REST.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function execute(
) {
$runner = new Runner(
$config,
sprintf('%s %s', $request->getMethod(), (string) $request->getUri()),
sprintf('%s %s', $request->getMethod(), (string)$request->getUri()),
[self::class, 'doExecute'],
[$client, $request, $expectedClass]
);
Expand Down Expand Up @@ -120,15 +120,15 @@ interface_exists('\GuzzleHttp\Message\ResponseInterface')
*/
public static function decodeHttpResponse(
ResponseInterface $response,
RequestInterface $request = null,
?RequestInterface $request = null,
$expectedClass = null
) {
$code = $response->getStatusCode();

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

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

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

return (string) $response->getBody();
return (string)$response->getBody();
}

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

private static function isAltMedia(RequestInterface $request = null)
private static function isAltMedia(?RequestInterface $request = null)
{
if ($request && $qs = $request->getUri()->getQuery()) {
parse_str($qs, $query);
Expand Down
2 changes: 1 addition & 1 deletion src/Service/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Exception extends GoogleException
public function __construct(
$message,
$code = 0,
Exception $previous = null,
?Exception $previous = null,
$errors = []
) {
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Task/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Composer
*/
public static function cleanup(
Event $event,
Filesystem $filesystem = null
?Filesystem $filesystem = null
) {
$composer = $event->getComposer();
$extra = $composer->getPackage()->getExtra();
Expand Down
Loading