public function writeReport(Report $report): void
    {
        $xml = new \DOMDocument('1.0', 'UTF-8');

        $root = $xml->createElement('checkstyle');
        $root->setAttribute('version', APP_NAME . '-' . APP_VERSION);

        foreach ($report->getFiles() as $file) {
            $xmlFile = $xml->createElement('file');
            $xmlFile->setAttribute('name', $file->getFilename());

            foreach ($file->getIssues() as $issue) {
                $xmlWarning = $xml->createElement('error');
                $xmlWarning->setAttribute('line', "" . $issue->getLine());
                $xmlWarning->setAttribute('severity', $issue->getSeverity());
                $xmlWarning->setAttribute('message', $issue->getMessage());
                $xmlWarning->setAttribute('source', $issue->getSource());

                if ($issue->getColumn() !== null) {
                    $xmlWarning->setAttribute('column', "" . $issue->getColumn());
                }

                $xmlFile->appendChild($xmlWarning);
            }

            $root->appendChild($xmlFile);
        }

        $xml->appendChild($root);
        $xml->formatOutput = true;

        $this->output->write($xml->saveXML());
    }
public function writeReport(Report $report): void
    {
        $xml = new \DOMDocument('1.0', 'UTF-8');

        $root = $xml->createElement('checkstyle');
        $root->setAttribute('version', APP_NAME . '-' . APP_VERSION);

        foreach ($report->getFiles() as $file) {
            $xmlFile = $xml->createElement('file');
            $xmlFile->setAttribute('name', $file->getFilename());

            foreach ($file->getIssues() as $issue) {
                $xmlWarning = $xml->createElement('error');
                $xmlWarning->setAttribute('line', "" . $issue->getLine());
                $xmlWarning->setAttribute('severity', $issue->getSeverity());
                $xmlWarning->setAttribute('message', $issue->getMessage());
                $xmlWarning->setAttribute('source', $issue->getSource());

                if ($issue->getColumn() !== null) {
                    $xmlWarning->setAttribute('column', "" . $issue->getColumn());
                }

                $xmlFile->appendChild($xmlWarning);
            }

            $root->appendChild($xmlFile);
        }

        $xml->appendChild($root);
        $xml->formatOutput = true;

        $this->output->write($xml->saveXML());
    }
public function writeReport ( Report $ report ) : void { $ xml = new \ DOMDocument ( '1.0' , 'UTF-8' ) ; $ root = $ xml -> createElement ( 'checkstyle' ) ; $ root -> setAttribute ( 'version' , APP_NAME . '-' . APP_VERSION ) ; foreach ( $ report -> getFiles ( ) as $ file ) { $ xmlFile = $ xml -> createElement ( 'file' ) ; $ xmlFile -> setAttribute ( 'name' , $ file -> getFilename ( ) ) ; foreach ( $ file -> getIssues ( ) as $ issue ) { $ xmlWarning = $ xml -> createElement ( 'error' ) ; $ xmlWarning -> setAttribute ( 'line' , "" . $ issue -> getLine ( ) ) ; $ xmlWarning -> setAttribute ( 'severity' , $ issue -> getSeverity ( ) ) ; $ xmlWarning -> setAttribute ( 'message' , $ issue -> getMessage ( ) ) ; $ xmlWarning -> setAttribute ( 'source' , $ issue -> getSource ( ) ) ; if ( $ issue -> getColumn ( ) !== null ) { $ xmlWarning -> setAttribute ( 'column' , "" . $ issue -> getColumn ( ) ) ; } $ xmlFile -> appendChild ( $ xmlWarning ) ; } $ root -> appendChild ( $ xmlFile ) ; } $ xml -> appendChild ( $ root ) ; $ xml -> formatOutput = true ; $ this -> output -> write ( $ xml -> saveXML ( ) ) ; }
Writes a report in checkstyle XML format.

@param Report $report The report to print.
@return void
Writes a report in checkstyle XML format .