mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-21 16:02:23 +02:00
decopuling composer.json modifying methods
This commit is contained in:
parent
a79e0a8887
commit
acdeb51f0d
@ -80,25 +80,9 @@ final class CompileCommand extends Command
|
||||
|
||||
$json = Json::decode($fileContent, Json::FORCE_ARRAY);
|
||||
|
||||
// remove dev dependencies (they create conflicts)
|
||||
unset($json['require-dev'], $json['autoload-dev']);
|
||||
$json = $this->removeDevKeys($json);
|
||||
|
||||
unset($json['replace']);
|
||||
|
||||
$json['name'] = 'rector/rector';
|
||||
|
||||
// simplify autoload (remove not packed build directory]
|
||||
$json['autoload']['psr-4']['Rector\\'] = 'src';
|
||||
|
||||
// use phpstan/phpstan-src, because the phpstan.phar cannot be packed into rector.phar
|
||||
$phpstanVersion = $json['require']['phpstan/phpstan'];
|
||||
$json['require']['phpstan/phpstan-src'] = $phpstanVersion;
|
||||
unset($json['require']['phpstan/phpstan']);
|
||||
|
||||
$json['repositories'][] = [
|
||||
'type' => 'vcs',
|
||||
'url' => 'https://github.com/phpstan/phpstan-src.git',
|
||||
];
|
||||
$json = $this->replacePHPStanWithPHPStanSrc($json);
|
||||
|
||||
$encodedJson = Json::encode($json, Json::PRETTY);
|
||||
|
||||
@ -114,4 +98,32 @@ final class CompileCommand extends Command
|
||||
|
||||
// re-run @todo composer update on root
|
||||
}
|
||||
|
||||
/**
|
||||
* Use phpstan/phpstan-src, because the phpstan.phar cannot be packed into rector.phar
|
||||
*/
|
||||
private function replacePHPStanWithPHPStanSrc(array $json): array
|
||||
{
|
||||
$phpstanVersion = $json['require']['phpstan/phpstan'];
|
||||
$json['require']['phpstan/phpstan-src'] = $phpstanVersion;
|
||||
unset($json['require']['phpstan/phpstan']);
|
||||
|
||||
$json['repositories'][] = [
|
||||
'type' => 'vcs',
|
||||
'url' => 'https://github.com/phpstan/phpstan-src.git',
|
||||
];
|
||||
|
||||
return $json;
|
||||
}
|
||||
|
||||
private function removeDevKeys(array $json): array
|
||||
{
|
||||
$keysToRemove = ['require-dev', 'autoload-dev', 'replace'];
|
||||
|
||||
foreach ($keysToRemove as $keyToRemove) {
|
||||
unset($json[$keyToRemove]);
|
||||
}
|
||||
|
||||
return $json;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user