diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index a82930c7d..11534f149 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -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\\ given on the left side\\.$#" count: 1 diff --git a/src/Composer/Util/SyncHelper.php b/src/Composer/Util/SyncHelper.php index 198169212..766dc6ce3 100644 --- a/src/Composer/Util/SyncHelper.php +++ b/src/Composer/Util/SyncHelper.php @@ -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]); } }