Open jrfnl opened 7 months ago
Another comment from a PR review which should probably be looked into:
... it should be verified that the sniff is actually in line with PSR-2 (including the errata).
What I mean by that is as follows:
Given the following code sample (multiple blank lines between interface names, no comments):
class ClassName extends ParentClass implements \Foo\Bar\Countable, \Serializable {}
The sniff would currently throw a
Only one interface may be specified per line in a multi-line implements declaration (PSR2.Classes.ClassDeclaration.InterfaceSameLine)
error. And the fixer would remove the blank lines.However, PSR-2 states "Lists of implements MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one interface per line.".
Given the above, there are two things to question about the sniff:
- If each interface name is already on its own line, should the sniff enforce "no blank lines between interface name lines" ? I don't see anything in PSR-2 which says it should, so this looks like something where the sniffs goes beyond its remit.
- If it would be decided that it should (possibly because this has been clarified on the PSR mailinglist or in the PSR-2 errata, or even because not doing so would change the expected behaviour of the sniff), is it correct that this is handled by the
InterfaceSameLine
error code ? Or should this be a separate error code, something likeNoBlankLinesBetweenInterfaceNames
?If I would have ever come across a multi-line implements like the above and would then have seen the
Only one interface may be specified per line in a multi-line implements declaration
error, I would have reported this as a bug in the sniff as the sniff is reporting something which is just not true (as each interface is already on its own line).
As per the note left on PR #424 :
And from a reply to a PR review: