Improve error messages for solver problems
parent
12abff8b4c
commit
5bea5974f7
|
@ -66,10 +66,10 @@ class Problem
|
||||||
$ext = substr($job['packageName'], 4);
|
$ext = substr($job['packageName'], 4);
|
||||||
$error = extension_loaded($ext) ? 'has the wrong version ('.phpversion($ext).') installed' : 'is missing from your system';
|
$error = extension_loaded($ext) ? 'has the wrong version ('.phpversion($ext).') installed' : 'is missing from your system';
|
||||||
|
|
||||||
return 'The requested PHP extension "'.$job['packageName'].'" '.$this->constraintToText($job['constraint']).$error.'.';
|
return 'The requested PHP extension '.$job['packageName'].$this->constraintToText($job['constraint']).' '.$error.'.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'The requested package "'.$job['packageName'].'" '.$this->constraintToText($job['constraint']).'could not be found.';
|
return 'The requested package '.$job['packageName'].$this->constraintToText($job['constraint']).' could not be found.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,14 +115,27 @@ class Problem
|
||||||
{
|
{
|
||||||
switch ($job['cmd']) {
|
switch ($job['cmd']) {
|
||||||
case 'install':
|
case 'install':
|
||||||
return 'Installation of package "'.$job['packageName'].'" '.$this->constraintToText($job['constraint']).'was requested. Satisfiable by packages ['.implode(', ', $job['packages']).'].';
|
if (!$job['packages']) {
|
||||||
case 'update':
|
return 'No package found to satisfy install request for '.$job['packageName'].$this->constraintToText($job['constraint']);
|
||||||
return 'Update of package "'.$job['packageName'].'" '.$this->constraintToText($job['constraint']).'was requested.';
|
|
||||||
case 'remove':
|
|
||||||
return 'Removal of package "'.$job['packageName'].'" '.$this->constraintToText($job['constraint']).'was requested.';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'Job(cmd='.$job['cmd'].', target='.$job['packageName'].', packages=['.implode(', ', $job['packages']).'])';
|
return 'Installation request for '.$job['packageName'].$this->constraintToText($job['constraint']).': Satisfiable by ['.$this->getPackageList($job['packages']).'].';
|
||||||
|
case 'update':
|
||||||
|
return 'Update request for '.$job['packageName'].$this->constraintToText($job['constraint']).'.';
|
||||||
|
case 'remove':
|
||||||
|
return 'Removal request for '.$job['packageName'].$this->constraintToText($job['constraint']).'';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'Job(cmd='.$job['cmd'].', target='.$job['packageName'].', packages=['.$this->packageList($job['packages']).'])';
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getPackageList($packages)
|
||||||
|
{
|
||||||
|
return implode(', ', array_map(function ($package) {
|
||||||
|
return $package->getPrettyString();
|
||||||
|
},
|
||||||
|
$packages
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,6 +146,6 @@ class Problem
|
||||||
*/
|
*/
|
||||||
protected function constraintToText($constraint)
|
protected function constraintToText($constraint)
|
||||||
{
|
{
|
||||||
return ($constraint) ? 'with constraint '.$constraint.' ' : '';
|
return ($constraint) ? ' '.$constraint : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -171,7 +171,7 @@ class Rule
|
||||||
$package1 = $this->pool->literalToPackage($this->literals[0]);
|
$package1 = $this->pool->literalToPackage($this->literals[0]);
|
||||||
$package2 = $this->pool->literalToPackage($this->literals[1]);
|
$package2 = $this->pool->literalToPackage($this->literals[1]);
|
||||||
|
|
||||||
return 'Package "'.$package1.'" conflicts with "'.$package2.'"';
|
return 'Package '.$package1->getPrettyString().' conflicts with '.$package2->getPrettyString().'"';
|
||||||
|
|
||||||
case self::RULE_PACKAGE_REQUIRES:
|
case self::RULE_PACKAGE_REQUIRES:
|
||||||
$literals = $this->literals;
|
$literals = $this->literals;
|
||||||
|
|
|
@ -201,6 +201,11 @@ abstract class BasePackage implements PackageInterface
|
||||||
return $this->getUniqueName();
|
return $this->getUniqueName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPrettyString()
|
||||||
|
{
|
||||||
|
return $this->getPrettyName().'-'.$this->getPrettyVersion();
|
||||||
|
}
|
||||||
|
|
||||||
public function __clone()
|
public function __clone()
|
||||||
{
|
{
|
||||||
$this->repository = null;
|
$this->repository = null;
|
||||||
|
|
|
@ -356,4 +356,11 @@ interface PackageInterface
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function __toString();
|
public function __toString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the package into a pretty readable string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPrettyString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue