-
-
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
feat: Introduce NoEmptyBlockFixer
#7061
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Wow, I never thought anyone would use my branch for anything, nice one :D |
18a19b9
to
f7b4929
Compare
|
||
--- Original | ||
+++ New | ||
-<?php while ($foo) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while($itrator->consume()) {}
I wonder if it makes sense to have config which structures could be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be added later as improvement, I would rather leave it as is now.
$this->doTest($expected, $input); | ||
} | ||
|
||
public static function provideTestFixCases(): iterable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<?php
echo 1;
{}
echo 2;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixer must be a candidate for input code.
- currently fixer works for loops, switches etc. Is it required to handle this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would imagine {}
to be handled by NoEmptyBlockFixer
, if we want to touch only loop
, then we would have NoEmptyBodyBlockOfLoopFixer
, but I would recommend to not have that very specialized rule that covers only some limited cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, I just don't think that rule must cover every possible scenario since the very beginning. It's not my code, I just refurbished it from the ancient branch, I would like to provide it "as-is" (not counting required alignments). Then we can improve it even more. Example with {}
is such an edge case that in my opinion doesn't have to be handled now.
f7b4929
to
b548f36
Compare
@ntzm do you have an idea why nested |
Not sure sorry, I don't really have any capacity nowadays to work on anything PHP open source related 😢 |
This comment was marked as outdated.
This comment was marked as outdated.
21e8421
to
1364e11
Compare
NoEmptyBlockFixer
NoEmptyBlockFixer
The name is "empty block" as enduser I would expect this to be fixed as well: <?php {}
echo 1;
{}
?> |
@SpacePossum please look here 😉. I've rebased it only without any additional changes, will try to solve CI issues soon but I don't want to work on this PR more than it's required. Any improvements can be added later. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@SpacePossum which question of yours I did not respond to 🤷♂️? In terms of empty I said I just did a rebase without any code changes to keep PR up-to-date so it's not marked as stale. When I will actually work on it, I'll take your comment into consideration. What's the problem here? |
Not sure about a "problem," but this PR doesn't look finished to me, no matter who was or is the author, so I can ask no? |
Looking at tests for `NoTrailingWhitespaceFixer`, it leaves one whitespace character after `<?php`, so integration test provided for `no_empty_block,no_trailing_whitespace` is invalid. https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/a7bbaa14c75806d62c668a079abcaae3d7233729/tests/Fixer/Whitespace/NoTrailingWhitespaceFixerTest.php#L118-L121
1364e11
to
16a0144
Compare
Fixes #3514, created by @ntzm, rebased and synced with current requirements by me 😉.
1 test case is failing, I will investigate only after initial green light that we actually want this fixer (@keradus said it's OK if it's marked as risky, and it is).