Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Runner.php

function Runner::processChildProcs

Waits for child processes to complete and cleans up after them.

The reporting information returned by each child process is merged into the main reporter class.

Parameters

array $childProcs An array of child processes to wait for.:

Return value

bool

1 call to Runner::processChildProcs()
Runner::run in vendor/squizlabs/php_codesniffer/src/Runner.php
Performs the run.

File

vendor/squizlabs/php_codesniffer/src/Runner.php, line 771

Class

Runner

Namespace

PHP_CodeSniffer

Code

private function processChildProcs($childProcs) {
    $numProcessed = 0;
    $totalBatches = count($childProcs);
    $success = true;
    while (count($childProcs) > 0) {
        $pid = pcntl_waitpid(0, $status);
        if ($pid <= 0) {
            continue;
        }
        $childProcessStatus = pcntl_wexitstatus($status);
        if ($childProcessStatus !== 0) {
            $success = false;
        }
        $out = $childProcs[$pid];
        unset($childProcs[$pid]);
        if (file_exists($out) === false) {
            continue;
        }
        include $out;
        unlink($out);
        $numProcessed++;
        if (isset($childOutput) === false) {
            // The child process died, so the run has failed.
            $file = new DummyFile('', $this->ruleset, $this->config);
            $file->setErrorCounts(1, 0, 0, 0);
            $this->printProgress($file, $totalBatches, $numProcessed);
            $success = false;
            continue;
        }
        $this->reporter->totalFiles += $childOutput['totalFiles'];
        $this->reporter->totalErrors += $childOutput['totalErrors'];
        $this->reporter->totalWarnings += $childOutput['totalWarnings'];
        $this->reporter->totalFixable += $childOutput['totalFixable'];
        $this->reporter->totalFixed += $childOutput['totalFixed'];
        if (isset($debugOutput) === true) {
            echo $debugOutput;
        }
        if (isset($childCache) === true) {
            foreach ($childCache as $path => $cache) {
                Cache::set($path, $cache);
            }
        }
        // Fake a processed file so we can print progress output for the batch.
        $file = new DummyFile('', $this->ruleset, $this->config);
        $file->setErrorCounts($childOutput['totalErrors'], $childOutput['totalWarnings'], $childOutput['totalFixable'], $childOutput['totalFixed']);
        $this->printProgress($file, $totalBatches, $numProcessed);
    }
    
    //end while
    return $success;
}
RSS feed
Powered by Drupal