1
0
Fork 0

refactor: update `SyncHelper` (#11485)

Get rid of 3 PHPStan issues
pull/11496/head
Pol Dellaiera 2023-06-06 15:25:54 +02:00 committed by GitHub
parent 0e05c2c68a
commit 45977c7cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 18 deletions

View File

@ -4933,21 +4933,6 @@ parameters:
count: 1
path: ../src/Composer/Util/Svn.php
-
message: "#^Only booleans are allowed in a ternary operator condition, Composer\\\\Package\\\\PackageInterface\\|null given\\.$#"
count: 1
path: ../src/Composer/Util/SyncHelper.php
-
message: "#^Only booleans are allowed in an if condition, React\\\\Promise\\\\PromiseInterface\\|null given\\.$#"
count: 1
path: ../src/Composer/Util/SyncHelper.php
-
message: "#^Parameter \\#2 \\$target of method Composer\\\\Downloader\\\\DownloaderInterface\\:\\:update\\(\\) expects Composer\\\\Package\\\\PackageInterface, Composer\\\\Package\\\\PackageInterface\\|null given\\.$#"
count: 1
path: ../src/Composer/Util/SyncHelper.php
-
message: "#^Only booleans are allowed in &&, array\\<int\\|string, true\\> given on the left side\\.$#"
count: 1

View File

@ -31,14 +31,14 @@ class SyncHelper
*/
public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, string $path, PackageInterface $package, ?PackageInterface $prevPackage = null): void
{
$type = $prevPackage ? 'update' : 'install';
$type = $prevPackage !== null ? 'update' : 'install';
try {
self::await($loop, $downloader->download($package, $path, $prevPackage));
self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
if ($type === 'update') {
if ($type === 'update' && $prevPackage !== null) {
self::await($loop, $downloader->update($package, $prevPackage, $path));
} else {
self::await($loop, $downloader->install($package, $path));
@ -58,7 +58,7 @@ class SyncHelper
*/
public static function await(Loop $loop, ?PromiseInterface $promise = null): void
{
if ($promise) {
if ($promise !== null) {
$loop->wait([$promise]);
}
}