From b71ec58e30da602a3d3f04feb00f9dc4f806245b Mon Sep 17 00:00:00 2001 From: Dmitry Patsura Date: Fri, 7 Jun 2019 17:51:24 +0300 Subject: Fix(rr): Workaround for Symfony < 4.1.x --- src/bin/rr | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/bin/rr b/src/bin/rr index 633b5a25..87403e38 100644 --- a/src/bin/rr +++ b/src/bin/rr @@ -226,7 +226,7 @@ class RRHelper curl_setopt($curlResource, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curlResource, CURLOPT_FILE, $zipFile); curl_setopt($curlResource, CURLOPT_PROGRESSFUNCTION, - function ($resource, $download_size, $downloaded, $upload_size, $uploaded) use ($progressBar) { + function ($resource, $download_size, $downloaded, $upload_size, $uploaded) use (&$progressBar, $output) { if ($download_size == 0) { return; } @@ -235,8 +235,15 @@ class RRHelper $progressBar->start(); } + if ($progressBar->getMaxSteps() != $download_size) { + /** + * Workaround for symfony < 4.1.x, for example PHP 7.0 will use 3.x + * feature #26449 Make ProgressBar::setMaxSteps public (ostrolucky) + */ + $progressBar = new ProgressBar($output, $download_size); + } + $progressBar->setFormat('[%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% ' . intval($download_size / 1024) . 'KB'); - $progressBar->setMaxSteps($download_size); $progressBar->setProgress($downloaded); }); curl_setopt($curlResource, CURLOPT_NOPROGRESS, false); // needed to make progress function work -- cgit v1.2.3