-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php70] Handle reverse sorting check on IfToSpaceshipRector (#1676)
* Create a test for reverse sorting * Closes #1674 * [ci-review] Rector Rectify * [ci-review] Rector Rectify * remove applied skip * moved skip to apply Co-authored-by: John Blackbourn <johnbillion@gmail.com> Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
a17759c
commit a9d2982
Showing
4 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
rules-tests/Php70/Rector/If_/IfToSpaceshipRector/Fixture/reverse.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php70\Rector\If_\IfToSpaceshipRector\Reverse; | ||
|
||
class Reverse | ||
{ | ||
public function run() | ||
{ | ||
$languages = []; | ||
usort($languages, function ($a, $b) { | ||
if ($a[0] === $b[0]) { | ||
return 0; | ||
} else { | ||
return ($a[0] > $b[0]) ? 1 : -1; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php70\Rector\If_\IfToSpaceshipRector\Reverse; | ||
|
||
class Reverse | ||
{ | ||
public function run() | ||
{ | ||
$languages = []; | ||
usort($languages, function ($a, $b) { | ||
return $b[0] <=> $a[0]; | ||
}); | ||
} | ||
} | ||
|
||
?> |
37 changes: 37 additions & 0 deletions
37
rules-tests/Php70/Rector/If_/IfToSpaceshipRector/Fixture/reverse2.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php70\Rector\If_\IfToSpaceshipRector\Reverse; | ||
|
||
class Reverse2 | ||
{ | ||
public function run() | ||
{ | ||
$languages = []; | ||
usort($languages, function ($a, $b) { | ||
if ($a[0] === $b[0]) { | ||
return 0; | ||
} | ||
|
||
return ($a[0] < $b[0]) ? -1 : 1; | ||
}); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php70\Rector\If_\IfToSpaceshipRector\Reverse; | ||
|
||
class Reverse2 | ||
{ | ||
public function run() | ||
{ | ||
$languages = []; | ||
usort($languages, function ($a, $b) { | ||
return $a[0] <=> $b[0]; | ||
}); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters