diff --git a/src/StaticsMergerPlugin.php b/src/StaticsMergerPlugin.php index 0212124..519a351 100644 --- a/src/StaticsMergerPlugin.php +++ b/src/StaticsMergerPlugin.php @@ -261,7 +261,7 @@ public function getStaticPackages() { $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getPackages(); - return array_filter($packages, function (Package $package) { + return array_filter($packages, function (PackageInterface $package) { return $package->getType() == static::PACKAGE_TYPE && $this->getStaticMaps($package->getName()); }); } diff --git a/test/StaticsMergerPluginTest.php b/test/StaticsMergerPluginTest.php index 42921d5..18a18ca 100644 --- a/test/StaticsMergerPluginTest.php +++ b/test/StaticsMergerPluginTest.php @@ -2,6 +2,7 @@ namespace Jh\StaticsMergerTest; +use Composer\Package\AliasPackage; use Composer\Package\Package; use Composer\Package\PackageInterface; use Composer\Package\RootPackage; @@ -974,4 +975,21 @@ public function relativePathTestDataProvider() array('same/dir/assets/test', 'same/dir/assets/file', './file') ); } + + public function testGetStaticPackagesAllowsAliasPackageInstance() + { + $this->createRootPackage(); + $staticPackage = $this->createStaticPackage(); + + $truePackage = new Package("package/package", "1.0.0", "package/package"); + $aliasPackage = new AliasPackage($truePackage, '1.1.1', 'alias/package'); + + $this->localRepository->addPackage($aliasPackage); + $this->localRepository->addPackage($staticPackage); + + $this->activatePlugin(); + $staticPackages = $this->plugin->getStaticPackages(); + + $this->assertNotEmpty($staticPackages); + } }