Skip to content

Commit 2d8dcd1

Browse files
committed
Mitigation of some problems
1 parent 3405e43 commit 2d8dcd1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Command/FixerApplication.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,9 @@ private function downloadPhar(
359359

360360
$output->writeln('<fg=green>Downloading the latest PHPStan Pro...</>');
361361

362+
$pharPathResource = fopen($pharPath, 'w');
362363
$progressBar = new ProgressBar($output);
363-
$client->requestStreaming('GET', $latestInfo['url'])->then(static function (ResponseInterface $response) use ($loop, $pharPath, $progressBar): void {
364+
$client->requestStreaming('GET', $latestInfo['url'])->done(static function (ResponseInterface $response) use ($loop, $pharPath, $progressBar, $pharPathResource): void {
364365
$body = $response->getBody();
365366
if (!$body instanceof \React\Stream\ReadableStreamInterface) {
366367
throw new \PHPStan\ShouldNotHappenException();
@@ -371,7 +372,7 @@ private function downloadPhar(
371372
$progressBar->setMessage(sprintf('%.2f MB', $totalSize / 1000000), 'fileSize');
372373
$progressBar->start($totalSize);
373374

374-
$destination = new \React\Stream\WritableResourceStream(fopen($pharPath, 'w'), $loop);
375+
$destination = new \React\Stream\WritableResourceStream($pharPathResource, $loop);
375376
$body->pipe($destination);
376377

377378
$bytes = 0;
@@ -383,6 +384,8 @@ private function downloadPhar(
383384

384385
$loop->run();
385386

387+
fclose($pharPathResource);
388+
386389
$progressBar->finish();
387390
$output->writeln('');
388391
$output->writeln('');

0 commit comments

Comments
 (0)