mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-19 17:42:23 +00:00
[prefixed] prefix vendor by vendor name
This commit is contained in:
parent
731fe21ddb
commit
15cc050332
4
.github/workflows/build_scoped_rector.yaml
vendored
4
.github/workflows/build_scoped_rector.yaml
vendored
|
@ -40,9 +40,7 @@ jobs:
|
|||
- run: rm -rf rector-build/packages-tests rector-build/rules-tests rector-build/tests
|
||||
|
||||
# 2. downgrade rector
|
||||
- run: |
|
||||
php -d memory_limit=-1 bin/rector process bin rector.php --config build/config/config-downgrade.php --working-dir rector-build --ansi
|
||||
sh build/downgrade-rector.sh rector-build
|
||||
- run: sh build/downgrade-rector.sh rector-build
|
||||
|
||||
# 3. prefix classes
|
||||
- run: sh build/build-rector-scoped.sh rector-build rector-prefixed-downgraded
|
||||
|
|
|
@ -42,11 +42,9 @@ final class DowngradePathsCommand extends Command
|
|||
$targetPhpVersion = (string) $input->getArgument(self::OPTION_PHP_VERSION);
|
||||
|
||||
$downgradePaths = $this->whyNotVendorPackagesResolver->resolveFromPhpVersion($targetPhpVersion);
|
||||
|
||||
$downgradePaths = array_values($downgradePaths);
|
||||
|
||||
$rulesPaths = $this->resolveRulesPaths();
|
||||
$downgradePaths = array_merge($downgradePaths, $rulesPaths);
|
||||
$downgradePaths = $this->normalizeSingleDirectoryNesting($downgradePaths);
|
||||
|
||||
// make symplify grouped into 1 directory, to make covariance downgrade work with all dependent classes
|
||||
$rulesPaths = $this->resolveRulesPaths();
|
||||
|
@ -54,43 +52,15 @@ final class DowngradePathsCommand extends Command
|
|||
|
||||
// make symplify grouped into 1 directory, to make covariance downgrade work with all dependent classes
|
||||
foreach ($downgradePaths as $key => $downgradePath) {
|
||||
if (Strings::startsWith($downgradePath, 'vendor/symplify')) {
|
||||
unset($downgradePaths[$key]);
|
||||
}
|
||||
|
||||
if (Strings::startsWith($downgradePath, 'vendor/symfony')) {
|
||||
unset($downgradePaths[$key]);
|
||||
}
|
||||
|
||||
if (Strings::startsWith($downgradePath, 'vendor/nikic')) {
|
||||
unset($downgradePaths[$key]);
|
||||
}
|
||||
|
||||
if (Strings::startsWith($downgradePath, 'vendor/psr')) {
|
||||
unset($downgradePaths[$key]);
|
||||
}
|
||||
|
||||
if (Strings::startsWith($downgradePath, 'vendor/symfony/service-contracts')) {
|
||||
unset($downgradePaths[$key]);
|
||||
}
|
||||
|
||||
if (Strings::startsWith($downgradePath, 'vendor/doctrine')) {
|
||||
unset($downgradePaths[$key]);
|
||||
}
|
||||
|
||||
if (Strings::startsWith($downgradePath, 'vendor/nette')) {
|
||||
if (in_array($downgradePath, ['vendor/symplify', 'vendor/symfony', 'vendor/nikic', 'vendor/psr'], true)) {
|
||||
unset($downgradePaths[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$downgradePaths = array_merge([
|
||||
'vendor/symplify vendor/symfony vendor/psr vendor/nikic src packages vendor/symfony/service-contracts',
|
||||
'vendor/doctrine',
|
||||
'vendor/nette'
|
||||
'vendor/symplify vendor/symfony vendor/nikic vendor/psr bin src packages rector.php',
|
||||
], $downgradePaths);
|
||||
|
||||
|
||||
|
||||
$downgradePaths = array_values($downgradePaths);
|
||||
|
||||
// bash format
|
||||
|
@ -119,4 +89,21 @@ final class DowngradePathsCommand extends Command
|
|||
|
||||
return $rulesPaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $downgradePaths
|
||||
* @return string[]
|
||||
*/
|
||||
private function normalizeSingleDirectoryNesting(array $downgradePaths): array
|
||||
{
|
||||
foreach ($downgradePaths as $key => $downgradePath) {
|
||||
if (! Strings::startsWith($downgradePath, 'vendor/')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$downgradePaths[$key] = Strings::before($downgradePath, '/', 2);
|
||||
}
|
||||
|
||||
return array_unique($downgradePaths);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user