Skip to content
Closed
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
<ini name="assert.active" value="1" />
<ini name="assert.exception" value="1" />
<ini name="assert.bail" value="0" />
<env name="XDEBUG_MODE" value="off"/>
<ini name="pcov.enabled" value="1"/>
<ini name="xdebug.mode" value="off"/>
</php>
</phpunit>
5 changes: 5 additions & 0 deletions src/Internal/FulfilledPromise.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ public function catch(callable $onRejected): PromiseInterface
return $this;
}

/**
* @param callable(): (void|PromiseInterface<void>) $onFulfilledOrRejected
* @return PromiseInterface<T>
*/
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;
});
Expand Down
5 changes: 5 additions & 0 deletions src/Promise.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ public function catch(callable $onRejected): PromiseInterface
});
}

/**
* @param callable(): (void|PromiseInterface<void>) $onFulfilledOrRejected
* @return PromiseInterface<T>
*/
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;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ echo 'NEVER';

?>
--EXPECTF--
Fatal error: Unexpected RuntimeException: foo in %s line %d
%AFatal error: Unexpected RuntimeException: foo in %s%s
Original file line number Diff line number Diff line change
Expand Up @@ -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