From 18e268556dcdadff3d9cd5ed9290fa7d647efb07 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 1 Apr 2021 10:14:21 +0200 Subject: [PATCH] Fix type warning on php8.1, refs #9770 --- src/Composer/Command/CreateProjectCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index d7cfd1039..a1ad373b5 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -343,7 +343,9 @@ EOT } if (null === $stability) { - if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) { + if (null === $packageVersion) { + $stability = 'stable'; + } elseif (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) { $stability = $match[1]; } else { $stability = VersionParser::parseStability($packageVersion);