@@ -286,6 +286,11 @@ private function loadModuleClassesDependencies(PackageInterface $package): array
286286 $ installer = $ this ->composer ->getInstallationManager ();
287287 $ packagePath = $ installer ->getInstallPath ($ package );
288288
289+ if ($ packagePath === null || $ packagePath === '' ) {
290+ // Do not try to discover dependencies for metapackage and other
291+ // potential package types that have no install location.
292+ return [];
293+ }
289294 $ this ->mapAutoloaders ($ package ->getAutoload (), $ dependencies , $ packagePath );
290295
291296 return $ dependencies ->getArrayCopy ();
@@ -748,7 +753,7 @@ private function cacheInjector(InjectorInterface $injector, int $packageType): v
748753 *
749754 * @param AutoloadRules $autoload List of autoloader types and associated autoloader definitions.
750755 * @param ArrayObject $dependencies Module dependencies defined by the module.
751- * @param string $packagePath Path to the package on the filesystem.
756+ * @param non-empty- string $packagePath Path to the package on the filesystem.
752757 * @psalm-param ArrayObject<non-empty-string,list<non-empty-string>> $dependencies
753758 */
754759 private function mapAutoloaders (array $ autoload , ArrayObject $ dependencies , string $ packagePath ): void
@@ -764,7 +769,7 @@ private function mapAutoloaders(array $autoload, ArrayObject $dependencies, stri
764769 * @param array $map Map of namespace => path(s) pairs.
765770 * @param string $type Type of autoloader being iterated.
766771 * @param ArrayObject $dependencies Module dependencies defined by the module.
767- * @param string $packagePath Path to the package on the filesystem.
772+ * @param non-empty- string $packagePath Path to the package on the filesystem.
768773 * @psalm-param array<int|string, array<array-key, string>|string> $map
769774 * @psalm-param ArrayObject<non-empty-string,list<non-empty-string>> $dependencies
770775 */
@@ -783,7 +788,7 @@ private function mapType(array $map, string $type, ArrayObject $dependencies, st
783788 * @param string|int $namespace PHP namespace to which the paths map or index of file/directory list.
784789 * @param string $type Type of autoloader being iterated.
785790 * @param ArrayObject $dependencies Module dependencies defined by the module.
786- * @param string $packagePath Path to the package on the filesystem.
791+ * @param non-empty- string $packagePath Path to the package on the filesystem.
787792 * @psalm-param list<string> $paths
788793 * @psalm-param ArrayObject<non-empty-string,list<non-empty-string>> $dependencies
789794 */
@@ -806,7 +811,7 @@ private function mapNamespacePaths(
806811 * @param string|int $namespace PHP namespace to which the paths map.
807812 * @param string $type Type of autoloader being iterated.
808813 * @param ArrayObject $dependencies Module dependencies defined by the module.
809- * @param string $packagePath Path to the package on the filesystem.
814+ * @param non-empty- string $packagePath Path to the package on the filesystem.
810815 * @psalm-param ArrayObject<non-empty-string,list<non-empty-string>> $dependencies
811816 */
812817 private function mapPath (
0 commit comments