|
7 | 7 | * report from the command line. |
8 | 8 | * |
9 | 9 | * @author Greg Sherwood <gsherwood@squiz.net> |
10 | | - * @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl> |
11 | 10 | * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600) |
12 | | - * @copyright 2025 PHPCSStandards and contributors |
13 | 11 | * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence |
14 | 12 | */ |
15 | 13 |
|
16 | 14 | namespace PHP_CodeSniffer\Reports; |
17 | 15 |
|
18 | 16 | use PHP_CodeSniffer\Exceptions\DeepExitException; |
19 | 17 | use PHP_CodeSniffer\Files\File; |
20 | | -use PHP_CodeSniffer\Reporter; |
21 | 18 | use PHP_CodeSniffer\Util\ExitCode; |
22 | 19 | use PHP_CodeSniffer\Util\Timing; |
23 | 20 | use PHP_CodeSniffer\Util\Writers\StatusWriter; |
@@ -63,12 +60,8 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false, |
63 | 60 | // Replacing STDIN, so output current file to STDOUT |
64 | 61 | // even if nothing was fixed. Exit here because we |
65 | 62 | // can't process any more than 1 file in this setup. |
66 | | - echo $phpcsFile->fixer->getContents(); |
67 | | - |
68 | | - // Fake a Reporter instance to allow for getting a proper exit code. |
69 | | - $reporter = $this->createReporterInstance($phpcsFile); |
70 | | - |
71 | | - throw new DeepExitException('', ExitCode::calculate($reporter)); |
| 63 | + $fixedContent = $phpcsFile->fixer->getContents(); |
| 64 | + throw new DeepExitException($fixedContent, ExitCode::OKAY); |
72 | 65 | } |
73 | 66 |
|
74 | 67 | if ($errors === 0) { |
@@ -253,39 +246,4 @@ public function generate( |
253 | 246 | }//end generate() |
254 | 247 |
|
255 | 248 |
|
256 | | - /** |
257 | | - * Create a "fake" Reporter instance to allow for getting a proper exit code when scanning code provided via STDIN. |
258 | | - * |
259 | | - * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being reported on. |
260 | | - * |
261 | | - * @return \PHP_CodeSniffer\Reporter |
262 | | - */ |
263 | | - private function createReporterInstance(File $phpcsFile) |
264 | | - { |
265 | | - $reporter = new class extends Reporter { |
266 | | - |
267 | | - |
268 | | - /** |
269 | | - * Overload the constructor as we don't need it. |
270 | | - */ |
271 | | - public function __construct() |
272 | | - { |
273 | | - }//end __construct() |
274 | | - |
275 | | - |
276 | | - }; |
277 | | - |
278 | | - $reporter->totalFiles = 1; |
279 | | - $reporter->totalErrors = $phpcsFile->getErrorCount(); |
280 | | - $reporter->totalWarnings = $phpcsFile->getWarningCount(); |
281 | | - $reporter->totalFixableErrors = $phpcsFile->getFixableErrorCount(); |
282 | | - $reporter->totalFixableWarnings = $phpcsFile->getFixableWarningCount(); |
283 | | - $reporter->totalFixedErrors = $phpcsFile->getFixedErrorCount(); |
284 | | - $reporter->totalFixedWarnings = $phpcsFile->getFixedWarningCount(); |
285 | | - |
286 | | - return $reporter; |
287 | | - |
288 | | - }//end createReporterInstance() |
289 | | - |
290 | | - |
291 | 249 | }//end class |
0 commit comments