From da0c874e89260514c4eff8f6bfec29e0df501f35 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 1 Feb 2022 04:16:42 +0100 Subject: [PATCH] Ruleset::explain(): fix plural vs singular phrasing When running the `phpcs --standard=Name -e` command, the line at the top of the output would always presume that a standard contains more than one sniff. The sniff count for the standards within the standard - `StandardName (# sniff[s])` - already handled this correctly. Fixed the top line now. Output without this fix: ``` The DummySubDir standard contains 1 sniffs DummySubDir (1 sniff) ---------------------- DummySubDir.Demo.Demo ``` Output with this fix: ``` The DummySubDir standard contains 1 sniff DummySubDir (1 sniff) ---------------------- DummySubDir.Demo.Demo ``` --- src/Ruleset.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Ruleset.php b/src/Ruleset.php index 7e659706c8..f90e7b6d2b 100644 --- a/src/Ruleset.php +++ b/src/Ruleset.php @@ -249,7 +249,12 @@ public function explain() // one last time and clear the output buffer. $sniffs[] = ''; - echo PHP_EOL."The $this->name standard contains $sniffCount sniffs".PHP_EOL; + $summaryLine = PHP_EOL."The $this->name standard contains 1 sniff".PHP_EOL; + if ($sniffCount !== 1) { + $summaryLine = str_replace('1 sniff', "$sniffCount sniffs", $summaryLine); + } + + echo $summaryLine; ob_start();