From c5aa3dc02127757fc042c03a19481161deeceb70 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 8 Mar 2024 08:51:56 +0100 Subject: [PATCH] Update deps, update baseline (1677, 97), fixes #11875 --- phpstan/baseline.neon | 27 +++++++++------------ src/Composer/Command/ValidateCommand.php | 4 +-- src/Composer/Package/Loader/ArrayLoader.php | 4 +-- src/Composer/Platform/Version.php | 4 ++- src/Composer/Util/Git.php | 5 ++-- src/Composer/Util/Http/ProxyHelper.php | 6 +++-- src/Composer/Util/Http/ProxyManager.php | 1 + src/Composer/Util/RemoteFilesystem.php | 2 ++ 8 files changed, 28 insertions(+), 25 deletions(-) diff --git a/phpstan/baseline.neon b/phpstan/baseline.neon index b17166a49..45dcac955 100644 --- a/phpstan/baseline.neon +++ b/phpstan/baseline.neon @@ -1656,7 +1656,7 @@ parameters: path: ../src/Composer/Downloader/FileDownloader.php - - message: "#^Strict comparison using \\=\\=\\= between null and Composer\\\\Util\\\\Http\\\\Response will always evaluate to false\\.$#" + message: "#^Strict comparison using \\=\\=\\= between null and Composer\\\\Util\\\\Http\\\\Response\\|string will always evaluate to false\\.$#" count: 1 path: ../src/Composer/Downloader/FileDownloader.php @@ -4228,11 +4228,6 @@ parameters: count: 1 path: ../src/Composer/Util/Http/CurlDownloader.php - - - message: "#^Parameter \\#1 \\$mh of function curl_multi_setopt expects resource, resource\\|false given\\.$#" - count: 2 - path: ../src/Composer/Util/Http/CurlDownloader.php - - message: "#^Parameter \\#1 \\$str of function preg_quote expects string, string\\|false\\|null given\\.$#" count: 1 @@ -4313,11 +4308,6 @@ parameters: count: 1 path: ../src/Composer/Util/Http/CurlDownloader.php - - - message: "#^Property Composer\\\\Util\\\\Http\\\\CurlDownloader\\:\\:\\$multiHandle \\(resource\\|null\\) does not accept resource\\|false\\.$#" - count: 1 - path: ../src/Composer/Util/Http/CurlDownloader.php - - message: "#^Short ternary operator is not allowed\\. Use null coalesce operator if applicable or consider using long ternary\\.$#" count: 1 @@ -4483,6 +4473,11 @@ parameters: count: 1 path: ../src/Composer/Util/NoProxyPattern.php + - + message: "#^Method Composer\\\\Util\\\\NoProxyPattern\\:\\:ipCheckData\\(\\) never assigns null to &\\$ipdata so it can be removed from the by\\-ref type\\.$#" + count: 1 + path: ../src/Composer/Util/NoProxyPattern.php + - message: "#^Only booleans are allowed in a negated boolean, bool\\|stdClass given\\.$#" count: 1 @@ -4773,6 +4768,11 @@ parameters: count: 1 path: ../src/Composer/Util/RemoteFilesystem.php + - + message: "#^Parameter &\\$responseHeaders @param\\-out type of method Composer\\\\Util\\\\RemoteFilesystem\\:\\:getRemoteContents\\(\\) expects list\\, array\\ given\\.$#" + count: 1 + path: ../src/Composer/Util/RemoteFilesystem.php + - message: "#^Property Composer\\\\Util\\\\RemoteFilesystem\\:\\:\\$scheme \\(string\\) does not accept string\\|false\\|null\\.$#" count: 1 @@ -5321,11 +5321,6 @@ parameters: count: 1 path: ../tests/Composer/Test/Question/StrictConfirmationQuestionTest.php - - - message: "#^Cannot call method getDistType\\(\\) on Composer\\\\Package\\\\BasePackage\\|null\\.$#" - count: 1 - path: ../tests/Composer/Test/Repository/ArtifactRepositoryTest.php - - message: "#^Parameter \\#1 \\$haystack of function strpos expects string, string\\|null given\\.$#" count: 2 diff --git a/src/Composer/Command/ValidateCommand.php b/src/Composer/Command/ValidateCommand.php index 529401e98..d9d8c7510 100644 --- a/src/Composer/Command/ValidateCommand.php +++ b/src/Composer/Command/ValidateCommand.php @@ -106,7 +106,7 @@ EOT $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true); // $errors include publish and lock errors when exists - $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0); + $exitCode = count($errors) > 0 ? 2 : (($isStrict && count($warnings) > 0) ? 1 : 0); if ($input->getOption('with-dependencies')) { $localRepo = $composer->getRepositoryManager()->getLocalRepository(); @@ -122,7 +122,7 @@ EOT $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors); // $errors include publish errors when exists - $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0); + $depCode = count($errors) > 0 ? 2 : (($isStrict && count($warnings) > 0) ? 1 : 0); $exitCode = max($depCode, $exitCode); } } diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 44b778f29..daa540bd8 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -313,8 +313,8 @@ class ArrayLoader implements LoaderInterface } /** - * @param array>>> $linkCache - * @param mixed[] $config + * @param array>>> $linkCache + * @param mixed[] $config */ private function configureCachedLinks(array &$linkCache, PackageInterface $package, array $config): void { diff --git a/src/Composer/Platform/Version.php b/src/Composer/Platform/Version.php index 8a3f23e4a..56abb1bb1 100644 --- a/src/Composer/Platform/Version.php +++ b/src/Composer/Platform/Version.php @@ -20,7 +20,9 @@ use Composer\Pcre\Preg; class Version { /** - * @param bool $isFips Set by the method + * @param bool $isFips Set by the method + * + * @param-out bool $isFips */ public static function parseOpenssl(string $opensslVersion, ?bool &$isFips): ?string { diff --git a/src/Composer/Util/Git.php b/src/Composer/Util/Git.php index f8e503d82..67af22e8d 100644 --- a/src/Composer/Util/Git.php +++ b/src/Composer/Util/Git.php @@ -357,11 +357,12 @@ class Git } /** - * @param string[] $match + * @param array $match + * @param-out array $match */ private function isAuthenticationFailure(string $url, array &$match): bool { - if (!Preg::isMatch('{^(https?://)([^/]+)(.*)$}i', $url, $match)) { + if (!Preg::isMatchStrictGroups('{^(https?://)([^/]+)(.*)$}i', $url, $match)) { return false; } diff --git a/src/Composer/Util/Http/ProxyHelper.php b/src/Composer/Util/Http/ProxyHelper.php index 58056e429..f2d864f29 100644 --- a/src/Composer/Util/Http/ProxyHelper.php +++ b/src/Composer/Util/Http/ProxyHelper.php @@ -104,10 +104,12 @@ class ProxyHelper /** * Searches $_SERVER for case-sensitive values * - * @param string[] $names Names to search for - * @param string|null $name Name of any found value + * @param non-empty-list $names Names to search for + * @param string|null $name Name of any found value, you should only rely on it if the function returned a non-null value * * @return string|null The found value + * + * @param-out string $name */ private static function getProxyEnv(array $names, ?string &$name): ?string { diff --git a/src/Composer/Util/Http/ProxyManager.php b/src/Composer/Util/Http/ProxyManager.php index 5af53ad0c..731638ab8 100644 --- a/src/Composer/Util/Http/ProxyManager.php +++ b/src/Composer/Util/Http/ProxyManager.php @@ -94,6 +94,7 @@ class ProxyManager } else { $proxyUrl = $this->fullProxy[$scheme]; $options = $this->streams[$scheme]['options']; + assert(is_array($options)); ProxyHelper::setRequestFullUri($requestUrl, $options); $formattedProxyUrl = $this->safeProxy[$scheme]; } diff --git a/src/Composer/Util/RemoteFilesystem.php b/src/Composer/Util/RemoteFilesystem.php index 8abf015a7..0cc9df772 100644 --- a/src/Composer/Util/RemoteFilesystem.php +++ b/src/Composer/Util/RemoteFilesystem.php @@ -509,6 +509,8 @@ class RemoteFilesystem * @param int $maxFileSize The maximum allowed file size * * @return string|false The response contents or false on failure + * + * @param-out list $responseHeaders */ protected function getRemoteContents(string $originUrl, string $fileUrl, $context, ?array &$responseHeaders = null, ?int $maxFileSize = null) {