From 62d5f4f295794e856b69be4e94b3b2edb34e4177 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 2 Feb 2022 22:18:00 +0100 Subject: [PATCH] Fix phpstan errors --- phpstan/baseline.neon | 39 ++++++------------- src/Composer/Downloader/PathDownloader.php | 4 +- tests/Composer/Test/InstalledVersionsTest.php | 2 + 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index 5c33d1b38..3d77449f0 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -2740,11 +2740,6 @@ parameters: count: 1 path: ../src/Composer/DependencyResolver/GenericRule.php - - - message: "#^Cannot access offset 0 on array\\{int, Composer\\\\DependencyResolver\\\\Rule\\}\\|false\\.$#" - count: 1 - path: ../src/Composer/DependencyResolver/LockTransaction.php - - message: "#^Only booleans are allowed in &&, DateTime\\|null given on the left side\\.$#" count: 1 @@ -3050,16 +3045,6 @@ parameters: count: 1 path: ../src/Composer/DependencyResolver/RuleWatchGraph.php - - - message: "#^Cannot access offset 0 on array\\{int, Composer\\\\DependencyResolver\\\\Rule\\}\\|false\\.$#" - count: 1 - path: ../src/Composer/DependencyResolver/Solver.php - - - - message: "#^Cannot access offset 1 on array\\{int, Composer\\\\DependencyResolver\\\\Rule\\}\\|false\\.$#" - count: 1 - path: ../src/Composer/DependencyResolver/Solver.php - - message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#" count: 2 @@ -3526,7 +3511,17 @@ parameters: path: ../src/Composer/Downloader/HgDownloader.php - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" + message: "#^Call to function in_array\\(\\) with arguments 20, array\\{0\\: 10\\|20, 1\\?\\: 20\\} and true will always evaluate to true\\.$#" + count: 1 + path: ../src/Composer/Downloader/PathDownloader.php + + - + message: "#^Call to function in_array\\(\\) with arguments 20, non\\-empty\\-array\\ and true will always evaluate to true\\.$#" + count: 1 + path: ../src/Composer/Downloader/PathDownloader.php + + - + message: "#^Else branch is unreachable because previous condition is always true\\.$#" count: 1 path: ../src/Composer/Downloader/PathDownloader.php @@ -5540,11 +5535,6 @@ parameters: count: 1 path: ../src/Composer/Repository/FilterRepository.php - - - message: "#^Parameter \\#1 \\$pattern of static method Composer\\\\Pcre\\\\Preg\\:\\:isMatch\\(\\) expects string, string\\|null given\\.$#" - count: 1 - path: ../src/Composer/Repository/FilterRepository.php - - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" count: 7 @@ -5580,11 +5570,6 @@ parameters: count: 2 path: ../src/Composer/Repository/PathRepository.php - - - message: "#^Offset 'versions' does not exist on array\\{symlink\\?\\: bool, relative\\?\\: bool, versions\\?\\: array\\\\}\\.$#" - count: 1 - path: ../src/Composer/Repository/PathRepository.php - - message: "#^Only booleans are allowed in &&, string\\|false given on the right side\\.$#" count: 1 @@ -6997,7 +6982,7 @@ parameters: - message: "#^Offset 'options' does not exist on array\\{url\\: string, options\\?\\: array, copyTo\\?\\: string\\|null\\}\\.$#" - count: 5 + count: 3 path: ../src/Composer/Util/HttpDownloader.php - diff --git a/src/Composer/Downloader/PathDownloader.php b/src/Composer/Downloader/PathDownloader.php index 97de3a6e0..5482bf43d 100644 --- a/src/Composer/Downloader/PathDownloader.php +++ b/src/Composer/Downloader/PathDownloader.php @@ -126,7 +126,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter } } } catch (IOException $e) { - if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) { + if (in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) { if ($output) { $this->io->writeError(''); $this->io->writeError(' Symlink failed, fallback to use mirroring!'); @@ -272,7 +272,7 @@ class PathDownloader extends FileDownloader implements VcsCapableDownloaderInter // Check we can use junctions safely if we are on Windows if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) { - if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies)) { + if (!in_array(self::STRATEGY_MIRROR, $allowedStrategies, true)) { throw new \RuntimeException('You are on an old Windows / old PHP combo which does not allow Composer to use junctions/symlinks and this path repository has symlink:true in its options so copying is not allowed'); } $currentStrategy = self::STRATEGY_MIRROR; diff --git a/tests/Composer/Test/InstalledVersionsTest.php b/tests/Composer/Test/InstalledVersionsTest.php index 4c27b2e0f..a2c4b17d7 100644 --- a/tests/Composer/Test/InstalledVersionsTest.php +++ b/tests/Composer/Test/InstalledVersionsTest.php @@ -12,11 +12,13 @@ namespace Composer\Test; +use Composer\Autoload\ClassLoader; use Composer\InstalledVersions; use Composer\Semver\VersionParser; class InstalledVersionsTest extends TestCase { + /** @var array */ private static $previousRegisteredLoaders; /**