Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,21 @@ jobs:
cd e2e/bug-14036
composer install
../../bin/phpstan analyze
- script: |
cd e2e/vvv-with-debug
OUTPUT=$(../../bin/phpstan analyze -l 0 -vvv --debug test.php 2>&1)
echo "$OUTPUT"
../bashunit -a not_contains 'Parallel processing scheduler' "$OUTPUT"
- script: |
cd e2e/vvv-with-debug
OUTPUT=$(../../bin/phpstan analyze -l 0 -vvv --debug --configuration parallel.neon test.php 2>&1)
echo "$OUTPUT"
../bashunit -a not_contains 'Parallel processing scheduler' "$OUTPUT"
- script: |
cd e2e/vvv-with-debug
OUTPUT=$(../../bin/phpstan analyze -l 0 -vvv test.php 2>&1)
echo "$OUTPUT"
../bashunit -a contains 'Parallel processing scheduler' "$OUTPUT"

steps:
- name: Harden the runner (Audit all outbound calls)
Expand Down
3 changes: 3 additions & 0 deletions e2e/vvv-with-debug/parallel.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
parameters:
parallel:
maximumNumberOfProcesses: 2
1 change: 1 addition & 0 deletions e2e/vvv-with-debug/test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php
41 changes: 19 additions & 22 deletions src/Command/AnalyserRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,30 +71,27 @@ public function runAnalyser(
);
}

$schedule = $this->scheduler->scheduleWork($this->cpuCoreCounter->getNumberOfCpuCores(), $files);
$mainScript = null;
if (isset($_SERVER['argv'][0]) && is_file($_SERVER['argv'][0])) {
$mainScript = $_SERVER['argv'][0];
}
if (!$debug && $allowParallel && function_exists('proc_open')) {
$schedule = $this->scheduler->scheduleWork($this->cpuCoreCounter->getNumberOfCpuCores(), $files);

$mainScript = null;
if (isset($_SERVER['argv'][0]) && is_file($_SERVER['argv'][0])) {
$mainScript = $_SERVER['argv'][0];
}

if (
!$debug
&& $allowParallel
&& function_exists('proc_open')
&& $mainScript !== null
&& $schedule->getNumberOfProcesses() > 0
) {
$loop = new StreamSelectLoop();
$result = null;
$promise = $this->parallelAnalyser->analyse($loop, $schedule, $mainScript, $postFileCallback, $projectConfigFile, $tmpFile, $insteadOfFile, $input, null);
$promise->then(static function (AnalyserResult $tmp) use (&$result): void {
$result = $tmp;
});
$loop->run();
if ($result === null) {
throw new ShouldNotHappenException();
if ($mainScript !== null && $schedule->getNumberOfProcesses() > 0) {
$loop = new StreamSelectLoop();
$result = null;
$promise = $this->parallelAnalyser->analyse($loop, $schedule, $mainScript, $postFileCallback, $projectConfigFile, $tmpFile, $insteadOfFile, $input, null);
$promise->then(static function (AnalyserResult $tmp) use (&$result): void {
$result = $tmp;
});
$loop->run();
if ($result === null) {
throw new ShouldNotHappenException();
}
return $result;
}
return $result;
}

return $this->analyser->analyse(
Expand Down
Loading