Skip to content

Commit

Permalink
bug #5010 SimplifiedNullReturnFixer - must run before VoidReturnFixer…
Browse files Browse the repository at this point in the history
… (kubawerlos)

This PR was squashed before being merged into the 2.15 branch.

Discussion
----------

SimplifiedNullReturnFixer - must run before VoidReturnFixer

Commits
-------

d58e3cb SimplifiedNullReturnFixer - must run before VoidReturnFixer
  • Loading branch information
keradus committed Jun 27, 2020
2 parents ff8ca0e + d58e3cb commit 52e1417
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Fixer/FunctionNotation/VoidReturnFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function getDefinition()
* {@inheritdoc}
*
* Must run before PhpdocNoEmptyReturnFixer, ReturnTypeDeclarationFixer.
* Must run after SimplifiedNullReturnFixer.
*/
public function getPriority()
{
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/ReturnNotation/SimplifiedNullReturnFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ function xyz(): void { return null; }
/**
* {@inheritdoc}
*
* Must run before NoUselessReturnFixer.
* Must run before NoUselessReturnFixer, VoidReturnFixer.
*/
public function getPriority()
{
return -17;
return 16;
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public function provideFixersPriorityCases()
[$fixers['protected_to_private'], $fixers['ordered_class_elements']],
[$fixers['return_assignment'], $fixers['blank_line_before_statement']],
[$fixers['simplified_null_return'], $fixers['no_useless_return']],
[$fixers['simplified_null_return'], $fixers['void_return']],
[$fixers['single_import_per_statement'], $fixers['multiline_whitespace_before_semicolons']],
[$fixers['single_import_per_statement'], $fixers['no_leading_import_slash']],
[$fixers['single_import_per_statement'], $fixers['no_singleline_whitespace_before_semicolons']],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
Integration of fixers: simplified_null_return,void_return.
--RULESET--
{"simplified_null_return": true, "void_return": true}
--REQUIREMENTS--
{"php": 70100}
--EXPECT--
<?php
class Foo {
public function bar(): void
{
return;
}
}

--INPUT--
<?php
class Foo {
public function bar()
{
return null;
}
}

0 comments on commit 52e1417

Please sign in to comment.