Skip to content

Commit

Permalink
Ruleset::explain(): fix plural vs singular phrasing
Browse files Browse the repository at this point in the history
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
```
  • Loading branch information
jrfnl committed Feb 1, 2022
1 parent 498a939 commit da0c874
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Ruleset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit da0c874

Please sign in to comment.