/**
* @param string $fileName
* @param RequestInterface $request
* @param string $type
* @return ResponseInterface
*/
private function executePhpFile($fileName, RequestInterface $request, $type)
{
$process = $this->getProcess($fileName, $request);
$process->start();
$this->eventDispatcher->dispatch(new CgiExecuteEvent(sprintf('cgi.verify.%s.executing', $type), $request));
$process->wait();
if (!$process->isSuccessful()) {
throw CodeExecutionException::fromProcess($process);
}
//if no status line, pre-pend 200 OK
$output = $process->getOutput();
if (!preg_match('/^HTTP\\/([1-9]\\d*\\.\\d) ([1-5]\\d{2})(\\s+(.+))?\\r\\n/', $output)) {
$output = "HTTP/1.0 200 OK\r\n" . $output;
}
return ResponseSerializer::fromString($output);
}