From c54ae148efa738a00e86ecb95779b71f79208adc Mon Sep 17 00:00:00 2001 From: paulrotmann Date: Wed, 6 Aug 2025 18:54:27 +0200 Subject: [PATCH] Update PHPStan --- composer.json | 2 +- src/Internal/FulfilledPromise.php | 5 +++++ src/Promise.php | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5d1e277..e2e6ffc 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "php": ">=7.1.0" }, "require-dev": { - "phpstan/phpstan": "1.10.39 || 1.4.10", + "phpstan/phpstan": "1.12.19 || 1.4.10", "phpunit/phpunit": "^9.6 || ^7.5" }, "autoload": { diff --git a/src/Internal/FulfilledPromise.php b/src/Internal/FulfilledPromise.php index 8664ffd..dcd243d 100644 --- a/src/Internal/FulfilledPromise.php +++ b/src/Internal/FulfilledPromise.php @@ -56,9 +56,14 @@ public function catch(callable $onRejected): PromiseInterface return $this; } + /** + * @param callable(): (void|PromiseInterface) $onFulfilledOrRejected + * @return PromiseInterface + */ public function finally(callable $onFulfilledOrRejected): PromiseInterface { return $this->then(function ($value) use ($onFulfilledOrRejected): PromiseInterface { + /** @var T $value */ return resolve($onFulfilledOrRejected())->then(function () use ($value) { return $value; }); diff --git a/src/Promise.php b/src/Promise.php index 4ac2700..997b649 100644 --- a/src/Promise.php +++ b/src/Promise.php @@ -94,9 +94,14 @@ public function catch(callable $onRejected): PromiseInterface }); } + /** + * @param callable(): (void|PromiseInterface) $onFulfilledOrRejected + * @return PromiseInterface + */ public function finally(callable $onFulfilledOrRejected): PromiseInterface { return $this->then(static function ($value) use ($onFulfilledOrRejected): PromiseInterface { + /** @var T $value */ return resolve($onFulfilledOrRejected())->then(function () use ($value) { return $value; });