Hi! it's not obvious what is the issue and how much better it would be if this was accepted, probably worth sharing before/after screenshots of the diff it makes in the different IDEs
regards, Mathieu Rochette On Friday, March 27th, 2026 at 12:05, Amanzhol Zhaparov <[email protected]> wrote: > Hello PHP-FIG members, > > I would like to start a discussion regarding a potential refinement or an > allowed alternative in the PER Coding Style (successor to PSR-12), > specifically concerning section 5.1 (if, elseif, else). > > Currently, the standard strictly requires else and elseif to be on the same > line as the closing brace of the previous block: > > PHP > > if ($expr1) { > // body > } else { > // body > } > > The Problem: Code Folding & Scannability In modern development environments > (JetBrains PhpStorm, VS Code, Sublime Text), the "Code Folding" feature is > essential for navigating large files. When a developer collapses an if block > following the PSR-12 standard, the else keyword often gets hidden or visually > merged into a single line like: if ($expr1) { ... } else { > > This makes it difficult to quickly scan the code to see if an alternative > logic branch exists without unfolding every block. > > The Proposal: I propose to allow (or recommend as an alternative) placing > else and elseif on a new line, similar to the Allman style but keeping the > opening brace on the same line as the keyword: > > PHP > > if ($expr1) { > // if body > } > elseif ($expr2) { > // elseif body > } > else { > // else body > } > > Benefits: > > 1. Improved Visual Hierarchy: Each logical branch starts on its own line, > making the structure clear at a glance. > > 2. Better IDE Integration: When the if block is folded, the else or elseif > remains clearly visible on the next line, preserving the "map" of the logic. > > 3. Consistency: It aligns with how many developers naturally separate > distinct logical steps. > > > I understand that PSR-12 aimed for vertical compactness, but with > high-resolution monitors and the heavy use of IDE folding features, the > "saved line" often comes at the cost of readability. > > I would love to hear the community's thoughts on whether the PER Coding Style > could be updated to allow this formatting as a valid alternative. > > Best regards, Amanzhol Zhaparov > > -- > 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 view this discussion visit > https://groups.google.com/d/msgid/php-fig/cb762a86-90a3-4192-b80c-c1627be4255bn%40googlegroups.com. -- 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 view this discussion visit https://groups.google.com/d/msgid/php-fig/ibgXlpgMBG8VVZJAHVLTkvM61l3IlNb7PS3E4Cte6HjhvYlC6KHk72mq8WVvA-648uSj5bGV0LYM9Szuf6sQh5YKe6WkLHNAlnmXCsX1wRw%3D%40rochette.cc.
publickey - [email protected] - 0x8D30BA0E.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature
