Skip to content

[PSR-12] space after closing parenthesis for alternative control structure syntax #3391

Answered by gsherwood
herndlm asked this question in Q&A
Discussion options

You must be logged in to vote

First, I strongly recommend not trying to enforce PSR12 on template code. Alternate syntax rules were excluded from the PSR standards on purpose so they wouldn't mix template standards with other coding standards. Hence the use of "brace" everywhere.

But if you want to use it, PHPCS sees the opening brace of this alternate IF syntax as the : and the closing brace as the endif. The sniffs that check control structures don't care if you're using regular or alternate syntax - they just check that the opening and closing scope tokens are in the right spots. This behaviour is completely intentional throughout PHPCS.

You may also want to consider excluding this specific sniff or error code from…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@herndlm
Comment options

Answer selected by herndlm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants