Skip to content

Commit db60ae8

Browse files
Bound constraints by copying extra.symfony.require
1 parent 7d488f0 commit db60ae8

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/Flex.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,23 @@ public function configureProject(Event $event)
238238
{
239239
$json = new JsonFile(Factory::getComposerFile());
240240
$manipulator = new JsonManipulator(file_get_contents($json->getPath()));
241+
241242
// new projects are most of the time proprietary
242243
$manipulator->addMainKey('license', 'proprietary');
244+
245+
// replace unbounded contraints for symfony/* packages by extra.symfony.require
246+
$config = json_decode($contents);
247+
if ($symfonyVersion = $config['extra']['symfony']['require'] ?? null) {
248+
$versions = $this->downloader->get('/versions.json');
249+
foreach (['require', 'require-dev'] as $type) {
250+
foreach ($config[$type] ?? [] as $package => $version) {
251+
if ('*' === $version && isset($versions['splits'][$package])) {
252+
$manipulator->addLink($type, $package, $symfonyVersion);
253+
}
254+
}
255+
}
256+
}
257+
243258
// 'name' and 'description' are only required for public packages
244259
// don't use $manipulator->removeProperty() for BC with Composer 1.0
245260
$contents = preg_replace('{^\s*+"(?:name|description)":.*,$\n}m', '', $manipulator->getContents());

src/PackageResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ private function parseVersion(string $package, string $version, bool $isRequire)
9898
try {
9999
$config = @json_decode(file_get_contents(Factory::getComposerFile()), true);
100100
} finally {
101-
if (!$isRequire || !isset($config['require']['symfony/framework-bundle'])) {
101+
if (!$isRequire || !($config['extra']['symfony']['require'] || isset($config['require']['symfony/framework-bundle']))) {
102102
return '';
103103
}
104104
}
105-
$version = $config['require']['symfony/framework-bundle'];
105+
$version = $config['extra']['symfony']['require'] ?? $config['require']['symfony/framework-bundle'];
106106
} elseif ('next' === $version) {
107107
$version = '^'.self::$versions[$version].'@dev';
108108
} elseif (\in_array($version, self::$SYMFONY_VERSIONS, true)) {

0 commit comments

Comments
 (0)