From 3df3166db016c1fccefa2cd6cc677ded5a456c71 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 22 Sep 2022 15:37:08 +0200 Subject: [PATCH] Move to react/async --- composer.json | 2 +- composer.lock | 145 ++++++++++++++++--------------- src/Command/FixerApplication.php | 11 +-- 3 files changed, 81 insertions(+), 77 deletions(-) diff --git a/composer.json b/composer.json index 045f2637ee..37ed69b79b 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,6 @@ "require": { "php": "^8.0", "composer-runtime-api": "^2.0", - "clue/block-react": "^1.4", "clue/ndjson-react": "^1.0", "composer/ca-bundle": "^1.2", "composer/xdebug-handler": "^3.0.3", @@ -26,6 +25,7 @@ "ondrejmirtes/better-reflection": "5.8.0.1", "phpstan/php-8-stubs": "0.3.37", "phpstan/phpdoc-parser": "1.8.0", + "react/async": "^3", "react/child-process": "^0.6.4", "react/event-loop": "^1.2", "react/http": "^1.1", diff --git a/composer.lock b/composer.lock index 67df278d65..045dfc9bc6 100644 --- a/composer.lock +++ b/composer.lock @@ -4,76 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "81a7b67c9083f923cb206f0174e2e99b", + "content-hash": "39edc53fea87afaca545a764e2a1c6c7", "packages": [ - { - "name": "clue/block-react", - "version": "v1.5.0", - "source": { - "type": "git", - "url": "https://github.com/clue/reactphp-block.git", - "reference": "718b0571a94aa693c6fffc72182e87257ac900f3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/clue/reactphp-block/zipball/718b0571a94aa693c6fffc72182e87257ac900f3", - "reference": "718b0571a94aa693c6fffc72182e87257ac900f3", - "shasum": "" - }, - "require": { - "php": ">=5.3", - "react/event-loop": "^1.2", - "react/promise": "^3.0 || ^2.7 || ^1.2.1", - "react/promise-timer": "^1.5" - }, - "require-dev": { - "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", - "react/http": "^1.4" - }, - "type": "library", - "autoload": { - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Christian Lück", - "email": "christian@clue.engineering" - } - ], - "description": "Lightweight library that eases integrating async components built for ReactPHP in a traditional, blocking environment.", - "homepage": "https://github.com/clue/reactphp-block", - "keywords": [ - "async", - "await", - "blocking", - "event loop", - "promise", - "reactphp", - "sleep", - "synchronous" - ], - "support": { - "issues": "https://github.com/clue/reactphp-block/issues", - "source": "https://github.com/clue/reactphp-block/tree/v1.5.0" - }, - "funding": [ - { - "url": "https://clue.engineering/support", - "type": "custom" - }, - { - "url": "https://github.com/clue", - "type": "github" - } - ], - "time": "2021-10-20T14:07:33+00:00" - }, { "name": "clue/ndjson-react", "version": "v1.2.0", @@ -2403,6 +2335,81 @@ }, "time": "2020-03-23T09:12:05+00:00" }, + { + "name": "react/async", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/async.git", + "reference": "3c3b812be77aec14bf8300b052ba589c9a5bc95b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/async/zipball/3c3b812be77aec14bf8300b052ba589c9a5bc95b", + "reference": "3c3b812be77aec14bf8300b052ba589c9a5bc95b", + "shasum": "" + }, + "require": { + "php": ">=7.1", + "react/event-loop": "^1.2", + "react/promise": "^3.0 || ^2.8 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^7.5" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Async utilities for ReactPHP", + "keywords": [ + "async", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/async/issues", + "source": "https://github.com/reactphp/async/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-07-11T14:17:23+00:00" + }, { "name": "react/cache", "version": "v1.1.1", diff --git a/src/Command/FixerApplication.php b/src/Command/FixerApplication.php index eb2d79bf3c..bd9d5e3b6a 100644 --- a/src/Command/FixerApplication.php +++ b/src/Command/FixerApplication.php @@ -32,6 +32,7 @@ use PHPStan\ShouldNotHappenException; use Psr\Http\Message\ResponseInterface; use React\ChildProcess\Process; +use React\EventLoop\Loop; use React\EventLoop\LoopInterface; use React\EventLoop\StreamSelectLoop; use React\Http\Browser; @@ -47,7 +48,6 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Throwable; -use function Clue\React\Block\await; use function count; use function defined; use function escapeshellarg; @@ -63,6 +63,7 @@ use function min; use function mkdir; use function parse_url; +use function React\Async\await; use function React\Promise\resolve; use function sprintf; use function strlen; @@ -363,11 +364,8 @@ private function downloadPhar( $output->writeln('Checking if there\'s a new PHPStan Pro release...'); } - $loop = new StreamSelectLoop(); $client = new Browser( - $loop, new Connector( - $loop, [ 'timeout' => 5, 'tls' => [ @@ -380,9 +378,8 @@ private function downloadPhar( /** * @var array{url: string, version: string} $latestInfo - * @phpstan-ignore-next-line */ - $latestInfo = Json::decode((string) await($client->get(sprintf('https://fixer-download-api.phpstan.com/latest?%s', http_build_query(['phpVersion' => PHP_VERSION_ID]))), $loop, 5.0)->getBody(), Json::FORCE_ARRAY); + $latestInfo = Json::decode((string) await($client->get(sprintf('https://fixer-download-api.phpstan.com/latest?%s', http_build_query(['phpVersion' => PHP_VERSION_ID]))))->getBody(), Json::FORCE_ARRAY); if ($currentVersion !== null && $latestInfo['version'] === $currentVersion) { $this->writeInfoFile($infoPath, $latestInfo['version']); $output->writeln('You\'re running the latest PHPStan Pro!'); @@ -417,7 +414,7 @@ private function downloadPhar( $output->writeln(sprintf('Could not download the PHPStan Pro executable: %s', $e->getMessage())); }); - $loop->run(); + Loop::run(); fclose($pharPathResource);