From 100008de3426259ff282a8047eaa4bec900076fe Mon Sep 17 00:00:00 2001 From: Tim Kelty Date: Tue, 4 Feb 2025 14:12:01 -0500 Subject: [PATCH] Silence known deprecations from http-signatures package --- src/Helper.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Helper.php b/src/Helper.php index 0047f02..9ffd7bd 100644 --- a/src/Helper.php +++ b/src/Helper.php @@ -44,16 +44,29 @@ public static function makeGatewayApiRequest(iterable $headers): ResponseInterfa throw new Exception('Gateway API requests require a URL.'); } - $context = Helper::createSigningContext($headers->keys()); - $request = new Request( - 'HEAD', - (string) $url, - $headers->all(), - ); + // Silence known dynamic property deprecations from HttpSignatures + return self::withoutDeprecationErrors(function() use ($headers, $url) { + $context = Helper::createSigningContext($headers->keys()); + $request = new Request( + 'HEAD', + (string) $url, + $headers->all(), + ); - return Craft::createGuzzleClient()->send( - $context->signer()->sign($request) - ); + return Craft::createGuzzleClient()->send( + $context->signer()->sign($request) + ); + }); + } + + private static function withoutDeprecationErrors(callable $callback): mixed + { + $errorLevel = error_reporting(error_reporting()); + error_reporting($errorLevel & ~E_DEPRECATED); + $return = $callback(); + error_reporting($errorLevel); + + return $return; } private static function createSigningContext(iterable $headers = []): Context