Parse the Xml result from Subversion

@param  string $output
@param  array  $arguments
@return array
960379
protected function parseDiffOutput($output, array $arguments = array())
    {
        if (!isset($arguments['--xml']) || false === $arguments['--xml']) {
            // non xml results are not supported
            return $output;
        }

        if (!isset($arguments['--summarize']) || false === $arguments['--summarize']) {
            // non summarized results are not supported
            return $output;
        }

        $sxml = simplexml_load_string($output);

        $retval = array();
        foreach ($sxml->xpath('//path') as $item) {
            $url = (string) $item;
            $path = ltrim(str_replace($this->client->getSvnUrl(''), '', $url), '/');

            // @todo move to a Mapper class?
            $status = (string) $item->attributes()->item;
            switch ($status) {
                case "modified":
                    $status = Status::MODIFIED;
                    break;
                case "added":
                    $status = Status::ADDED;
                    break;
                case "deleted":
                    $status = Status::DELETED;
                    break;
            }

            $file = new VcsFileInfo($path, $this->getClient()->getHead());
            $file->setStatus($status);

            $retval[] = $file;
        }

        return $retval;
    }
990721
protected function processReport($output)
    {
        $data = json_decode(trim($output), true);

        if (!is_array($data)) {
            $this->phpci->log($output);
            throw new \Exception(PHPCI\Helper\Lang::get('could_not_process_report'));
        }

        $errors = $data['totals']['errors'];
        $warnings = $data['totals']['warnings'];

        foreach ($data['files'] as $fileName => $file) {
            $fileName = str_replace($this->phpci->buildPath, '', $fileName);

            foreach ($file['messages'] as $message) {
                $this->build->reportError(
                    $this->phpci,
                    'php_code_sniffer',
                    'PHPCS: ' . $message['message'],
                    $message['type'] == 'ERROR' ? BuildError::SEVERITY_HIGH : BuildError::SEVERITY_LOW,
                    $fileName,
                    $message['line']
                );
            }
        }

        return array($errors, $warnings);
    }
232150
private function parse(string $method, ...$arguments)
    {
        if (null === $this->value) {
            return $this->default;
        }

        return self::$method($this->value, ...$arguments);
    }
1005163
private static function parseCommands(array $arguments):array
    {
        $commands = [];
        foreach ($arguments as $one) {
            if (strpos($one, '--') === false) {
                $commands[] = $one;
            }
        }
        return ($commands);
    }
548834
protected function fetchLinkableNodes ($output, $includeImages = false)
    {
        $crawler = $this->getCrawler($output);
        $filter  = 'link, script[src]';

        if ( $includeImages ) {
            $filter .= ', img[src]';
        }

        return new Collection($crawler->filter($filter)->extract([ 'src', 'href' ]));
    }
1357674
protected function parseOutput($compiler, $output)
    {
        $jsPhpize = $this->getJsPhpizeEngine($compiler);
        $output = preg_replace(
            '/\{\s*\?><\?(?:php)?\s*\}/',
            '{}',
            $output
        );
        $output = preg_replace(
            '/\}\s*\?><\?(?:php)?\s*(' .
            'else(if)?|for|while|switch|function' .
            ')(?![a-zA-Z0-9_])/',
            '} $1',
            $output
        );

        $dependencies = $jsPhpize->compileDependencies();
        if ($dependencies !== '') {
            $output = $compiler->getFormatter()->handleCode($dependencies) . $output;
        }

        $jsPhpize->flushDependencies();

        return $output;
    }
690430
protected function parse($output)
    {
        $lines = explode(PHP_EOL, $output);
        $stats = array();
        foreach ($lines as $line) {
            $data = explode(' ', $line);
            array_walk($data, 'trim');
            $stats[] = array_values(array_filter($data, function ($value) {
                return strlen($value) > 0;
            }));
        }

        return $stats;
    }
1257311
public function executeCommand(&$output)
	{
		$descriptorspec = array(
			0 => array("pipe", "r"), // stdin is a pipe that the child will read from
			1 => array("pipe", "w"), // stdout is a pipe that the child will write to
			2 => array("pipe", "w") // stderr is a pipe that the child will write to
		);

		$process = proc_open($this->cmd . ' ' . $this->getParams() . ' ' . $this->getInputSource() . ' ' . $this->getPDFPath(), $descriptorspec, $pipes);

		$output = stream_get_contents($pipes[1]) . stream_get_contents($pipes[2]);

		fclose($pipes[0]);
		fclose($pipes[1]);
		fclose($pipes[2]);

		return proc_close($process);
	}
756151
public function merge($output)
    {
        if (empty($this->files)) {
            throw new \LogicException("You need to add some files to merge by calling one of addFile, addFiles, setFiles methods");
        }

        /**
         * @var string $outputFiles
         */
        $outputFiles = array();
        foreach ($this->files as $file) {
            if (!$this->supports($file)) {
                if (!$this->omitUnsupported) {
                    throw new UnsupportedException(sprintf("Transformer for file '%s' not found, mime: %s", $file->getPath(), $file->getMimeType()));
                }
                continue;
            }
            if (!$this->driver->supports($file)) {
                $outputFile = $this->getTransformer($file)->transform($file);
                if (!$outputFile) {
                    throw new \LogicException(sprintf("Transformer should return NeuroSys\\FileMerger\\File in '%s' format", $this->driver->getFormat()));
                }
                $outputFiles[] = $outputFile->getPath();
            } else {
                $outputFiles[] = $file->getPath();
            }
        }

        if (count($outputFiles) == 1) {
            copy(end($outputFiles), $output);
        } elseif ($outputFiles) {
            $this->driver->merge($outputFiles, $output);
        }

        // reset files array
        $this->files = array();
    }
93182
private function dumpAssetic(OutputInterface $output)
    {
        $command = $this->getApplication()->find('assetic:dump');

        $arguments = [
            'command' => 'assetic:dump',
            '--env' => 'prod',
            '--no-debug' => true,
        ];

        $input = new ArrayInput($arguments);

        return $command->run($input, $output);
    }
517331
def _parse_output(self, output_xml):
    """"""
    output = Output(self._lutron,
                    name=output_xml.get('Name'),
                    watts=int(output_xml.get('Wattage')),
                    output_type=output_xml.get('OutputType'),
                    integration_id=int(output_xml.get('IntegrationID')))
    return output
473166
public function format(array $output): iterable
    {
        $formatted = [];
        $pattern = sprintf('#^(?:%s)\t(.+)$#i', implode('|', $this->status));
        foreach ($output as $row) {
            $matches = [];
            if (preg_match($pattern, $row, $matches)) {
                $formatted[] = $matches[1];
            }
        }
        return $formatted;
    }
119821
public static function normalizeOutputsStruct(array $outputs) {
        $result = [];

        foreach ($outputs as $k => $v) {
            if (is_numeric($k)) {
                if (!is_array($v)) {
                    throw new \InvalidArgumentException("outputs should be [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ]");
                }

                if (isset($v['address']) && isset($v['value'])) {
                    $address = $v['address'];
                    $value = $v['value'];
                } elseif (count($v) == 2 && isset($v[0]) && isset($v[1])) {
                    $address = $v[0];
                    $value = $v[1];
                } else {
                    throw new \InvalidArgumentException("outputs should be [address => value, ] or [[address, value], ] or [['address' => address, 'value' => value], ]");
                }
            } else {
                $address = $k;
                $value = $v;
            }

            $result[] = ['address' => $address, 'value' => $value];
        }

        return $result;
    }
467930
public function parse($arguments)
    {
        if (!is_array($arguments)) {
            $arguments = explode(' ', $arguments);
        }
        $operands = array();
        $numArgs = count($arguments);
        for ($i = 0; $i < $numArgs; ++$i) {
            $arg = trim($arguments[$i]);
            if (empty($arg)) {
                continue;
            }
            if (($arg === '--') || ($arg === '-') || (mb_substr($arg, 0, 1) !== '-')){
                // no more options, treat the remaining arguments as operands
                $firstOperandIndex = ($arg == '--') ? $i + 1 : $i;
                $operands = array_slice($arguments, $firstOperandIndex);
                break;
            }
            if (mb_substr($arg, 0, 2) == '--') {
                $this->addLongOption($arguments, $i);
            } else {
                $this->addShortOption($arguments, $i);
            }
        } // endfor

        $this->addDefaultValues();

        // remove '--' from operands array
        foreach ($operands as $operand) {
            if ($operand !== '--') {
                $this->operands[] = $operand;
            }
        }
    }
65352
public function output( $output ) {
		$response = $this->response();
		$response = $response->withBody( Psr7\stream_for( $output ) );
		return $response;
	}
995567
public function parse(array $vars = [])
    {
        $this->loadVars($vars);

        $output = $this->parsePhp();

        // Run Template Engines
        $output = $this->template->parse($output, $this->vars);

        // Run String Engines
        $output = $this->string->parse($output, $this->vars);

        return $output;
    }
704221
protected function parseComposerContent($output, $resource, $path, $rev)
    {
        if (!trim($output)) {
            return array('_nonexistent_package' => true);
        }

        $composer = (array) JsonFile::parseJson($output, $this->baseUrl.$resource.$rev);

        return $this->addComposerTime($composer, $path, $rev);
    }