Skip to content

Commit 277e060

Browse files
bug #699 Avoid filtering out aliases of valid packages (Seldaek)
This PR was merged into the 1.8-dev branch. Discussion ---------- Avoid filtering out aliases of valid packages It'd be good to add tests for this ... and I am not sure if the branch-alias check at line 67/68 is still needed if aliases are handled properly, might be or might not be.. I don't fully grasp the scope of what flex does here. Commits ------- 27de569 Avoid filtering out aliases of valid packages
2 parents 1cc7023 + 27de569 commit 277e060

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/PackageFilter.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Flex;
1313

1414
use Composer\IO\IOInterface;
15+
use Composer\Package\AliasPackage;
1516
use Composer\Package\PackageInterface;
1617
use Composer\Semver\Constraint\Constraint;
1718
use Composer\Semver\VersionParser;
@@ -54,20 +55,25 @@ public function removeLegacyPackages(array $data): array
5455
$oneSymfony = false;
5556
foreach ($data as $package) {
5657
$name = $package->getName();
57-
$version = $package->getVersion();
58+
$versions = [$package->getVersion()];
59+
if ($package instanceof AliasPackage) {
60+
$versions[] = $package->getAliasOf()->getVersion();
61+
}
5862
if ('symfony/symfony' !== $name && !isset($knownVersions['splits'][$name])) {
5963
$filteredPackages[] = $package;
6064
continue;
6165
}
6266

63-
if (null !== $alias = $package->getExtra()['branch-alias'][$version] ?? null) {
64-
$version = $this->versionParser->normalize($alias);
67+
if (null !== $alias = $package->getExtra()['branch-alias'][$package->getVersion()] ?? null) {
68+
$versions[] = $this->versionParser->normalize($alias);
6569
}
6670

67-
if ($this->symfonyConstraints->matches(new Constraint('==', $version))) {
68-
$filteredPackages[] = $package;
69-
$oneSymfony = $oneSymfony || 'symfony/symfony' === $name;
70-
continue;
71+
foreach ($versions as $version) {
72+
if ($this->symfonyConstraints->matches(new Constraint('==', $version))) {
73+
$filteredPackages[] = $package;
74+
$oneSymfony = $oneSymfony || 'symfony/symfony' === $name;
75+
continue 2;
76+
}
7177
}
7278

7379
if ('symfony/symfony' === $name) {

0 commit comments

Comments
 (0)