Skip to content

Commit f2db6d1

Browse files
phpstan-botclaude
andcommitted
Make AnalyserResult::processedFiles non-optional, remove unused callback parameter
Address review feedback: - Remove default value from AnalyserResult::$processedFiles, add explicit processedFiles: [] at all construction sites - Remove unused $processedFiles parameter from non-debug postFileCallback - Revert postFileCallback type annotations to optional second parameter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ab11d4a commit f2db6d1

File tree

6 files changed

+9
-6
lines changed

6 files changed

+9
-6
lines changed

src/Analyser/Analyser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
/**
3737
* @param string[] $files
3838
* @param Closure(string $file): void|null $preFileCallback
39-
* @param Closure(int, list<string>): void|null $postFileCallback
39+
* @param Closure(int, list<string>=): void|null $postFileCallback
4040
* @param string[]|null $allAnalysedFiles
4141
*/
4242
public function analyse(

src/Analyser/AnalyserResult.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct(
4444
private array $exportedNodes,
4545
private bool $reachedInternalErrorsCountLimit,
4646
private int $peakMemoryUsageBytes,
47-
private array $processedFiles = [],
47+
private array $processedFiles,
4848
)
4949
{
5050
}

src/Command/AnalyseApplication.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,13 @@ private function runAnalyser(
244244
exportedNodes: [],
245245
reachedInternalErrorsCountLimit: false,
246246
peakMemoryUsageBytes: memory_get_peak_usage(true),
247+
processedFiles: [],
247248
);
248249
}
249250

250251
if (!$debug) {
251252
$preFileCallback = null;
252-
$postFileCallback = static function (int $step, array $processedFiles) use ($errorOutput): void {
253+
$postFileCallback = static function (int $step) use ($errorOutput): void {
253254
$errorOutput->getStyle()->progressAdvance($step);
254255
};
255256

@@ -264,7 +265,7 @@ private function runAnalyser(
264265
$postFileCallback = null;
265266
if ($stdOutput->isDebug()) {
266267
$previousMemory = memory_get_peak_usage(true);
267-
$postFileCallback = static function (int $step, array $processedFiles) use ($stdOutput, &$previousMemory, &$startTime, &$linesOfCode): void {
268+
$postFileCallback = static function (int $step, array $processedFiles = []) use ($stdOutput, &$previousMemory, &$startTime, &$linesOfCode): void {
268269
if ($startTime === null) {
269270
throw new ShouldNotHappenException();
270271
}

src/Command/AnalyserRunner.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(
3737
* @param string[] $files
3838
* @param string[] $allAnalysedFiles
3939
* @param Closure(string $file): void|null $preFileCallback
40-
* @param Closure(int, list<string>): void|null $postFileCallback
40+
* @param Closure(int, list<string>=): void|null $postFileCallback
4141
*/
4242
public function runAnalyser(
4343
array $files,
@@ -68,6 +68,7 @@ public function runAnalyser(
6868
exportedNodes: [],
6969
reachedInternalErrorsCountLimit: false,
7070
peakMemoryUsageBytes: memory_get_peak_usage(true),
71+
processedFiles: [],
7172
);
7273
}
7374

src/Command/FixerWorkerCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ private function runAnalyser(LoopInterface $loop, Container $container, array $f
404404
exportedNodes: [],
405405
reachedInternalErrorsCountLimit: false,
406406
peakMemoryUsageBytes: memory_get_peak_usage(true),
407+
processedFiles: [],
407408
));
408409
}
409410

src/Parallel/ParallelAnalyser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function __construct(
5858
}
5959

6060
/**
61-
* @param Closure(int, list<string>): void|null $postFileCallback
61+
* @param Closure(int, list<string>=): void|null $postFileCallback
6262
* @param (callable(list<Error>, list<Error>, string[]): void)|null $onFileAnalysisHandler
6363
* @return PromiseInterface<AnalyserResult>
6464
*/

0 commit comments

Comments
 (0)