From d4073a40f9c2ec779233bcb0f8f4878bc0ef8e1b Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Fri, 12 Feb 2021 11:14:40 +0100 Subject: [PATCH] Prepend runtime-autoloaders so that dependencies get loaded over Composer bundled packages As Composer is generally compatible with newer versions of Symfony than the bundled ones, this should not be a problem if dependencies are shared, and it ensures that the most relevant code gets loaded. --- src/Composer/Autoload/AutoloadGenerator.php | 4 ++-- src/Composer/EventDispatcher/EventDispatcher.php | 4 ++-- src/Composer/Plugin/PluginManager.php | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Composer/Autoload/AutoloadGenerator.php b/src/Composer/Autoload/AutoloadGenerator.php index fa5dd9cf2..fd5a594e5 100644 --- a/src/Composer/Autoload/AutoloadGenerator.php +++ b/src/Composer/Autoload/AutoloadGenerator.php @@ -517,9 +517,9 @@ EOF; * @param array $autoloads see parseAutoloads return value * @return ClassLoader */ - public function createLoader(array $autoloads) + public function createLoader(array $autoloads, $vendorDir = null) { - $loader = new ClassLoader(); + $loader = new ClassLoader($vendorDir); if (isset($autoloads['psr-0'])) { foreach ($autoloads['psr-0'] as $namespace => $path) { diff --git a/src/Composer/EventDispatcher/EventDispatcher.php b/src/Composer/EventDispatcher/EventDispatcher.php index faedb969a..882b160e2 100644 --- a/src/Composer/EventDispatcher/EventDispatcher.php +++ b/src/Composer/EventDispatcher/EventDispatcher.php @@ -435,8 +435,8 @@ class EventDispatcher $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages(); $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages); $map = $generator->parseAutoloads($packageMap, $package); - $this->loader = $generator->createLoader($map); - $this->loader->register(); + $this->loader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir')); + $this->loader->register(true); return $scripts[$event->getName()]; } diff --git a/src/Composer/Plugin/PluginManager.php b/src/Composer/Plugin/PluginManager.php index 4c5d4d9bf..27a21ce81 100644 --- a/src/Composer/Plugin/PluginManager.php +++ b/src/Composer/Plugin/PluginManager.php @@ -198,8 +198,8 @@ class PluginManager } $map = $generator->parseAutoloads($autoloads, $rootPackage); - $classLoader = $generator->createLoader($map); - $classLoader->register(); + $classLoader = $generator->createLoader($map, $this->composer->getConfig()->get('vendor-dir')); + $classLoader->register(true); foreach ($classes as $class) { if (class_exists($class, false)) {