function Solver::makeAssertionRuleDecisions
1 call to Solver::makeAssertionRuleDecisions()
- Solver::solve in vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ Solver.php
File
-
vendor/
composer/ composer/ src/ Composer/ DependencyResolver/ Solver.php, line 80
Class
- Solver
- @author Nils Adermann <naderman@naderman.de>
Namespace
Composer\DependencyResolverCode
private function makeAssertionRuleDecisions() : void {
$decisionStart = \count($this->decisions) - 1;
$rulesCount = \count($this->rules);
for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
$rule = $this->rules->ruleById[$ruleIndex];
if (!$rule->isAssertion() || $rule->isDisabled()) {
continue;
}
$literals = $rule->getLiterals();
$literal = $literals[0];
if (!$this->decisions
->decided($literal)) {
$this->decisions
->decide($literal, 1, $rule);
continue;
}
if ($this->decisions
->satisfy($literal)) {
continue;
}
// found a conflict
if (RuleSet::TYPE_LEARNED === $rule->getType()) {
$rule->disable();
continue;
}
$conflict = $this->decisions
->decisionRule($literal);
if (RuleSet::TYPE_PACKAGE === $conflict->getType()) {
$problem = new Problem();
$problem->addRule($rule);
$problem->addRule($conflict);
$rule->disable();
$this->problems[] = $problem;
continue;
}
// conflict with another root require/fixed package
$problem = new Problem();
$problem->addRule($rule);
$problem->addRule($conflict);
// push all of our rules (can only be root require/fixed package rules)
// asserting this literal on the problem stack
foreach ($this->rules
->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
continue;
}
$assertRuleLiterals = $assertRule->getLiterals();
$assertRuleLiteral = $assertRuleLiterals[0];
if (abs($literal) !== abs($assertRuleLiteral)) {
continue;
}
$problem->addRule($assertRule);
$assertRule->disable();
}
$this->problems[] = $problem;
$this->decisions
->resetToOffset($decisionStart);
$ruleIndex = -1;
}
}