From a8597ef4206d6e4709a8872cccd25a6b3b275104 Mon Sep 17 00:00:00 2001 From: Giuseppe Mazzapica Date: Mon, 29 May 2023 13:06:49 +0200 Subject: [PATCH] Use an empty string as fallback for InstallationManager::etInstallPath For Composer 2.5.6+ compatibility --- src/Asset/Config.php | 9 ++------- src/Asset/Factory.php | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Asset/Config.php b/src/Asset/Config.php index 63e2789..fe17fba 100644 --- a/src/Asset/Config.php +++ b/src/Asset/Config.php @@ -129,7 +129,7 @@ public static function forAssetConfigInRoot( /** * @param PackageInterface $package - * @param string|null $path + * @param string $path * @param ModeResolver $modeResolver * @param Filesystem $filesystem * @param array $rootEnv @@ -137,7 +137,7 @@ public static function forAssetConfigInRoot( */ public static function forComposerPackage( PackageInterface $package, - ?string $path, + string $path, ModeResolver $modeResolver, Filesystem $filesystem, array $rootEnv = [] @@ -161,11 +161,6 @@ public static function forComposerPackage( $instance = new static($data, $modeResolver, $rootEnv); $instance->byPackage = true; if ($isRoot) { - if (!is_string($path)) { - // This never happens when asset compiler calls this method, but it is a public - // method and the type allows it. So let it throw a telling error. - throw new \Error('Root configuration can not be constructed without a valid path.'); - } $instance->byRootPackage = true; $name = $package->getName(); $instance->rootConfig = RootConfig::new( diff --git a/src/Asset/Factory.php b/src/Asset/Factory.php index e3e4e76..fd3d13e 100644 --- a/src/Asset/Factory.php +++ b/src/Asset/Factory.php @@ -108,7 +108,7 @@ public function attemptFactory( $isRoot = ($package instanceof RootPackageInterface); $path = $isRoot ? $this->rootDir - : $this->installationManager->getInstallPath($package); + : ($this->installationManager->getInstallPath($package) ?? ''); if (!$config && (!$rootLevelPackageConfig || $packageOrDefaultAllowed)) { $packageLevelConfig = Config::forComposerPackage(