Issue with SpaceAroundControlStructures and comments on top of control structure
Opened this issue · 7 comments
Hi there, lovely tool. I've been using it for a few days and I'm loving it already. I'm having a little issue though with comments on top of control structures when I use the "SpaceAroundControlStructures" formatter. Basically, all the spaces before the comments are getting removed, and is not intended properly anymore. I attached a screenshot.
Not sure if it's a problem of combination with some other options (I'm using a lot). I can put the list here if needed. Anything I can do to give a hand?
I'm having the same issue (ST3). I've verified that it still does it when using only the "SpaceAroundControlStructures" transformation. I'm using PSR2 formatting.
So it seems to be an issue about how phpfmt handles the extra line on top of the control structure when there are comments. But there's no way to report an issue in the phpfmt github. When I have a bit of time I'll see if I can fix the code and send a PR.
@ParadoxD It's an issue with the DocBlock which should start with two **, not one *. Thanks to @subins2000 for checking. In my case, I had the "DocBlockToComment" pass enabled, so I've removed it. Comments in normal structure will now be DockBlock comments, but it's fine.
I've made a PR, let's see. Even the normal "//" comments didn't work, which was annoying. So with the PR the normal comments "/*" and "//" act like the DocBlocks. They are indented correctly and there is a space between the control structure and the comments (which we might want to remove, and add the space on top of the comments?)
@godbout Personally, I'd consider the comment to be part of the control structure, and say the space should come above it. Similar to how a DocBlock acts. But I'd be happy with just about anything at this point that doesn't align all my comments to the left! 😛
Yep agreed. I'll check when I have time.
I checked, and the reason why the DocBlock is stuck to the control structure has nothing to do with the SpaceAroundControlStructures pass, it is because of the NoSpaceAfterPHPDocBlocks. So there's a bit more of reflection needed. Does a NoSpaceAfterComments make sense? Or a NoSpaceAfterAnyTypeOfComments? Do we always want to remove the space after normal comments?