1
0
Fork 0

Fix implementation of filterPackages

pull/7904/head
Jordi Boggiano 2019-01-14 16:37:33 +01:00
parent fd5c5ff6bc
commit c97b7a9be5
1 changed files with 13 additions and 5 deletions

View File

@ -185,17 +185,25 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
{
$packages = array();
if (null === $constraint) {
if ($returnFirstMatch) {
return reset($packages);
}
return $packages;
}
$filteredPackages = array();
foreach ($packages as $package) {
$pkgConstraint = new Constraint('==', $package->getVersion());
if (null === $constraint || $constraint->matches($pkgConstraint)) {
if ($constraint->matches($pkgConstraint)) {
if ($returnFirstMatch) {
return $package;
}
$packages[] = $package;
$filteredPackages[] = $package;
}
}
@ -203,7 +211,7 @@ class ComposerRepository extends ArrayRepository implements ConfigurableReposito
return null;
}
return $packages;
return $filteredPackages;
}
public function getPackages()