phpphpcodesnifferphpcs

Is there any Customizable Sniff Properties for classes/traits/interfaces?


is there any Customizable Sniff Properties for classes/traits/interfaces to do the followings;

I am expecting a rule for something like this.

example

Valid code

Class Example()
{
  /** Content */

}

Invalid Code: After the content it does not have a blank line & before the content there is a space allowed

Class Example()
{
 
 /** Content */
}

Solution

  • Please refer Squiz.WhiteSpace.FunctionSpacing sniff.

    Not completely it matches, but as most classes will have functions at the end, the "One line after last" can be enforced and if the class content starts with a function, the "No blank line before first" as well.

    Refererance: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Customisable-Sniff-Properties#squizwhitespacefunctionspacing

    found this solution form different source