diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a398ff9..bfddda3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,10 +7,11 @@ on: jobs: PHPUnit: name: PHPUnit (PHP ${{ matrix.php }}) - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: php: + - 8.4 - 8.3 - 8.2 - 8.1 @@ -24,7 +25,7 @@ jobs: - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - coverage: xdebug + coverage: ${{ matrix.php < 8.0 && 'xdebug' || 'pcov' }} ini-file: development - run: composer install - run: vendor/bin/phpunit --coverage-text @@ -34,10 +35,11 @@ jobs: PHPStan: name: PHPStan (PHP ${{ matrix.php }}) - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 strategy: matrix: php: + - 8.4 - 8.3 - 8.2 - 8.1 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/phpunit.xml.dist b/phpunit.xml.dist index 33ea968..4305518 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -28,5 +28,8 @@ + + + diff --git a/src/Internal/FulfilledPromise.php b/src/Internal/FulfilledPromise.php index 8664ffd..ec693a3 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..11e928b 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; }); diff --git a/tests/FunctionSetRejectionHandlerThatTriggersDefaultHandlerShouldTerminateProgramForUnhandled.phpt b/tests/FunctionSetRejectionHandlerThatTriggersDefaultHandlerShouldTerminateProgramForUnhandled.phpt index 14b5c7c..8531f6d 100644 --- a/tests/FunctionSetRejectionHandlerThatTriggersDefaultHandlerShouldTerminateProgramForUnhandled.phpt +++ b/tests/FunctionSetRejectionHandlerThatTriggersDefaultHandlerShouldTerminateProgramForUnhandled.phpt @@ -21,4 +21,4 @@ echo 'NEVER'; ?> --EXPECTF-- -Fatal error: Unexpected RuntimeException: foo in %s line %d +%AFatal error: Unexpected RuntimeException: foo in %s%s diff --git a/tests/FunctionSetRejectionHandlerThatTriggersErrorHandlerThatThrowsShouldTerminateProgramForUnhandled.phpt b/tests/FunctionSetRejectionHandlerThatTriggersErrorHandlerThatThrowsShouldTerminateProgramForUnhandled.phpt index 5ed9687..f5acd57 100644 --- a/tests/FunctionSetRejectionHandlerThatTriggersErrorHandlerThatThrowsShouldTerminateProgramForUnhandled.phpt +++ b/tests/FunctionSetRejectionHandlerThatTriggersErrorHandlerThatThrowsShouldTerminateProgramForUnhandled.phpt @@ -27,9 +27,4 @@ echo 'NEVER'; --EXPECTF-- Fatal error: Uncaught OverflowException from unhandled promise rejection handler: This function should never throw in %s:%d Stack trace: -#0 [internal function]: {closure%S}(%S) -#1 %s(%d): trigger_error(%S) -#2 %s/src/Internal/RejectedPromise.php(%d): {closure%S}(%S) -#3 %s/src/functions.php(%d): React\Promise\Internal\RejectedPromise->__destruct() -#4 %s(%d): React\Promise\reject(%S) -#5 %A{main} +%A