| 253 | | } |
|---|
| 254 | | |
|---|
| 255 | | // process output |
|---|
| 256 | | foreach ($this->formatters as $fe) { |
|---|
| 257 | | $output = ''; |
|---|
| 258 | | |
|---|
| 259 | | switch ($fe->getType()) { |
|---|
| 260 | | case 'default': |
|---|
| 261 | | // default format goes to logs, no buffering |
|---|
| 262 | | $this->outputCustomFormat($codeSniffer); |
|---|
| 263 | | $fe->setUseFile(false); |
|---|
| 264 | | break; |
|---|
| 265 | | |
|---|
| 266 | | case 'xml': |
|---|
| 267 | | ob_start(); |
|---|
| 268 | | $codeSniffer->printXMLErrorReport($this->showWarnings); |
|---|
| 269 | | $output = ob_get_contents(); |
|---|
| 270 | | ob_end_clean(); |
|---|
| 271 | | break; |
|---|
| 272 | | |
|---|
| 273 | | case 'checkstyle': |
|---|
| 274 | | ob_start(); |
|---|
| 275 | | $codeSniffer->printCheckstyleErrorReport($this->showWarnings); |
|---|
| 276 | | $output = ob_get_contents(); |
|---|
| 277 | | ob_end_clean(); |
|---|
| 278 | | break; |
|---|
| 279 | | |
|---|
| 280 | | case 'csv': |
|---|
| 281 | | ob_start(); |
|---|
| 282 | | $codeSniffer->printCSVErrorReport($this->showWarnings); |
|---|
| 283 | | $output = ob_get_contents(); |
|---|
| 284 | | ob_end_clean(); |
|---|
| 285 | | break; |
|---|
| 286 | | |
|---|
| 287 | | case 'report': |
|---|
| 288 | | ob_start(); |
|---|
| 289 | | $codeSniffer->printErrorReport($this->showWarnings); |
|---|
| 290 | | $output = ob_get_contents(); |
|---|
| 291 | | ob_end_clean(); |
|---|
| 292 | | break; |
|---|
| 293 | | |
|---|
| 294 | | case 'summary': |
|---|
| 295 | | ob_start(); |
|---|
| 296 | | $codeSniffer->printErrorReportSummary($this->showWarnings); |
|---|
| 297 | | $output = ob_get_contents(); |
|---|
| 298 | | ob_end_clean(); |
|---|
| 299 | | break; |
|---|
| 300 | | |
|---|
| 301 | | case 'doc': |
|---|
| 302 | | ob_start(); |
|---|
| 303 | | $codeSniffer->generateDocs($this->standard, $this->sniffs); |
|---|
| 304 | | $output = ob_get_contents(); |
|---|
| 305 | | ob_end_clean(); |
|---|
| 306 | | break; |
|---|
| 307 | | |
|---|
| 308 | | default: |
|---|
| 309 | | $this->log('Unknown output format "' . $fe->getType() . '"', Project::MSG_INFO); |
|---|
| 310 | | continue; //skip to next formatter in list |
|---|
| 311 | | break; |
|---|
| 312 | | } //end switch |
|---|
| 313 | | |
|---|
| 314 | | if (!$fe->getUseFile()) { |
|---|
| 315 | | // output raw to console |
|---|
| 316 | | echo $output; |
|---|
| 317 | | |
|---|
| 318 | | } else { |
|---|
| 319 | | // write to file |
|---|
| 320 | | $outputFile = $fe->getOutfile(); |
|---|
| 321 | | $check = file_put_contents($outputFile, $output); |
|---|
| 322 | | if (is_bool($check) && !$check) { |
|---|
| 323 | | throw new BuildException('Error writing output to ' . $outputFile); |
|---|
| 324 | | } |
|---|
| | 253 | } |
|---|
| | 254 | |
|---|
| | 255 | // process output |
|---|
| | 256 | foreach ($this->formatters as $fe) { |
|---|
| | 257 | $output = ''; |
|---|
| | 258 | |
|---|
| | 259 | switch ($fe->getType()) { |
|---|
| | 260 | case 'default': |
|---|
| | 261 | // default format goes to logs, no buffering |
|---|
| | 262 | $this->outputCustomFormat($codeSniffer); |
|---|
| | 263 | $fe->setUseFile(false); |
|---|
| | 264 | break; |
|---|
| | 265 | |
|---|
| | 266 | case 'xml': |
|---|
| | 267 | ob_start(); |
|---|
| | 268 | $codeSniffer->printXMLErrorReport($this->showWarnings); |
|---|
| | 269 | $output = ob_get_contents(); |
|---|
| | 270 | ob_end_clean(); |
|---|
| | 271 | break; |
|---|
| | 272 | |
|---|
| | 273 | case 'checkstyle': |
|---|
| | 274 | ob_start(); |
|---|
| | 275 | $codeSniffer->printCheckstyleErrorReport($this->showWarnings); |
|---|
| | 276 | $output = ob_get_contents(); |
|---|
| | 277 | ob_end_clean(); |
|---|
| | 278 | break; |
|---|
| | 279 | |
|---|
| | 280 | case 'csv': |
|---|
| | 281 | ob_start(); |
|---|
| | 282 | $codeSniffer->printCSVErrorReport($this->showWarnings); |
|---|
| | 283 | $output = ob_get_contents(); |
|---|
| | 284 | ob_end_clean(); |
|---|
| | 285 | break; |
|---|
| | 286 | |
|---|
| | 287 | case 'report': |
|---|
| | 288 | ob_start(); |
|---|
| | 289 | $codeSniffer->printErrorReport($this->showWarnings); |
|---|
| | 290 | $output = ob_get_contents(); |
|---|
| | 291 | ob_end_clean(); |
|---|
| | 292 | break; |
|---|
| | 293 | |
|---|
| | 294 | case 'summary': |
|---|
| | 295 | ob_start(); |
|---|
| | 296 | $codeSniffer->printErrorReportSummary($this->showWarnings); |
|---|
| | 297 | $output = ob_get_contents(); |
|---|
| | 298 | ob_end_clean(); |
|---|
| | 299 | break; |
|---|
| | 300 | |
|---|
| | 301 | case 'doc': |
|---|
| | 302 | ob_start(); |
|---|
| | 303 | $codeSniffer->generateDocs($this->standard, $this->sniffs); |
|---|
| | 304 | $output = ob_get_contents(); |
|---|
| | 305 | ob_end_clean(); |
|---|
| | 306 | break; |
|---|
| | 307 | |
|---|
| | 308 | default: |
|---|
| | 309 | $this->log('Unknown output format "' . $fe->getType() . '"', Project::MSG_INFO); |
|---|
| | 310 | continue; //skip to next formatter in list |
|---|
| | 311 | break; |
|---|
| | 312 | } //end switch |
|---|
| | 313 | |
|---|
| | 314 | if (!$fe->getUseFile()) { |
|---|
| | 315 | // output raw to console |
|---|
| | 316 | echo $output; |
|---|
| | 317 | |
|---|
| | 318 | } else { |
|---|
| | 319 | // write to file |
|---|
| | 320 | $outputFile = $fe->getOutfile(); |
|---|
| | 321 | $check = file_put_contents($outputFile, $output); |
|---|
| | 322 | if (is_bool($check) && !$check) { |
|---|
| | 323 | throw new BuildException('Error writing output to ' . $outputFile); |
|---|