diff --git a/composer.json b/composer.json index a1891be..4806233 100644 --- a/composer.json +++ b/composer.json @@ -43,16 +43,16 @@ "minimum-stability": "stable", "prefer-stable": true, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.17.0", - "illuminate/cache": "^9.38.0 || ^10.13.2 || ^11.36.1", - "phpstan/phpstan": "^1.10.16", - "phpunit/phpunit": "^9.5.26 || ^10.2.1", + "friendsofphp/php-cs-fixer": "^3.25.1", + "illuminate/cache": "^9.38.0 || ^10.21.0 || ^11.36.1", + "phpstan/phpstan": "^1.10.32", + "phpunit/phpunit": "^9.5.26 || ^10.3.2", "roave/security-advisories": "dev-latest" }, "require": { "php": "^8.1.0", "guzzlehttp/guzzle": "^6.5.8 || ^7.4.5", - "guzzlehttp/promises": "^1.0.0", + "guzzlehttp/promises": "^1.4.0 || ^2.0.0", "nesbot/carbon": "^3.0.0", "psr/http-message": "^1.0.0 || ^2.0.0", "psr/simple-cache": "^1.0.0 || ^2.0.0 || ^3.0.0" diff --git a/composer.lock b/composer.lock index 5ee3b3b..20bd690 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c7af3bdd7fa13ca247dcf47e212dbee8", + "content-hash": "5b89e4002645975848a99afd715a7211", "packages": [ { "name": "carbonphp/carbon-doctrine-types", @@ -203,29 +203,33 @@ }, { "name": "guzzlehttp/promises", - "version": "1.5.3", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e" + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/67ab6e18aaa14d753cc148911d273f6e6cb6721e", - "reference": "67ab6e18aaa14d753cc148911d273f6e6cb6721e", + "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455", + "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455", "shasum": "" }, "require": { - "php": ">=5.5" + "php": "^7.2.5 || ^8.0" }, "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" }, "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, "autoload": { - "files": [ - "src/functions_include.php" - ], "psr-4": { "GuzzleHttp\\Promise\\": "src/" } @@ -262,7 +266,7 @@ ], "support": { "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.5.3" + "source": "https://github.com/guzzle/promises/tree/2.0.4" }, "funding": [ { @@ -278,7 +282,7 @@ "type": "tidelift" } ], - "time": "2023-05-21T12:31:43+00:00" + "time": "2024-10-17T10:06:22+00:00" }, { "name": "guzzlehttp/psr7", diff --git a/src/RetryAfterMiddleware.php b/src/RetryAfterMiddleware.php index 575a52a..4863bf7 100644 --- a/src/RetryAfterMiddleware.php +++ b/src/RetryAfterMiddleware.php @@ -7,14 +7,13 @@ use Carbon\CarbonImmutable; use Carbon\CarbonInterface; use GuzzleHttp\Exception\BadResponseException; +use GuzzleHttp\Promise\Create; use GuzzleHttp\Promise\PromiseInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\SimpleCache\CacheInterface; use Throwable; -use function GuzzleHttp\Promise\rejection_for; - class RetryAfterMiddleware { public const HEADER = 'Retry-After'; @@ -49,7 +48,7 @@ public function __invoke(callable $handler): callable $now = new CarbonImmutable(); if ($retryAfter->greaterThanOrEqualTo($now)) { - return rejection_for(new RetryAfterException( + return Create::rejectionFor(new RetryAfterException( $this->retryAfterMessage($retryAfter, $now), $request, )); @@ -67,7 +66,7 @@ function (Throwable $reason) use ($key): PromiseInterface { $this->checkHeader($reason->getResponse(), $key); } - return rejection_for($reason); + return Create::rejectionFor($reason); } ); }; diff --git a/tests/RetryAfterMiddlewareTest.php b/tests/RetryAfterMiddlewareTest.php index 8275921..4be0d5e 100644 --- a/tests/RetryAfterMiddlewareTest.php +++ b/tests/RetryAfterMiddlewareTest.php @@ -111,7 +111,7 @@ public function it_fails_during_retry_after_date_period($mockHttpHandler): void $cachedRetryAfterObj = new CarbonImmutable($cachedRetryAfter); - $this->assertSame(self::RETRY_AFTER_SECONDS, $now->diffInSeconds($cachedRetryAfterObj)); + $this->assertSame(self::RETRY_AFTER_SECONDS, (int)$now->diffInSeconds($cachedRetryAfterObj)); // Second request is stopped at the beginning of retry after period try { @@ -202,7 +202,7 @@ public function it_fails_during_retry_after_seconds_period($mockHttpHandler): vo $cachedRetryAfterObj = new CarbonImmutable($cachedRetryAfter); - $this->assertSame(self::RETRY_AFTER_SECONDS, $now->diffInSeconds($cachedRetryAfterObj)); + $this->assertSame(self::RETRY_AFTER_SECONDS, (int)$now->diffInSeconds($cachedRetryAfterObj)); // Second request is stopped at the beginning of retry after period try {