Task/Collect/CodeAnalyser.php
protected function sendCommand($command, $payload) {
    fwrite($this->pipes[0], $command . ':' . $payload . PHP_EOL);

    $status_line = trim(fgets($this->pipes[1]));

    // An empty status line means the script has stopped responding, and has
    // presumably crashed.
    if (empty($status_line)) {
      return FALSE;
    }

    // An expected status line that matches the sent command means everything
    // went fine.
    if ($status_line == "$command OK") {
      return TRUE;
    }

    // If something's gone wrong, get any further output from the script so we
    // can see error messages.
    while ($line = fgets($this->pipes[1])) {
      dump($line);
    }

    throw new \Exception("Command $command with payload '$payload' failed.");
  }
protected function sendCommand($command, $payload) {
    fwrite($this->pipes[0], $command . ':' . $payload . PHP_EOL);

    $status_line = trim(fgets($this->pipes[1]));

    // An empty status line means the script has stopped responding, and has
    // presumably crashed.
    if (empty($status_line)) {
      return FALSE;
    }

    // An expected status line that matches the sent command means everything
    // went fine.
    if ($status_line == "$command OK") {
      return TRUE;
    }

    // If something's gone wrong, get any further output from the script so we
    // can see error messages.
    while ($line = fgets($this->pipes[1])) {
      dump($line);
    }

    throw new \Exception("Command $command with payload '$payload' failed.");
  }
protected function sendCommand ( $ command , $ payload ) { fwrite ( $ this -> pipes [ 0 ] , $ command . ':' . $ payload . PHP_EOL ) ; $ status_line = trim ( fgets ( $ this -> pipes [ 1 ] ) ) ; // An empty status line means the script has stopped responding, and has // presumably crashed. if ( empty ( $ status_line ) ) { return FALSE ; } // An expected status line that matches the sent command means everything // went fine. if ( $ status_line == "$command OK" ) { return TRUE ; } // If something's gone wrong, get any further output from the script so we // can see error messages. while ( $ line = fgets ( $ this -> pipes [ 1 ] ) ) { dump ( $ line ) ; } throw new \ Exception ( "Command $command with payload '$payload' failed." ) ; }
Send a single command to the script.

@param string $command
The command to send to the script. One of:
- 'PSR4': A PSR4 namespace and folder to add to the autoloader.
- 'CLASS': A class to check.
@param string $payload
The value to send to the script. Format depends on the command.

@return bool
Returns TRUE if the command was successful; FALSE if the process appears
to have crashed.

@throws \Exception
Throws an exception if the command failed.
Send a single command to the script .