diff --git a/src/Composer/Package/Link.php b/src/Composer/Package/Link.php index 03ea3edff..16254f68e 100644 --- a/src/Composer/Package/Link.php +++ b/src/Composer/Package/Link.php @@ -56,11 +56,11 @@ class Link * @param string $description Used to create a descriptive string representation * @param string|null $prettyConstraint */ - public function __construct($source, $target, ConstraintInterface $constraint = null, $description = 'relates to', $prettyConstraint = null) + public function __construct($source, $target, ConstraintInterface $constraint, $description = 'relates to', $prettyConstraint = null) { $this->source = strtolower($source); $this->target = strtolower($target); - $this->constraint = $constraint ? $constraint : new EmptyConstraint(); + $this->constraint = $constraint; $this->description = $description; $this->prettyConstraint = $prettyConstraint; } diff --git a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php index c178e93d8..896221c13 100644 --- a/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php +++ b/tests/Composer/Test/Autoload/AutoloadGeneratorTest.php @@ -16,6 +16,7 @@ use Composer\Autoload\AutoloadGenerator; use Composer\Package\Link; use Composer\Package\Version\VersionParser; use Composer\Semver\Constraint\Constraint; +use Composer\Semver\Constraint\EmptyConstraint; use Composer\Util\Filesystem; use Composer\Package\AliasPackage; use Composer\Package\Package; @@ -366,8 +367,8 @@ class AutoloadGeneratorTest extends TestCase { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a'), - new Link('a', 'b/b'), + new Link('a', 'a/a', new EmptyConstraint()), + new Link('a', 'b/b', new EmptyConstraint()), )); $packages = array(); @@ -395,7 +396,7 @@ class AutoloadGeneratorTest extends TestCase { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a'), + new Link('a', 'a/a', new EmptyConstraint()), )); $packages = array(); @@ -403,11 +404,11 @@ class AutoloadGeneratorTest extends TestCase $packages[] = $b = new Package('b/b', '1.0', '1.0'); $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/'))); $a->setRequires(array( - new Link('a/a', 'b/b'), + new Link('a/a', 'b/b', new EmptyConstraint()), )); $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/'))); $b->setRequires(array( - new Link('b/b', 'a/a'), + new Link('b/b', 'a/a', new EmptyConstraint()), )); $this->repository->expects($this->once()) @@ -427,13 +428,13 @@ class AutoloadGeneratorTest extends TestCase public function testNonDevAutoloadShouldIncludeReplacedPackages() { $package = new Package('a', '1.0', '1.0'); - $package->setRequires(array(new Link('a', 'a/a'))); + $package->setRequires(array(new Link('a', 'a/a', new EmptyConstraint()))); $packages = array(); $packages[] = $a = new Package('a/a', '1.0', '1.0'); $packages[] = $b = new Package('b/b', '1.0', '1.0'); - $a->setRequires(array(new Link('a/a', 'b/c'))); + $a->setRequires(array(new Link('a/a', 'b/c', new EmptyConstraint()))); $b->setAutoload(array('psr-4' => array('B\\' => 'src/'))); $b->setReplaces( @@ -462,7 +463,7 @@ class AutoloadGeneratorTest extends TestCase { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a'), + new Link('a', 'a/a', new EmptyConstraint()), )); $packages = array(); @@ -470,11 +471,11 @@ class AutoloadGeneratorTest extends TestCase $packages[] = $b = new Package('b/b', '1.0', '1.0'); $a->setAutoload(array('psr-0' => array('A' => 'src/', 'A\\B' => 'lib/'))); $a->setRequires(array( - new Link('a/a', 'c/c'), + new Link('a/a', 'c/c', new EmptyConstraint()), )); $b->setAutoload(array('psr-0' => array('B\\Sub\\Name' => 'src/'))); $b->setReplaces(array( - new Link('b/b', 'c/c'), + new Link('b/b', 'c/c', new EmptyConstraint()), )); $this->repository->expects($this->once()) @@ -495,7 +496,7 @@ class AutoloadGeneratorTest extends TestCase { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a') + new Link('a', 'a/a', new EmptyConstraint()) )); $packages = array(); @@ -506,18 +507,18 @@ class AutoloadGeneratorTest extends TestCase $packages[] = $e = new Package('e/e', '1.0', '1.0'); $a->setAutoload(array('classmap' => array('src/A.php'))); $a->setRequires(array( - new Link('a/a', 'b/b') + new Link('a/a', 'b/b', new EmptyConstraint()) )); $b->setAutoload(array('classmap' => array('src/B.php'))); $b->setRequires(array( - new Link('b/b', 'e/e') + new Link('b/b', 'e/e', new EmptyConstraint()) )); $c->setAutoload(array('classmap' => array('src/C.php'))); $c->setReplaces(array( - new Link('c/c', 'b/b') + new Link('c/c', 'b/b', new EmptyConstraint()) )); $c->setRequires(array( - new Link('c/c', 'd/d') + new Link('c/c', 'd/d', new EmptyConstraint()) )); $d->setAutoload(array('classmap' => array('src/D.php'))); $e->setAutoload(array('classmap' => array('src/E.php'))); @@ -547,7 +548,7 @@ class AutoloadGeneratorTest extends TestCase { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a'), + new Link('a', 'a/a', new EmptyConstraint()), )); $package->setAutoload(array( @@ -652,8 +653,8 @@ EOF; { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a'), - new Link('a', 'b/b'), + new Link('a', 'a/a', new EmptyConstraint()), + new Link('a', 'b/b', new EmptyConstraint()), )); $packages = array(); @@ -692,8 +693,8 @@ EOF; { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a'), - new Link('a', 'b/b'), + new Link('a', 'a/a', new EmptyConstraint()), + new Link('a', 'b/b', new EmptyConstraint()), )); $packages = array(); @@ -732,9 +733,9 @@ EOF; { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a'), - new Link('a', 'b/b'), - new Link('a', 'c/c'), + new Link('a', 'a/a', new EmptyConstraint()), + new Link('a', 'b/b', new EmptyConstraint()), + new Link('a', 'c/c', new EmptyConstraint()), )); $packages = array(); @@ -777,9 +778,9 @@ EOF; { $package = new Package('a', '1.0', '1.0'); $package->setRequires(array( - new Link('a', 'a/a'), - new Link('a', 'b/b'), - new Link('a', 'c/c'), + new Link('a', 'a/a', new EmptyConstraint()), + new Link('a', 'b/b', new EmptyConstraint()), + new Link('a', 'c/c', new EmptyConstraint()), )); $packages = array(); @@ -827,9 +828,9 @@ EOF; $package = new Package('a', '1.0', '1.0'); $package->setAutoload(array('files' => array('root.php'))); $package->setRequires(array( - new Link('a', 'a/a'), - new Link('a', 'b/b'), - new Link('a', 'c/c'), + new Link('a', 'a/a', new EmptyConstraint()), + new Link('a', 'b/b', new EmptyConstraint()), + new Link('a', 'c/c', new EmptyConstraint()), )); $packages = array(); @@ -878,9 +879,9 @@ EOF; $notAutoloadPackage = new Package('a', '1.0', '1.0'); $requires = array( - new Link('a', 'a/a'), - new Link('a', 'b/b'), - new Link('a', 'c/c'), + new Link('a', 'a/a', new EmptyConstraint()), + new Link('a', 'b/b', new EmptyConstraint()), + new Link('a', 'c/c', new EmptyConstraint()), ); $autoloadPackage->setRequires($requires); $notAutoloadPackage->setRequires($requires); @@ -949,10 +950,10 @@ EOF; $package = new Package('a', '1.0', '1.0'); $package->setAutoload(array('files' => array('root2.php'))); $package->setRequires(array( - new Link('a', 'z/foo'), - new Link('a', 'b/bar'), - new Link('a', 'd/d'), - new Link('a', 'e/e'), + new Link('a', 'z/foo', new EmptyConstraint()), + new Link('a', 'b/bar', new EmptyConstraint()), + new Link('a', 'd/d', new EmptyConstraint()), + new Link('a', 'e/e', new EmptyConstraint()), )); $packages = array(); @@ -963,18 +964,18 @@ EOF; $packages[] = $e = new Package('e/e', '1.0', '1.0'); $z->setAutoload(array('files' => array('testA.php'))); - $z->setRequires(array(new Link('z/foo', 'c/lorem'))); + $z->setRequires(array(new Link('z/foo', 'c/lorem', new EmptyConstraint()))); $b->setAutoload(array('files' => array('testB.php'))); - $b->setRequires(array(new Link('b/bar', 'c/lorem'), new Link('b/bar', 'd/d'))); + $b->setRequires(array(new Link('b/bar', 'c/lorem', new EmptyConstraint()), new Link('b/bar', 'd/d', new EmptyConstraint()))); $c->setAutoload(array('files' => array('testC.php'))); $d->setAutoload(array('files' => array('testD.php'))); - $d->setRequires(array(new Link('d/d', 'c/lorem'))); + $d->setRequires(array(new Link('d/d', 'c/lorem', new EmptyConstraint()))); $e->setAutoload(array('files' => array('testE.php'))); - $e->setRequires(array(new Link('e/e', 'c/lorem'))); + $e->setRequires(array(new Link('e/e', 'c/lorem', new EmptyConstraint()))); $this->repository->expects($this->once()) ->method('getCanonicalPackages') @@ -1022,8 +1023,8 @@ EOF; 'classmap' => array($this->workingDir.'/src'), )); $mainPackage->setRequires(array( - new Link('z', 'a/a'), - new Link('z', 'b/b'), + new Link('z', 'a/a', new EmptyConstraint()), + new Link('z', 'b/b', new EmptyConstraint()), )); $packages = array(); @@ -1285,7 +1286,7 @@ EOF; 'files' => array('test.php'), )); $package->setRequires(array( - new Link('a', 'b/b'), + new Link('a', 'b/b', new EmptyConstraint()), )); $vendorPackage = new Package('b/b', '1.0', '1.0'); diff --git a/tests/Composer/Test/DependencyResolver/RuleTest.php b/tests/Composer/Test/DependencyResolver/RuleTest.php index cd3b74887..0f2face8f 100644 --- a/tests/Composer/Test/DependencyResolver/RuleTest.php +++ b/tests/Composer/Test/DependencyResolver/RuleTest.php @@ -19,6 +19,7 @@ use Composer\DependencyResolver\Pool; use Composer\Package\BasePackage; use Composer\Package\Link; use Composer\Repository\ArrayRepository; +use Composer\Semver\Constraint\EmptyConstraint; use Composer\Test\TestCase; class RuleTest extends TestCase @@ -102,7 +103,7 @@ class RuleTest extends TestCase $repositorySetMock = $this->getMockBuilder('Composer\Repository\RepositorySet')->disableOriginalConstructor()->getMock(); $requestMock = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock(); - $rule = new GenericRule(array($p1->getId(), -$p2->getId()), Rule::RULE_PACKAGE_REQUIRES, new Link('baz', 'foo', 'relates to', '*')); + $rule = new GenericRule(array($p1->getId(), -$p2->getId()), Rule::RULE_PACKAGE_REQUIRES, new Link('baz', 'foo', new EmptyConstraint(), 'relates to', '*')); $this->assertEquals('baz 1.1 relates to foo * -> satisfiable by foo[2.1].', $rule->getPrettyString($repositorySetMock, $requestMock, $pool, false)); } diff --git a/tests/Composer/Test/DependencyResolver/SolverTest.php b/tests/Composer/Test/DependencyResolver/SolverTest.php index 56d2d7e5b..a8f91910d 100644 --- a/tests/Composer/Test/DependencyResolver/SolverTest.php +++ b/tests/Composer/Test/DependencyResolver/SolverTest.php @@ -235,8 +235,8 @@ class SolverTest extends TestCase $this->repo->addPackage($newPackageA = $this->getPackage('A', '1.1')); $this->repo->addPackage($newPackageB = $this->getPackage('B', '1.1')); - $packageA->setRequires(array('b' => new Link('A', 'B', null, 'requires'))); - $newPackageA->setRequires(array('b' => new Link('A', 'B', null, 'requires'))); + $packageA->setRequires(array('b' => new Link('A', 'B', new EmptyConstraint(), 'requires'))); + $newPackageA->setRequires(array('b' => new Link('A', 'B', new EmptyConstraint(), 'requires'))); $this->reposComplete(); diff --git a/tests/Composer/Test/Package/RootAliasPackageTest.php b/tests/Composer/Test/Package/RootAliasPackageTest.php index a5fe9172d..5cfcd7179 100644 --- a/tests/Composer/Test/Package/RootAliasPackageTest.php +++ b/tests/Composer/Test/Package/RootAliasPackageTest.php @@ -14,6 +14,7 @@ namespace Composer\Test\Package; use Composer\Package\Link; use Composer\Package\RootAliasPackage; +use Composer\Semver\Constraint\EmptyConstraint; use Composer\Test\TestCase; use Prophecy\Argument; @@ -26,7 +27,7 @@ class RootAliasPackageTest extends TestCase $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); $this->assertEmpty($alias->getRequires()); - $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $links = array(new Link('a', 'b', new EmptyConstraint(), 'foo', 'self.version')); $alias->setRequires($links); $this->assertNotEmpty($alias->getRequires()); } @@ -38,7 +39,7 @@ class RootAliasPackageTest extends TestCase $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); $this->assertEmpty($alias->getDevRequires()); - $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $links = array(new Link('a', 'b', new EmptyConstraint(), 'foo', 'self.version')); $alias->setDevRequires($links); $this->assertNotEmpty($alias->getDevRequires()); } @@ -50,7 +51,7 @@ class RootAliasPackageTest extends TestCase $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); $this->assertEmpty($alias->getConflicts()); - $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $links = array(new Link('a', 'b', new EmptyConstraint(), 'foo', 'self.version')); $alias->setConflicts($links); $this->assertNotEmpty($alias->getConflicts()); } @@ -62,7 +63,7 @@ class RootAliasPackageTest extends TestCase $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); $this->assertEmpty($alias->getProvides()); - $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $links = array(new Link('a', 'b', new EmptyConstraint(), 'foo', 'self.version')); $alias->setProvides($links); $this->assertNotEmpty($alias->getProvides()); } @@ -74,7 +75,7 @@ class RootAliasPackageTest extends TestCase $alias = new RootAliasPackage($root->reveal(), '1.0', '1.0.0.0'); $this->assertEmpty($alias->getReplaces()); - $links = array(new Link('a', 'b', null, 'foo', 'self.version')); + $links = array(new Link('a', 'b', new EmptyConstraint(), 'foo', 'self.version')); $alias->setReplaces($links); $this->assertNotEmpty($alias->getReplaces()); } diff --git a/tests/Composer/Test/Repository/InstalledRepositoryTest.php b/tests/Composer/Test/Repository/InstalledRepositoryTest.php index a37adb058..4c63f0670 100644 --- a/tests/Composer/Test/Repository/InstalledRepositoryTest.php +++ b/tests/Composer/Test/Repository/InstalledRepositoryTest.php @@ -16,6 +16,7 @@ use Composer\Repository\InstalledRepository; use Composer\Repository\ArrayRepository; use Composer\Repository\InstalledArrayRepository; use Composer\Package\Link; +use Composer\Semver\Constraint\EmptyConstraint; use Composer\Test\TestCase; class InstalledRepositoryTest extends TestCase @@ -30,8 +31,8 @@ class InstalledRepositoryTest extends TestCase $arrayRepoTwo->addPackage($bar = $this->getPackage('bar', '1')); $arrayRepoTwo->addPackage($bar2 = $this->getPackage('bar', '2')); - $foo->setReplaces(array(new Link('foo', 'provided'))); - $bar2->setProvides(array(new Link('bar', 'provided'))); + $foo->setReplaces(array(new Link('foo', 'provided', new EmptyConstraint()))); + $bar2->setProvides(array(new Link('bar', 'provided', new EmptyConstraint()))); $repo = new InstalledRepository(array($arrayRepoOne, $arrayRepoTwo));