diff --git a/composer.json b/composer.json index 07b8d0cbd8..1bdf06a080 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "react/dns": "^1.10", "react/event-loop": "^1.2", "react/http": "^1.1", - "react/promise": "^2.8", + "react/promise": "^3.2", "react/socket": "^1.3", "react/stream": "^1.1", "symfony/console": "^5.4.3", diff --git a/composer.lock b/composer.lock index 9cd09c7383..f415b2efb8 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ab6cb886f84d8d18fe7aaac1bc2d029c", + "content-hash": "fdd06989b69fb1102e9ab8059a949ea3", "packages": [ { "name": "clue/ndjson-react", @@ -2859,23 +2859,24 @@ }, { "name": "react/promise", - "version": "v2.11.0", + "version": "v3.2.0", "source": { "type": "git", "url": "https://github.com/reactphp/promise.git", - "reference": "1a8460931ea36dc5c76838fec5734d55c88c6831" + "reference": "8a164643313c71354582dc850b42b33fa12a4b63" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise/zipball/1a8460931ea36dc5c76838fec5734d55c88c6831", - "reference": "1a8460931ea36dc5c76838fec5734d55c88c6831", + "url": "https://api.github.com/repos/reactphp/promise/zipball/8a164643313c71354582dc850b42b33fa12a4b63", + "reference": "8a164643313c71354582dc850b42b33fa12a4b63", "shasum": "" }, "require": { - "php": ">=5.4.0" + "php": ">=7.1.0" }, "require-dev": { - "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + "phpstan/phpstan": "1.10.39 || 1.4.10", + "phpunit/phpunit": "^9.6 || ^7.5" }, "type": "library", "autoload": { @@ -2919,7 +2920,7 @@ ], "support": { "issues": "https://github.com/reactphp/promise/issues", - "source": "https://github.com/reactphp/promise/tree/v2.11.0" + "source": "https://github.com/reactphp/promise/tree/v3.2.0" }, "funding": [ { @@ -2927,7 +2928,7 @@ "type": "open_collective" } ], - "time": "2023-11-16T16:16:50+00:00" + "time": "2024-05-24T10:39:05+00:00" }, { "name": "react/socket", diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9aa1e6ea5a..7b041d052c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -139,26 +139,6 @@ parameters: count: 1 path: src/Command/ErrorsConsoleStyle.php - - - message: "#^Call to an undefined method React\\\\Promise\\\\PromiseInterface\\\\:\\:done\\(\\)\\.$#" - count: 1 - path: src/Command/FixerApplication.php - - - - message: "#^Unable to resolve the template type T in call to function React\\\\Async\\\\await$#" - count: 1 - path: src/Command/FixerApplication.php - - - - message: "#^Call to an undefined method React\\\\Promise\\\\PromiseInterface\\\\:\\:done\\(\\)\\.$#" - count: 1 - path: src/Command/FixerWorkerCommand.php - - - - message: "#^Call to an undefined method React\\\\Promise\\\\PromiseInterface\\\\:\\:done\\(\\)\\.$#" - count: 1 - path: src/Command/WorkerCommand.php - - message: "#^Variable method call on Nette\\\\Schema\\\\Elements\\\\AnyOf\\|Nette\\\\Schema\\\\Elements\\\\Structure\\|Nette\\\\Schema\\\\Elements\\\\Type\\.$#" count: 1 diff --git a/src/Command/FixerApplication.php b/src/Command/FixerApplication.php index 17033d7533..17896dcf9b 100644 --- a/src/Command/FixerApplication.php +++ b/src/Command/FixerApplication.php @@ -29,8 +29,7 @@ use React\EventLoop\LoopInterface; use React\EventLoop\StreamSelectLoop; use React\Http\Browser; -use React\Promise\CancellablePromiseInterface; -use React\Promise\ExtendedPromiseInterface; +use React\Promise\PromiseInterface; use React\Socket\ConnectionInterface; use React\Socket\Connector; use React\Socket\TcpServer; @@ -64,8 +63,8 @@ class FixerApplication { - /** @var (ExtendedPromiseInterface&CancellablePromiseInterface)|null */ - private $processInProgress; + /** @var PromiseInterface|null */ + private PromiseInterface|null $processInProgress = null; private bool $fileMonitorActive = true; @@ -348,7 +347,7 @@ private function downloadPhar( throw new ShouldNotHappenException(sprintf('Could not open file %s for writing.', $pharPath)); } $progressBar = new ProgressBar($output); - $client->requestStreaming('GET', $latestInfo['url'])->done(static function (ResponseInterface $response) use ($progressBar, $pharPathResource): void { + $client->requestStreaming('GET', $latestInfo['url'])->then(static function (ResponseInterface $response) use ($progressBar, $pharPathResource): void { $body = $response->getBody(); if (!$body instanceof ReadableStreamInterface) { throw new ShouldNotHappenException(); @@ -470,7 +469,7 @@ private function analyse( )); $this->processInProgress = $process->run(); - $this->processInProgress->done(function () use ($server): void { + $this->processInProgress->then(function () use ($server): void { $this->processInProgress = null; $server->close(); }, function (Throwable $e) use ($server, $output, $phpstanFixerEncoder): void { diff --git a/src/Command/FixerWorkerCommand.php b/src/Command/FixerWorkerCommand.php index 942c66e486..4b0ab82281 100644 --- a/src/Command/FixerWorkerCommand.php +++ b/src/Command/FixerWorkerCommand.php @@ -123,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $loop = new StreamSelectLoop(); $tcpConnector = new TcpConnector($loop); - $tcpConnector->connect(sprintf('127.0.0.1:%d', $serverPort))->done(function (ConnectionInterface $connection) use ($container, $inceptionResult, $configuration, $input, $ignoredErrorHelperResult, $loop): void { + $tcpConnector->connect(sprintf('127.0.0.1:%d', $serverPort))->then(function (ConnectionInterface $connection) use ($container, $inceptionResult, $configuration, $input, $ignoredErrorHelperResult, $loop): void { // phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly $jsonInvalidUtf8Ignore = defined('JSON_INVALID_UTF8_IGNORE') ? JSON_INVALID_UTF8_IGNORE : 0; // phpcs:enable @@ -314,6 +314,7 @@ private function filterErrors(array $errors, IgnoredErrorHelperResult $ignoredEr /** * @param string[] $files * @param callable(list, list, string[]): void $onFileAnalysisHandler + * @return PromiseInterface */ private function runAnalyser(LoopInterface $loop, Container $container, array $files, ?string $configuration, InputInterface $input, callable $onFileAnalysisHandler): PromiseInterface { diff --git a/src/Command/WorkerCommand.php b/src/Command/WorkerCommand.php index 01be926b0f..b33eb5df71 100644 --- a/src/Command/WorkerCommand.php +++ b/src/Command/WorkerCommand.php @@ -126,7 +126,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $analysedFiles = array_fill_keys($analysedFiles, true); $tcpConnector = new TcpConnector($loop); - $tcpConnector->connect(sprintf('127.0.0.1:%d', $port))->done(function (ConnectionInterface $connection) use ($container, $identifier, $output, $analysedFiles): void { + $tcpConnector->connect(sprintf('127.0.0.1:%d', $port))->then(function (ConnectionInterface $connection) use ($container, $identifier, $output, $analysedFiles): void { // phpcs:disable SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly $jsonInvalidUtf8Ignore = defined('JSON_INVALID_UTF8_IGNORE') ? JSON_INVALID_UTF8_IGNORE : 0; // phpcs:enable diff --git a/src/Parallel/ParallelAnalyser.php b/src/Parallel/ParallelAnalyser.php index 8bc740dd2c..37c3734de6 100644 --- a/src/Parallel/ParallelAnalyser.php +++ b/src/Parallel/ParallelAnalyser.php @@ -54,6 +54,7 @@ public function __construct( /** * @param Closure(int ): void|null $postFileCallback * @param (callable(list, list, string[]): void)|null $onFileAnalysisHandler + * @return PromiseInterface */ public function analyse( LoopInterface $loop, @@ -83,6 +84,7 @@ public function analyse( $reachedInternalErrorsCountLimit = false; $exportedNodes = []; + /** @var Deferred $deferred */ $deferred = new Deferred(); $server = new TcpServer('127.0.0.1:0', $loop); diff --git a/src/Process/ProcessPromise.php b/src/Process/ProcessPromise.php index 91362ace74..55e3cbcf2e 100644 --- a/src/Process/ProcessPromise.php +++ b/src/Process/ProcessPromise.php @@ -5,9 +5,8 @@ use PHPStan\ShouldNotHappenException; use React\ChildProcess\Process; use React\EventLoop\LoopInterface; -use React\Promise\CancellablePromiseInterface; use React\Promise\Deferred; -use React\Promise\ExtendedPromiseInterface; +use React\Promise\PromiseInterface; use function fclose; use function rewind; use function stream_get_contents; @@ -16,6 +15,7 @@ class ProcessPromise { + /** @var Deferred */ private Deferred $deferred; private ?Process $process = null; @@ -33,9 +33,9 @@ public function getName(): string } /** - * @return ExtendedPromiseInterface&CancellablePromiseInterface + * @return PromiseInterface */ - public function run(): CancellablePromiseInterface + public function run(): PromiseInterface { $tmpStdOutResource = tmpfile(); if ($tmpStdOutResource === false) { @@ -72,6 +72,9 @@ public function run(): CancellablePromiseInterface } if ($exitCode === 0) { + if ($stdOut === false) { + $stdOut = ''; + } $this->deferred->resolve($stdOut); return; } @@ -79,7 +82,6 @@ public function run(): CancellablePromiseInterface $this->deferred->reject(new ProcessCrashedException($stdOut . $stdErr)); }); - /** @var ExtendedPromiseInterface&CancellablePromiseInterface */ return $this->deferred->promise(); }