From 249f9f6d3d44ff07df0ffcaebd98848b365360ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Thu, 7 Oct 2021 07:05:53 +0200 Subject: [PATCH] Require PHP 8.1+ and add `mixed` type declarations --- .gitattributes | 1 - .github/workflows/ci.yml | 8 -------- README.md | 10 ++++++---- composer.json | 4 ++-- phpunit.xml.dist | 1 - phpunit.xml.legacy | 18 ------------------ src/functions.php | 4 ++-- 7 files changed, 10 insertions(+), 36 deletions(-) delete mode 100644 phpunit.xml.legacy diff --git a/.gitattributes b/.gitattributes index 21be40c..aa6c312 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,5 +2,4 @@ /.github/ export-ignore /.gitignore export-ignore /phpunit.xml.dist export-ignore -/phpunit.xml.legacy export-ignore /tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0b1b36b..1b83b36 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,11 +12,6 @@ jobs: matrix: php: - 8.1 - - 8.0 - - 7.4 - - 7.3 - - 7.2 - - 7.1 steps: - uses: actions/checkout@v2 - uses: shivammathur/setup-php@v2 @@ -25,6 +20,3 @@ jobs: coverage: xdebug - run: composer install - run: vendor/bin/phpunit --coverage-text - if: ${{ matrix.php >= 7.3 }} - - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy - if: ${{ matrix.php < 7.3 }} diff --git a/README.md b/README.md index 522bef6..2869657 100644 --- a/README.md +++ b/README.md @@ -338,14 +338,16 @@ $ composer require react/async:dev-main See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades. This project aims to run on any platform and thus does not require any PHP -extensions and supports running on PHP 7.1 through current PHP 8+. +extensions and supports running on PHP 8.1+. It's *highly recommended to use the latest supported PHP version* for this project. We're committed to providing long-term support (LTS) options and to provide a smooth upgrade path. If you're using an older PHP version, you may use the -[`2.x` branch](https://github.com/reactphp/async/tree/2.x) which provides a -compatible API but does not take advantage of newer language features. You may -target both versions at the same time to support a wider range of PHP versions. +[`3.x` branch](https://github.com/reactphp/async/tree/3.x) (PHP 7.1+) or +[`2.x` branch](https://github.com/reactphp/async/tree/2.x) (PHP 5.3+) which both +provide a compatible API but do not take advantage of newer language features. +You may target multiple versions at the same time to support a wider range of +PHP versions. ## Tests diff --git a/composer.json b/composer.json index a839932..45e183a 100644 --- a/composer.json +++ b/composer.json @@ -26,12 +26,12 @@ } ], "require": { - "php": ">=7.1", + "php": ">=8.1", "react/event-loop": "^1.2", "react/promise": "^2.8 || ^1.2.1" }, "require-dev": { - "phpunit/phpunit": "^9.3 || ^7.5" + "phpunit/phpunit": "^9.3" }, "autoload": { "files": [ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fa88e7e..f4b5805 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,6 +1,5 @@ - - - - - - - ./tests/ - - - - - ./src/ - - - diff --git a/src/functions.php b/src/functions.php index ad91688..45c8116 100644 --- a/src/functions.php +++ b/src/functions.php @@ -50,7 +50,7 @@ * @throws \Throwable when the promise is rejected with a `Throwable` * @throws \UnexpectedValueException when the promise is rejected with an unexpected value (Promise API v1 or v2 only) */ -function await(PromiseInterface $promise) +function await(PromiseInterface $promise): mixed { $wait = true; $resolved = null; @@ -212,7 +212,7 @@ function ($error) use (&$exception, &$rejected, &$wait) { * @return PromiseInterface * @since 3.0.0 */ -function coroutine(callable $function, ...$args): PromiseInterface +function coroutine(callable $function, mixed ...$args): PromiseInterface { try { $generator = $function(...$args);