Description
As I'm working on the implementation of PER2.0 I'm facing some issues with some sniffs.
In the first introductory of section 4 of PER 2.0 it states:
If class contains no additional declarations (such as an exception that exists only to extend another exception with a new type), then the body of the class SHOULD be abbreviated as {} and placed on the same line as the previous symbol, separated by a space. For example:
class MyException extends \RuntimeException {}
For this this issue, specifically: PSR2.Classes.ClassDeclaration.OpenBraceNewLine
and Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore
have an effect.
PSR2.Classes.ClassDeclaration.OpenBraceNewLine
This is for PER 2.0 'not always' valid anymore. When the closing brace is adjacent to the opening brace, it needs to not be on a newline. To check this in this sniff might be odd since it is not related to PSR2. But I would like some option to 'disable' specific cases for this error.
We could also make a new sniff where we inherit this one and extend it for PER2.0?
We should discuss the desired solution for this.
Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore
This is a difficult sniff for PER 2.0. Since closing braces do not need to be on a line by itself when the opening-brace is adjacent to the left AND for only functions, methods and classes.
The easiest fix for PER2.0 might be to have an option to this sniff to disable this error when a opening brace is adjacent on the left. The openbrace sniffs might catch the cases where the 'closing brace is not allowed there' and then we omit this rule for these situations.
@jrfnl Combining 2 sniffs in one issue feels a bit odd I think, but it is related to one section of PER 2.0. Let me know if you rather like '1 sniff discussion' per issue.
- I have read the Contribution Guidelines and this is not a support question.
- I intend to create a pull request to implement this feature. Open for it, but needs discussion first.