Skip to content

FileName Sniff can output multiple errors #96

Closed
@jaymcp

Description

@jaymcp

Describe the bug
The FileName Sniff will output two separate errors if the file contains a class with an incorrect file name.

To Reproduce

  1. Create a file called FooClass.php
  2. Add a barebones class into the file:
<?php

class FooClass {}
  1. Run phpcs FooClass.php
  2. 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)

Screenshots

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions