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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/b3949635-7725-475e-a166-8fbaac60427c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to