-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: Fix indentation of comment on switch case #6490
base: master
Are you sure you want to change the base?
bug: Fix indentation of comment on switch case #6490
Conversation
This creates a conflict with PSR-12 rule about the |
There are 3 states of comment indentation: a) "for case body" so the fixer should work like following (in order): a) state is invalid if the next token (excluding other comments) is c) should be always fixed to a) when a) state is not valid, fix to b) some usecases:
|
Thinking about this again. Currently this is supported for Instead of extending this hazardous behavior to |
Yes, if comment is not the last statement/token or if it is inside curly braces (where it is always part of the body block), then simply both levels of comment indentation can be allowed/unfixed + zero indentation for comments. If different, it should still be fixed as if it was part of the body block. |
@SpacePossum @keradus @kubawerlos What is your opinion about this? |
@SpacePossum and myself on holidays, maybe @kubawerlos or @localheinz ? |
hi! any update on this? |
IMHO there is, if the comment is preceded by a new line: switch (true) {
case 'foo':
// inner block comment
case 'bar':
break;
// outer block comment
case 'baz':
break;
} If there are no empty lines at all, there is no reliable way indeed. |
Also, if a comment comes directly after the |
@leofeyer new line before comment can't determine indentation: switch (true) {
case 'foo':
$foo = [];
// Some complex logic
foreach ($foo as $f) {
}
// Some comment
break;
// outer block comment
case 'baz':
break;
} But yeah, when comment is after |
This comment has been minimized.
This comment has been minimized.
#7624 introduced a new option to control this behavior for |
Since this pull request has not had any activity within the last 90 days, I have marked it as stale. The purpose of this action is to enforce backlog review once in a while. This is mostly for maintainers and helps with keeping repository in good condition, because stale issues and PRs can accumulate over time and make it harder for others to find relevant information. It is also possible that some changes has been made to the repo already, and issue or PR became outdated, but wasn't closed for some reason. This action helps with periodic review and closing of such stale items in automated way. You may let maintainers handle this or verify current relevancy by yourself, to help with re-triage. Any activity will remove stale label so it won't be automatically closed at this point. I will close it if no further activity occurs within the next 14 days. Please keep your branch up-to-date by rebasing it when main branch is ahead of it, thanks in advance! |
Fixes #6470 (comment), #6572 and #7179.