feat: Introduce BlankLineAfterStatement fixer#9563
Conversation
| 'if' => \T_IF, | ||
| 'switch' => \T_SWITCH, |
There was a problem hiding this comment.
We could also consider folding the BlankLineAfterNamespaceFixer into this fixer:
| 'if' => \T_IF, | |
| 'switch' => \T_SWITCH, | |
| 'if' => \T_IF, | |
| 'namespace' => \T_NAMESPACE, | |
| 'switch' => \T_SWITCH, |
There was a problem hiding this comment.
I would only do this if you also merge the BlankLineBeforeNamespace into the BlankLineBeforeStatement too.
Coverage Report for CI Build 25506351237Coverage decreased (-0.007%) to 93.798%Details
Uncovered Changes
Coverage Regressions3 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
| 'do' => \T_DO, | ||
| 'for' => \T_FOR, | ||
| 'foreach' => \T_FOREACH, | ||
| 'if' => \T_IF, | ||
| 'switch' => \T_SWITCH, | ||
| 'try' => \T_TRY, | ||
| 'while' => \T_WHILE, |
There was a problem hiding this comment.
One thing about these (except declare):
- maybe we should also include
match? - are these statements or something else ("blocks")?
- should these be addressed by a different fixer with a more appropriate name?
There was a problem hiding this comment.
if switch is included, then imho so should match
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #9563 +/- ##
============================================
- Coverage 94.07% 94.06% -0.01%
- Complexity 10860 10905 +45
============================================
Files 583 584 +1
Lines 34171 34325 +154
============================================
+ Hits 32145 32287 +142
- Misses 2026 2038 +12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| /** | ||
| * {@inheritdoc} | ||
| * | ||
| * Must run after NoUselessElseFixer. |
|
|
||
| List of statements which must be followed by an empty line. | ||
|
|
||
| Allowed values: a subset of ``['declare', 'do', 'for', 'foreach', 'if', 'switch', 'try', 'while']`` |
There was a problem hiding this comment.
the before version also has require(_once) and include(_once), does it make sense to add those too?
| ['statements' => ['try']], | ||
| ]; | ||
|
|
||
| yield 'try-catch-finally - blank line inserted after the end of the whole chain' => [ |
There was a problem hiding this comment.
Does it also work with multiple catch blocks?
What about try {} finally {} without catch?
46ac6bc to
b9547bd
Compare
This pull request
BlankLineAfterStatementfixerFollows #9540 (comment).
💁♂️ This is based on existing work, most importantly, @erickskrauch's work on https://github.com/erickskrauch/php-cs-fixer-custom-fixers/blob/1.3.1/src/Fixer/Whitespace/LineBreakAfterStatementsFixer.php.