From c27dca83ef21bd44c41c1a60dd2e7ab1afa70a13 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 8 May 2022 10:39:36 +0200 Subject: [PATCH 1/2] Fix deprecated syntax since PHP 8.2 (#10766) --- src/Composer/Autoload/AutoloadGenerator.php | 2 +- src/Composer/DependencyResolver/Problem.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index 87b346595..802cf1b52 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -889,7 +889,7 @@ EXT_CHECKS; // platform_check.php @generated by Composer \$issues = array(); -${requiredPhp}${requiredExtensions} +{$requiredPhp}{$requiredExtensions} if (\$issues) { if (!headers_sent()) { header('HTTP/1.1 500 Internal Server Error'); diff --git a/src/Composer/DependencyResolver/Problem.php b/src/Composer/DependencyResolver/Problem.php index 124a544cb..0ebe14c2a 100644 --- a/src/Composer/DependencyResolver/Problem.php +++ b/src/Composer/DependencyResolver/Problem.php @@ -363,7 +363,7 @@ class Problem $providersStr = implode(array_map(function ($p) { $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : ''; - return " - ${p['name']}".$description."\n"; + return ' - '.$p['name'].$description."\n"; }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers)); if (count($providers) > $maxProviders + 1) { $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n"; From 1d0fa9349563565452474d131d33dc23317febb1 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 11 May 2022 09:39:56 +0200 Subject: [PATCH 2/2] 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);