From 1d0fa9349563565452474d131d33dc23317febb1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 11 May 2022 09:39:56 +0200 Subject: [PATCH] Fix lock:false still outputting lock file changes --- phpstan/baseline.neon | 96 ++++++-------------------------------- src/Composer/Installer.php | 44 +++++++++-------- 2 files changed, 37 insertions(+), 103 deletions(-) diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index 1dfceca48..a3f616c0c 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -12,11 +12,6 @@ parameters: - message: "#^Casting to bool something that's already bool\\.$#" - count: 6 - path: ../src/Composer/Autoload/AutoloadGenerator.php - - - - message: "#^Casting to string something that's already string\\.$#" count: 1 path: ../src/Composer/Autoload/AutoloadGenerator.php @@ -65,14 +60,9 @@ parameters: count: 1 path: ../src/Composer/Autoload/AutoloadGenerator.php - - - message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#" - count: 1 - path: ../src/Composer/Autoload/AutoloadGenerator.php - - message: "#^Only booleans are allowed in a negated boolean, string given\\.$#" - count: 4 + count: 3 path: ../src/Composer/Autoload/AutoloadGenerator.php - @@ -157,7 +147,7 @@ parameters: - message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" - count: 2 + count: 1 path: ../src/Composer/Autoload/AutoloadGenerator.php - @@ -275,11 +265,6 @@ parameters: count: 1 path: ../src/Composer/Autoload/ClassMapGenerator.php - - - message: "#^Casting to bool something that's already bool\\.$#" - count: 2 - path: ../src/Composer/Cache.php - - message: "#^Only booleans are allowed in a negated boolean, int given\\.$#" count: 1 @@ -2475,11 +2460,6 @@ parameters: count: 2 path: ../src/Composer/Config.php - - - message: "#^Casting to bool something that's already bool\\.$#" - count: 1 - path: ../src/Composer/Config.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 2 @@ -3745,11 +3725,6 @@ parameters: count: 1 path: ../src/Composer/EventDispatcher/EventDispatcher.php - - - message: "#^Casting to bool something that's already bool\\.$#" - count: 1 - path: ../src/Composer/EventDispatcher/EventDispatcher.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 1 @@ -4010,11 +3985,6 @@ parameters: count: 1 path: ../src/Composer/Installer.php - - - message: "#^Casting to bool something that's already bool\\.$#" - count: 15 - path: ../src/Composer/Installer.php - - message: "#^Only booleans are allowed in &&, array\\\\> given on the right side\\.$#" count: 1 @@ -4025,6 +3995,11 @@ parameters: count: 1 path: ../src/Composer/Installer.php + - + message: "#^Only booleans are allowed in &&, mixed given on the left side\\.$#" + count: 1 + path: ../src/Composer/Installer.php + - message: "#^Only booleans are allowed in &&, mixed given on the right side\\.$#" count: 2 @@ -4075,6 +4050,11 @@ parameters: count: 1 path: ../src/Composer/Installer.php + - + message: "#^Only booleans are allowed in an if condition, mixed given\\.$#" + count: 2 + path: ../src/Composer/Installer.php + - message: "#^Only booleans are allowed in \\|\\|, array\\\\|null given on the left side\\.$#" count: 2 @@ -4445,11 +4425,6 @@ parameters: count: 4 path: ../src/Composer/Json/JsonManipulator.php - - - message: "#^Casting to string something that's already string\\.$#" - count: 1 - path: ../src/Composer/Json/JsonValidationException.php - - message: "#^Variable method call on Composer\\\\Package\\\\BasePackage\\.$#" count: 1 @@ -4625,21 +4600,11 @@ parameters: count: 2 path: ../src/Composer/Package/Dumper/ArrayDumper.php - - - message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#" - count: 1 - path: ../src/Composer/Package/Loader/ArrayLoader.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 10 path: ../src/Composer/Package/Loader/ArrayLoader.php - - - message: "#^Instanceof between Composer\\\\Package\\\\CompletePackage and Composer\\\\Package\\\\CompletePackage will always evaluate to true\\.$#" - count: 1 - path: ../src/Composer/Package/Loader/ArrayLoader.php - - message: "#^Instanceof between Composer\\\\Package\\\\CompletePackage and Composer\\\\Package\\\\CompletePackageInterface will always evaluate to true\\.$#" count: 1 @@ -4680,11 +4645,6 @@ parameters: count: 1 path: ../src/Composer/Package/Loader/ArrayLoader.php - - - message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#" - count: 1 - path: ../src/Composer/Package/Loader/JsonLoader.php - - message: "#^Parameter \\#1 \\$json of static method Composer\\\\Json\\\\JsonFile\\:\\:parseJson\\(\\) expects string\\|null, string\\|false given\\.$#" count: 1 @@ -5120,11 +5080,6 @@ parameters: count: 1 path: ../src/Composer/Plugin/PostFileDownloadEvent.php - - - message: "#^Casting to bool something that's already bool\\.$#" - count: 1 - path: ../src/Composer/Question/StrictConfirmationQuestion.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 2 @@ -5455,16 +5410,6 @@ parameters: count: 1 path: ../src/Composer/Repository/FilesystemRepository.php - - - message: "#^Call to function is_array\\(\\) with array\\ will always evaluate to true\\.$#" - count: 2 - path: ../src/Composer/Repository/FilterRepository.php - - - - message: "#^Call to function is_bool\\(\\) with bool will always evaluate to true\\.$#" - count: 1 - path: ../src/Composer/Repository/FilterRepository.php - - message: "#^Only booleans are allowed in &&, string\\|null given on the left side\\.$#" count: 1 @@ -6582,7 +6527,7 @@ parameters: - message: "#^Call to function is_resource\\(\\) with resource will always evaluate to true\\.$#" - count: 4 + count: 3 path: ../src/Composer/Util/Http/CurlDownloader.php - @@ -6860,11 +6805,6 @@ parameters: count: 1 path: ../src/Composer/Util/Http/RequestProxy.php - - - message: "#^Casting to int something that's already int\\.$#" - count: 1 - path: ../src/Composer/Util/Http/Response.php - - message: "#^Anonymous function uses \\$this assigned to variable \\$downloader\\. Use \\$this directly in the function body\\.$#" count: 2 @@ -7140,11 +7080,6 @@ parameters: count: 1 path: ../src/Composer/Util/Platform.php - - - message: "#^Casting to string something that's already string\\.$#" - count: 1 - path: ../src/Composer/Util/Platform.php - - message: "#^Only booleans are allowed in &&, array\\|false given on the left side\\.$#" count: 1 @@ -8088,11 +8023,6 @@ parameters: count: 4 path: ../tests/Composer/Test/InstallerTest.php - - - message: "#^Call to function is_array\\(\\) with array\\ will always evaluate to true\\.$#" - count: 1 - path: ../tests/Composer/Test/InstallerTest.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 9 diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 31aacde00..6326158dd 100644 --- a/src/Composer/Installer.php +++ b/src/Composer/Installer.php @@ -507,23 +507,25 @@ class Installer } } - $this->io->writeError(sprintf( - "Lock file operations: %d install%s, %d update%s, %d removal%s", - count($installNames), - 1 === count($installNames) ? '' : 's', - count($updateNames), - 1 === count($updateNames) ? '' : 's', - count($uninstalls), - 1 === count($uninstalls) ? '' : 's' - )); - if ($installNames) { - $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE); - } - if ($updateNames) { - $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE); - } - if ($uninstalls) { - $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE); + if ($this->config->get('lock')) { + $this->io->writeError(sprintf( + "Lock file operations: %d install%s, %d update%s, %d removal%s", + count($installNames), + 1 === count($installNames) ? '' : 's', + count($updateNames), + 1 === count($updateNames) ? '' : 's', + count($uninstalls), + 1 === count($uninstalls) ? '' : 's' + )); + if ($installNames) { + $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE); + } + if ($updateNames) { + $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE); + } + if ($uninstalls) { + $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE); + } } } @@ -550,8 +552,8 @@ class Installer $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage()); } - // output op, but alias op only in debug verbosity - if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) { + // output op if lock file is enabled, but alias op only in debug verbosity + if ($this->config->get('lock') && (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug())) { $this->io->writeError(' - ' . $operation->show(true)); } } @@ -655,7 +657,9 @@ class Installer */ protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false) { - $this->io->writeError('Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').''); + if ($this->config->get('lock')) { + $this->io->writeError('Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').''); + } $lockedRepository = $this->locker->getLockedRepository($this->devMode);