As we discussed here https://github.com/squizlabs/PHP_CodeSniffer/issues/2314 we should enforce some standards on comments at least to be inline with the surrounding code.
On Monday, April 23, 2018 at 7:06:56 AM UTC+2, Greg Sherwood wrote: > > Hi, > > I'm working on the PSR-12 standard for PHP_CodeSniffer. I have a question > about comments in general. > > PSR-2 explicitly excluded comments so I ended up writing a lot of checks > that just treat comments like whitespace. PSR-12 doesn't look like it does > this, but it hardly mentions comments, so I'm not sure how to deal with > them. > > For example, I'm working on checks around use statements for traits. I can > see that use statements need to be one per line, and the example code > indicates that there should not be blank lines between these statements: > > class ClassName >> { >> use FirstTrait; >> use SecondTrait; >> use ThirdTrait; >> } > > > What I don't know is: > > 1. Can you put blank lines between use statements? For example: > > class ClassName >> { >> use FirstTrait; > > >> use SecondTrait; > > > > > > use ThirdTrait; >> } > > > 2. Can you put comments in between use statements? What about before the > first use statement? If so, how should it be done (with or without blank > lines? how many blank lines?): > > class ClassName >> { >> // We need this for reasons. >> use FirstTrait; >> // We need these two more for reasons. >> use SecondTrait; >> use ThirdTrait; >> } > > > or > > class ClassName >> { >> // We need this for reasons. >> use FirstTrait; > > >> // We need these two more for reasons. >> use SecondTrait; >> use ThirdTrait; >> } > > > Or some other way? > > PSR-12 does say The use keyword used inside the classes to implement > traits MUST be declared on the next line after the opening brace" so a > comment before the use statement would contradict this, but I'm not sure if > a comment needs to be excluded from this check. > > Thanks > -- You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+unsubscr...@googlegroups.com. To post to this group, send email to php-fig@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/f8dc801b-50d8-4b40-afca-ae7eda4c20e0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.