diff --git a/.gitattributes b/.gitattributes index 4a09071e..21be40ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,4 +2,5 @@ /.github/ export-ignore /.gitignore export-ignore /phpunit.xml.dist export-ignore -/tests export-ignore +/phpunit.xml.legacy export-ignore +/tests/ export-ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4be7ca28..85aad9c5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,10 +7,14 @@ on: jobs: PHPUnit: name: PHPUnit (PHP ${{ matrix.php }}) - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 strategy: matrix: php: + - 8.3 + - 8.2 + - 8.1 + - 8.0 - 7.4 - 7.3 - 7.2 @@ -21,22 +25,34 @@ jobs: - 5.4 - 5.3 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} coverage: xdebug + ini-file: development + ini-values: disable_functions='' # do not disable PCNTL functions on PHP < 8.1 + extensions: sockets, pcntl + env: + fail-fast: true # fail step if any extension can not be installed - run: composer install - run: vendor/bin/phpunit --coverage-text --exclude-group internet + if: ${{ matrix.php >= 7.3 }} + - run: vendor/bin/phpunit --coverage-text --exclude-group internet -c phpunit.xml.legacy + if: ${{ matrix.php < 7.3 }} PHPUnit-hhvm: name: PHPUnit (HHVM) - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 continue-on-error: true steps: - - uses: actions/checkout@v2 - - uses: azjezz/setup-hhvm@v1 + - uses: actions/checkout@v4 + - run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM + - name: Run hhvm composer.phar require --dev react/async:^2 react/promise:^2 phpunit/phpunit:^5.7 # downgrade Async and Promise for HHVM + uses: docker://hhvm/hhvm:3.30-lts-latest with: - version: lts-3.30 - - run: hhvm $(which composer) require phpunit/phpunit:^5 --dev # requires legacy phpunit - - run: hhvm vendor/bin/phpunit --exclude-group internet + args: hhvm composer.phar require --dev react/async:^2 react/promise:^2 phpunit/phpunit:^5.7 + - name: Run hhvm vendor/bin/phpunit --exclude-group internet + uses: docker://hhvm/hhvm:3.30-lts-latest + with: + args: hhvm vendor/bin/phpunit --exclude-group internet diff --git a/CHANGELOG.md b/CHANGELOG.md index c588ac1f..f5f711e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,34 @@ # Changelog +## 1.4.0 (2023-07-11) + +A major new feature release, see [**release announcement**](https://clue.engineering/2023/announcing-reactphp-promise-v3). + +* Feature: Add support for new Promise v3 release. + (#464 and #524 by @clue) + +* Feature: Support PHP 8.2 release. + (#491 by @Nielsvanpach) + +* Improve test suite, update dependencies and report failed assertions. + (#462 and #501 by @clue and #466 and #492 by @SimonFrings) + +## 1.3.0 (2022-07-11) + +A major new feature release, see [**release announcement**](https://clue.engineering/2022/announcing-reactphp-async). + +* Feature: Add new Async component to core components. + (#458 by @clue) + +* Feature: Support PHP 8.1 release. + (#451 by @clue) + +* Improve documentation, update HTTP server example for reactphp/http v1.6.0 release. + (#449 and #459 by @clue and #457 by @nhedger) + +* Improve test suite, support PHPUnit 9 and update dependencies to avoid skipping tests. + (#450 and #454 by @clue and #455 by @SimonFrings) + ## 1.2.0 (2021-07-11) A major new feature release, see [**release announcement**](https://clue.engineering/2021/announcing-reactphp-default-loop). diff --git a/README.md b/README.md index 0adc0fb1..f8e1d0f2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@
- Build Status + Build Status

@@ -23,17 +23,20 @@ client/server and interaction with processes. Third-party libraries can use thes components to create async network clients/servers and more. ```php -$server = new React\Http\Server(function (Psr\Http\Message\ServerRequestInterface $request) { - return new React\Http\Message\Response( - 200, - array( - 'Content-Type' => 'text/plain' - ), +listen($socket); echo "Server running at http://127.0.0.1:8080" . PHP_EOL; @@ -87,6 +90,9 @@ Node.js (V8). Promises/A implementation for PHP. [Read the documentation](https://github.com/reactphp/promise) +* **Async** + Async utilities and fibers for ReactPHP. + [Read the documentation](https://github.com/reactphp/async) ## Network Components @@ -98,16 +104,10 @@ Node.js (V8). Event-driven UDP client and server sockets for ReactPHP. [Read the documentation](https://github.com/reactphp/datagram) -## Protocol Components - * **HTTP** - Event-driven, streaming plaintext HTTP and secure HTTPS server for ReactPHP. + Event-driven, streaming HTTP client and server implementation for ReactPHP. [Read the documentation](https://github.com/reactphp/http) -* **HTTPClient** - Event-driven, streaming HTTP client for ReactPHP. - [Read the documentation](https://github.com/reactphp/http-client) - * **DNS** Async DNS resolver for ReactPHP. [Read the documentation](https://github.com/reactphp/dns) @@ -130,7 +130,6 @@ Node.js (V8). The missing link between Promise-land and Stream-land, built on top of ReactPHP. [Read the documentation](https://github.com/reactphp/promise-stream) - ## Built with ReactPHP * **Thruway** @@ -203,14 +202,14 @@ This means that instead of installing something like a "ReactPHP framework", you pick only the components that you need. This project follows [SemVer](https://semver.org/) for all its stable components. -The recommended way to install these components is [through Composer](https://getcomposer.org). -[New to Composer?](http://getcomposer.org/doc/00-intro.md) +The recommended way to install these components is [through Composer](https://getcomposer.org/). +[New to Composer?](https://getcomposer.org/doc/00-intro.md) For example, this may look something like this: ```bash # recommended install: pick required components -$ composer require react/event-loop react/http +composer require react/event-loop react/http ``` As an alternative, we also provide a meta package that will install all stable @@ -220,10 +219,10 @@ installed like this: ```bash # quick protoyping only: install all stable components -$ composer require react/react:^1.2 +composer require react/react:^1.4 ``` -For more details, check out [ReactPHP's homepage](https://reactphp.org) for +For more details, check out [ReactPHP's homepage](https://reactphp.org/) for quickstart examples and usage details. See also the combined [changelog for all ReactPHP components](https://reactphp.org/changelog.html) @@ -270,16 +269,16 @@ Thank you! ## Tests To run the test suite, you first need to clone this repo and then install all -dependencies [through Composer](https://getcomposer.org): +dependencies [through Composer](https://getcomposer.org/): ```bash -$ composer install +composer install ``` To run the test suite, go to the project root and run: ```bash -$ php vendor/bin/phpunit +vendor/bin/phpunit ``` The test suite also contains a number of functional integration tests that rely @@ -288,7 +287,7 @@ these are skipped by default during CI runs. If you also do not want to run thes they can simply be skipped like this: ```bash -$ php vendor/bin/phpunit --exclude-group internet +vendor/bin/phpunit --exclude-group internet ``` ## License diff --git a/composer.json b/composer.json index 1045b721..3f752a63 100644 --- a/composer.json +++ b/composer.json @@ -9,20 +9,20 @@ }, "require": { "php": ">=5.3.8", - "react/cache": "^1.0", - "react/dns": "^1.8", - "react/event-loop": "^1.2", - "react/http": "^1.4", - "react/promise": "^2.1 || ^1.2", - "react/promise-stream": "^1.1.1", - "react/promise-timer": "^1.7", - "react/socket": "^1.8", - "react/stream": "^1.2" + "react/async": "^4.3 || ^3.2 || ^2.2", + "react/cache": "^1.1", + "react/dns": "^1.13", + "react/event-loop": "^1.5", + "react/http": "^1.11", + "react/promise": "^3.2 || ^2.10 || ^1.3", + "react/promise-stream": "^1.7", + "react/promise-timer": "^1.11", + "react/socket": "^1.15", + "react/stream": "^1.4" }, "require-dev": { - "clue/block-react": "^1.1", "clue/stream-filter": "^1.3", - "phpunit/phpunit": "^7.0 || ^6.0 || ^5.7 || ^4.8.35" + "phpunit/phpunit": "^9.6 || ^7.5 || ^5.7 || ^4.8.36" }, "config": { "preferred-install": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 69bbf0ea..d5d26a2e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,17 +1,30 @@ - + + + + ./vendor/react/event-loop/tests/ ./vendor/react/*/tests/ - - ./vendor/react/event-loop/tests/BinTest.php - - - + + ./vendor/react/*/src/ - - + + + + + + + + + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy new file mode 100644 index 00000000..2cd2f9b1 --- /dev/null +++ b/phpunit.xml.legacy @@ -0,0 +1,26 @@ + + + + + + + ./vendor/react/*/tests/ + + + + + ./vendor/react/*/src/ + + + + + + + + + + + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index db5b8cac..2af732cf 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -2,7 +2,9 @@ $autoload = require __DIR__ . '/../vendor/autoload.php'; -// register all `autoload-dev` paths from React's components +assert($autoload instanceof Composer\Autoload\ClassLoader); + +// register all `autoload-dev` paths from ReactPHP's components foreach (glob(__DIR__ . '/../vendor/react/*/composer.json') as $b) { $config = json_decode(file_get_contents($b), true); @@ -15,17 +17,3 @@ } } } - -// load all legacy test bootstrap scripts from React's components -foreach (glob(__DIR__ . '/../vendor/react/*/tests/bootstrap.php') as $b) { - // skip legacy react/promise for now and use manual autoload path from bootstrap config - // @link https://github.com/reactphp/promise/blob/1.x/tests/bootstrap.php - // @link https://github.com/reactphp/promise/blob/2.x/tests/bootstrap.php - if (strpos($b, 'react/promise/tests/bootstrap.php') !== false) { - $autoload->add('React\Promise', __DIR__ . '/../vendor/react/promise/tests'); - $autoload->addPsr4('React\\Promise\\', __DIR__ . '/../vendor/react/promise/tests'); - continue; - } - - include $b; -}