Skip to content

Commit 2ae4619

Browse files
committed
Scheduler - fixed wrong number of processes for 1 job
1 parent 96271c3 commit 2ae4619

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/Parallel/ParallelAnalyser.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ public function analyse(
184184

185185
$loop->run();
186186

187+
if (count($jobs) > 0) {
188+
throw new \PHPStan\ShouldNotHappenException('Some jobs remaining');
189+
}
190+
187191
return new AnalyserResult(
188192
$errors,
189193
$internalErrors,

src/Parallel/Scheduler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function scheduleWork(
3434
{
3535
$jobs = array_chunk($files, $this->jobSize);
3636
$numberOfProcesses = min(
37-
(int) floor(count($jobs) / $this->minimumNumberOfJobsPerProcess),
37+
max((int) floor(count($jobs) / $this->minimumNumberOfJobsPerProcess), 1),
3838
$cpuCores
3939
);
4040

tests/PHPStan/Parallel/SchedulerTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ public function dataSchedule(): array
5555
2,
5656
[30, 30, 30, 30, 4],
5757
],
58+
[
59+
16,
60+
16,
61+
2,
62+
20,
63+
1,
64+
1,
65+
[1],
66+
],
5867
];
5968
}
6069

0 commit comments

Comments
 (0)