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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/.gitattributes export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/phpunit.xml.legacy export-ignore
/tests/ export-ignore
/types/ export-ignore
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,18 @@ jobs:
- run: composer self-update --2.2 # downgrade Composer for HHVM
- run: hhvm $(which composer) install
- run: hhvm vendor/bin/phpunit

PHPStan:
name: PHPStan
runs-on: ubuntu-20.04
strategy:
matrix:
php:
- 8.1
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
- run: composer require phpstan/phpstan
- run: vendor/bin/phpstan
4 changes: 4 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
paths:
- types
level: max
6 changes: 6 additions & 0 deletions src/React/Promise/PromiseInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

namespace React\Promise;

/** @template T */
interface PromiseInterface
{
/**
* @template TReturn of mixed
* @param callable(T): TReturn $fulfilledHandler
* @return (TReturn is PromiseInterface ? TReturn : PromiseInterface<TReturn>)
*/
public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null);
}
9 changes: 9 additions & 0 deletions types/PromiseInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

use function PHPStan\Testing\assertType;
use function React\Promise\resolve;

$passThroughBoolFn = static fn (bool $bool): bool => $bool;

assertType('React\Promise\PromiseInterface<bool>', resolve(true));
assertType('React\Promise\PromiseInterface<bool>', resolve(true)->then($passThroughBoolFn));