Skip to content

Commit 2bfed63

Browse files
committed
Updated Rector to commit a134f6a4f9025323710e707feb16a69c1e9bf9d7
rectorphp/rector-src@a134f6a Allow using a canonical dist file (#7845)
1 parent 3a6d2f5 commit 2bfed63

13 files changed

Lines changed: 97 additions & 50 deletions

File tree

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '5ce62c73c14eea1926c23bd58fecd67a6852816e';
22+
public const PACKAGE_VERSION = 'a134f6a4f9025323710e707feb16a69c1e9bf9d7';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-02-03 19:00:29';
27+
public const RELEASE_DATE = '2026-02-03 22:32:11';
2828
/**
2929
* @var int
3030
*/

src/Bootstrap/RectorConfigsResolver.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@
88
use RectorPrefix202602\Webmozart\Assert\Assert;
99
final class RectorConfigsResolver
1010
{
11+
/**
12+
* @var string
13+
*/
14+
public const DEFAULT_CONFIG_FILE = 'rector.php';
15+
/**
16+
* @var string
17+
*/
18+
public const DEFAULT_DIST_CONFIG_FILE = 'rector.dist.php';
1119
public function provide(): BootstrapConfigs
1220
{
1321
$argvInput = new ArgvInput();
14-
$mainConfigFile = $this->resolveFromInputWithFallback($argvInput, 'rector.php');
22+
$mainConfigFile = $this->resolveFromInputWithFallback($argvInput);
1523
return new BootstrapConfigs($mainConfigFile, []);
1624
}
1725
private function resolveFromInput(ArgvInput $argvInput): ?string
@@ -23,13 +31,18 @@ private function resolveFromInput(ArgvInput $argvInput): ?string
2331
Assert::fileExists($configFile);
2432
return realpath($configFile);
2533
}
26-
private function resolveFromInputWithFallback(ArgvInput $argvInput, string $fallbackFile): ?string
34+
private function resolveFromInputWithFallback(ArgvInput $argvInput): ?string
2735
{
2836
$configFile = $this->resolveFromInput($argvInput);
2937
if ($configFile !== null) {
3038
return $configFile;
3139
}
32-
return $this->createFallbackFileInfoIfFound($fallbackFile);
40+
// Try rector.php first, then fall back to rector.dist.php
41+
$rectorConfigFile = $this->createFallbackFileInfoIfFound(self::DEFAULT_CONFIG_FILE);
42+
if ($rectorConfigFile !== null) {
43+
return $rectorConfigFile;
44+
}
45+
return $this->createFallbackFileInfoIfFound(self::DEFAULT_DIST_CONFIG_FILE);
3346
}
3447
private function createFallbackFileInfoIfFound(string $fallbackFile): ?string
3548
{

src/Configuration/ConfigInitializer.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
namespace Rector\Configuration;
55

66
use RectorPrefix202602\Nette\Utils\FileSystem;
7+
use Rector\Bootstrap\RectorConfigsResolver;
78
use Rector\Contract\Rector\RectorInterface;
89
use Rector\FileSystem\InitFilePathsResolver;
910
use Rector\PostRector\Contract\Rector\PostRectorInterface;
@@ -34,12 +35,17 @@ public function __construct(array $rectors, InitFilePathsResolver $initFilePaths
3435
}
3536
public function createConfig(string $projectDirectory): void
3637
{
37-
$commonRectorConfigPath = $projectDirectory . '/rector.php';
38+
$commonRectorConfigPath = $projectDirectory . '/' . RectorConfigsResolver::DEFAULT_CONFIG_FILE;
39+
$distRectorConfigPath = $projectDirectory . '/' . RectorConfigsResolver::DEFAULT_DIST_CONFIG_FILE;
3840
if (file_exists($commonRectorConfigPath)) {
39-
$this->symfonyStyle->warning('Register rules or sets in your "rector.php" config');
41+
$this->symfonyStyle->warning('Register rules or sets in your "' . RectorConfigsResolver::DEFAULT_CONFIG_FILE . '" config');
4042
return;
4143
}
42-
$response = $this->symfonyStyle->ask('No "rector.php" config found. Should we generate it for you?', 'yes');
44+
if (file_exists($distRectorConfigPath)) {
45+
$this->symfonyStyle->warning('Register rules or sets in your "' . RectorConfigsResolver::DEFAULT_DIST_CONFIG_FILE . '" config');
46+
return;
47+
}
48+
$response = $this->symfonyStyle->ask('No "' . RectorConfigsResolver::DEFAULT_CONFIG_FILE . '" config found. Should we generate it for you?', 'yes');
4349
// be tolerant about input
4450
if (!in_array($response, ['yes', 'YES', 'y', 'Y'], \true)) {
4551
// okay, nothing we can do

src/Console/ConsoleApplication.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,11 @@ private function removeUnusedOptions(InputDefinition $inputDefinition): void
9090
}
9191
private function addCustomOptions(InputDefinition $inputDefinition): void
9292
{
93-
$inputDefinition->addOption(new InputOption(Option::CONFIG, 'c', InputOption::VALUE_REQUIRED, 'Path to config file', $this->getDefaultConfigPath()));
93+
$inputDefinition->addOption(new InputOption(Option::CONFIG, 'c', InputOption::VALUE_REQUIRED, 'Path to config file'));
9494
$inputDefinition->addOption(new InputOption(Option::DEBUG, null, InputOption::VALUE_NONE, 'Enable debug verbosity'));
9595
$inputDefinition->addOption(new InputOption(Option::XDEBUG, null, InputOption::VALUE_NONE, 'Allow running xdebug'));
9696
$inputDefinition->addOption(new InputOption(Option::CLEAR_CACHE, null, InputOption::VALUE_NONE, 'Clear cache before starting the execution of the command'));
9797
}
98-
private function getDefaultConfigPath(): string
99-
{
100-
return getcwd() . '/rector.php';
101-
}
10298
private function enableXdebug(InputInterface $input): void
10399
{
104100
$isXdebugAllowed = $input->hasParameterOption('--xdebug');

src/Parallel/Command/WorkerCommandLineFactory.php

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,32 @@ public function create(string $mainScript, string $mainCommandClass, string $wor
7979
// disable colors, breaks json_decode() otherwise
8080
// @see https://github.com/symfony/symfony/issues/1238
8181
$workerCommandArray[] = '--no-ansi';
82+
// Only pass --config if explicitly set via command line
83+
// If not set, the worker will resolve config using RectorConfigsResolver fallback mechanism
8284
if ($input->hasOption(Option::CONFIG)) {
83-
$workerCommandArray[] = '--config';
84-
/**
85-
* On parallel, the command is generated with `--config` addition
86-
* Using escapeshellarg() to ensure the --config path escaped, even when it has a space.
87-
*
88-
* eg:
89-
* --config /path/e2e/parallel with space/rector.php
90-
*
91-
* that can cause error:
92-
*
93-
* File /rector-src/e2e/parallel\" was not found
94-
*
95-
* the escaped result is:
96-
*
97-
* --config '/path/e2e/parallel with space/rector.php'
98-
*
99-
* tested in macOS and Ubuntu (github action)
100-
*/
101-
$config = (string) $input->getOption(Option::CONFIG);
102-
$workerCommandArray[] = escapeshellarg($this->filePathHelper->relativePath($config));
85+
$configValue = $input->getOption(Option::CONFIG);
86+
if (is_string($configValue) && $configValue !== '') {
87+
$workerCommandArray[] = '--config';
88+
/**
89+
* On parallel, the command is generated with `--config` addition
90+
* Using escapeshellarg() to ensure the --config path escaped, even when it has a space.
91+
*
92+
* eg:
93+
* --config /path/e2e/parallel with space/rector.php
94+
*
95+
* that can cause error:
96+
*
97+
* File /rector-src/e2e/parallel\" was not found
98+
*
99+
* the escaped result is:
100+
*
101+
* --config '/path/e2e/parallel with space/rector.php'
102+
*
103+
* tested in macOS and Ubuntu (github action)
104+
*/
105+
$config = $configValue;
106+
$workerCommandArray[] = escapeshellarg($this->filePathHelper->relativePath($config));
107+
}
103108
}
104109
if ($input->getOption(Option::ONLY) !== null) {
105110
$workerCommandArray[] = self::OPTION_DASHES . Option::ONLY;
@@ -112,8 +117,8 @@ private function shouldSkipOption(InputInterface $input, string $optionName): bo
112117
if (!$input->hasOption($optionName)) {
113118
return \true;
114119
}
115-
// skip output format, not relevant in parallel worker command
116-
return $optionName === Option::OUTPUT_FORMAT;
120+
// skip output format and config, handled separately in create()
121+
return $optionName === Option::OUTPUT_FORMAT || $optionName === Option::CONFIG;
117122
}
118123
/**
119124
* @return string[]

vendor/composer/installed.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,12 +1818,12 @@
18181818
"source": {
18191819
"type": "git",
18201820
"url": "https:\/\/github.com\/rectorphp\/rector-phpunit.git",
1821-
"reference": "80cdb1b0bb8a48c76dd89a31ab57b5a51c4a85b0"
1821+
"reference": "13caf933b09f2bb5780af6dd570fda6815e46b89"
18221822
},
18231823
"dist": {
18241824
"type": "zip",
1825-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/80cdb1b0bb8a48c76dd89a31ab57b5a51c4a85b0",
1826-
"reference": "80cdb1b0bb8a48c76dd89a31ab57b5a51c4a85b0",
1825+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-phpunit\/zipball\/13caf933b09f2bb5780af6dd570fda6815e46b89",
1826+
"reference": "13caf933b09f2bb5780af6dd570fda6815e46b89",
18271827
"shasum": ""
18281828
},
18291829
"require": {
@@ -1850,7 +1850,7 @@
18501850
"tomasvotruba\/unused-public": "^2.2",
18511851
"tracy\/tracy": "^2.11"
18521852
},
1853-
"time": "2026-02-03T18:39:55+00:00",
1853+
"time": "2026-02-03T21:27:37+00:00",
18541854
"default-branch": true,
18551855
"type": "rector-extension",
18561856
"extra": {
@@ -1882,12 +1882,12 @@
18821882
"source": {
18831883
"type": "git",
18841884
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
1885-
"reference": "582fc7c2da185937e9f980f53a1f60a4343ab529"
1885+
"reference": "54ebd77323464d79799666a9ea7de59c4592a938"
18861886
},
18871887
"dist": {
18881888
"type": "zip",
1889-
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/582fc7c2da185937e9f980f53a1f60a4343ab529",
1890-
"reference": "582fc7c2da185937e9f980f53a1f60a4343ab529",
1889+
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/54ebd77323464d79799666a9ea7de59c4592a938",
1890+
"reference": "54ebd77323464d79799666a9ea7de59c4592a938",
18911891
"shasum": ""
18921892
},
18931893
"require": {
@@ -1921,7 +1921,7 @@
19211921
"tomasvotruba\/unused-public": "^2.2",
19221922
"tracy\/tracy": "^2.11"
19231923
},
1924-
"time": "2026-01-23T15:31:06+00:00",
1924+
"time": "2026-02-03T19:03:28+00:00",
19251925
"default-branch": true,
19261926
"type": "rector-extension",
19271927
"extra": {

0 commit comments

Comments
 (0)