How about rules in section 5?
- The body MUST be on the next line after the opening brace - The closing brace MUST be on the next line after the body On Monday, January 27, 2020 at 3:27:02 PM UTC+3, Michael Voříšek wrote: > > While following PSR-12 implementation on PHP-CS-Fixer, a comment indicated > an ambiguousness in the PSR-12 text: > https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues/4756 > > Empty code block is very common in classes (like the ones that extend > \Exception), functions (to pass empty callable if no null is allowed), > catch blocks (if some expressions should be caught/supressed but not > handled) etc. > > Currently this is not defined in the PSR-12 except one example with > anonymous class: https://www.php-fig.org/psr/psr-12/#8-anonymous-classes > > I do belive that PSR-12 should be very clear about this as the usage is > very common. > > My proposal is: add a blank line before the closing bracket if and only if > a new line is before the opening bracket and there is no content inside the > block (code nor comment), i.e.: > > class A extends B > { > } > > try { > // try body > } catch (FirstThrowableType $e) {} > > > but what to with if/else like this one: > if () { > } else {} > > or try/catch: > try { > } finally { > // finally body > } > > or do/while like: > do { > } while(); > > extend my proposal condition "a new line is before the opening bracket, there > is no content inside the block and the closing bracket is the last part of > that expression (except semicolon)" > > What do you think? > > -- 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 view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/872f7ffc-164d-4de6-886a-0dc4e8843944%40googlegroups.com.