File tree Expand file tree Collapse file tree 5 files changed +40
-6
lines changed Expand file tree Collapse file tree 5 files changed +40
-6
lines changed Original file line number Diff line number Diff line change 2020 coverage : xdebug
2121 - run : composer install
2222 - run : vendor/bin/phpunit --coverage-text
23+
24+ static-analysis :
25+ name : PHPStan
26+ runs-on : ubuntu-20.04
27+ continue-on-error : true
28+ steps :
29+ - uses : actions/checkout@v3
30+ - uses : shivammathur/setup-php@v2
31+ with :
32+ php-version : 8.1
33+ - run : composer require phpstan/phpstan
34+ - name : Execute type checking
35+ run : vendor/bin/phpstan --configuration="phpstan.types.neon.dist"
Original file line number Diff line number Diff line change 2828 "require" : {
2929 "php" : " >=8.1" ,
3030 "react/event-loop" : " ^1.2" ,
31- "react/promise" : " ^3.0 || ^2.8 || ^1.2.1 "
31+ "react/promise" : " dev-2.x-add-basic-template-annotations as 2.13.0 "
3232 },
33+ "repositories" : [
34+ {
35+ "type" : " vcs" ,
36+ "url" : " https://github.com/WyriHaximus-secret-labs/promise"
37+ }
38+ ],
3339 "require-dev" : {
3440 "phpunit/phpunit" : " ^9.3"
3541 },
Original file line number Diff line number Diff line change 1+ parameters:
2+ paths:
3+ - types
4+ level: max
Original file line number Diff line number Diff line change 174174 * $promise->cancel();
175175 * await($promise);
176176 * ```
177- *
178- * @param callable(mixed ...$args):mixed $function
179- * @return callable(): PromiseInterface<mixed >
177+ * @template T
178+ * @param callable(): T $function
179+ * @return callable(): PromiseInterface<T >
180180 * @since 4.0.0
181181 * @see coroutine()
182182 */
@@ -266,8 +266,9 @@ function async(callable $function): callable
266266 * }
267267 * ```
268268 *
269- * @param PromiseInterface $promise
270- * @return mixed returns whatever the promise resolves to
269+ * @template T
270+ * @param PromiseInterface<T> $promise
271+ * @return T
271272 * @throws \Exception when the promise is rejected with an `Exception`
272273 * @throws \Throwable when the promise is rejected with a `Throwable`
273274 * @throws \UnexpectedValueException when the promise is rejected with an unexpected value (Promise API v1 or v2 only)
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use function PHPStan \Testing \assertType ;
4+ use function React \Async \await ;
5+ use function React \Promise \resolve ;
6+
7+ $ passThroughBoolFn = static fn (bool $ bool ): bool => $ bool ;
8+
9+ assertType ('bool ' , await (resolve (true )));
10+ assertType ('bool ' , await (resolve (true )->then ($ passThroughBoolFn )));
You can’t perform that action at this time.
0 commit comments