diff --git a/src/ApplicationDefaultCredentials.php b/src/ApplicationDefaultCredentials.php index c2cf66e39..2b94b4b86 100644 --- a/src/ApplicationDefaultCredentials.php +++ b/src/ApplicationDefaultCredentials.php @@ -366,9 +366,9 @@ private static function onGce( */ public static function getDefaultLogger(): null|LoggerInterface { - $loggingFlag = getenv(self::SDK_DEBUG_FLAG); + $loggingFlag = (string)getenv(self::SDK_DEBUG_FLAG); - if (!$loggingFlag || strtolower(getenv((string) $loggingFlag)) !== 'true') { + if (!$loggingFlag || strtolower($loggingFlag) !== 'true') { return null; } diff --git a/src/HttpHandler/Guzzle6HttpHandler.php b/src/HttpHandler/Guzzle6HttpHandler.php index a47ceee15..25f952c50 100644 --- a/src/HttpHandler/Guzzle6HttpHandler.php +++ b/src/HttpHandler/Guzzle6HttpHandler.php @@ -21,7 +21,7 @@ use GuzzleHttp\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use Psr\log\LoggerInterface; +use Psr\Log\LoggerInterface; class Guzzle6HttpHandler { @@ -76,7 +76,7 @@ public function async(RequestInterface $request, array $options = []) $requestEvent->method = $request->getMethod(); $requestEvent->url = $request->getUri()->__toString(); $requestEvent->headers = $request->getHeaders(); - $requestEvent->payload = json_encode($request->getBody()->getContents()); + $requestEvent->payload = json_encode($request->getBody()->getContents()) ?? null; $requestEvent->retryAttempt = $options['retryAttempt'] ?? null; $this->logRequest($requestEvent); @@ -87,8 +87,8 @@ public function async(RequestInterface $request, array $options = []) $responseEvent = new LogEvent($requestEvent->timestamp); $responseEvent->headers = $response->getHeaders(); - $responseEvent->payload = json_encode($response->getBody()->getContents()); - $response->status = $response->getStatusCode(); + $responseEvent->payload = json_encode($response->getBody()->getContents()) ?? null; + $responseEvent->status = $response->getStatusCode(); $this->logResponse($responseEvent); } diff --git a/src/Logger/LoggingTrait.php b/src/Logger/LoggingTrait.php index 83ba46509..c702cb4af 100644 --- a/src/Logger/LoggingTrait.php +++ b/src/Logger/LoggingTrait.php @@ -85,7 +85,7 @@ private function logResponse(LogEvent $event): void /** * @param array $headers - * @return null|array + * @return null|array */ private function getJwtToken(array $headers): null|array {