From 4c8e41d9a922005360bad3889ac3fdcc350c2195 Mon Sep 17 00:00:00 2001 From: Tyson Andre Date: Tue, 15 Oct 2019 21:21:25 -0400 Subject: [PATCH 1/2] Fix misc phpdoc and strpos arg order nits https://www.php.net/strpos has the signature `strpos ( string $haystack , mixed $needle [, int $offset = 0 ] ) : int` (The needle is usually the constant) `strpos('/', $suggestion)` would only be `false` for `''` and `'/'` So the existing check would just not suggest **anything** that was already installed (from pecl, built-in, or composer). The intent seems to be to not suggest non-vendored php packages that were already installed. (b20cc22ebb1d9f8ed467f0ea353391be7442ad3d) --- src/Composer/Command/SuggestsCommand.php | 2 +- src/Composer/Package/BasePackage.php | 2 +- src/Composer/Util/Zip.php | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Composer/Command/SuggestsCommand.php b/src/Composer/Command/SuggestsCommand.php index a200f8f69..13f742023 100644 --- a/src/Composer/Command/SuggestsCommand.php +++ b/src/Composer/Command/SuggestsCommand.php @@ -90,7 +90,7 @@ EOT continue; } foreach ($package['suggest'] as $suggestion => $reason) { - if (false === strpos('/', $suggestion) && null !== $platform->findPackage($suggestion, '*')) { + if (null !== $platform->findPackage($suggestion, '*')) { continue; } if (!isset($installed[$suggestion])) { diff --git a/src/Composer/Package/BasePackage.php b/src/Composer/Package/BasePackage.php index f2f5be707..9630e7ef0 100644 --- a/src/Composer/Package/BasePackage.php +++ b/src/Composer/Package/BasePackage.php @@ -239,7 +239,7 @@ abstract class BasePackage implements PackageInterface * Build a regexp from a package name, expanding * globs as required * * @param string $whiteListedPattern - * @param bool $wrap Wrap the cleaned string by the given string + * @param string $wrap Wrap the cleaned string by the given string * @return string */ public static function packageNameToRegexp($whiteListedPattern, $wrap = '{^%s$}i') diff --git a/src/Composer/Util/Zip.php b/src/Composer/Util/Zip.php index 8c79d106c..ab10d5bbf 100644 --- a/src/Composer/Util/Zip.php +++ b/src/Composer/Util/Zip.php @@ -21,7 +21,6 @@ class Zip * Gets content of the root composer.json inside a ZIP archive. * * @param string $pathToZip - * @param string $filename * * @return string|null */ From d73cef3fb4d03da5fc846604caa629bf684da79c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 24 Oct 2019 11:16:42 +0200 Subject: [PATCH 2/2] Avoid calling findPackage for non-platform packages --- src/Composer/Command/SuggestsCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Command/SuggestsCommand.php b/src/Composer/Command/SuggestsCommand.php index 13f742023..a7ec3dad8 100644 --- a/src/Composer/Command/SuggestsCommand.php +++ b/src/Composer/Command/SuggestsCommand.php @@ -90,7 +90,7 @@ EOT continue; } foreach ($package['suggest'] as $suggestion => $reason) { - if (null !== $platform->findPackage($suggestion, '*')) { + if (preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $suggestion) && null !== $platform->findPackage($suggestion, '*')) { continue; } if (!isset($installed[$suggestion])) {