From a0d86054e666aa195d28c85cb2675ca70054c678 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 18 Apr 2024 16:01:11 +0300 Subject: [PATCH 1/2] CS fix --- lib/Factory.php | 8 ++++---- lib/RetryMiddlewareFactory.php | 8 ++++---- tests/Unit/Utils/SignatureTest.php | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Factory.php b/lib/Factory.php index 18155f91..4b2055cf 100644 --- a/lib/Factory.php +++ b/lib/Factory.php @@ -11,12 +11,12 @@ */ class Factory { - public static function create(ClientInterface $client = null, Config $config = null): Discovery + public static function create(?ClientInterface $client = null, ?Config $config = null): Discovery { return new Discovery($client ?: new Client(), $config ?: new Config()); } - public static function createWithApiKey(string $apiKey, ClientInterface $client = null): Discovery + public static function createWithApiKey(string $apiKey, ?ClientInterface $client = null): Discovery { $config = new Config(); $config->setApiKey($apiKey); @@ -24,7 +24,7 @@ public static function createWithApiKey(string $apiKey, ClientInterface $client return static::create($client, $config); } - public static function createWithDeveloperApiKey(string $apiKey, ClientInterface $client = null): Discovery + public static function createWithDeveloperApiKey(string $apiKey, ?ClientInterface $client = null): Discovery { $config = new Config(); $config->setDeveloperApiKey($apiKey); @@ -32,7 +32,7 @@ public static function createWithDeveloperApiKey(string $apiKey, ClientInterface return static::create($client, $config); } - public static function createWithAccessToken(string $accessToken, ClientInterface $client = null): Discovery + public static function createWithAccessToken(string $accessToken, ?ClientInterface $client = null): Discovery { $config = new Config(); $config->setAccessToken($accessToken); diff --git a/lib/RetryMiddlewareFactory.php b/lib/RetryMiddlewareFactory.php index 519c4713..f063d475 100644 --- a/lib/RetryMiddlewareFactory.php +++ b/lib/RetryMiddlewareFactory.php @@ -9,14 +9,14 @@ class RetryMiddlewareFactory { public static function createInternalErrorsMiddleware( - callable $delayFunction = null, + ?callable $delayFunction = null, int $maxRetries = 5 ) { return static::createMiddlewareByHttpCodeRange(500, 504, $delayFunction, $maxRetries); } public static function createRateLimitMiddleware( - callable $delayFunction = null, + ?callable $delayFunction = null, int $maxRetries = 5 ) { return static::createMiddlewareByHttpCodes([429], $delayFunction, $maxRetries); @@ -53,7 +53,7 @@ public static function getRetryFunctionByRange( return function ( $retries, Request $request, - Response $response = null + ?Response $response = null ) use ($from, $to, $maxRetries) { if ($retries >= $maxRetries) { return false; @@ -74,7 +74,7 @@ public static function getRetryFunction(array $codes, int $maxRetries = 5) return function ( $retries, Request $request, - Response $response = null + ?Response $response = null ) use ($codes, $maxRetries) { if ($retries >= $maxRetries) { return false; diff --git a/tests/Unit/Utils/SignatureTest.php b/tests/Unit/Utils/SignatureTest.php index d25416e7..359a9e5c 100644 --- a/tests/Unit/Utils/SignatureTest.php +++ b/tests/Unit/Utils/SignatureTest.php @@ -87,9 +87,9 @@ public function unexpectedValueExceptionTimestampTest(): void public static function generateHubspotSignatureV3( string $secret, string $requestBody, - string $httpUri = null, + ?string $httpUri = null, string $httpMethod = 'POST', - int $timestamp = null + ?int $timestamp = null ): string { $sourceString = $httpMethod.$httpUri.$requestBody.$timestamp; From 1033927e780d8c63669fb54465902b45fd3443c5 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 18 Apr 2024 16:02:52 +0300 Subject: [PATCH 2/2] change php version --- .github/workflows/php-cs-fixer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml index 80f2008a..44a45225 100644 --- a/.github/workflows/php-cs-fixer.yml +++ b/.github/workflows/php-cs-fixer.yml @@ -15,7 +15,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: '8.0' + php-version: '7.4' - run: "composer install --no-interaction --no-progress --no-suggest"