Skip to content

Commit 115e67f

Browse files
committed
bug #677 Fix unpacking nested packs into composer.json (nicolas-grekas)
This PR was merged into the 1.8-dev branch. Discussion ---------- Fix unpacking nested packs into composer.json Fix #676 Commits ------- 958a3a3 Fix unpacking nested packs into composer.json
2 parents 1eab1e8 + 958a3a3 commit 115e67f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Unpacker.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,12 @@ public function __construct(Composer $composer, PackageResolver $resolver, bool
4141
$this->dryRun = $dryRun;
4242
}
4343

44-
public function unpack(Operation $op, Result $result = null): Result
44+
public function unpack(Operation $op, Result $result = null, &$links = []): Result
4545
{
4646
if (null === $result) {
4747
$result = new Result();
4848
}
4949

50-
$links = [];
51-
5250
$localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
5351
foreach ($op->getPackages() as $package) {
5452
$pkg = $localRepo->findPackage($package['name'], $package['version'] ?: '*');
@@ -83,7 +81,7 @@ public function unpack(Operation $op, Result $result = null): Result
8381
if ('symfony-pack' === $subPkg->getType()) {
8482
$subOp = new Operation(true, $op->shouldSort());
8583
$subOp->addPackage($subPkg->getName(), $constraint, $package['dev']);
86-
$result = $this->unpack($subOp, $result);
84+
$result = $this->unpack($subOp, $result, $links);
8785
continue;
8886
}
8987

@@ -117,6 +115,10 @@ public function unpack(Operation $op, Result $result = null): Result
117115
}
118116
}
119117

118+
if ($this->dryRun || 1 < \func_num_args()) {
119+
return $result;
120+
}
121+
120122
$jsonPath = Factory::getComposerFile();
121123
$jsonContent = file_get_contents($jsonPath);
122124
$jsonStored = json_decode($jsonContent, true);
@@ -150,9 +152,7 @@ public function unpack(Operation $op, Result $result = null): Result
150152
}
151153
}
152154

153-
if (!$this->dryRun && 1 === \func_num_args()) {
154-
file_put_contents($jsonPath, $jsonManipulator->getContents());
155-
}
155+
file_put_contents($jsonPath, $jsonManipulator->getContents());
156156

157157
return $result;
158158
}

0 commit comments

Comments
 (0)