Skip to content
Draft
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
31 changes: 22 additions & 9 deletions src/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down