Skip to content

Commit 228203d

Browse files
committed
Updated Rector to commit 2328ea6338d2496c409aaf2d8a001052e323feda
rectorphp/rector-src@2328ea6 [skip] track used skips as class => [paths] map (#8074)
1 parent d7cb788 commit 228203d

6 files changed

Lines changed: 52 additions & 27 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 = '19dcdb7816f10cb502a1b2ef5a6628185f74e49d';
22+
public const PACKAGE_VERSION = '2328ea6338d2496c409aaf2d8a001052e323feda';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2026-06-21 13:42:16';
27+
public const RELEASE_DATE = '2026-06-21 14:38:56';
2828
/**
2929
* @var int
3030
*/

src/Parallel/Application/ParallelFileProcessor.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function process(Schedule $schedule, string $mainScript, callable $postFi
7171
$fileDiffs = [];
7272
/** @var SystemError[] $systemErrors */
7373
$systemErrors = [];
74-
/** @var array<string, true> $usedSkips */
74+
/** @var array<string, array<string, true>> $usedSkips */
7575
$usedSkips = [];
7676
$tcpServer = new TcpServer('127.0.0.1:0', $streamSelectLoop);
7777
$this->processPool = new ProcessPool($tcpServer);
@@ -127,11 +127,14 @@ function (array $json) use ($parallelProcess, &$systemErrors, &$fileDiffs, &$use
127127
* file_diffs: array<string, mixed>,
128128
* files_count: int,
129129
* system_errors_count: int,
130-
* used_skips: string[]
130+
* used_skips: array<string, string[]>
131131
* } $json */
132132
$totalChanged += $json[Bridge::TOTAL_CHANGED];
133-
foreach ($json[Bridge::USED_SKIPS] as $usedSkip) {
134-
$usedSkips[$usedSkip] = \true;
133+
foreach ($json[Bridge::USED_SKIPS] as $skip => $paths) {
134+
$usedSkips[$skip] ??= [];
135+
foreach ($paths as $path) {
136+
$usedSkips[$skip][$path] = \true;
137+
}
135138
}
136139
// decode arrays to objects
137140
foreach ($json[Bridge::SYSTEM_ERRORS] as $jsonError) {
@@ -191,6 +194,10 @@ function ($exitCode, string $stdErr) use (&$systemErrors, $processIdentifier): v
191194
if ($reachedSystemErrorsCountLimit) {
192195
$systemErrors[] = new SystemError(sprintf('Reached system errors count limit of %d, exiting...', self::SYSTEM_ERROR_LIMIT));
193196
}
194-
return new ProcessResult($systemErrors, $fileDiffs, $totalChanged, array_keys($usedSkips));
197+
$mergedUsedSkips = [];
198+
foreach ($usedSkips as $skip => $paths) {
199+
$mergedUsedSkips[$skip] = array_keys($paths);
200+
}
201+
return new ProcessResult($systemErrors, $fileDiffs, $totalChanged, $mergedUsedSkips);
195202
}
196203
}

src/Reporting/UnusedSkipResolver.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ private function resolveGlobalRelativePaths(): array
100100
return $globalRelativePaths;
101101
}
102102
/**
103-
* @param string[] $usedSkips
103+
* @param array<string, string[]> $usedSkips
104104
* @return string[]
105105
*/
106106
private function resolveUnusedRuleScopedSkips(array $usedSkips): array
@@ -110,9 +110,9 @@ private function resolveUnusedRuleScopedSkips(array $usedSkips): array
110110
foreach ($this->resolveRelativePathsByClass() as $rectorClass => $relativePaths) {
111111
$unusedRelativePaths = [];
112112
foreach ($relativePaths as $path => $relativePath) {
113-
// used skips are tracked scoped to their rule as "class|path", so the same path
113+
// used skips are tracked scoped to their rule (class => [path]), so the same path
114114
// skipped under another rule does not mark this one used (see SkipSkipper)
115-
if (!in_array($rectorClass . '|' . $path, $usedSkips, \true)) {
115+
if (!in_array($path, $usedSkips[$rectorClass] ?? [], \true)) {
116116
$unusedRelativePaths[] = $relativePath;
117117
}
118118
}
@@ -125,14 +125,15 @@ private function resolveUnusedRuleScopedSkips(array $usedSkips): array
125125
return $unusedSkips;
126126
}
127127
/**
128-
* @param string[] $usedSkips
128+
* @param array<string, string[]> $usedSkips
129129
* @return string[]
130130
*/
131131
private function resolveUnusedGlobalSkips(array $usedSkips): array
132132
{
133133
$unusedSkips = [];
134134
foreach ($this->resolveGlobalRelativePaths() as $path => $relativePath) {
135-
if (!in_array($path, $usedSkips, \true)) {
135+
// global path skips are tracked by their own path key, with no nested paths
136+
if (!array_key_exists($path, $usedSkips)) {
136137
$unusedSkips[] = $relativePath;
137138
}
138139
}

src/Skipper/Skipper/SkipSkipper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ public function doesMatchSkip($checker, string $filePath, array $skippedClasses)
3434
$this->usedSkipCollector->markUsed($skippedClass);
3535
return \true;
3636
}
37-
// mark the specific matched path used, scoped to its rule via "class|path" - the same
38-
// path can be skipped under multiple rules, so a path-only key would mark them all used
37+
// mark the specific matched path used, scoped to its rule - the same path can be skipped
38+
// under multiple rules, so the path is nested under its rule, not tracked on its own
3939
$matchedPath = $this->fileInfoMatcher->matchPattern($filePath, $skippedFiles);
4040
if ($matchedPath !== null) {
41-
$this->usedSkipCollector->markUsed($skippedClass . '|' . $matchedPath);
41+
$this->usedSkipCollector->markUsed($skippedClass, $matchedPath);
4242
return \true;
4343
}
4444
}

src/Skipper/Skipper/UsedSkipCollector.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,29 @@
1212
final class UsedSkipCollector
1313
{
1414
/**
15-
* @var array<string, true>
15+
* Map of skip element (rule class or global path) to the set of paths matched under it.
16+
* Rule-scoped skips collect their matched paths; skip-everywhere rules and global path skips
17+
* keep an empty path set, the same shape as the "->withSkip()" config.
18+
*
19+
* @var array<string, array<string, true>>
1620
*/
1721
private array $usedSkips = [];
18-
public function markUsed(string $skip): void
22+
public function markUsed(string $skip, ?string $path = null): void
1923
{
20-
$this->usedSkips[$skip] = \true;
24+
$this->usedSkips[$skip] ??= [];
25+
if ($path !== null) {
26+
$this->usedSkips[$skip][$path] = \true;
27+
}
2128
}
2229
/**
23-
* @return string[]
30+
* @return array<string, string[]>
2431
*/
2532
public function provide(): array
2633
{
27-
return array_keys($this->usedSkips);
34+
$usedSkips = [];
35+
foreach ($this->usedSkips as $skip => $paths) {
36+
$usedSkips[$skip] = array_keys($paths);
37+
}
38+
return $usedSkips;
2839
}
2940
}

src/ValueObject/ProcessResult.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ final class ProcessResult
2323
*/
2424
private int $totalChanged;
2525
/**
26-
* @var string[]
26+
* @var array<string, string[]>
2727
*/
2828
private array $usedSkips = [];
2929
/**
3030
* @param SystemError[] $systemErrors
3131
* @param FileDiff[] $fileDiffs
32-
* @param string[] $usedSkips
32+
* @param array<string, string[]> $usedSkips
3333
*/
3434
public function __construct(array $systemErrors, array $fileDiffs, int $totalChanged, array $usedSkips = [])
3535
{
@@ -39,7 +39,10 @@ public function __construct(array $systemErrors, array $fileDiffs, int $totalCha
3939
$this->usedSkips = $usedSkips;
4040
Assert::allIsInstanceOf($systemErrors, SystemError::class);
4141
Assert::allIsInstanceOf($fileDiffs, FileDiff::class);
42-
Assert::allString($usedSkips);
42+
Assert::allString(array_keys($usedSkips));
43+
foreach ($usedSkips as $usedSkip) {
44+
Assert::allString($usedSkip);
45+
}
4346
}
4447
/**
4548
* @return SystemError[]
@@ -71,19 +74,22 @@ public function addSystemErrors(array $systemErrors): void
7174
* their result from worker processes only. Merge those main-process marks back in, or they would
7275
* be wrongly reported as unused.
7376
*
74-
* @param string[] $usedSkips
77+
* @param array<string, string[]> $usedSkips
7578
*/
7679
public function addUsedSkips(array $usedSkips): void
7780
{
78-
Assert::allString($usedSkips);
79-
$this->usedSkips = array_values(array_unique(array_merge($this->usedSkips, $usedSkips)));
81+
foreach ($usedSkips as $skip => $paths) {
82+
Assert::allString($paths);
83+
$existingPaths = $this->usedSkips[$skip] ?? [];
84+
$this->usedSkips[$skip] = array_values(array_unique(array_merge($existingPaths, $paths)));
85+
}
8086
}
8187
public function getTotalChanged(): int
8288
{
8389
return $this->totalChanged;
8490
}
8591
/**
86-
* @return string[]
92+
* @return array<string, string[]>
8793
*/
8894
public function getUsedSkips(): array
8995
{

0 commit comments

Comments
 (0)