Skip to content

Commit

Permalink
Fix handling of upper-bound platform req ignores to not act on confli…
Browse files Browse the repository at this point in the history
…cts (composer#11037)

* Fix handling of upper-bound platform req ignores to not act on conflicts, fixes composer#11020

* Optimization
  • Loading branch information
Seldaek authored and emahorvat52 committed Jan 18, 2023
1 parent 8310f40 commit 52bca7d
Showing 1 changed file with 4 additions and 10 deletions.
Expand Up @@ -39,7 +39,7 @@ final class IgnoreListPlatformRequirementFilter implements PlatformRequirementFi
*/
public function __construct(array $reqList)
{
$ignoreAll = $ignoreUpperBound = array();
$ignoreAll = $ignoreUpperBound = [];
foreach ($reqList as $req) {
if (substr($req, -1) === '+') {
$ignoreUpperBound[] = substr($req, 0, -1);
Expand All @@ -51,11 +51,7 @@ public function __construct(array $reqList)
$this->ignoreUpperBoundRegex = BasePackage::packageNamesToRegexp($ignoreUpperBound);
}

/**
* @param string $req
* @return bool
*/
public function isIgnored($req)
public function isIgnored(string $req): bool
{
if (!PlatformRepository::isPlatformPackage($req)) {
return false;
Expand All @@ -65,11 +61,9 @@ public function isIgnored($req)
}

/**
* @param string $req
* @return ConstraintInterface
* @param bool $allowUpperBoundOverride For conflicts we do not want the upper bound to be skipped
*/
public function filterConstraint($req, ConstraintInterface $constraint, $allowUpperBoundOverride = true)
public function filterConstraint(string $req, ConstraintInterface $constraint, bool $allowUpperBoundOverride = true): ConstraintInterface
{
if (!PlatformRepository::isPlatformPackage($req)) {
return $constraint;
Expand All @@ -86,7 +80,7 @@ public function filterConstraint($req, ConstraintInterface $constraint, $allowUp
$intervals = Intervals::get($constraint);
$last = end($intervals['numeric']);
if ($last !== false && (string) $last->getEnd() !== (string) Interval::untilPositiveInfinity()) {
$constraint = new MultiConstraint(array($constraint, new Constraint('>=', $last->getEnd()->getVersion())), false);
$constraint = new MultiConstraint([$constraint, new Constraint('>=', $last->getEnd()->getVersion())], false);
}

return $constraint;
Expand Down

0 comments on commit 52bca7d

Please sign in to comment.