Skip to content

Commit

Permalink
bug #5385 SingleLineCommentStyleFixer- run before NoUselessReturnFixe…
Browse files Browse the repository at this point in the history
…r (kubawerlos)

This PR was merged into the 2.17 branch.

Discussion
----------

SingleLineCommentStyleFixer- run before NoUselessReturnFixer

Fixes #5382

Ping @mvorisek for review (as a reporter of bug).

Commits
-------

c262d5c Make single_line_comment_style runs after no_useless_return
  • Loading branch information
keradus committed Dec 23, 2020
2 parents da8c26f + c262d5c commit 1b81c27
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Fixer/Comment/SingleLineCommentStyleFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ public function getDefinition()
);
}

/**
* {@inheritdoc}
*
* Must run after NoUselessReturnFixer.
*/
public function getPriority()
{
return -19;
}

/**
* {@inheritdoc}
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/ReturnNotation/NoUselessReturnFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function example($b) {
/**
* {@inheritdoc}
*
* Must run before BlankLineBeforeReturnFixer, BlankLineBeforeStatementFixer, NoExtraBlankLinesFixer, NoWhitespaceInBlankLineFixer.
* Must run before BlankLineBeforeReturnFixer, BlankLineBeforeStatementFixer, NoExtraBlankLinesFixer, NoWhitespaceInBlankLineFixer, SingleLineCommentStyleFixer.
* Must run after NoEmptyStatementFixer, NoUnneededCurlyBracesFixer, NoUselessElseFixer, SimplifiedNullReturnFixer.
*/
public function getPriority()
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public function provideFixersPriorityCases()
[$fixers['no_useless_return'], $fixers['blank_line_before_statement']],
[$fixers['no_useless_return'], $fixers['no_extra_blank_lines']],
[$fixers['no_useless_return'], $fixers['no_whitespace_in_blank_line']],
[$fixers['no_useless_return'], $fixers['single_line_comment_style']],
[$fixers['no_useless_sprintf'], $fixers['method_argument_space']],
[$fixers['no_useless_sprintf'], $fixers['native_function_casing']],
[$fixers['no_useless_sprintf'], $fixers['no_empty_statement']],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Integration of fixers: no_useless_return,single_line_comment_style.
--RULESET--
{ "no_useless_return": true, "single_line_comment_style": true }
--EXPECT--
<?php
function foo()
{
// foo
}

--INPUT--
<?php
function foo()
{
return/* foo */;
}

0 comments on commit 1b81c27

Please sign in to comment.