Skip to content

Commit

Permalink
Add support of guzzlehttp/promises:2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ChVuagniaux committed May 22, 2023
1 parent cfee7da commit a109b57
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"ext-json": "*",
"composer/semver": "^1.4|^2.0|^3.0",
"guzzlehttp/guzzle": "^6.3|^7.0",
"guzzlehttp/promises": "^1.0|^2.0",
"illuminate/http": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/routing": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0",
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10.0"
Expand Down
15 changes: 14 additions & 1 deletion src/Classes/Composer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Composer\Semver\Semver;
use Composer\Semver\VersionParser;
use GuzzleHttp\Client;
use GuzzleHttp\Promise\Utils;
use GuzzleHttp\Psr7\Response;
use Illuminate\Support\Arr;
use Illuminate\Support\Collection;
Expand Down Expand Up @@ -68,7 +69,7 @@ public function getPackagesData()
});
});

\GuzzleHttp\Promise\settle($promises)->wait();
$this->waitForPromises($promises);
});

return $packages;
Expand Down Expand Up @@ -223,4 +224,16 @@ private function getVersionsFromPackagist(string $package)

return $versions;
}

private function waitForPromises(array $promises) {

if (method_exists(Utils::class, 'settle')){
Utils::settle($promises)->wait();

return;
}

// Support of guzzle/promises < 1.4
\GuzzleHttp\Promise\settle($promises)->wait();
}
}

0 comments on commit a109b57

Please sign in to comment.