From 3ae662f4c7be3f37aa8628d3540486ba79c1de94 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 7 Jun 2023 15:19:44 +0200 Subject: [PATCH 1/8] Fix EventDispatcher on windows picking bat files when using "@php binary", fixes #11490 --- src/Composer/EventDispatcher/EventDispatcher.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index 95ca80d20..b564cf367 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -351,6 +351,14 @@ class EventDispatcher if ($matched && !file_exists($match[0])) { $finder = new ExecutableFinder; if ($pathToExec = $finder->find($match[0])) { + if (Platform::isWindows()) { + $execWithoutExt = Preg::replace('{\.(exe|bat|cmd|com)$}i', '', $pathToExec); + // prefer non-extension file if it exists when executing with PHP + if (file_exists($execWithoutExt)) { + $pathToExec = $execWithoutExt; + } + unset($execWithoutExt); + } $pathAndArgs = $pathToExec . substr($pathAndArgs, strlen($match[0])); } } From ff67cdf6e6c9933e925950b0f407b03294456c36 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 7 Jun 2023 16:19:44 +0200 Subject: [PATCH 2/8] Ignore ICU CDLR version fetching when ICU cannot initialize the resource bundle, fixes #11492 --- src/Composer/Repository/PlatformRepository.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 116f2b2dc..2e90e05f3 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -333,8 +333,10 @@ class PlatformRepository extends ArrayRepository // Add a separate version for the CLDR library version if ($this->runtime->hasClass('ResourceBundle')) { - $cldrVersion = $this->runtime->invoke(['ResourceBundle', 'create'], ['root', 'ICUDATA', false])->get('Version'); - $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version'); + $resourceBundle = $this->runtime->invoke(['ResourceBundle', 'create'], ['root', 'ICUDATA', false]); + if ($resourceBundle !== null) { + $this->addLibrary('icu-cldr', $resourceBundle->get('Version');, 'ICU CLDR project version'); + } } if ($this->runtime->hasClass('IntlChar')) { From 7f6de3635478f4c6017c044d9a27a2e1fe8d3cab Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Wed, 7 Jun 2023 16:35:29 +0200 Subject: [PATCH 3/8] Fix typo --- src/Composer/Repository/PlatformRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/Repository/PlatformRepository.php b/src/Composer/Repository/PlatformRepository.php index 2e90e05f3..2b98cae94 100644 --- a/src/Composer/Repository/PlatformRepository.php +++ b/src/Composer/Repository/PlatformRepository.php @@ -335,7 +335,7 @@ class PlatformRepository extends ArrayRepository if ($this->runtime->hasClass('ResourceBundle')) { $resourceBundle = $this->runtime->invoke(['ResourceBundle', 'create'], ['root', 'ICUDATA', false]); if ($resourceBundle !== null) { - $this->addLibrary('icu-cldr', $resourceBundle->get('Version');, 'ICU CLDR project version'); + $this->addLibrary('icu-cldr', $resourceBundle->get('Version'), 'ICU CLDR project version'); } } From c12b551d3a0453328af2b553889fa9eedb786459 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Thu, 8 Jun 2023 16:30:13 +0200 Subject: [PATCH 4/8] Update type declarations on ClassLoader, fixes #11482 (#11500) --- src/Composer/Autoload/ClassLoader.php | 96 +++++++++++++-------------- 1 file changed, 45 insertions(+), 51 deletions(-) diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index a72151c77..179ccd497 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -45,35 +45,34 @@ class ClassLoader /** @var \Closure(string):void */ private static $includeFile; - /** @var ?string */ + /** @var string|null */ private $vendorDir; // PSR-4 /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array[] - * @psalm-var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * @var array[] - * @psalm-var array> + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array> */ private $prefixesPsr0 = array(); /** - * @var array[] - * @psalm-var array + * @var list */ private $fallbackDirsPsr0 = array(); @@ -81,8 +80,7 @@ class ClassLoader private $useIncludePath = false; /** - * @var string[] - * @psalm-var array + * @var array */ private $classMap = array(); @@ -90,21 +88,20 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var bool[] - * @psalm-var array + * @var array */ private $missingClasses = array(); - /** @var ?string */ + /** @var string|null */ private $apcuPrefix; /** - * @var self[] + * @var array */ private static $registeredLoaders = array(); /** - * @param ?string $vendorDir + * @param string|null $vendorDir */ public function __construct($vendorDir = null) { @@ -113,7 +110,7 @@ class ClassLoader } /** - * @return string[] + * @return array> */ public function getPrefixes() { @@ -125,8 +122,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array> + * @return array> */ public function getPrefixesPsr4() { @@ -134,8 +130,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirs() { @@ -143,8 +138,7 @@ class ClassLoader } /** - * @return array[] - * @psalm-return array + * @return list */ public function getFallbackDirsPsr4() { @@ -152,8 +146,7 @@ class ClassLoader } /** - * @return string[] Array of classname => path - * @psalm-return array + * @return array Array of classname => path */ public function getClassMap() { @@ -161,8 +154,7 @@ class ClassLoader } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap + * @param array $classMap Class to filename map * * @return void */ @@ -179,24 +171,25 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - (array) $paths + $paths ); } @@ -205,19 +198,19 @@ class ClassLoader $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; + $this->prefixesPsr0[$first][$prefix] = $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - (array) $paths + $paths ); } } @@ -226,9 +219,9 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -236,17 +229,18 @@ class ClassLoader */ public function addPsr4($prefix, $paths, $prepend = false) { + $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - (array) $paths, + $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - (array) $paths + $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -256,18 +250,18 @@ class ClassLoader throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; + $this->prefixDirsPsr4[$prefix] = $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, + $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - (array) $paths + $paths ); } } @@ -276,8 +270,8 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories * * @return void */ @@ -294,8 +288,8 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -481,9 +475,9 @@ class ClassLoader } /** - * Returns the currently registered loaders indexed by their corresponding vendor directories. + * Returns the currently registered loaders keyed by their corresponding vendor directories. * - * @return self[] + * @return array */ public static function getRegisteredLoaders() { From 45368a5bde130b66a0d5cb38b78c22a931d37451 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 9 Jun 2023 17:08:20 +0200 Subject: [PATCH 5/8] Update types some more, refs #11500 --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a96e5d37..79ac978a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### [2.5.8] 2023-06-09 + + * Fixed regression in edge cases where root package gets added to a repository already during the install process (#11495) + * Fixed EventDispatcher on windows picking bat files when using "@php binary" (#11490) + * Fixed ICU CDLR version parsing failing the whole process when ICU cannot initialize the resource bundle (#11492) + * Fixed type declarations on ClassLoader (#11500) + ### [2.5.7] 2023-05-24 * Fixed regression preventing autoloading the dependencies of metapackages when running --no-dev (#11481) @@ -1724,6 +1731,7 @@ * Initial release +[2.5.8]: https://github.com/composer/composer/compare/2.5.7...2.5.8 [2.5.7]: https://github.com/composer/composer/compare/2.5.6...2.5.7 [2.5.6]: https://github.com/composer/composer/compare/2.5.5...2.5.6 [2.5.5]: https://github.com/composer/composer/compare/2.5.4...2.5.5 From 3f385d466fef9bdd355a6ec01ec7c1875bd95f92 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 9 Jun 2023 17:13:00 +0200 Subject: [PATCH 6/8] Update types some more, refs #11500 --- src/Composer/Autoload/ClassLoader.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Composer/Autoload/ClassLoader.php b/src/Composer/Autoload/ClassLoader.php index 179ccd497..7824d8f7e 100644 --- a/src/Composer/Autoload/ClassLoader.php +++ b/src/Composer/Autoload/ClassLoader.php @@ -54,7 +54,7 @@ class ClassLoader */ private $prefixLengthsPsr4 = array(); /** - * @var array> + * @var array> */ private $prefixDirsPsr4 = array(); /** @@ -68,7 +68,7 @@ class ClassLoader * * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) * - * @var array> + * @var array>> */ private $prefixesPsr0 = array(); /** @@ -122,7 +122,7 @@ class ClassLoader } /** - * @return array> + * @return array> */ public function getPrefixesPsr4() { From 4c516146167d1392c8b9b269bb7c24115d262164 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 9 Jun 2023 17:13:21 +0200 Subject: [PATCH 7/8] Release 2.5.8 --- src/Composer/Composer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index 8a870cc47..a6901dced 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -51,10 +51,10 @@ class Composer extends PartialComposer * * @see getVersion() */ - public const VERSION = '@package_version@'; - public const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; - public const RELEASE_DATE = '@release_date@'; - public const SOURCE_VERSION = '2.5.999-dev+source'; + public const VERSION = '2.5.8'; + public const BRANCH_ALIAS_VERSION = ''; + public const RELEASE_DATE = '2023-06-09 17:13:21'; + public const SOURCE_VERSION = ''; /** * Version number of the internal composer-runtime-api package From 7b03fa1ba3a3aefe0c153a87c14f4e60b4dc0b5c Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 9 Jun 2023 17:13:22 +0200 Subject: [PATCH 8/8] Reverting release version changes --- src/Composer/Composer.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Composer/Composer.php b/src/Composer/Composer.php index a6901dced..8a870cc47 100644 --- a/src/Composer/Composer.php +++ b/src/Composer/Composer.php @@ -51,10 +51,10 @@ class Composer extends PartialComposer * * @see getVersion() */ - public const VERSION = '2.5.8'; - public const BRANCH_ALIAS_VERSION = ''; - public const RELEASE_DATE = '2023-06-09 17:13:21'; - public const SOURCE_VERSION = ''; + public const VERSION = '@package_version@'; + public const BRANCH_ALIAS_VERSION = '@package_branch_alias_version@'; + public const RELEASE_DATE = '@release_date@'; + public const SOURCE_VERSION = '2.5.999-dev+source'; /** * Version number of the internal composer-runtime-api package