Skip to content

Commit 7f685f6

Browse files
Copy extra.symfony.require when unpacking
1 parent 955774e commit 7f685f6

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

src/Command/RequireCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4747
$op->addPackage($package['name'], $package['version'] ?? '', $input->getOption('dev'));
4848
}
4949

50-
$unpacker = new Unpacker($this->getComposer());
50+
$unpacker = new Unpacker($this->getComposer(), $this->resolver);
5151
$result = $unpacker->unpack($op);
5252
$io = $this->getIO();
5353
foreach ($result->getUnpacked() as $pkg) {

src/Command/UnpackCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
7979
$op->addPackage($pkg->getName(), $pkg->getVersion(), $dev);
8080
}
8181

82-
$unpacker = new Unpacker($composer);
82+
$unpacker = new Unpacker($composer, $this->resolver);
8383
$result = $unpacker->unpack($op);
8484

8585
// remove the packages themselves

src/PackageResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function resolve(array $arguments = [], bool $isRequire = false): array
8080
return array_unique($requires);
8181
}
8282

83-
private function parseVersion(string $package, string $version, bool $isRequire): string
83+
public function parseVersion(string $package, string $version, bool $isRequire): string
8484
{
8585
if (0 !== strpos($package, 'symfony/')) {
8686
return $version ? ':'.$version : '';
@@ -94,7 +94,7 @@ private function parseVersion(string $package, string $version, bool $isRequire)
9494
return $version ? ':'.$version : '';
9595
}
9696

97-
if (!$version) {
97+
if (!$version || '*' === $version) {
9898
try {
9999
$config = @json_decode(file_get_contents(Factory::getComposerFile()), true);
100100
} finally {

src/Unpacker.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121
class Unpacker
2222
{
2323
private $composer;
24+
private $resolver;
2425

25-
public function __construct(Composer $composer)
26+
public function __construct(Composer $composer, PackageResolver $resolver)
2627
{
2728
$this->composer = $composer;
29+
$this->resolver = $resolver;
2830
}
2931

3032
public function unpack(Operation $op): Result
@@ -53,7 +55,10 @@ public function unpack(Operation $op): Result
5355
continue;
5456
}
5557

56-
if (!$manipulator->addLink($package['dev'] ? 'require-dev' : 'require', $link->getTarget(), $link->getPrettyConstraint(), $op->shouldSort())) {
58+
$constraint = $link->getPrettyConstraint();
59+
$constraint = substr($this->resolver->parseVersion($link->getTarget(), $constraint, !$package['dev']), 1) ?: $constraint;
60+
61+
if (!$manipulator->addLink($package['dev'] ? 'require-dev' : 'require', $link->getTarget(), $constraint, $op->shouldSort())) {
5762
throw new \RuntimeException(sprintf('Unable to unpack package "%s".', $link->getTarget()));
5863
}
5964
}

0 commit comments

Comments
 (0)