FileName Sniff can output multiple errors
Closed this issue · 0 comments
jaymcp commented
Describe the bug
The FileName Sniff will output two separate errors if the file contains a class with an incorrect file name.
To Reproduce
- Create a file called
FooClass.php
- Add a barebones class into the file:
<?php
class FooClass {}
- Run
phpcs FooClass.php
- See two errors relating to the filename, instead of one
Expected behaviour
The Sniff should output one error:
Class file names should be based on the class name with "class-" prepended. Expected class-foo-class.php, but found FooClass.php.
PHPCS(BigBite.Files.FileName.InvalidClassFileName)
Platform
- OS: MacOS
- Shell: BASH
Additional context
Whilst both errors are technically correct, the InvalidClassFileName
error should take precedence over the NotHyphenatedLowercase
error in applicable situations.
It is important to maintain the NotHyphenatedLowercase
error for non-class files.