You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using simple conditions for early returns / guard statements the current formatting is quite verbose:
functiontest($arg1) {
if (!$arg) return;
for ($i = 0; $i < 10; $i++) {
if ($i % 2 === 0) continue;
// do something if the number is odd
}
}
will be converted to:
functiontest($arg1) {
if (!$arg) {
return;
}
for ($i = 0; $i < 10; $i++) {
if ($i % 2 === 0) {
continue;
}
// do something if the number is odd
}
}
It would be great if these single line conditions would be preserved. Alot of formatters for c-style languages like prettier for javascript or ClangFormat allow this, resulting in much more concise code.
The text was updated successfully, but these errors were encountered:
Hi @arnoson, thanks for reaching out about this. We chose to adhere to the PER-CS coding standard in this project as much as possible, which doesn't allow single line conditions: https://www.php-fig.org/per/coding-style/#5-control-structures
That's why I don't think this is a change we should be making, but I'll leave the issue open for further discussion.
When using simple conditions for early returns / guard statements the current formatting is quite verbose:
will be converted to:
It would be great if these single line conditions would be preserved. Alot of formatters for c-style languages like prettier for javascript or ClangFormat allow this, resulting in much more concise code.
The text was updated successfully, but these errors were encountered: