|
@@ -38,6 +38,12 @@ abstract class BasePackage implements PackageInterface
|
|
|
const STABILITY_ALPHA = 15;
|
|
|
const STABILITY_DEV = 20;
|
|
|
|
|
|
+ const MATCH_NAME = -1;
|
|
|
+ const MATCH_NONE = 0;
|
|
|
+ const MATCH = 1;
|
|
|
+ const MATCH_PROVIDE = 2;
|
|
|
+ const MATCH_REPLACE = 3;
|
|
|
+
|
|
|
public static $stabilities = array(
|
|
|
'stable' => self::STABILITY_STABLE,
|
|
|
'RC' => self::STABILITY_RC,
|
|
@@ -122,27 +128,27 @@ abstract class BasePackage implements PackageInterface
|
|
|
*
|
|
|
* @param string $name Name of the package to be matched
|
|
|
* @param LinkConstraintInterface $constraint The constraint to verify
|
|
|
- * @return bool Whether this package matches the name and constraint
|
|
|
+ * @return int One of the MATCH* constants of this class or 0 if there is no match
|
|
|
*/
|
|
|
public function matches($name, LinkConstraintInterface $constraint)
|
|
|
{
|
|
|
if ($this->name === $name) {
|
|
|
- return $constraint->matches(new VersionConstraint('==', $this->getVersion()));
|
|
|
+ return $constraint->matches(new VersionConstraint('==', $this->getVersion())) ? self::MATCH : self::MATCH_NAME;
|
|
|
}
|
|
|
|
|
|
foreach ($this->getProvides() as $link) {
|
|
|
if ($link->getTarget() === $name && $constraint->matches($link->getConstraint())) {
|
|
|
- return true;
|
|
|
+ return self::MATCH_PROVIDE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
foreach ($this->getReplaces() as $link) {
|
|
|
if ($link->getTarget() === $name && $constraint->matches($link->getConstraint())) {
|
|
|
- return true;
|
|
|
+ return self::MATCH_REPLACE;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return false;
|
|
|
+ return self::MATCH_NONE;
|
|
|
}
|
|
|
|
|
|
public function getRepository()
|