Description
The following code sample will give a fixer conflict when the Squiz
ruleset is run against it as the Squiz.Classes.ClassDeclaration
sniff demands exactly one blank line after a class, while the Squiz.WhiteSpace.FunctionSpacing
sniff demands exactly two blank lines before a function.
class MyClass2
{
var $x;
}
/** ************************************************************************
* Example with no errors.
**************************************************************************/
function example() {}
This can be prevented from either sniff by checking either that the next non-empty token is a function
keyword (ClassDeclaration
) or that the previous non-empty token is a close brace of an OO construct (FunctionSpacing
) and bowing out if that's the case.
@gsherwood I'm not sure which of the two sniffs should have precedence, i.e. which sniff should be adjusted ? Guidance appreciated.
I'm happy to prepare the PR once it's clear what the desired fix should be.
Also: there are a number of unintentional parse errors in test files where global functions are prefixed with a visibility keyword. Those would need to be fixed too, as otherwise the fixer conflict would still show (previous/next non-empty would be the visibility keyword breaking the fix).