Skip to content

Commit a9979f5

Browse files
committed
Revert "Use the new exit codes when scanning code from STDIN"
This reverts commit b872aeb.
1 parent 156dfbc commit a9979f5

1 file changed

Lines changed: 2 additions & 44 deletions

File tree

src/Reports/Cbf.php

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@
77
* report from the command line.
88
*
99
* @author Greg Sherwood <gsherwood@squiz.net>
10-
* @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl>
1110
* @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
12-
* @copyright 2025 PHPCSStandards and contributors
1311
* @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
1412
*/
1513

1614
namespace PHP_CodeSniffer\Reports;
1715

1816
use PHP_CodeSniffer\Exceptions\DeepExitException;
1917
use PHP_CodeSniffer\Files\File;
20-
use PHP_CodeSniffer\Reporter;
2118
use PHP_CodeSniffer\Util\ExitCode;
2219
use PHP_CodeSniffer\Util\Timing;
2320
use PHP_CodeSniffer\Util\Writers\StatusWriter;
@@ -63,12 +60,8 @@ public function generateFileReport($report, File $phpcsFile, $showSources=false,
6360
// Replacing STDIN, so output current file to STDOUT
6461
// even if nothing was fixed. Exit here because we
6562
// 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);
7265
}
7366

7467
if ($errors === 0) {
@@ -253,39 +246,4 @@ public function generate(
253246
}//end generate()
254247

255248

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-
291249
}//end class

0 commit comments

Comments
 (0)