djoos / Symfony-coding-standard

Development repository for the Symfony coding standard
MIT License
402 stars 102 forks source link

Opening brace should not match one-lined anonymous function #122

Closed soullivaneuh closed 6 years ago

soullivaneuh commented 6 years ago

Found on Symfony codebase: https://github.com/symfony/symfony/blob/cf898572a0194340ca2d8111891f8a6b9f860654/src/Symfony/Component/Config/Definition/Builder/ExprBuilder.php#L40

But phpcs will say:

Opening brace must be the last content on the line
Closing brace must be on a line by itself
Missing blank line before return statement

See also: https://github.com/squizlabs/PHP_CodeSniffer/issues/1580

Workaround:

<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.ContentAfterBrace"/>
<exclude name="Squiz.WhiteSpace.ScopeClosingBrace.ContentBefore"/>
<exclude name="PEAR.WhiteSpace.ScopeClosingBrace.Line"/>
<exclude name="Symfony.Formatting.BlankLineBeforeReturn.Invalid"/>
wickedOne commented 6 years ago

does https://github.com/djoos/Symfony-coding-standard/pull/141 fix this issue?

don't think that pointing to a piece of code in the symfony repo provides a proper argument whether or not a coding standard rule is valid or not; please provide a code sample and arguments from symfony's coding standards page to make a point

soullivaneuh commented 6 years ago

don't think that pointing to a piece of code in the symfony repo

Maybe some Symfony maintainer could answer, but I don't think why they will not apply Symfony coding standard on the Symfony codebase. :-)

djoos commented 6 years ago

Hi guys,

the coding standards page is what we base us on as codebases (even the Symfony repo!) could have bits (for different, sensible reasons) of legacy code that is not in-line with the standard... Those are then up to the CI setup on the codebase to be knowingly excluded.

Hope this helps!